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

Unified Diff: ash/wm/video_detector_unittest.cc

Issue 10905026: Add is_fullscreen to video updates (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Responded to derat's comments Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/video_detector.cc ('k') | chrome/browser/chromeos/power/video_activity_notifier.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/video_detector_unittest.cc
diff --git a/ash/wm/video_detector_unittest.cc b/ash/wm/video_detector_unittest.cc
index 0730ee7b7e50968ca9b08da0b23939667fa989c7..b916818a03281d82152878b00a8cda92f1c88a0d 100644
--- a/ash/wm/video_detector_unittest.cc
+++ b/ash/wm/video_detector_unittest.cc
@@ -23,17 +23,37 @@ namespace test {
// video is playing.
class TestVideoDetectorObserver : public VideoDetectorObserver {
public:
- TestVideoDetectorObserver() : num_invocations_(0) {}
+ TestVideoDetectorObserver() : num_invocations_(0),
+ num_fullscreens_(0),
+ num_not_fullscreens_(0)_{}
int num_invocations() const { return num_invocations_; }
- void reset_stats() { num_invocations_ = 0; }
+ int num_fullscreens() const { return num_fullscreens_; }
+ int num_not_fullscreens() const { return num_not_fullscreens_; }
+ void reset_stats() {
+ num_invocations_ = 0;
+ num_fullscreens_ = 0;
+ num_not_fullscreens_ = 0;
+ }
// VideoDetectorObserver implementation.
- virtual void OnVideoDetected() OVERRIDE { num_invocations_++; }
+ virtual void OnVideoDetected(bool is_fullscreen) OVERRIDE {
+ num_invocations_++;
+ if (is_fullscreen)
+ num_fullscreens++;
+ else
+ num_not_fullscreens++;
+ }
private:
// Number of times that OnVideoDetected() has been called.
int num_invocations_;
+ // Number of times that OnVideoDetected() has been called with is_fullscreen
+ // == true.
+ int num_fullscreens_;
+ // Number of times that OnVideoDetected() has been called with is_fullscreen
+ // == false.
+ int num_not_fullscreens_;
DISALLOW_COPY_AND_ASSIGN(TestVideoDetectorObserver);
};
@@ -88,8 +108,7 @@ TEST_F(VideoDetectorTest, Basic) {
for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i)
detector_->OnWindowPaintScheduled(window.get(), update_region);
EXPECT_EQ(0, observer_->num_invocations());
-
- // Send not-quite-enough adaquately-sized updates.
+ // Send not-quite-enough adaquately-sized updates.
Daniel Erat 2012/08/31 19:15:58 nit: re-add blank line before this one and fix ind
rharrison 2012/09/04 20:12:56 Done.
observer_->reset_stats();
AdvanceTime(base::TimeDelta::FromSeconds(2));
update_region.set_size(
@@ -98,15 +117,17 @@ TEST_F(VideoDetectorTest, Basic) {
for (int i = 0; i < VideoDetector::kMinFramesPerSecond - 1; ++i)
detector_->OnWindowPaintScheduled(window.get(), update_region);
EXPECT_EQ(0, observer_->num_invocations());
-
- // We should get notified after the next update, but not in response to
+ // We should get notified after the next update, but not in response to
Daniel Erat 2012/08/31 19:15:58 ditto
rharrison 2012/09/04 20:12:56 Done.
// additional updates.
detector_->OnWindowPaintScheduled(window.get(), update_region);
EXPECT_EQ(1, observer_->num_invocations());
+ EXPECT_EQ(0, observer_->num_fullscreens());
+ EXPECT_EQ(1, observer_->num_not_fullscreens());
detector_->OnWindowPaintScheduled(window.get(), update_region);
EXPECT_EQ(1, observer_->num_invocations());
-
- // Spread out the frames over two seconds; we shouldn't detect video.
+ EXPECT_EQ(0, observer_->num_fullscreens());
+ EXPECT_EQ(1, observer_->num_not_fullscreens());
+ // Spread out the frames over two seconds; we shouldn't detect video.
Daniel Erat 2012/08/31 19:15:58 ditto
rharrison 2012/09/04 20:12:56 Done.
observer_->reset_stats();
AdvanceTime(base::TimeDelta::FromSeconds(2));
for (int i = 0; i < VideoDetector::kMinFramesPerSecond - 1; ++i)
@@ -116,8 +137,7 @@ TEST_F(VideoDetectorTest, Basic) {
detector_->OnWindowPaintScheduled(window.get(), update_region);
EXPECT_EQ(0, observer_->num_invocations());
}
-
-TEST_F(VideoDetectorTest, WindowNotVisible) {
+ TEST_F(VideoDetectorTest, WindowNotVisible) {
Daniel Erat 2012/08/31 19:15:58 ditto
rharrison 2012/09/04 20:12:56 Done.
gfx::Rect window_bounds(gfx::Point(), gfx::Size(1024, 768));
scoped_ptr<aura::Window> window(
aura::test::CreateTestWindow(SK_ColorRED, 12345, window_bounds, NULL));
@@ -135,16 +155,16 @@ TEST_F(VideoDetectorTest, WindowNotVisible) {
for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i)
detector_->OnWindowPaintScheduled(window.get(), update_region);
EXPECT_EQ(0, observer_->num_invocations());
-
- // Make the window visible and send more updates.
+ // Make the window visible and send more updates.
Daniel Erat 2012/08/31 19:15:58 ditto
rharrison 2012/09/04 20:12:56 Done.
observer_->reset_stats();
AdvanceTime(base::TimeDelta::FromSeconds(2));
window->Show();
for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i)
detector_->OnWindowPaintScheduled(window.get(), update_region);
EXPECT_EQ(1, observer_->num_invocations());
-
- // We also shouldn't report video in a window that's fully offscreen.
+ EXPECT_EQ(0, observer_->num_fullscreens());
+ EXPECT_EQ(1, observer_->num_not_fullscreens());
+ // We also shouldn't report video in a window that's fully offscreen.
Daniel Erat 2012/08/31 19:15:58 ditto
rharrison 2012/09/04 20:12:56 Done.
observer_->reset_stats();
AdvanceTime(base::TimeDelta::FromSeconds(2));
gfx::Rect offscreen_bounds(
@@ -156,8 +176,7 @@ TEST_F(VideoDetectorTest, WindowNotVisible) {
detector_->OnWindowPaintScheduled(window.get(), update_region);
EXPECT_EQ(0, observer_->num_invocations());
}
-
-TEST_F(VideoDetectorTest, MultipleWindows) {
+ TEST_F(VideoDetectorTest, MultipleWindows) {
Daniel Erat 2012/08/31 19:15:58 ditto
rharrison 2012/09/04 20:12:56 Done.
// Create two windows.
gfx::Rect window_bounds(gfx::Point(), gfx::Size(1024, 768));
scoped_ptr<aura::Window> window1(
@@ -176,6 +195,8 @@ TEST_F(VideoDetectorTest, MultipleWindows) {
for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i)
detector_->OnWindowPaintScheduled(window2.get(), update_region);
EXPECT_EQ(1, observer_->num_invocations());
+ EXPECT_EQ(0, observer_->num_fullscreens());
+ EXPECT_EQ(1, observer_->num_not_fullscreens());
}
// Test that the observer receives repeated notifications.
@@ -191,7 +212,8 @@ TEST_F(VideoDetectorTest, RepeatedNotifications) {
for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i)
detector_->OnWindowPaintScheduled(window.get(), update_region);
EXPECT_EQ(1, observer_->num_invocations());
-
+ EXPECT_EQ(0, observer_->num_fullscreens());
+ EXPECT_EQ(1, observer_->num_not_fullscreens());
// Let enough time pass that a second notification should be sent.
observer_->reset_stats();
AdvanceTime(base::TimeDelta::FromSeconds(
@@ -199,6 +221,26 @@ TEST_F(VideoDetectorTest, RepeatedNotifications) {
for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i)
detector_->OnWindowPaintScheduled(window.get(), update_region);
EXPECT_EQ(1, observer_->num_invocations());
+ EXPECT_EQ(0, observer_->num_fullscreens());
+ EXPECT_EQ(1, observer_->num_not_fullscreens());
+}
+
+// Test that the observer receives a true value when the window is fullscreen.
+TEST_F(VideoDetectorTest, FullscreenWindow) {
+ gfx::Rect window_bounds(gfx::Point(), gfx::Size(1024, 768));
+ scoped_ptr<aura::Window> window(
+ aura::test::CreateTestWindow(SK_ColorRED, 12345, window_bounds, NULL));
+ window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
+
+ gfx::Rect update_region(
+ gfx::Point(),
+ gfx::Size(VideoDetector::kMinUpdateWidth,
+ - VideoDetector::kMinUpdateHeight));
Daniel Erat 2012/08/31 19:15:58 editor mishap? it looks like you have a minus sig
rharrison 2012/09/04 20:12:56 I suspect all of these issues come from me fouling
+ for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i)
+ detector_->OnWindowPaintScheduled(window.get(), update_region);
+ EXPECT_EQ(1, observer_->num_invocations());
+ EXPECT_EQ(1, observer_->num_fullscreens());
+ EXPECT_EQ(0, observer_->num_not_fullscreens());
}
} // namespace test
« no previous file with comments | « ash/wm/video_detector.cc ('k') | chrome/browser/chromeos/power/video_activity_notifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698