Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: chromeos/components/tether/connect_tethering_operation_unittest.cc

Issue 2926503002: [CrOS Tether] Create proto_test_util.cc/h and move CreateTestDeviceStatus() there. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/connect_tethering_operation.h" 5 #include "chromeos/components/tether/connect_tethering_operation.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "chromeos/components/tether/ble_constants.h" 11 #include "chromeos/components/tether/ble_constants.h"
12 #include "chromeos/components/tether/fake_ble_connection_manager.h" 12 #include "chromeos/components/tether/fake_ble_connection_manager.h"
13 #include "chromeos/components/tether/message_wrapper.h" 13 #include "chromeos/components/tether/message_wrapper.h"
14 #include "chromeos/components/tether/mock_tether_host_response_recorder.h" 14 #include "chromeos/components/tether/mock_tether_host_response_recorder.h"
15 #include "chromeos/components/tether/proto/tether.pb.h" 15 #include "chromeos/components/tether/proto/tether.pb.h"
16 #include "chromeos/components/tether/proto_test_util.h"
16 #include "components/cryptauth/remote_device_test_util.h" 17 #include "components/cryptauth/remote_device_test_util.h"
17 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 20
20 using testing::_; 21 using testing::_;
21 using testing::StrictMock; 22 using testing::StrictMock;
22 23
23 namespace chromeos { 24 namespace chromeos {
24 25
25 namespace tether { 26 namespace tether {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 bool has_received_failure; 58 bool has_received_failure;
58 ConnectTetheringResponse_ResponseCode error_code; 59 ConnectTetheringResponse_ResponseCode error_code;
59 }; 60 };
60 61
61 std::string CreateConnectTetheringRequestString() { 62 std::string CreateConnectTetheringRequestString() {
62 ConnectTetheringRequest request; 63 ConnectTetheringRequest request;
63 return MessageWrapper(request).ToRawMessage(); 64 return MessageWrapper(request).ToRawMessage();
64 } 65 }
65 66
66 DeviceStatus CreateFakeDeviceStatus() { 67 DeviceStatus CreateFakeDeviceStatus() {
67 WifiStatus wifi_status; 68 return CreateTestDeviceStatus("Google Fi", 75 /* battery_percentage */,
68 wifi_status.set_status_code( 69 4 /* connection_strength */);
69 WifiStatus_StatusCode::WifiStatus_StatusCode_NOT_CONNECTED);
70
71 DeviceStatus device_status;
72 device_status.set_battery_percentage(75);
73 device_status.set_cell_provider("Google Fi");
74 device_status.set_connection_strength(4);
75 device_status.mutable_wifi_status()->CopyFrom(wifi_status);
76
77 return device_status;
78 } 70 }
79 71
80 std::string CreateConnectTetheringResponseString( 72 std::string CreateConnectTetheringResponseString(
81 ConnectTetheringResponse_ResponseCode response_code, 73 ConnectTetheringResponse_ResponseCode response_code,
82 bool use_proto_without_ssid_and_password) { 74 bool use_proto_without_ssid_and_password) {
83 ConnectTetheringResponse response; 75 ConnectTetheringResponse response;
84 response.set_response_code(response_code); 76 response.set_response_code(response_code);
85 77
86 // Only set SSID/password if |response_code| is SUCCESS. 78 // Only set SSID/password if |response_code| is SUCCESS.
87 if (!use_proto_without_ssid_and_password && 79 if (!use_proto_without_ssid_and_password &&
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 // The maximum number of connection failures has occurred. 240 // The maximum number of connection failures has occurred.
249 EXPECT_TRUE(test_observer_->has_received_failure); 241 EXPECT_TRUE(test_observer_->has_received_failure);
250 EXPECT_EQ(ConnectTetheringResponse_ResponseCode:: 242 EXPECT_EQ(ConnectTetheringResponse_ResponseCode::
251 ConnectTetheringResponse_ResponseCode_UNKNOWN_ERROR, 243 ConnectTetheringResponse_ResponseCode_UNKNOWN_ERROR,
252 test_observer_->error_code); 244 test_observer_->error_code);
253 } 245 }
254 246
255 } // namespace tether 247 } // namespace tether
256 248
257 } // namespace cryptauth 249 } // namespace cryptauth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698