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

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

Issue 2819383002: [CrOS Tether] Update NetworkState to include tether properties and integrate into NetworkStateHandl… (Closed)
Patch Set: stevenjb@ comment. Created 3 years, 8 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 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/active_host_network_state_updater.h" 5 #include "chromeos/components/tether/active_host_network_state_updater.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "chromeos/components/tether/fake_active_host.h" 12 #include "chromeos/components/tether/fake_active_host.h"
13 #include "chromeos/dbus/dbus_thread_manager.h" 13 #include "chromeos/dbus/dbus_thread_manager.h"
14 #include "chromeos/network/network_state.h" 14 #include "chromeos/network/network_state.h"
15 #include "chromeos/network/network_state_test.h" 15 #include "chromeos/network/network_state_test.h"
16 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h" 18 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h"
19 19
20 namespace chromeos { 20 namespace chromeos {
21 21
22 namespace tether { 22 namespace tether {
23 23
24 namespace { 24 namespace {
25 25
26 const char kFakeDeviceId[] = "fakeDeviceId"; 26 const char kFakeDeviceId[] = "fakeDeviceId";
27 const char kWifiNetworkGuid[] = "wifiNetworkGuid"; 27 const char kWifiNetworkGuid[] = "wifiNetworkGuid";
28 const char kTetherNetworkGuid[] = "tetherNetworkGuid"; 28 const char kTetherNetworkGuid[] = "tetherNetworkGuid";
29 const char kTetherNetworkName[] = "tetherNetworkName";
30 29
31 std::string CreateWifiConfigurationJsonString(const std::string& guid) { 30 std::string CreateWifiConfigurationJsonString(const std::string& guid) {
32 std::stringstream ss; 31 std::stringstream ss;
33 ss << "{" 32 ss << "{"
34 << " \"GUID\": \"" << guid << "\"," 33 << " \"GUID\": \"" << guid << "\","
35 << " \"Type\": \"" << shill::kTypeWifi << "\"," 34 << " \"Type\": \"" << shill::kTypeWifi << "\","
36 << " \"State\": \"" << shill::kStateIdle << "\"" 35 << " \"State\": \"" << shill::kStateIdle << "\""
37 << "}"; 36 << "}";
38 return ss.str(); 37 return ss.str();
39 } 38 }
(...skipping 12 matching lines...) Expand all
52 SetUpWifiNetwork(); 51 SetUpWifiNetwork();
53 52
54 fake_active_host_ = base::MakeUnique<FakeActiveHost>(); 53 fake_active_host_ = base::MakeUnique<FakeActiveHost>();
55 54
56 updater_ = base::WrapUnique(new ActiveHostNetworkStateUpdater( 55 updater_ = base::WrapUnique(new ActiveHostNetworkStateUpdater(
57 fake_active_host_.get(), network_state_handler())); 56 fake_active_host_.get(), network_state_handler()));
58 } 57 }
59 58
60 void SetUpTetherNetwork() { 59 void SetUpTetherNetwork() {
61 // Add tether network whose status will be changed during the test. 60 // Add tether network whose status will be changed during the test.
62 network_state_handler()->AddTetherNetworkState(kTetherNetworkGuid, 61 network_state_handler()->AddTetherNetworkState(
63 kTetherNetworkName); 62 kTetherNetworkGuid, "TetherNetworkName", "TetherNetworkCarrier",
63 100 /* battery_percentage */, 100 /* signal_strength */);
64 } 64 }
65 65
66 void SetUpWifiNetwork() { 66 void SetUpWifiNetwork() {
67 ConfigureService(CreateWifiConfigurationJsonString(kWifiNetworkGuid)); 67 ConfigureService(CreateWifiConfigurationJsonString(kWifiNetworkGuid));
68 network_state_handler()->AssociateTetherNetworkStateWithWifiNetwork( 68 network_state_handler()->AssociateTetherNetworkStateWithWifiNetwork(
69 kTetherNetworkGuid, kWifiNetworkGuid); 69 kTetherNetworkGuid, kWifiNetworkGuid);
70 } 70 }
71 71
72 void TearDown() override { 72 void TearDown() override {
73 ShutdownNetworkState(); 73 ShutdownNetworkState();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 fake_active_host_->SetActiveHostConnected(kFakeDeviceId, kTetherNetworkGuid, 116 fake_active_host_->SetActiveHostConnected(kFakeDeviceId, kTetherNetworkGuid,
117 kWifiNetworkGuid); 117 kWifiNetworkGuid);
118 VerifyConnected(); 118 VerifyConnected();
119 119
120 fake_active_host_->SetActiveHostDisconnected(); 120 fake_active_host_->SetActiveHostDisconnected();
121 VerifyDisconnected(); 121 VerifyDisconnected();
122 } 122 }
123 123
124 } // namespace tether 124 } // namespace tether
125 125
126 } // namespace cryptauth 126 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698