summaryrefslogtreecommitdiffstats
path: root/ui/chromeos
diff options
context:
space:
mode:
authortapted <tapted@chromium.org>2015-06-17 19:54:09 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-18 02:55:47 +0000
commit71b440acbb273cd8fcc22a587b4604038cfd3a1e (patch)
treebc6bd5a8f39e21fdd70840c124736effc677b676 /ui/chromeos
parent6e6b751edaef93725d8ecd8142c32704bfe422e7 (diff)
downloadchromium_src-71b440acbb273cd8fcc22a587b4604038cfd3a1e.zip
chromium_src-71b440acbb273cd8fcc22a587b4604038cfd3a1e.tar.gz
chromium_src-71b440acbb273cd8fcc22a587b4604038cfd3a1e.tar.bz2
Make ViewsTestHelpers DCHECK that all Widgets are destroyed before unit test tear down
Running custom_button_unittest.cc on Mac resulted in some use-after-free errors. The problem: Widgets hold on to a Compositor. If they are not all closed when the ContextFactory is torn down by ViewsTestBase, then bad stuff happens when the Widget is closed afterwards (e.g. by scoped_ptr<Widget>s on the test harness with WIDGET_OWNS_NATIVE_WIDGET). Since many tests do not try to create Desktop Aura widgets, they will instead create Ash-style Widgets that are owned by the RootWindow. These get automatically destroyed when the RootWindow is torn down by AuraTestHelper. However, on Mac there are only desktop widgets, so any unclosed widgets remain "unowned". A browser_test can rely on Widget::CloseAllSecondaryWidgets(), but not a unit_test. This CL adds a check to ViewsTestHelperMac to anticipate these use-after-frees. The same check is added to ViewsTestHelperAura to help tests detect these errors before going through the CQ. Tests that were not closing Widgets are updated. Most unit tests did already close their Widgets. For the majority of those that were not, it seems accidental. BUG=412234 Review URL: https://codereview.chromium.org/1180623007 Cr-Commit-Position: refs/heads/master@{#334985}
Diffstat (limited to 'ui/chromeos')
-rw-r--r--ui/chromeos/ime/candidate_window_view_unittest.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/ui/chromeos/ime/candidate_window_view_unittest.cc b/ui/chromeos/ime/candidate_window_view_unittest.cc
index 6bfa059..6b18a48 100644
--- a/ui/chromeos/ime/candidate_window_view_unittest.cc
+++ b/ui/chromeos/ime/candidate_window_view_unittest.cc
@@ -74,6 +74,11 @@ class CandidateWindowViewTest : public views::ViewsTestBase {
candidate_window_view_->InitWidget();
}
+ void TearDown() override {
+ candidate_window_view_->GetWidget()->CloseNow();
+ views::ViewsTestBase::TearDown();
+ }
+
CandidateWindowView* candidate_window_view() {
return candidate_window_view_;
}
@@ -109,8 +114,7 @@ class CandidateWindowViewTest : public views::ViewsTestBase {
}
private:
- // owned by |parent_|.
- CandidateWindowView* candidate_window_view_;
+ CandidateWindowView* candidate_window_view_; // Owned by its Widget.
DISALLOW_COPY_AND_ASSIGN(CandidateWindowViewTest);
};