| OLD | NEW |
| (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 |
| OLD | NEW |