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

Side by Side Diff: ash/system/chromeos/power/video_activity_notifier_unittest.cc

Issue 2155693003: ash: Use EXPECT_TRUE/FALSE vs EXPECT_EQ in VideoActivityNotifierTest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/system/chromeos/power/video_activity_notifier.h" 5 #include "ash/system/chromeos/power/video_activity_notifier.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "ash/wm/video_detector.h" 10 #include "ash/wm/video_detector.h"
(...skipping 30 matching lines...) Expand all
41 41
42 DISALLOW_COPY_AND_ASSIGN(VideoActivityNotifierTest); 42 DISALLOW_COPY_AND_ASSIGN(VideoActivityNotifierTest);
43 }; 43 };
44 44
45 // Test that powerd is notified immediately when video changes to a new playing 45 // Test that powerd is notified immediately when video changes to a new playing
46 // state or the screen is unlocked. 46 // state or the screen is unlocked.
47 TEST_F(VideoActivityNotifierTest, NotifyImmediatelyOnStateChange) { 47 TEST_F(VideoActivityNotifierTest, NotifyImmediatelyOnStateChange) {
48 EXPECT_FALSE(power_client_->have_video_activity_report()); 48 EXPECT_FALSE(power_client_->have_video_activity_report());
49 49
50 notifier_->OnVideoStateChanged(VideoDetector::State::PLAYING_WINDOWED); 50 notifier_->OnVideoStateChanged(VideoDetector::State::PLAYING_WINDOWED);
51 EXPECT_EQ(false, power_client_->PopVideoActivityReport()); 51 EXPECT_FALSE(power_client_->PopVideoActivityReport());
52 52
53 notifier_->OnVideoStateChanged(VideoDetector::State::PLAYING_FULLSCREEN); 53 notifier_->OnVideoStateChanged(VideoDetector::State::PLAYING_FULLSCREEN);
54 EXPECT_EQ(true, power_client_->PopVideoActivityReport()); 54 EXPECT_TRUE(power_client_->PopVideoActivityReport());
55 55
56 notifier_->OnLockStateChanged(true); 56 notifier_->OnLockStateChanged(true);
57 EXPECT_FALSE(power_client_->have_video_activity_report()); 57 EXPECT_FALSE(power_client_->have_video_activity_report());
58 58
59 notifier_->OnLockStateChanged(false); 59 notifier_->OnLockStateChanged(false);
60 EXPECT_EQ(true, power_client_->PopVideoActivityReport()); 60 EXPECT_TRUE(power_client_->PopVideoActivityReport());
61 61
62 notifier_->OnVideoStateChanged(VideoDetector::State::PLAYING_WINDOWED); 62 notifier_->OnVideoStateChanged(VideoDetector::State::PLAYING_WINDOWED);
63 EXPECT_EQ(false, power_client_->PopVideoActivityReport()); 63 EXPECT_FALSE(power_client_->PopVideoActivityReport());
64 64
65 notifier_->OnVideoStateChanged(VideoDetector::State::NOT_PLAYING); 65 notifier_->OnVideoStateChanged(VideoDetector::State::NOT_PLAYING);
66 EXPECT_FALSE(power_client_->have_video_activity_report()); 66 EXPECT_FALSE(power_client_->have_video_activity_report());
67 67
68 notifier_->OnVideoStateChanged(VideoDetector::State::PLAYING_WINDOWED); 68 notifier_->OnVideoStateChanged(VideoDetector::State::PLAYING_WINDOWED);
69 EXPECT_EQ(false, power_client_->PopVideoActivityReport()); 69 EXPECT_FALSE(power_client_->PopVideoActivityReport());
70 } 70 }
71 71
72 // Test that powerd is notified periodically while video is ongoing. 72 // Test that powerd is notified periodically while video is ongoing.
73 TEST_F(VideoActivityNotifierTest, NotifyPeriodically) { 73 TEST_F(VideoActivityNotifierTest, NotifyPeriodically) {
74 // The timer shouldn't be running initially. 74 // The timer shouldn't be running initially.
75 EXPECT_FALSE(notifier_->TriggerTimeoutForTest()); 75 EXPECT_FALSE(notifier_->TriggerTimeoutForTest());
76 76
77 // The timer should start in response to windowed video. 77 // The timer should start in response to windowed video.
78 notifier_->OnVideoStateChanged(VideoDetector::State::PLAYING_WINDOWED); 78 notifier_->OnVideoStateChanged(VideoDetector::State::PLAYING_WINDOWED);
79 EXPECT_EQ(false, power_client_->PopVideoActivityReport()); 79 EXPECT_FALSE(power_client_->PopVideoActivityReport());
80 EXPECT_FALSE(power_client_->have_video_activity_report()); 80 EXPECT_FALSE(power_client_->have_video_activity_report());
81 EXPECT_TRUE(notifier_->TriggerTimeoutForTest()); 81 EXPECT_TRUE(notifier_->TriggerTimeoutForTest());
82 EXPECT_EQ(false, power_client_->PopVideoActivityReport()); 82 EXPECT_FALSE(power_client_->PopVideoActivityReport());
83 EXPECT_FALSE(power_client_->have_video_activity_report()); 83 EXPECT_FALSE(power_client_->have_video_activity_report());
84 84
85 // After fullscreen video starts, the timer should start reporting that 85 // After fullscreen video starts, the timer should start reporting that
86 // instead. 86 // instead.
87 notifier_->OnVideoStateChanged(VideoDetector::State::PLAYING_FULLSCREEN); 87 notifier_->OnVideoStateChanged(VideoDetector::State::PLAYING_FULLSCREEN);
88 EXPECT_EQ(true, power_client_->PopVideoActivityReport()); 88 EXPECT_TRUE(power_client_->PopVideoActivityReport());
89 EXPECT_FALSE(power_client_->have_video_activity_report()); 89 EXPECT_FALSE(power_client_->have_video_activity_report());
90 EXPECT_TRUE(notifier_->TriggerTimeoutForTest()); 90 EXPECT_TRUE(notifier_->TriggerTimeoutForTest());
91 EXPECT_EQ(true, power_client_->PopVideoActivityReport()); 91 EXPECT_TRUE(power_client_->PopVideoActivityReport());
92 EXPECT_FALSE(power_client_->have_video_activity_report()); 92 EXPECT_FALSE(power_client_->have_video_activity_report());
93 93
94 // Locking the screen should stop the timer. 94 // Locking the screen should stop the timer.
95 notifier_->OnLockStateChanged(true); 95 notifier_->OnLockStateChanged(true);
96 EXPECT_FALSE(notifier_->TriggerTimeoutForTest()); 96 EXPECT_FALSE(notifier_->TriggerTimeoutForTest());
97 EXPECT_FALSE(power_client_->have_video_activity_report()); 97 EXPECT_FALSE(power_client_->have_video_activity_report());
98 98
99 // Unlocking it should restart the timer. 99 // Unlocking it should restart the timer.
100 notifier_->OnLockStateChanged(false); 100 notifier_->OnLockStateChanged(false);
101 EXPECT_EQ(true, power_client_->PopVideoActivityReport()); 101 EXPECT_TRUE(power_client_->PopVideoActivityReport());
102 EXPECT_FALSE(power_client_->have_video_activity_report()); 102 EXPECT_FALSE(power_client_->have_video_activity_report());
103 EXPECT_TRUE(notifier_->TriggerTimeoutForTest()); 103 EXPECT_TRUE(notifier_->TriggerTimeoutForTest());
104 EXPECT_EQ(true, power_client_->PopVideoActivityReport()); 104 EXPECT_TRUE(power_client_->PopVideoActivityReport());
105 EXPECT_FALSE(power_client_->have_video_activity_report()); 105 EXPECT_FALSE(power_client_->have_video_activity_report());
106 106
107 // The timer should stop when video video. 107 // The timer should stop when video video.
108 notifier_->OnVideoStateChanged(VideoDetector::State::NOT_PLAYING); 108 notifier_->OnVideoStateChanged(VideoDetector::State::NOT_PLAYING);
109 EXPECT_FALSE(notifier_->TriggerTimeoutForTest()); 109 EXPECT_FALSE(notifier_->TriggerTimeoutForTest());
110 EXPECT_FALSE(power_client_->have_video_activity_report()); 110 EXPECT_FALSE(power_client_->have_video_activity_report());
111 } 111 }
112 112
113 } // namespace ash 113 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698