Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: ash/wm/video_detector_unittest.cc

Issue 303163003: ash: Fix VideoDetectorTest's WindowState usage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test instead Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ash/wm/window_state.cc » ('j') | ash/wm/window_state.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/video_detector.h" 5 #include "ash/wm/video_detector.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "ash/wm/window_state.h" 9 #include "ash/wm/window_state.h"
10 #include "ash/wm/wm_event.h" 10 #include "ash/wm/wm_event.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // Test that the observer receives a true value when the window is fullscreen. 277 // Test that the observer receives a true value when the window is fullscreen.
278 TEST_F(VideoDetectorTest, FullscreenWindow) { 278 TEST_F(VideoDetectorTest, FullscreenWindow) {
279 if (!SupportsMultipleDisplays()) 279 if (!SupportsMultipleDisplays())
280 return; 280 return;
281 281
282 UpdateDisplay("1024x768,1024x768"); 282 UpdateDisplay("1024x768,1024x768");
283 283
284 const gfx::Rect kLeftBounds(gfx::Point(), gfx::Size(1024, 768)); 284 const gfx::Rect kLeftBounds(gfx::Point(), gfx::Size(1024, 768));
285 scoped_ptr<aura::Window> window( 285 scoped_ptr<aura::Window> window(
286 CreateTestWindowInShell(SK_ColorRED, 12345, kLeftBounds)); 286 CreateTestWindowInShell(SK_ColorRED, 12345, kLeftBounds));
287 wm::WindowState window_state(window.get()); 287 wm::WindowState* window_state = wm::GetWindowState(window.get());
288 const wm::WMEvent toggle_fullscreen_event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 288 const wm::WMEvent toggle_fullscreen_event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
289 window_state.OnWMEvent(&toggle_fullscreen_event); 289 window_state->OnWMEvent(&toggle_fullscreen_event);
290 ASSERT_TRUE(window_state.IsFullscreen()); 290 ASSERT_TRUE(window_state->IsFullscreen());
291 window->Focus(); 291 window->Focus();
292 const gfx::Rect kUpdateRegion( 292 const gfx::Rect kUpdateRegion(
293 gfx::Point(), 293 gfx::Point(),
294 gfx::Size(VideoDetector::kMinUpdateWidth, 294 gfx::Size(VideoDetector::kMinUpdateWidth,
295 VideoDetector::kMinUpdateHeight)); 295 VideoDetector::kMinUpdateHeight));
296 for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i) 296 for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i)
297 detector_->OnWindowPaintScheduled(window.get(), kUpdateRegion); 297 detector_->OnWindowPaintScheduled(window.get(), kUpdateRegion);
298 EXPECT_EQ(1, observer_->num_invocations()); 298 EXPECT_EQ(1, observer_->num_invocations());
299 EXPECT_EQ(1, observer_->num_fullscreens()); 299 EXPECT_EQ(1, observer_->num_fullscreens());
300 EXPECT_EQ(0, observer_->num_not_fullscreens()); 300 EXPECT_EQ(0, observer_->num_not_fullscreens());
301 301
302 // Make the first window non-fullscreen and open a second fullscreen window on 302 // Make the first window non-fullscreen and open a second fullscreen window on
303 // a different desktop. 303 // a different desktop.
304 window_state.OnWMEvent(&toggle_fullscreen_event); 304 window_state->OnWMEvent(&toggle_fullscreen_event);
305 ASSERT_FALSE(window_state.IsFullscreen()); 305 ASSERT_FALSE(window_state->IsFullscreen());
306 const gfx::Rect kRightBounds(gfx::Point(1024, 0), gfx::Size(1024, 768)); 306 const gfx::Rect kRightBounds(gfx::Point(1024, 0), gfx::Size(1024, 768));
307 scoped_ptr<aura::Window> other_window( 307 scoped_ptr<aura::Window> other_window(
308 CreateTestWindowInShell(SK_ColorBLUE, 6789, kRightBounds)); 308 CreateTestWindowInShell(SK_ColorBLUE, 6789, kRightBounds));
309 wm::WindowState other_window_state(other_window.get()); 309 wm::WindowState* other_window_state = wm::GetWindowState(other_window.get());
310 other_window_state.OnWMEvent(&toggle_fullscreen_event); 310 other_window_state->OnWMEvent(&toggle_fullscreen_event);
311 ASSERT_TRUE(other_window_state.IsFullscreen()); 311 ASSERT_TRUE(other_window_state->IsFullscreen());
312 312
313 // When video is detected in the first (now non-fullscreen) window, fullscreen 313 // When video is detected in the first (now non-fullscreen) window, fullscreen
314 // video should still be reported due to the second window being fullscreen. 314 // video should still be reported due to the second window being fullscreen.
315 // This avoids situations where non-fullscreen video could be reported when 315 // This avoids situations where non-fullscreen video could be reported when
316 // multiple videos are playing in fullscreen and non-fullscreen windows. 316 // multiple videos are playing in fullscreen and non-fullscreen windows.
317 observer_->reset_stats(); 317 observer_->reset_stats();
318 AdvanceTime(base::TimeDelta::FromSeconds(2)); 318 AdvanceTime(base::TimeDelta::FromSeconds(2));
319 for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i) 319 for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i)
320 detector_->OnWindowPaintScheduled(window.get(), kUpdateRegion); 320 detector_->OnWindowPaintScheduled(window.get(), kUpdateRegion);
321 EXPECT_EQ(1, observer_->num_invocations()); 321 EXPECT_EQ(1, observer_->num_invocations());
322 EXPECT_EQ(1, observer_->num_fullscreens()); 322 EXPECT_EQ(1, observer_->num_fullscreens());
323 EXPECT_EQ(0, observer_->num_not_fullscreens()); 323 EXPECT_EQ(0, observer_->num_not_fullscreens());
324 324
325 // Make the second window non-fullscreen and check that the next video report 325 // Make the second window non-fullscreen and check that the next video report
326 // is non-fullscreen. 326 // is non-fullscreen.
327 other_window_state.OnWMEvent(&toggle_fullscreen_event); 327 other_window_state->OnWMEvent(&toggle_fullscreen_event);
328 ASSERT_FALSE(other_window_state.IsFullscreen()); 328 ASSERT_FALSE(other_window_state->IsFullscreen());
329 observer_->reset_stats(); 329 observer_->reset_stats();
330 AdvanceTime(base::TimeDelta::FromSeconds(2)); 330 AdvanceTime(base::TimeDelta::FromSeconds(2));
331 for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i) 331 for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i)
332 detector_->OnWindowPaintScheduled(window.get(), kUpdateRegion); 332 detector_->OnWindowPaintScheduled(window.get(), kUpdateRegion);
333 EXPECT_EQ(1, observer_->num_invocations()); 333 EXPECT_EQ(1, observer_->num_invocations());
334 EXPECT_EQ(0, observer_->num_fullscreens()); 334 EXPECT_EQ(0, observer_->num_fullscreens());
335 EXPECT_EQ(1, observer_->num_not_fullscreens()); 335 EXPECT_EQ(1, observer_->num_not_fullscreens());
336 } 336 }
337 337
338 } // namespace test 338 } // namespace test
339 } // namespace ash 339 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/wm/window_state.cc » ('j') | ash/wm/window_state.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698