| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 void set_device_id_for_next_timer( | 140 void set_device_id_for_next_timer( |
| 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 WifiStatus wifi_status; | |
| 151 wifi_status.set_status_code( | |
| 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 } | |
| 163 | |
| 164 TetherAvailabilityResponse CreateTetherAvailabilityResponse() { | 150 TetherAvailabilityResponse CreateTetherAvailabilityResponse() { |
| 165 TetherAvailabilityResponse response; | 151 TetherAvailabilityResponse response; |
| 166 response.set_response_code( | 152 response.set_response_code( |
| 167 TetherAvailabilityResponse_ResponseCode:: | 153 TetherAvailabilityResponse_ResponseCode:: |
| 168 TetherAvailabilityResponse_ResponseCode_TETHER_AVAILABLE); | 154 TetherAvailabilityResponse_ResponseCode_TETHER_AVAILABLE); |
| 169 response.mutable_device_status()->CopyFrom(CreateFakeDeviceStatus()); | 155 response.mutable_device_status()->CopyFrom( |
| 156 CreateDeviceStatusWithFakeFields()); |
| 170 return response; | 157 return response; |
| 171 } | 158 } |
| 172 | 159 |
| 173 } // namespace | 160 } // namespace |
| 174 | 161 |
| 175 class MessageTransferOperationTest : public testing::Test { | 162 class MessageTransferOperationTest : public testing::Test { |
| 176 protected: | 163 protected: |
| 177 MessageTransferOperationTest() | 164 MessageTransferOperationTest() |
| 178 : test_devices_(cryptauth::GenerateTestRemoteDevices(4)) { | 165 : test_devices_(cryptauth::GenerateTestRemoteDevices(4)) { |
| 179 // These tests are written under the assumption that there are a maximum of | 166 // These tests are written under the assumption that there are a maximum of |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 fake_ble_connection_manager_->SetDeviceStatus( | 587 fake_ble_connection_manager_->SetDeviceStatus( |
| 601 test_devices_[3], cryptauth::SecureChannel::Status::DISCONNECTED); | 588 test_devices_[3], cryptauth::SecureChannel::Status::DISCONNECTED); |
| 602 EXPECT_FALSE(operation_->HasDeviceAuthenticated(test_devices_[3])); | 589 EXPECT_FALSE(operation_->HasDeviceAuthenticated(test_devices_[3])); |
| 603 EXPECT_FALSE(IsDeviceRegistered(test_devices_[3])); | 590 EXPECT_FALSE(IsDeviceRegistered(test_devices_[3])); |
| 604 EXPECT_FALSE(GetResponseTimerForDevice(test_devices_[3])); | 591 EXPECT_FALSE(GetResponseTimerForDevice(test_devices_[3])); |
| 605 } | 592 } |
| 606 | 593 |
| 607 } // namespace tether | 594 } // namespace tether |
| 608 | 595 |
| 609 } // namespace chromeos | 596 } // namespace chromeos |
| OLD | NEW |