| 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_scanner.h" | 5 #include "chromeos/components/tether/host_scanner.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // point. | 189 // point. |
| 190 battery_percentage = 0; | 190 battery_percentage = 0; |
| 191 connection_strength = 0; | 191 connection_strength = 0; |
| 192 break; | 192 break; |
| 193 } | 193 } |
| 194 | 194 |
| 195 DeviceStatus device_status = CreateFakeDeviceStatus( | 195 DeviceStatus device_status = CreateFakeDeviceStatus( |
| 196 cell_provider_name, battery_percentage, connection_strength); | 196 cell_provider_name, battery_percentage, connection_strength); |
| 197 | 197 |
| 198 // Require set-up for odd-numbered device indices. | 198 // Require set-up for odd-numbered device indices. |
| 199 bool set_up_required = i % 2 == 0; | 199 bool setup_required = i % 2 == 0; |
| 200 | 200 |
| 201 scanned_device_infos.push_back(HostScannerOperation::ScannedDeviceInfo( | 201 scanned_device_infos.push_back(HostScannerOperation::ScannedDeviceInfo( |
| 202 remote_devices[i], device_status, set_up_required)); | 202 remote_devices[i], device_status, setup_required)); |
| 203 } | 203 } |
| 204 | 204 |
| 205 return scanned_device_infos; | 205 return scanned_device_infos; |
| 206 } | 206 } |
| 207 | 207 |
| 208 } // namespace | 208 } // namespace |
| 209 | 209 |
| 210 class HostScannerTest : public testing::Test { | 210 class HostScannerTest : public testing::Test { |
| 211 protected: | 211 protected: |
| 212 HostScannerTest() | 212 HostScannerTest() |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 EXPECT_EQ(0, cache_item.battery_percentage); | 325 EXPECT_EQ(0, cache_item.battery_percentage); |
| 326 else | 326 else |
| 327 EXPECT_EQ(status.battery_percentage(), cache_item.battery_percentage); | 327 EXPECT_EQ(status.battery_percentage(), cache_item.battery_percentage); |
| 328 | 328 |
| 329 if (!status.has_connection_strength() || status.connection_strength() > 4) | 329 if (!status.has_connection_strength() || status.connection_strength() > 4) |
| 330 EXPECT_EQ(100, cache_item.signal_strength); | 330 EXPECT_EQ(100, cache_item.signal_strength); |
| 331 else if (status.connection_strength() < 0) | 331 else if (status.connection_strength() < 0) |
| 332 EXPECT_EQ(0, cache_item.signal_strength); | 332 EXPECT_EQ(0, cache_item.signal_strength); |
| 333 else | 333 else |
| 334 EXPECT_EQ(status.connection_strength() * 25, cache_item.signal_strength); | 334 EXPECT_EQ(status.connection_strength() * 25, cache_item.signal_strength); |
| 335 |
| 336 EXPECT_EQ(scanned_device_info.setup_required, cache_item.setup_required); |
| 335 } | 337 } |
| 336 | 338 |
| 337 const std::vector<cryptauth::RemoteDevice> test_devices_; | 339 const std::vector<cryptauth::RemoteDevice> test_devices_; |
| 338 const std::vector<HostScannerOperation::ScannedDeviceInfo> | 340 const std::vector<HostScannerOperation::ScannedDeviceInfo> |
| 339 test_scanned_device_infos; | 341 test_scanned_device_infos; |
| 340 | 342 |
| 341 std::unique_ptr<FakeTetherHostFetcher> fake_tether_host_fetcher_; | 343 std::unique_ptr<FakeTetherHostFetcher> fake_tether_host_fetcher_; |
| 342 std::unique_ptr<FakeBleConnectionManager> fake_ble_connection_manager_; | 344 std::unique_ptr<FakeBleConnectionManager> fake_ble_connection_manager_; |
| 343 std::unique_ptr<HostScanDevicePrioritizer> fake_host_scan_device_prioritizer_; | 345 std::unique_ptr<HostScanDevicePrioritizer> fake_host_scan_device_prioritizer_; |
| 344 std::unique_ptr<MockTetherHostResponseRecorder> | 346 std::unique_ptr<MockTetherHostResponseRecorder> |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 EXPECT_TRUE(host_scanner_->HasRecentlyScanned()); | 597 EXPECT_TRUE(host_scanner_->HasRecentlyScanned()); |
| 596 | 598 |
| 597 // Move past the limit. | 599 // Move past the limit. |
| 598 test_clock_->Advance(base::TimeDelta::FromSeconds(1)); | 600 test_clock_->Advance(base::TimeDelta::FromSeconds(1)); |
| 599 EXPECT_FALSE(host_scanner_->HasRecentlyScanned()); | 601 EXPECT_FALSE(host_scanner_->HasRecentlyScanned()); |
| 600 } | 602 } |
| 601 | 603 |
| 602 } // namespace tether | 604 } // namespace tether |
| 603 | 605 |
| 604 } // namespace chromeos | 606 } // namespace chromeos |
| OLD | NEW |