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

Side by Side Diff: chromeos/components/tether/host_scanner_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/host_scanner_operation.h" 5 #include "chromeos/components/tether/host_scanner_operation.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "chromeos/components/tether/ble_constants.h" 12 #include "chromeos/components/tether/ble_constants.h"
13 #include "chromeos/components/tether/fake_ble_connection_manager.h" 13 #include "chromeos/components/tether/fake_ble_connection_manager.h"
14 #include "chromeos/components/tether/message_wrapper.h" 14 #include "chromeos/components/tether/message_wrapper.h"
15 #include "chromeos/components/tether/mock_host_scan_device_prioritizer.h" 15 #include "chromeos/components/tether/mock_host_scan_device_prioritizer.h"
16 #include "chromeos/components/tether/mock_tether_host_response_recorder.h" 16 #include "chromeos/components/tether/mock_tether_host_response_recorder.h"
17 #include "chromeos/components/tether/proto/tether.pb.h" 17 #include "chromeos/components/tether/proto/tether.pb.h"
18 #include "chromeos/components/tether/proto_test_util.h"
18 #include "components/cryptauth/remote_device_test_util.h" 19 #include "components/cryptauth/remote_device_test_util.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 using testing::_; 22 using testing::_;
22 using testing::StrictMock; 23 using testing::StrictMock;
23 24
24 namespace chromeos { 25 namespace chromeos {
25 26
26 namespace tether { 27 namespace tether {
27 28
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 std::vector<HostScannerOperation::ScannedDeviceInfo> scanned_devices_so_far; 71 std::vector<HostScannerOperation::ScannedDeviceInfo> scanned_devices_so_far;
71 bool has_final_scan_result_been_sent; 72 bool has_final_scan_result_been_sent;
72 }; 73 };
73 74
74 std::string CreateTetherAvailabilityRequestString() { 75 std::string CreateTetherAvailabilityRequestString() {
75 TetherAvailabilityRequest request; 76 TetherAvailabilityRequest request;
76 return MessageWrapper(request).ToRawMessage(); 77 return MessageWrapper(request).ToRawMessage();
77 } 78 }
78 79
79 DeviceStatus CreateFakeDeviceStatus(std::string cell_provider_name) { 80 DeviceStatus CreateFakeDeviceStatus(std::string cell_provider_name) {
80 WifiStatus wifi_status; 81 return CreateTestDeviceStatus(cell_provider_name, 75 /* battery_percentage */,
81 wifi_status.set_status_code( 82 4 /* connection_strength */);
82 WifiStatus_StatusCode::WifiStatus_StatusCode_CONNECTED);
83 wifi_status.set_ssid("Google A");
84
85 DeviceStatus device_status;
86 device_status.set_battery_percentage(75);
87 device_status.set_cell_provider(cell_provider_name);
88 device_status.set_connection_strength(4);
89 device_status.mutable_wifi_status()->CopyFrom(wifi_status);
90
91 return device_status;
92 } 83 }
93 84
94 std::string CreateTetherAvailabilityResponseString( 85 std::string CreateTetherAvailabilityResponseString(
95 TetherAvailabilityResponse_ResponseCode response_code, 86 TetherAvailabilityResponse_ResponseCode response_code,
96 const std::string& cell_provider_name) { 87 const std::string& cell_provider_name) {
97 TetherAvailabilityResponse response; 88 TetherAvailabilityResponse response;
98 response.set_response_code(response_code); 89 response.set_response_code(response_code);
99 response.mutable_device_status()->CopyFrom( 90 response.mutable_device_status()->CopyFrom(
100 CreateFakeDeviceStatus(cell_provider_name)); 91 CreateFakeDeviceStatus(cell_provider_name));
101 return MessageWrapper(response).ToRawMessage(); 92 return MessageWrapper(response).ToRawMessage();
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 "noService", true /* expected_to_be_last_scan_result */); 359 "noService", true /* expected_to_be_last_scan_result */);
369 360
370 // The scan should be over, and still no new scan results should have come in. 361 // The scan should be over, and still no new scan results should have come in.
371 EXPECT_TRUE(test_observer_->has_final_scan_result_been_sent); 362 EXPECT_TRUE(test_observer_->has_final_scan_result_been_sent);
372 EXPECT_EQ(2u, test_observer_->scanned_devices_so_far.size()); 363 EXPECT_EQ(2u, test_observer_->scanned_devices_so_far.size());
373 } 364 }
374 365
375 } // namespace tether 366 } // namespace tether
376 367
377 } // namespace chromeos 368 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698