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

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

Issue 1284833004: Remove remaining legacy SplitString calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 protected: 120 protected:
121 NetworkChangeNotifierChromeosUpdateTest() : default_network_("") { 121 NetworkChangeNotifierChromeosUpdateTest() : default_network_("") {
122 } 122 }
123 ~NetworkChangeNotifierChromeosUpdateTest() override {} 123 ~NetworkChangeNotifierChromeosUpdateTest() override {}
124 124
125 void SetNotifierState(const NotifierState& notifier_state) { 125 void SetNotifierState(const NotifierState& notifier_state) {
126 notifier_.connection_type_ = notifier_state.type; 126 notifier_.connection_type_ = notifier_state.type;
127 notifier_.service_path_ = notifier_state.service_path; 127 notifier_.service_path_ = notifier_state.service_path;
128 notifier_.ip_address_ = notifier_state.ip_address; 128 notifier_.ip_address_ = notifier_state.ip_address;
129 notifier_.max_bandwidth_mbps_ = notifier_state.max_bandwidth; 129 notifier_.max_bandwidth_mbps_ = notifier_state.max_bandwidth;
130 std::vector<std::string> dns_servers; 130 std::vector<std::string> dns_servers =
131 base::SplitString(notifier_state.dns_servers, ',', &dns_servers); 131 base::SplitString(notifier_state.dns_servers, ",",
132 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
132 notifier_.dns_servers_ = dns_servers; 133 notifier_.dns_servers_ = dns_servers;
133 } 134 }
134 135
135 void VerifyNotifierState(const NotifierState& notifier_state) { 136 void VerifyNotifierState(const NotifierState& notifier_state) {
136 EXPECT_EQ(notifier_state.type, notifier_.connection_type_); 137 EXPECT_EQ(notifier_state.type, notifier_.connection_type_);
137 EXPECT_EQ(notifier_state.service_path, notifier_.service_path_); 138 EXPECT_EQ(notifier_state.service_path, notifier_.service_path_);
138 EXPECT_EQ(notifier_state.ip_address, notifier_.ip_address_); 139 EXPECT_EQ(notifier_state.ip_address, notifier_.ip_address_);
139 EXPECT_EQ(notifier_state.max_bandwidth, notifier_.max_bandwidth_mbps_); 140 EXPECT_EQ(notifier_state.max_bandwidth, notifier_.max_bandwidth_mbps_);
140 std::vector<std::string> dns_servers; 141 std::vector<std::string> dns_servers =
141 base::SplitString(notifier_state.dns_servers, ',', &dns_servers); 142 base::SplitString(notifier_state.dns_servers, ",",
143 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
142 EXPECT_EQ(dns_servers, notifier_.dns_servers_); 144 EXPECT_EQ(dns_servers, notifier_.dns_servers_);
143 } 145 }
144 146
145 // Sets the default network state used for notifier updates. 147 // Sets the default network state used for notifier updates.
146 void SetDefaultNetworkState( 148 void SetDefaultNetworkState(
147 const DefaultNetworkState& default_network_state) { 149 const DefaultNetworkState& default_network_state) {
148 default_network_.visible_ = true; 150 default_network_.visible_ = true;
149 if (default_network_state.is_connected) 151 if (default_network_state.is_connected)
150 default_network_.connection_state_ = shill::kStateOnline; 152 default_network_.connection_state_ = shill::kStateOnline;
151 else 153 else
152 default_network_.connection_state_ = shill::kStateConfiguration; 154 default_network_.connection_state_ = shill::kStateConfiguration;
153 default_network_.type_ = default_network_state.type; 155 default_network_.type_ = default_network_state.type;
154 default_network_.network_technology_ = 156 default_network_.network_technology_ =
155 default_network_state.network_technology; 157 default_network_state.network_technology;
156 default_network_.path_ = default_network_state.service_path; 158 default_network_.path_ = default_network_state.service_path;
157 default_network_.ip_address_ = default_network_state.ip_address; 159 default_network_.ip_address_ = default_network_state.ip_address;
158 std::vector<std::string> dns_servers; 160 std::vector<std::string> dns_servers =
159 base::SplitString(default_network_state.dns_servers, ',', &dns_servers); 161 base::SplitString(default_network_state.dns_servers, ",",
162 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
160 default_network_.dns_servers_ = dns_servers; 163 default_network_.dns_servers_ = dns_servers;
161 } 164 }
162 165
163 // Process an default network update based on the state of |default_network_|. 166 // Process an default network update based on the state of |default_network_|.
164 void ProcessDefaultNetworkUpdate(bool* type_changed, 167 void ProcessDefaultNetworkUpdate(bool* type_changed,
165 bool* ip_changed, 168 bool* ip_changed,
166 bool* dns_changed, 169 bool* dns_changed,
167 bool* max_bandwidth_changed) { 170 bool* max_bandwidth_changed) {
168 notifier_.UpdateState(&default_network_, type_changed, ip_changed, 171 notifier_.UpdateState(&default_network_, type_changed, ip_changed,
169 dns_changed, max_bandwidth_changed); 172 dns_changed, max_bandwidth_changed);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 VerifyNotifierState(test_cases[i].expected_state); 362 VerifyNotifierState(test_cases[i].expected_state);
360 EXPECT_EQ(test_cases[i].expected_type_changed, type_changed); 363 EXPECT_EQ(test_cases[i].expected_type_changed, type_changed);
361 EXPECT_EQ(test_cases[i].expected_ip_changed, ip_changed); 364 EXPECT_EQ(test_cases[i].expected_ip_changed, ip_changed);
362 EXPECT_EQ(test_cases[i].expected_dns_changed, dns_changed); 365 EXPECT_EQ(test_cases[i].expected_dns_changed, dns_changed);
363 EXPECT_EQ(test_cases[i].expected_max_bandwidth_changed, 366 EXPECT_EQ(test_cases[i].expected_max_bandwidth_changed,
364 max_bandwidth_changed); 367 max_bandwidth_changed);
365 } 368 }
366 } 369 }
367 370
368 } // namespace chromeos 371 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698