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

Side by Side Diff: remoting/host/host_power_save_blocker_unittest.cc

Issue 2080723008: [Chromoting] Use device::PowerSaveBlocker to block screen saver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve review comments 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 | « remoting/host/host_power_save_blocker.cc ('k') | remoting/host/remoting_me2me_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "remoting/host/host_power_save_blocker.h"
6
7 #include <memory>
8
9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h"
11 #include "base/threading/thread.h"
12 #include "remoting/host/fake_host_status_monitor.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 namespace remoting {
16
17 class HostPowerSaveBlockerTest : public testing::Test {
18 public:
19 HostPowerSaveBlockerTest();
20
21 protected:
22 bool is_activated() const;
23
24 void SetUp() override;
25
26 base::MessageLoopForUI ui_message_loop_;
27 base::Thread blocking_thread_;
28 FakeHostStatusMonitor monitor_;
29 std::unique_ptr<HostPowerSaveBlocker> blocker_;
30 };
31
32 HostPowerSaveBlockerTest::HostPowerSaveBlockerTest()
33 : blocking_thread_("block-thread") {}
34
35 void HostPowerSaveBlockerTest::SetUp() {
36 ASSERT_TRUE(blocking_thread_.StartWithOptions(
37 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)) &&
38 blocking_thread_.WaitUntilThreadStarted());
39 blocker_.reset(new HostPowerSaveBlocker(monitor_.AsWeakPtr(),
40 ui_message_loop_.task_runner(),
41 blocking_thread_.task_runner()));
42 }
43
44 bool HostPowerSaveBlockerTest::is_activated() const {
45 return !!blocker_->blocker_;
46 }
47
48 TEST_F(HostPowerSaveBlockerTest, Activated) {
49 blocker_->OnClientConnected("jid/jid1@jid2.org");
50 ASSERT_TRUE(is_activated());
51 blocker_->OnClientDisconnected("jid/jid3@jid4.org");
52 ASSERT_FALSE(is_activated());
53 }
54
55 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/host_power_save_blocker.cc ('k') | remoting/host/remoting_me2me_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698