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

Unified Diff: ash/system/chromeos/power/video_activity_notifier_unittest.cc

Issue 2732813002: chromeos: Move files in //ash/common to //ash, part 1 (Closed)
Patch Set: rebase Created 3 years, 10 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
Index: ash/system/chromeos/power/video_activity_notifier_unittest.cc
diff --git a/ash/system/chromeos/power/video_activity_notifier_unittest.cc b/ash/system/chromeos/power/video_activity_notifier_unittest.cc
deleted file mode 100644
index eaf9fc8e8c0ae6f372b8b9b1b58abf2220d517cd..0000000000000000000000000000000000000000
--- a/ash/system/chromeos/power/video_activity_notifier_unittest.cc
+++ /dev/null
@@ -1,113 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/system/chromeos/power/video_activity_notifier.h"
-
-#include <memory>
-
-#include "ash/test/ash_test_base.h"
-#include "ash/wm/video_detector.h"
-#include "base/macros.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/fake_power_manager_client.h"
-
-namespace ash {
-
-class VideoActivityNotifierTest : public test::AshTestBase {
- public:
- VideoActivityNotifierTest() {}
- ~VideoActivityNotifierTest() override {}
-
- void SetUp() override {
- test::AshTestBase::SetUp();
- power_client_ = static_cast<chromeos::FakePowerManagerClient*>(
- chromeos::DBusThreadManager::Get()->GetPowerManagerClient());
- detector_.reset(new VideoDetector());
- notifier_.reset(new VideoActivityNotifier(detector_.get()));
- }
-
- void TearDown() override {
- notifier_.reset();
- detector_.reset();
- test::AshTestBase::TearDown();
- }
-
- protected:
- chromeos::FakePowerManagerClient* power_client_; // Not owned.
-
- std::unique_ptr<VideoDetector> detector_;
- std::unique_ptr<VideoActivityNotifier> notifier_;
-
- DISALLOW_COPY_AND_ASSIGN(VideoActivityNotifierTest);
-};
-
-// Test that powerd is notified immediately when video changes to a new playing
-// state or the screen is unlocked.
-TEST_F(VideoActivityNotifierTest, NotifyImmediatelyOnStateChange) {
- EXPECT_FALSE(power_client_->have_video_activity_report());
-
- notifier_->OnVideoStateChanged(VideoDetector::State::PLAYING_WINDOWED);
- EXPECT_FALSE(power_client_->PopVideoActivityReport());
-
- notifier_->OnVideoStateChanged(VideoDetector::State::PLAYING_FULLSCREEN);
- EXPECT_TRUE(power_client_->PopVideoActivityReport());
-
- notifier_->OnLockStateChanged(true);
- EXPECT_FALSE(power_client_->have_video_activity_report());
-
- notifier_->OnLockStateChanged(false);
- EXPECT_TRUE(power_client_->PopVideoActivityReport());
-
- notifier_->OnVideoStateChanged(VideoDetector::State::PLAYING_WINDOWED);
- EXPECT_FALSE(power_client_->PopVideoActivityReport());
-
- notifier_->OnVideoStateChanged(VideoDetector::State::NOT_PLAYING);
- EXPECT_FALSE(power_client_->have_video_activity_report());
-
- notifier_->OnVideoStateChanged(VideoDetector::State::PLAYING_WINDOWED);
- EXPECT_FALSE(power_client_->PopVideoActivityReport());
-}
-
-// Test that powerd is notified periodically while video is ongoing.
-TEST_F(VideoActivityNotifierTest, NotifyPeriodically) {
- // The timer shouldn't be running initially.
- EXPECT_FALSE(notifier_->TriggerTimeoutForTest());
-
- // The timer should start in response to windowed video.
- notifier_->OnVideoStateChanged(VideoDetector::State::PLAYING_WINDOWED);
- EXPECT_FALSE(power_client_->PopVideoActivityReport());
- EXPECT_FALSE(power_client_->have_video_activity_report());
- EXPECT_TRUE(notifier_->TriggerTimeoutForTest());
- EXPECT_FALSE(power_client_->PopVideoActivityReport());
- EXPECT_FALSE(power_client_->have_video_activity_report());
-
- // After fullscreen video starts, the timer should start reporting that
- // instead.
- notifier_->OnVideoStateChanged(VideoDetector::State::PLAYING_FULLSCREEN);
- EXPECT_TRUE(power_client_->PopVideoActivityReport());
- EXPECT_FALSE(power_client_->have_video_activity_report());
- EXPECT_TRUE(notifier_->TriggerTimeoutForTest());
- EXPECT_TRUE(power_client_->PopVideoActivityReport());
- EXPECT_FALSE(power_client_->have_video_activity_report());
-
- // Locking the screen should stop the timer.
- notifier_->OnLockStateChanged(true);
- EXPECT_FALSE(notifier_->TriggerTimeoutForTest());
- EXPECT_FALSE(power_client_->have_video_activity_report());
-
- // Unlocking it should restart the timer.
- notifier_->OnLockStateChanged(false);
- EXPECT_TRUE(power_client_->PopVideoActivityReport());
- EXPECT_FALSE(power_client_->have_video_activity_report());
- EXPECT_TRUE(notifier_->TriggerTimeoutForTest());
- EXPECT_TRUE(power_client_->PopVideoActivityReport());
- EXPECT_FALSE(power_client_->have_video_activity_report());
-
- // The timer should stop when video video.
- notifier_->OnVideoStateChanged(VideoDetector::State::NOT_PLAYING);
- EXPECT_FALSE(notifier_->TriggerTimeoutForTest());
- EXPECT_FALSE(power_client_->have_video_activity_report());
-}
-
-} // namespace ash
« no previous file with comments | « ash/system/chromeos/power/video_activity_notifier.cc ('k') | ash/system/chromeos/rotation/tray_rotation_lock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698