OLD | NEW |
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 22 matching lines...) Expand all Loading... |
33 int num_invocations() const { return num_invocations_; } | 33 int num_invocations() const { return num_invocations_; } |
34 int num_fullscreens() const { return num_fullscreens_; } | 34 int num_fullscreens() const { return num_fullscreens_; } |
35 int num_not_fullscreens() const { return num_not_fullscreens_; } | 35 int num_not_fullscreens() const { return num_not_fullscreens_; } |
36 void reset_stats() { | 36 void reset_stats() { |
37 num_invocations_ = 0; | 37 num_invocations_ = 0; |
38 num_fullscreens_ = 0; | 38 num_fullscreens_ = 0; |
39 num_not_fullscreens_ = 0; | 39 num_not_fullscreens_ = 0; |
40 } | 40 } |
41 | 41 |
42 // VideoDetectorObserver implementation. | 42 // VideoDetectorObserver implementation. |
43 virtual void OnVideoDetected(bool is_fullscreen) OVERRIDE { | 43 virtual void OnVideoDetected(bool is_fullscreen) override { |
44 num_invocations_++; | 44 num_invocations_++; |
45 if (is_fullscreen) | 45 if (is_fullscreen) |
46 num_fullscreens_++; | 46 num_fullscreens_++; |
47 else | 47 else |
48 num_not_fullscreens_++; | 48 num_not_fullscreens_++; |
49 } | 49 } |
50 | 50 |
51 private: | 51 private: |
52 // Number of times that OnVideoDetected() has been called. | 52 // Number of times that OnVideoDetected() has been called. |
53 int num_invocations_; | 53 int num_invocations_; |
54 // Number of times that OnVideoDetected() has been called with is_fullscreen | 54 // Number of times that OnVideoDetected() has been called with is_fullscreen |
55 // == true. | 55 // == true. |
56 int num_fullscreens_; | 56 int num_fullscreens_; |
57 // Number of times that OnVideoDetected() has been called with is_fullscreen | 57 // Number of times that OnVideoDetected() has been called with is_fullscreen |
58 // == false. | 58 // == false. |
59 int num_not_fullscreens_; | 59 int num_not_fullscreens_; |
60 | 60 |
61 DISALLOW_COPY_AND_ASSIGN(TestVideoDetectorObserver); | 61 DISALLOW_COPY_AND_ASSIGN(TestVideoDetectorObserver); |
62 }; | 62 }; |
63 | 63 |
64 class VideoDetectorTest : public AshTestBase { | 64 class VideoDetectorTest : public AshTestBase { |
65 public: | 65 public: |
66 VideoDetectorTest() {} | 66 VideoDetectorTest() {} |
67 virtual ~VideoDetectorTest() {} | 67 virtual ~VideoDetectorTest() {} |
68 | 68 |
69 virtual void SetUp() OVERRIDE { | 69 virtual void SetUp() override { |
70 AshTestBase::SetUp(); | 70 AshTestBase::SetUp(); |
71 observer_.reset(new TestVideoDetectorObserver); | 71 observer_.reset(new TestVideoDetectorObserver); |
72 detector_ = Shell::GetInstance()->video_detector(); | 72 detector_ = Shell::GetInstance()->video_detector(); |
73 detector_->AddObserver(observer_.get()); | 73 detector_->AddObserver(observer_.get()); |
74 | 74 |
75 now_ = base::TimeTicks::Now(); | 75 now_ = base::TimeTicks::Now(); |
76 detector_->set_now_for_test(now_); | 76 detector_->set_now_for_test(now_); |
77 } | 77 } |
78 | 78 |
79 virtual void TearDown() OVERRIDE { | 79 virtual void TearDown() override { |
80 detector_->RemoveObserver(observer_.get()); | 80 detector_->RemoveObserver(observer_.get()); |
81 AshTestBase::TearDown(); | 81 AshTestBase::TearDown(); |
82 } | 82 } |
83 | 83 |
84 protected: | 84 protected: |
85 // Move |detector_|'s idea of the current time forward by |delta|. | 85 // Move |detector_|'s idea of the current time forward by |delta|. |
86 void AdvanceTime(base::TimeDelta delta) { | 86 void AdvanceTime(base::TimeDelta delta) { |
87 now_ += delta; | 87 now_ += delta; |
88 detector_->set_now_for_test(now_); | 88 detector_->set_now_for_test(now_); |
89 } | 89 } |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_->OnDelegatedFrameDamage(window.get(), kUpdateRegion); | 332 detector_->OnDelegatedFrameDamage(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 |
OLD | NEW |