summaryrefslogtreecommitdiffstats
path: root/ui/views/view_unittest_aura.cc
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/views/view_unittest_aura.cc
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/views/view_unittest_aura.cc')
-rw-r--r--ui/views/view_unittest_aura.cc3
1 files changed, 1 insertions, 2 deletions
diff --git a/ui/views/view_unittest_aura.cc b/ui/views/view_unittest_aura.cc
index 5b64910..f9f72f7 100644
--- a/ui/views/view_unittest_aura.cc
+++ b/ui/views/view_unittest_aura.cc
@@ -153,8 +153,7 @@ TEST_F(ViewAuraTest, RecreateLayersWithWindows) {
ui::Layer* v7_new_layer = w1_new_layer->children()[3];
ASSERT_EQ("v8 v9", ui::test::ChildLayerNamesAsString(*v7_new_layer));
}
- // The views and the widgets are destroyed when AuraTestHelper::TearDown()
- // destroys root_window().
+ w1->CloseNow();
}
} // namespace views