diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-30 10:16:19 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-30 10:16:19 +0000 |
commit | 316733f3b0e581cb57d15f4f1e1348b99be37d95 (patch) | |
tree | f3e3a9e1178d54db2596bb84434b5fb7a0f623a2 /ash | |
parent | 96fdf920cc2548a5bb64486b28b82329345a4f27 (diff) | |
download | chromium_src-316733f3b0e581cb57d15f4f1e1348b99be37d95.zip chromium_src-316733f3b0e581cb57d15f4f1e1348b99be37d95.tar.gz chromium_src-316733f3b0e581cb57d15f4f1e1348b99be37d95.tar.bz2 |
ash: Fix VideoDetectorTest's WindowState usage.
Make the VideoDetector FullscreenWindow test use
GetWindowState() to access WindowState objects. Otherwise,
the WindowStates don't get unregistered as WindowObservers
when they're destroyed. This was responsible for the test
crashes that resulted in r266681 being reverted.
BUG=365364
Review URL: https://codereview.chromium.org/303163003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273783 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/wm/video_detector_unittest.cc | 20 | ||||
-rw-r--r-- | ash/wm/window_state.cc | 4 |
2 files changed, 14 insertions, 10 deletions
diff --git a/ash/wm/video_detector_unittest.cc b/ash/wm/video_detector_unittest.cc index 7bd1ab9..025de63 100644 --- a/ash/wm/video_detector_unittest.cc +++ b/ash/wm/video_detector_unittest.cc @@ -284,10 +284,10 @@ TEST_F(VideoDetectorTest, FullscreenWindow) { const gfx::Rect kLeftBounds(gfx::Point(), gfx::Size(1024, 768)); scoped_ptr<aura::Window> window( CreateTestWindowInShell(SK_ColorRED, 12345, kLeftBounds)); - wm::WindowState window_state(window.get()); + wm::WindowState* window_state = wm::GetWindowState(window.get()); const wm::WMEvent toggle_fullscreen_event(wm::WM_EVENT_TOGGLE_FULLSCREEN); - window_state.OnWMEvent(&toggle_fullscreen_event); - ASSERT_TRUE(window_state.IsFullscreen()); + window_state->OnWMEvent(&toggle_fullscreen_event); + ASSERT_TRUE(window_state->IsFullscreen()); window->Focus(); const gfx::Rect kUpdateRegion( gfx::Point(), @@ -301,14 +301,14 @@ TEST_F(VideoDetectorTest, FullscreenWindow) { // Make the first window non-fullscreen and open a second fullscreen window on // a different desktop. - window_state.OnWMEvent(&toggle_fullscreen_event); - ASSERT_FALSE(window_state.IsFullscreen()); + window_state->OnWMEvent(&toggle_fullscreen_event); + ASSERT_FALSE(window_state->IsFullscreen()); const gfx::Rect kRightBounds(gfx::Point(1024, 0), gfx::Size(1024, 768)); scoped_ptr<aura::Window> other_window( CreateTestWindowInShell(SK_ColorBLUE, 6789, kRightBounds)); - wm::WindowState other_window_state(other_window.get()); - other_window_state.OnWMEvent(&toggle_fullscreen_event); - ASSERT_TRUE(other_window_state.IsFullscreen()); + wm::WindowState* other_window_state = wm::GetWindowState(other_window.get()); + other_window_state->OnWMEvent(&toggle_fullscreen_event); + ASSERT_TRUE(other_window_state->IsFullscreen()); // When video is detected in the first (now non-fullscreen) window, fullscreen // video should still be reported due to the second window being fullscreen. @@ -324,8 +324,8 @@ TEST_F(VideoDetectorTest, FullscreenWindow) { // Make the second window non-fullscreen and check that the next video report // is non-fullscreen. - other_window_state.OnWMEvent(&toggle_fullscreen_event); - ASSERT_FALSE(other_window_state.IsFullscreen()); + other_window_state->OnWMEvent(&toggle_fullscreen_event); + ASSERT_FALSE(other_window_state->IsFullscreen()); observer_->reset_stats(); AdvanceTime(base::TimeDelta::FromSeconds(2)); for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i) diff --git a/ash/wm/window_state.cc b/ash/wm/window_state.cc index 7c5c167..0b2e674 100644 --- a/ash/wm/window_state.cc +++ b/ash/wm/window_state.cc @@ -99,6 +99,10 @@ WindowState::WindowState(aura::Window* window) } WindowState::~WindowState() { + // WindowState is registered as an owned property of |window_|, and window + // unregisters all of its observers in its d'tor before destroying its + // properties. As a result, window_->RemoveObserver() doesn't need to (and + // shouldn't) be called here. } bool WindowState::HasDelegate() const { |