Chromium Code Reviews| Index: chromeos/components/tether/host_scanner_operation_unittest.cc |
| diff --git a/chromeos/components/tether/host_scanner_operation_unittest.cc b/chromeos/components/tether/host_scanner_operation_unittest.cc |
| index 81b8a29671ba1269687df580f59135ae3b5c5bd3..9da2b6f15a2bfe1dcbda8349a68f34063c32cbe8 100644 |
| --- a/chromeos/components/tether/host_scanner_operation_unittest.cc |
| +++ b/chromeos/components/tether/host_scanner_operation_unittest.cc |
| @@ -9,13 +9,16 @@ |
| #include <vector> |
| #include "base/logging.h" |
| +#include "base/test/scoped_task_environment.h" |
|
Ryan Hansberry
2017/06/19 19:17:48
It's a shame that this and host_scanner's test nee
Kyle Horimoto
2017/06/20 23:44:54
You're right - done.
|
| #include "chromeos/components/tether/ble_constants.h" |
| #include "chromeos/components/tether/fake_ble_connection_manager.h" |
| +#include "chromeos/components/tether/host_scan_device_prioritizer.h" |
| #include "chromeos/components/tether/message_wrapper.h" |
| -#include "chromeos/components/tether/mock_host_scan_device_prioritizer.h" |
| #include "chromeos/components/tether/mock_tether_host_response_recorder.h" |
| #include "chromeos/components/tether/proto/tether.pb.h" |
| #include "chromeos/components/tether/proto_test_util.h" |
| +#include "chromeos/dbus/dbus_thread_manager.h" |
| +#include "chromeos/network/network_state_test.h" |
| #include "components/cryptauth/remote_device_test_util.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -30,14 +33,19 @@ namespace { |
| const char kDefaultCarrier[] = "Google Fi"; |
| -class TestHostScanDevicePrioritizer : public MockHostScanDevicePrioritizer { |
| +class TestHostScanDevicePrioritizer : public HostScanDevicePrioritizer { |
| public: |
| - TestHostScanDevicePrioritizer() : MockHostScanDevicePrioritizer() {} |
| + TestHostScanDevicePrioritizer(NetworkStateHandler* network_state_handler) |
| + : HostScanDevicePrioritizer( |
| + network_state_handler, |
| + nullptr /* tether_host_response_recorder */, |
| + nullptr /* device_id_tether_network_guid_map */) {} |
| ~TestHostScanDevicePrioritizer() override {} |
| - // Simply reverses the device order. |
| + // HostScanDevicePrioritizer: |
| void SortByHostScanOrder( |
| std::vector<cryptauth::RemoteDevice>* remote_devices) const override { |
| + // Simply reverses the device order. |
| for (size_t i = 0; i < remote_devices->size() / 2; ++i) { |
| std::iter_swap(remote_devices->begin() + i, |
| remote_devices->end() - i - 1); |
| @@ -94,7 +102,7 @@ std::string CreateTetherAvailabilityResponseString( |
| } // namespace |
| -class HostScannerOperationTest : public testing::Test { |
| +class HostScannerOperationTest : public NetworkStateTest { |
| protected: |
| HostScannerOperationTest() |
| : tether_availability_request_string_( |
| @@ -106,14 +114,25 @@ class HostScannerOperationTest : public testing::Test { |
| } |
| void SetUp() override { |
| + DBusThreadManager::Initialize(); |
| + NetworkStateTest::SetUp(); |
| + |
| fake_ble_connection_manager_ = base::MakeUnique<FakeBleConnectionManager>(); |
| test_host_scan_device_prioritizer_ = |
| - base::MakeUnique<StrictMock<TestHostScanDevicePrioritizer>>(); |
| + base::MakeUnique<TestHostScanDevicePrioritizer>( |
| + network_state_handler()); |
| mock_tether_host_response_recorder_ = |
| base::MakeUnique<StrictMock<MockTetherHostResponseRecorder>>(); |
| test_observer_ = base::WrapUnique(new TestObserver()); |
| } |
| + void TearDown() override { |
| + test_host_scan_device_prioritizer_.reset(); |
| + ShutdownNetworkState(); |
| + NetworkStateTest::TearDown(); |
| + DBusThreadManager::Shutdown(); |
| + } |
| + |
| void ConstructOperation( |
| const std::vector<cryptauth::RemoteDevice>& remote_devices) { |
| operation_ = base::WrapUnique(new HostScannerOperation( |
| @@ -199,11 +218,12 @@ class HostScannerOperationTest : public testing::Test { |
| test_devices_[0], response_code, std::string(kDefaultCarrier), true); |
| } |
| + const base::test::ScopedTaskEnvironment scoped_task_environment_; |
| const std::string tether_availability_request_string_; |
| const std::vector<cryptauth::RemoteDevice> test_devices_; |
| std::unique_ptr<FakeBleConnectionManager> fake_ble_connection_manager_; |
| - std::unique_ptr<StrictMock<TestHostScanDevicePrioritizer>> |
| + std::unique_ptr<TestHostScanDevicePrioritizer> |
| test_host_scan_device_prioritizer_; |
| std::unique_ptr<StrictMock<MockTetherHostResponseRecorder>> |
| mock_tether_host_response_recorder_; |