Skip to content

Commit

Permalink
Add leak checking to all AXPlatformNodeWin unit tests.
Browse files Browse the repository at this point in the history
Bug: 793123
Change-Id: I2ea589a52a600ae0f0a7e6e2afe00727a6acfacf
Reviewed-on: https://chromium-review.googlesource.com/843240
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: Doug Turner <dougt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#526098}
  • Loading branch information
minorninth authored and Commit Bot committed Dec 23, 2017
1 parent fa49e30 commit d6fdfe4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ui/accessibility/platform/ax_platform_node_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,11 @@ AXPlatformNodeWin::~AXPlatformNodeWin() {
g_unique_id_map.Get().erase(unique_id_);
}

// static
size_t AXPlatformNodeWin::GetInstanceCountForTesting() {
return g_unique_id_map.Get().size();
}

const base::char16 AXPlatformNodeWin::kEmbeddedCharacter = L'\xfffc';

void AXPlatformNodeWin::CalculateRelationships() {
Expand Down
3 changes: 3 additions & 0 deletions ui/accessibility/platform/ax_platform_node_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))

~AXPlatformNodeWin() override;

// Return the number of instances of AXPlatformNodeWin, for leak testing.
static size_t GetInstanceCountForTesting();

// Represents a non-static text node in IAccessibleHypertext. This character
// is embedded in the response to IAccessibleText::get_text, indicating the
// position where a non-static text child object appears.
Expand Down
6 changes: 6 additions & 0 deletions ui/accessibility/platform/ax_platform_node_win_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ class AXPlatformNodeWinTest : public ui::AXPlatformNodeTest {
win::CreateATLModuleIfNeeded();
}

void TearDown() override {
// Destroy the tree and make sure we're not leaking any objects.
tree_.reset(nullptr);
ASSERT_EQ(0U, AXPlatformNodeWin::GetInstanceCountForTesting());
}

protected:
void BuildRelationships(ComPtr<IAccessible2> accessible) {
CHECK(accessible);
Expand Down

0 comments on commit d6fdfe4

Please sign in to comment.