| 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..80b81def327ba34d425d84c51f2204d5eb8c2ed6 100644
|
| --- a/ash/wm/video_detector_unittest.cc
|
| +++ b/ash/wm/video_detector_unittest.cc
|
| @@ -10,6 +10,7 @@
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/time.h"
|
| #include "third_party/skia/include/core/SkColor.h"
|
| +#include "ui/aura/client/aura_constants.h"
|
| #include "ui/aura/client/window_types.h"
|
| #include "ui/aura/root_window.h"
|
| #include "ui/aura/test/test_windows.h"
|
| @@ -23,17 +24,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);
|
| };
|
| @@ -103,8 +124,12 @@ TEST_F(VideoDetectorTest, Basic) {
|
| // 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());
|
| + 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.
|
| observer_->reset_stats();
|
| @@ -143,6 +168,8 @@ TEST_F(VideoDetectorTest, WindowNotVisible) {
|
| 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());
|
|
|
| // We also shouldn't report video in a window that's fully offscreen.
|
| observer_->reset_stats();
|
| @@ -176,6 +203,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 +220,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 +229,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));
|
| + 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
|
|
|