Commit 316733f3 authored by derat@chromium.org's avatar derat@chromium.org

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
parent 96fdf920
......@@ -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)
......
......@@ -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 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment