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

Side by Side Diff: chromeos/network/network_change_notifier_chromeos_unittest.cc

Issue 21030006: NetworkState cleanup, pass properties to InitialPropertiesReceived (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chromeos/network/network_change_notifier_chromeos.cc ('k') | chromeos/network/network_state.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/network/network_change_notifier_chromeos.h" 5 #include "chromeos/network/network_change_notifier_chromeos.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 18 matching lines...) Expand all
29 struct NotifierState { 29 struct NotifierState {
30 net::NetworkChangeNotifier::ConnectionType type; 30 net::NetworkChangeNotifier::ConnectionType type;
31 const char* service_path; 31 const char* service_path;
32 const char* ip_address; 32 const char* ip_address;
33 const char* dns_servers; 33 const char* dns_servers;
34 }; 34 };
35 35
36 struct DefaultNetworkState { 36 struct DefaultNetworkState {
37 bool is_connected; 37 bool is_connected;
38 const char* type; 38 const char* type;
39 const char* technology; 39 const char* network_technology;
40 const char* service_path; 40 const char* service_path;
41 const char* ip_address; 41 const char* ip_address;
42 const char* dns_servers; 42 const char* dns_servers;
43 }; 43 };
44 44
45 struct NotifierUpdateTestCase { 45 struct NotifierUpdateTestCase {
46 const char* test_description; 46 const char* test_description;
47 NotifierState initial_state; 47 NotifierState initial_state;
48 DefaultNetworkState default_network_state; 48 DefaultNetworkState default_network_state;
49 NotifierState expected_state; 49 NotifierState expected_state;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 126
127 // Sets the default network state used for notifier updates. 127 // Sets the default network state used for notifier updates.
128 void SetDefaultNetworkState( 128 void SetDefaultNetworkState(
129 const DefaultNetworkState& default_network_state) { 129 const DefaultNetworkState& default_network_state) {
130 if (default_network_state.is_connected) 130 if (default_network_state.is_connected)
131 default_network_.connection_state_ = flimflam::kStateOnline; 131 default_network_.connection_state_ = flimflam::kStateOnline;
132 else 132 else
133 default_network_.connection_state_ = flimflam::kStateConfiguration; 133 default_network_.connection_state_ = flimflam::kStateConfiguration;
134 default_network_.type_ = default_network_state.type; 134 default_network_.type_ = default_network_state.type;
135 default_network_.technology_ = default_network_state.technology; 135 default_network_.network_technology_ =
136 default_network_state.network_technology;
136 default_network_.path_ = default_network_state.service_path; 137 default_network_.path_ = default_network_state.service_path;
137 default_network_.ip_address_ = default_network_state.ip_address; 138 default_network_.ip_address_ = default_network_state.ip_address;
138 std::vector<std::string> dns_servers; 139 std::vector<std::string> dns_servers;
139 base::SplitString(default_network_state.dns_servers, ',', &dns_servers); 140 base::SplitString(default_network_state.dns_servers, ',', &dns_servers);
140 default_network_.dns_servers_ = dns_servers; 141 default_network_.dns_servers_ = dns_servers;
141 } 142 }
142 143
143 // Process an default network update based on the state of |default_network_|. 144 // Process an default network update based on the state of |default_network_|.
144 void ProcessDefaultNetworkUpdate(bool* type_changed, 145 void ProcessDefaultNetworkUpdate(bool* type_changed,
145 bool* ip_changed, 146 bool* ip_changed,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 bool type_changed = false, ip_changed = false, dns_changed = false; 225 bool type_changed = false, ip_changed = false, dns_changed = false;
225 ProcessDefaultNetworkUpdate(&type_changed, &ip_changed, &dns_changed); 226 ProcessDefaultNetworkUpdate(&type_changed, &ip_changed, &dns_changed);
226 VerifyNotifierState(test_cases[i].expected_state); 227 VerifyNotifierState(test_cases[i].expected_state);
227 EXPECT_TRUE(type_changed == test_cases[i].expected_type_changed); 228 EXPECT_TRUE(type_changed == test_cases[i].expected_type_changed);
228 EXPECT_TRUE(ip_changed == test_cases[i].expected_ip_changed); 229 EXPECT_TRUE(ip_changed == test_cases[i].expected_ip_changed);
229 EXPECT_TRUE(dns_changed == test_cases[i].expected_dns_changed); 230 EXPECT_TRUE(dns_changed == test_cases[i].expected_dns_changed);
230 } 231 }
231 } 232 }
232 233
233 } // namespace chromeos 234 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_change_notifier_chromeos.cc ('k') | chromeos/network/network_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698