OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/message_transfer_operation.h" | 5 #include "chromeos/components/tether/message_transfer_operation.h" |
6 | 6 |
7 #include "base/timer/mock_timer.h" | 7 #include "base/timer/mock_timer.h" |
8 #include "chromeos/components/tether/fake_ble_connection_manager.h" | 8 #include "chromeos/components/tether/fake_ble_connection_manager.h" |
9 #include "chromeos/components/tether/message_wrapper.h" | 9 #include "chromeos/components/tether/message_wrapper.h" |
| 10 #include "chromeos/components/tether/proto_test_util.h" |
10 #include "chromeos/components/tether/timer_factory.h" | 11 #include "chromeos/components/tether/timer_factory.h" |
11 #include "components/cryptauth/remote_device_test_util.h" | 12 #include "components/cryptauth/remote_device_test_util.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 namespace chromeos { | 16 namespace chromeos { |
16 | 17 |
17 namespace tether { | 18 namespace tether { |
18 | 19 |
19 namespace { | 20 namespace { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 const std::string& device_id_for_next_timer) { | 141 const std::string& device_id_for_next_timer) { |
141 device_id_for_next_timer_ = device_id_for_next_timer; | 142 device_id_for_next_timer_ = device_id_for_next_timer; |
142 } | 143 } |
143 | 144 |
144 private: | 145 private: |
145 std::string device_id_for_next_timer_; | 146 std::string device_id_for_next_timer_; |
146 std::unordered_map<std::string, base::MockTimer*> device_id_to_timer_map_; | 147 std::unordered_map<std::string, base::MockTimer*> device_id_to_timer_map_; |
147 }; | 148 }; |
148 | 149 |
149 DeviceStatus CreateFakeDeviceStatus() { | 150 DeviceStatus CreateFakeDeviceStatus() { |
150 WifiStatus wifi_status; | 151 return CreateTestDeviceStatus("Google Fi", 75 /* battery_percentage */, |
151 wifi_status.set_status_code( | 152 4 /* connection_strength */); |
152 WifiStatus_StatusCode::WifiStatus_StatusCode_CONNECTED); | |
153 wifi_status.set_ssid("Google A"); | |
154 | |
155 DeviceStatus device_status; | |
156 device_status.set_battery_percentage(75); | |
157 device_status.set_cell_provider("Google Fi"); | |
158 device_status.set_connection_strength(4); | |
159 device_status.mutable_wifi_status()->CopyFrom(wifi_status); | |
160 | |
161 return device_status; | |
162 } | 153 } |
163 | 154 |
164 TetherAvailabilityResponse CreateTetherAvailabilityResponse() { | 155 TetherAvailabilityResponse CreateTetherAvailabilityResponse() { |
165 TetherAvailabilityResponse response; | 156 TetherAvailabilityResponse response; |
166 response.set_response_code( | 157 response.set_response_code( |
167 TetherAvailabilityResponse_ResponseCode:: | 158 TetherAvailabilityResponse_ResponseCode:: |
168 TetherAvailabilityResponse_ResponseCode_TETHER_AVAILABLE); | 159 TetherAvailabilityResponse_ResponseCode_TETHER_AVAILABLE); |
169 response.mutable_device_status()->CopyFrom(CreateFakeDeviceStatus()); | 160 response.mutable_device_status()->CopyFrom(CreateFakeDeviceStatus()); |
170 return response; | 161 return response; |
171 } | 162 } |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 fake_ble_connection_manager_->SetDeviceStatus( | 591 fake_ble_connection_manager_->SetDeviceStatus( |
601 test_devices_[3], cryptauth::SecureChannel::Status::DISCONNECTED); | 592 test_devices_[3], cryptauth::SecureChannel::Status::DISCONNECTED); |
602 EXPECT_FALSE(operation_->HasDeviceAuthenticated(test_devices_[3])); | 593 EXPECT_FALSE(operation_->HasDeviceAuthenticated(test_devices_[3])); |
603 EXPECT_FALSE(IsDeviceRegistered(test_devices_[3])); | 594 EXPECT_FALSE(IsDeviceRegistered(test_devices_[3])); |
604 EXPECT_FALSE(GetResponseTimerForDevice(test_devices_[3])); | 595 EXPECT_FALSE(GetResponseTimerForDevice(test_devices_[3])); |
605 } | 596 } |
606 | 597 |
607 } // namespace tether | 598 } // namespace tether |
608 | 599 |
609 } // namespace chromeos | 600 } // namespace chromeos |
OLD | NEW |