OLD | NEW |
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 "chromeos/components/tether/host_scan_scheduler.h" | 5 #include "chromeos/components/tether/host_scan_scheduler.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "chromeos/components/tether/host_scanner.h" | 8 #include "chromeos/components/tether/host_scanner.h" |
9 #include "chromeos/dbus/power_manager_client.h" | 9 #include "chromeos/dbus/power_manager_client.h" |
10 #include "chromeos/login/login_state.h" | 10 #include "chromeos/login/login_state.h" |
11 #include "chromeos/network/network_handler.h" | 11 #include "chromeos/network/network_handler.h" |
12 #include "chromeos/network/network_state.h" | 12 #include "chromeos/network/network_state.h" |
13 #include "chromeos/network/network_state_handler.h" | 13 #include "chromeos/network/network_state_handler.h" |
14 #include "components/cryptauth/cryptauth_device_manager.h" | 14 #include "components/cryptauth/cryptauth_device_manager.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
18 namespace chromeos { | 18 namespace chromeos { |
19 | 19 |
20 namespace tether { | 20 namespace tether { |
21 | 21 |
22 class HostScanSchedulerTest : public testing::Test { | 22 class HostScanSchedulerTest : public testing::Test { |
23 protected: | 23 protected: |
24 class TestDelegate : public HostScanScheduler::Delegate { | 24 class TestDelegate : public HostScanScheduler::Delegate { |
25 public: | 25 public: |
26 TestDelegate(HostScanSchedulerTest* test) | 26 explicit TestDelegate(HostScanSchedulerTest* test) |
27 : test_(test), | 27 : test_(test), |
28 observer_(nullptr), | 28 observer_(nullptr), |
29 is_authenticated_user_logged_in(true), | 29 is_authenticated_user_logged_in(true), |
30 is_network_connected_or_connecting(false), | 30 is_network_connected_or_connecting(false), |
31 are_tether_hosts_synced(true) {} | 31 are_tether_hosts_synced(true) {} |
32 | 32 |
33 void AddObserver(HostScanScheduler* host_scan_scheduler) override { | 33 void AddObserver(HostScanScheduler* host_scan_scheduler) override { |
34 observer_ = host_scan_scheduler; | 34 observer_ = host_scan_scheduler; |
35 } | 35 } |
36 | 36 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 HostScanScheduler* observer_; | 76 HostScanScheduler* observer_; |
77 bool is_authenticated_user_logged_in; | 77 bool is_authenticated_user_logged_in; |
78 bool is_network_connected_or_connecting; | 78 bool is_network_connected_or_connecting; |
79 bool are_tether_hosts_synced; | 79 bool are_tether_hosts_synced; |
80 }; | 80 }; |
81 | 81 |
82 class FakeHostScanner : public HostScanner { | 82 class FakeHostScanner : public HostScanner { |
83 public: | 83 public: |
84 FakeHostScanner() | 84 FakeHostScanner() |
85 : HostScanner(nullptr, nullptr, nullptr, nullptr, nullptr), | 85 : HostScanner(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr), |
86 num_scans_started_(0) {} | 86 num_scans_started_(0) {} |
87 ~FakeHostScanner() override {} | 87 ~FakeHostScanner() override {} |
88 | 88 |
89 void StartScan() override { num_scans_started_++; } | 89 void StartScan() override { num_scans_started_++; } |
90 | 90 |
91 int num_scans_started() { return num_scans_started_; } | 91 int num_scans_started() { return num_scans_started_; } |
92 | 92 |
93 private: | 93 private: |
94 int num_scans_started_; | 94 int num_scans_started_; |
95 }; | 95 }; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 test_delegate_->set_are_tether_hosts_synced(false); | 221 test_delegate_->set_are_tether_hosts_synced(false); |
222 host_scan_scheduler_->OnSyncFinished( | 222 host_scan_scheduler_->OnSyncFinished( |
223 cryptauth::CryptAuthDeviceManager::SyncResult::SUCCESS, | 223 cryptauth::CryptAuthDeviceManager::SyncResult::SUCCESS, |
224 cryptauth::CryptAuthDeviceManager::DeviceChangeResult::UNCHANGED); | 224 cryptauth::CryptAuthDeviceManager::DeviceChangeResult::UNCHANGED); |
225 EXPECT_EQ(1, fake_host_scanner_->num_scans_started()); | 225 EXPECT_EQ(1, fake_host_scanner_->num_scans_started()); |
226 } | 226 } |
227 | 227 |
228 } // namespace tether | 228 } // namespace tether |
229 | 229 |
230 } // namespace chromeos | 230 } // namespace chromeos |
OLD | NEW |