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

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

Issue 10442017: Rename GetRootWindow() -> GetPrimaryRootWindow() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git-try -b linux_chromeos,win_aura Created 8 years, 7 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 | « ash/wm/video_detector.cc ('k') | ash/wm/visibility_controller.cc » ('j') | no next file with comments »
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 "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 EXPECT_EQ(0, observer_->num_invocations()); 112 EXPECT_EQ(0, observer_->num_invocations());
113 } 113 }
114 114
115 TEST_F(VideoDetectorTest, WindowNotVisible) { 115 TEST_F(VideoDetectorTest, WindowNotVisible) {
116 gfx::Rect window_bounds(gfx::Point(), gfx::Size(1024, 768)); 116 gfx::Rect window_bounds(gfx::Point(), gfx::Size(1024, 768));
117 scoped_ptr<aura::Window> window( 117 scoped_ptr<aura::Window> window(
118 aura::test::CreateTestWindow(SK_ColorRED, 12345, window_bounds, NULL)); 118 aura::test::CreateTestWindow(SK_ColorRED, 12345, window_bounds, NULL));
119 119
120 // Reparent the window to the root to make sure that visibility changes aren't 120 // Reparent the window to the root to make sure that visibility changes aren't
121 // animated. 121 // animated.
122 Shell::GetRootWindow()->AddChild(window.get()); 122 Shell::GetPrimaryRootWindow()->AddChild(window.get());
123 123
124 // We shouldn't report video that's played in a hidden window. 124 // We shouldn't report video that's played in a hidden window.
125 window->Hide(); 125 window->Hide();
126 gfx::Rect update_region( 126 gfx::Rect update_region(
127 gfx::Point(), 127 gfx::Point(),
128 gfx::Size(VideoDetector::kMinUpdateWidth, 128 gfx::Size(VideoDetector::kMinUpdateWidth,
129 VideoDetector::kMinUpdateHeight)); 129 VideoDetector::kMinUpdateHeight));
130 for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i) 130 for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i)
131 detector_->OnWindowPaintScheduled(window.get(), update_region); 131 detector_->OnWindowPaintScheduled(window.get(), update_region);
132 EXPECT_EQ(0, observer_->num_invocations()); 132 EXPECT_EQ(0, observer_->num_invocations());
133 133
134 // Make the window visible and send more updates. 134 // Make the window visible and send more updates.
135 observer_->reset_stats(); 135 observer_->reset_stats();
136 AdvanceTime(base::TimeDelta::FromSeconds(2)); 136 AdvanceTime(base::TimeDelta::FromSeconds(2));
137 window->Show(); 137 window->Show();
138 for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i) 138 for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i)
139 detector_->OnWindowPaintScheduled(window.get(), update_region); 139 detector_->OnWindowPaintScheduled(window.get(), update_region);
140 EXPECT_EQ(1, observer_->num_invocations()); 140 EXPECT_EQ(1, observer_->num_invocations());
141 141
142 // We also shouldn't report video in a window that's fully offscreen. 142 // We also shouldn't report video in a window that's fully offscreen.
143 observer_->reset_stats(); 143 observer_->reset_stats();
144 AdvanceTime(base::TimeDelta::FromSeconds(2)); 144 AdvanceTime(base::TimeDelta::FromSeconds(2));
145 gfx::Rect offscreen_bounds( 145 gfx::Rect offscreen_bounds(
146 gfx::Point(Shell::GetRootWindow()->bounds().width(), 0), 146 gfx::Point(Shell::GetPrimaryRootWindow()->bounds().width(), 0),
147 window_bounds.size()); 147 window_bounds.size());
148 window->SetBounds(offscreen_bounds); 148 window->SetBounds(offscreen_bounds);
149 ASSERT_EQ(offscreen_bounds, window->bounds()); 149 ASSERT_EQ(offscreen_bounds, window->bounds());
150 for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i) 150 for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i)
151 detector_->OnWindowPaintScheduled(window.get(), update_region); 151 detector_->OnWindowPaintScheduled(window.get(), update_region);
152 EXPECT_EQ(0, observer_->num_invocations()); 152 EXPECT_EQ(0, observer_->num_invocations());
153 } 153 }
154 154
155 TEST_F(VideoDetectorTest, MultipleWindows) { 155 TEST_F(VideoDetectorTest, MultipleWindows) {
156 // Create two windows. 156 // Create two windows.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 observer_->reset_stats(); 191 observer_->reset_stats();
192 AdvanceTime(base::TimeDelta::FromSeconds( 192 AdvanceTime(base::TimeDelta::FromSeconds(
193 static_cast<int64>(VideoDetector::kNotifyIntervalSec + 1))); 193 static_cast<int64>(VideoDetector::kNotifyIntervalSec + 1)));
194 for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i) 194 for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i)
195 detector_->OnWindowPaintScheduled(window.get(), update_region); 195 detector_->OnWindowPaintScheduled(window.get(), update_region);
196 EXPECT_EQ(1, observer_->num_invocations()); 196 EXPECT_EQ(1, observer_->num_invocations());
197 } 197 }
198 198
199 } // namespace test 199 } // namespace test
200 } // namespace ash 200 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/video_detector.cc ('k') | ash/wm/visibility_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698