commit | 7a903d4046d98cfcb90c52e35ec358824c6dc15a | [log] [tgz] |
---|---|---|
author | Jinsuk Kim <[email protected]> | Tue Jun 26 18:03:30 2018 |
committer | Commit Bot <[email protected]> | Tue Jun 26 18:03:30 2018 |
tree | a2450be401a594a1e65eb9fab768c9f0d05306b6 | |
parent | 75fe9b33ef2ec997b32582ef801ccc15c0fb34d7 [diff] [blame] |
Android: Add a unit test for WindowAndroid destruction Adds a unit test for https://crrev.com/c/1102823. Verified that the test fails before, but passes after the CL. Bug: b/78251221 Change-Id: Ib68ebe7675820ecea7b09061335aa9c821c99e95 Reviewed-on: https://chromium-review.googlesource.com/1112893 Commit-Queue: Jinsuk Kim <[email protected]> Reviewed-by: Bo <[email protected]> Cr-Commit-Position: refs/heads/master@{#570461}
diff --git a/ui/android/view_android_unittests.cc b/ui/android/view_android_unittests.cc index 9a90bf51..71c758d 100644 --- a/ui/android/view_android_unittests.cc +++ b/ui/android/view_android_unittests.cc
@@ -324,4 +324,27 @@ EXPECT_FALSE(bottom_observer.attached_); } +TEST(ViewAndroidTest, WindowAndroidDestructionDetachesAllViewAndroid) { + std::unique_ptr<WindowAndroid> window(WindowAndroid::CreateForTesting()); + ViewAndroid top; + ViewAndroid bottom; + + Observer top_observer; + Observer bottom_observer; + + top.AddObserver(&top_observer); + bottom.AddObserver(&bottom_observer); + + window->AddChild(&top); + top.AddChild(&bottom); + + EXPECT_TRUE(top_observer.attached_); + EXPECT_TRUE(bottom_observer.attached_); + + window.reset(); + + EXPECT_FALSE(top_observer.attached_); + EXPECT_FALSE(bottom_observer.attached_); +} + } // namespace ui