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/tether_host_fetcher.h" | 5 #include "chromeos/components/tether/tether_host_fetcher.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 class MockDeviceLoader : public cryptauth::RemoteDeviceLoader { | 85 class MockDeviceLoader : public cryptauth::RemoteDeviceLoader { |
86 public: | 86 public: |
87 MockDeviceLoader() | 87 MockDeviceLoader() |
88 : cryptauth::RemoteDeviceLoader( | 88 : cryptauth::RemoteDeviceLoader( |
89 std::vector<cryptauth::ExternalDeviceInfo>(), | 89 std::vector<cryptauth::ExternalDeviceInfo>(), |
90 "", | 90 "", |
91 "", | 91 "", |
92 nullptr) {} | 92 nullptr) {} |
93 ~MockDeviceLoader() override {} | 93 ~MockDeviceLoader() override {} |
94 | 94 |
95 MOCK_METHOD1( | 95 MOCK_METHOD2( |
96 Load, | 96 Load, |
97 void(const cryptauth::RemoteDeviceLoader::RemoteDeviceCallback&)); | 97 void(bool, const cryptauth::RemoteDeviceLoader::RemoteDeviceCallback&)); |
98 }; | 98 }; |
99 | 99 |
100 std::vector<cryptauth::ExternalDeviceInfo> | 100 std::vector<cryptauth::ExternalDeviceInfo> |
101 CreateTetherExternalDeviceInfosForRemoteDevices( | 101 CreateTetherExternalDeviceInfosForRemoteDevices( |
102 const std::vector<cryptauth::RemoteDevice> remote_devices) { | 102 const std::vector<cryptauth::RemoteDevice> remote_devices) { |
103 std::vector<cryptauth::ExternalDeviceInfo> device_infos; | 103 std::vector<cryptauth::ExternalDeviceInfo> device_infos; |
104 for (const auto& remote_device : remote_devices) { | 104 for (const auto& remote_device : remote_devices) { |
105 // Add an ExternalDeviceInfo with the same public key as the RemoteDevice. | 105 // Add an ExternalDeviceInfo with the same public key as the RemoteDevice. |
106 cryptauth::ExternalDeviceInfo info; | 106 cryptauth::ExternalDeviceInfo info; |
107 info.set_public_key(remote_device.public_key); | 107 info.set_public_key(remote_device.public_key); |
(...skipping 21 matching lines...) Expand all Loading... |
129 EXPECT_EQ(test_->test_device_infos_.size(), device_info_list.size()); | 129 EXPECT_EQ(test_->test_device_infos_.size(), device_info_list.size()); |
130 EXPECT_EQ(std::string(kTestUserId), user_id); | 130 EXPECT_EQ(std::string(kTestUserId), user_id); |
131 EXPECT_EQ(std::string(kTestUserPrivateKey), user_private_key); | 131 EXPECT_EQ(std::string(kTestUserPrivateKey), user_private_key); |
132 test_->fake_cryptauth_service_ | 132 test_->fake_cryptauth_service_ |
133 ->VerifySecureMessageDelegateCreatedByFactory( | 133 ->VerifySecureMessageDelegateCreatedByFactory( |
134 static_cast<cryptauth::FakeSecureMessageDelegate*>( | 134 static_cast<cryptauth::FakeSecureMessageDelegate*>( |
135 secure_message_delegate.get())); | 135 secure_message_delegate.get())); |
136 | 136 |
137 std::unique_ptr<MockDeviceLoader> device_loader = | 137 std::unique_ptr<MockDeviceLoader> device_loader = |
138 base::WrapUnique(new NiceMock<MockDeviceLoader>()); | 138 base::WrapUnique(new NiceMock<MockDeviceLoader>()); |
139 ON_CALL(*device_loader, Load(_)) | 139 ON_CALL(*device_loader, Load(false, _)) |
140 .WillByDefault( | 140 .WillByDefault( |
141 Invoke(this, &TestRemoteDeviceLoaderFactory::MockLoadImpl)); | 141 Invoke(this, &TestRemoteDeviceLoaderFactory::MockLoadImpl)); |
142 return std::move(device_loader); | 142 return std::move(device_loader); |
143 } | 143 } |
144 | 144 |
145 void MockLoadImpl( | 145 void MockLoadImpl( |
| 146 bool should_load_beacon_seeds, |
146 const cryptauth::RemoteDeviceLoader::RemoteDeviceCallback& callback) { | 147 const cryptauth::RemoteDeviceLoader::RemoteDeviceCallback& callback) { |
147 callback_ = callback; | 148 callback_ = callback; |
148 } | 149 } |
149 | 150 |
150 void InvokeLastCallback() { | 151 void InvokeLastCallback() { |
151 DCHECK(!callback_.is_null()); | 152 DCHECK(!callback_.is_null()); |
152 callback_.Run(test_->test_devices_); | 153 callback_.Run(test_->test_devices_); |
153 } | 154 } |
154 | 155 |
155 private: | 156 private: |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 EXPECT_EQ(1u, device_list_list_.size()); | 298 EXPECT_EQ(1u, device_list_list_.size()); |
298 EXPECT_EQ(test_devices_, device_list_list_[0]); | 299 EXPECT_EQ(test_devices_, device_list_list_[0]); |
299 EXPECT_EQ(2u, single_device_list_.size()); | 300 EXPECT_EQ(2u, single_device_list_.size()); |
300 EXPECT_EQ(test_devices_[0], *single_device_list_[0]); | 301 EXPECT_EQ(test_devices_[0], *single_device_list_[0]); |
301 EXPECT_EQ(nullptr, single_device_list_[1]); | 302 EXPECT_EQ(nullptr, single_device_list_[1]); |
302 } | 303 } |
303 | 304 |
304 } // namespace tether | 305 } // namespace tether |
305 | 306 |
306 } // namespace chromeos | 307 } // namespace chromeos |
OLD | NEW |