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

Side by Side Diff: chrome/browser/chromeos/cros/cros_network_functions_unittest.cc

Issue 10170003: Replace const char* in cros_network_functions.h with const std::stirng& (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Replaced const char[] with strings Created 8 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 | Annotate | Revision Log
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/chromeos/cros/cros_network_functions.h" 8 #include "chrome/browser/chromeos/cros/cros_network_functions.h"
9 #include "chrome/browser/chromeos/cros/gvalue_util.h" 9 #include "chrome/browser/chromeos/cros/gvalue_util.h"
10 #include "chrome/browser/chromeos/cros/mock_chromeos_network.h" 10 #include "chrome/browser/chromeos/cros/mock_chromeos_network.h"
(...skipping 21 matching lines...) Expand all
32 namespace { 32 namespace {
33 33
34 const char kExamplePath[] = "/foo/bar/baz"; 34 const char kExamplePath[] = "/foo/bar/baz";
35 35
36 // A mock to check arguments of NetworkPropertiesCallback and ensure that the 36 // A mock to check arguments of NetworkPropertiesCallback and ensure that the
37 // callback is called exactly once. 37 // callback is called exactly once.
38 class MockNetworkPropertiesCallback { 38 class MockNetworkPropertiesCallback {
39 public: 39 public:
40 // Creates a NetworkPropertiesCallback with expectations. 40 // Creates a NetworkPropertiesCallback with expectations.
41 static NetworkPropertiesCallback CreateCallback( 41 static NetworkPropertiesCallback CreateCallback(
42 const char* expected_path, 42 const std::string& expected_path,
43 const base::DictionaryValue& expected_result) { 43 const base::DictionaryValue& expected_result) {
44 MockNetworkPropertiesCallback* mock_callback = 44 MockNetworkPropertiesCallback* mock_callback =
45 new MockNetworkPropertiesCallback; 45 new MockNetworkPropertiesCallback;
46 46
47 EXPECT_CALL(*mock_callback, 47 EXPECT_CALL(*mock_callback,
48 Run(StrEq(expected_path), Pointee(IsEqualTo(&expected_result)))) 48 Run(expected_path, Pointee(IsEqualTo(&expected_result))))
49 .Times(1); 49 .Times(1);
50 50
51 return base::Bind(&MockNetworkPropertiesCallback::Run, 51 return base::Bind(&MockNetworkPropertiesCallback::Run,
52 base::Owned(mock_callback)); 52 base::Owned(mock_callback));
53 } 53 }
54 54
55 MOCK_METHOD2(Run, void(const char* path, 55 MOCK_METHOD2(Run, void(const std::string& path,
56 const base::DictionaryValue* result)); 56 const base::DictionaryValue* result));
57 }; 57 };
58 58
59 // A mock to check arguments of NetworkPropertiesWatcherCallback and ensure that 59 // A mock to check arguments of NetworkPropertiesWatcherCallback and ensure that
60 // the callback is called exactly once. 60 // the callback is called exactly once.
61 class MockNetworkPropertiesWatcherCallback { 61 class MockNetworkPropertiesWatcherCallback {
62 public: 62 public:
63 // Creates a NetworkPropertiesWatcherCallback with expectations. 63 // Creates a NetworkPropertiesWatcherCallback with expectations.
64 static NetworkPropertiesWatcherCallback CreateCallback( 64 static NetworkPropertiesWatcherCallback CreateCallback(
65 const std::string& expected_path, 65 const std::string& expected_path,
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 protected: 178 protected:
179 ScopedGValue argument_gvalue_; 179 ScopedGValue argument_gvalue_;
180 ScopedGHashTable argument_ghash_table_; 180 ScopedGHashTable argument_ghash_table_;
181 ScopedGHashTable result_ghash_table_; 181 ScopedGHashTable result_ghash_table_;
182 base::Callback<void(const char* path, 182 base::Callback<void(const char* path,
183 const char* key, 183 const char* key,
184 const GValue* gvalue)> property_changed_callback_; 184 const GValue* gvalue)> property_changed_callback_;
185 }; 185 };
186 186
187 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkServiceProperty) { 187 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkServiceProperty) {
188 const char service_path[] = "/"; 188 const std::string service_path = "/";
189 const char property[] = "property"; 189 const std::string property = "property";
190 EXPECT_CALL( 190 EXPECT_CALL(
191 *MockChromeOSNetwork::Get(), 191 *MockChromeOSNetwork::Get(),
192 SetNetworkServicePropertyGValue(service_path, property, _)) 192 SetNetworkServicePropertyGValue(StrEq(service_path), StrEq(property), _))
193 .WillOnce(Invoke( 193 .WillOnce(Invoke(
194 this, &CrosNetworkFunctionsLibcrosTest::OnSetNetworkPropertyGValue)); 194 this, &CrosNetworkFunctionsLibcrosTest::OnSetNetworkPropertyGValue));
195 const char key1[] = "key1"; 195 const std::string key1= "key1";
196 const std::string string1 = "string1"; 196 const std::string string1 = "string1";
197 const char key2[] = "key2"; 197 const std::string key2 = "key2";
198 const std::string string2 = "string2"; 198 const std::string string2 = "string2";
199 base::DictionaryValue value; 199 base::DictionaryValue value;
200 value.SetString(key1, string1); 200 value.SetString(key1, string1);
201 value.SetString(key2, string2); 201 value.SetString(key2, string2);
202 CrosSetNetworkServiceProperty(service_path, property, value); 202 CrosSetNetworkServiceProperty(service_path, property, value);
203 203
204 // Check the argument GHashTable. 204 // Check the argument GHashTable.
205 GHashTable* ghash_table = 205 GHashTable* ghash_table =
206 static_cast<GHashTable*>(g_value_get_boxed(argument_gvalue_.get())); 206 static_cast<GHashTable*>(g_value_get_boxed(argument_gvalue_.get()));
207 ASSERT_TRUE(ghash_table != NULL); 207 ASSERT_TRUE(ghash_table != NULL);
208 EXPECT_EQ(string1, static_cast<const char*>( 208 EXPECT_EQ(string1, static_cast<const char*>(
209 g_hash_table_lookup(ghash_table, key1))); 209 g_hash_table_lookup(ghash_table, key1.c_str())));
210 EXPECT_EQ(string2, static_cast<const char*>( 210 EXPECT_EQ(string2, static_cast<const char*>(
211 g_hash_table_lookup(ghash_table, key2))); 211 g_hash_table_lookup(ghash_table, key2.c_str())));
212 } 212 }
213 213
214 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosClearNetworkServiceProperty) { 214 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosClearNetworkServiceProperty) {
215 const char service_path[] = "/"; 215 const std::string service_path = "/";
216 const char property[] = "property"; 216 const std::string property = "property";
217 EXPECT_CALL(*MockChromeOSNetwork::Get(), 217 EXPECT_CALL(*MockChromeOSNetwork::Get(),
218 ClearNetworkServiceProperty(service_path, property)).Times(1); 218 ClearNetworkServiceProperty(StrEq(service_path),
219 StrEq(property))).Times(1);
219 CrosClearNetworkServiceProperty(service_path, property); 220 CrosClearNetworkServiceProperty(service_path, property);
220 } 221 }
221 222
222 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkDeviceProperty) { 223 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkDeviceProperty) {
223 const char device_path[] = "/"; 224 const std::string device_path = "/";
224 const char property[] = "property"; 225 const std::string property = "property";
225 EXPECT_CALL( 226 EXPECT_CALL(
226 *MockChromeOSNetwork::Get(), 227 *MockChromeOSNetwork::Get(),
227 SetNetworkDevicePropertyGValue(device_path, property, _)) 228 SetNetworkDevicePropertyGValue(StrEq(device_path), StrEq(property), _))
228 .WillOnce(Invoke( 229 .WillOnce(Invoke(
229 this, &CrosNetworkFunctionsLibcrosTest::OnSetNetworkPropertyGValue)); 230 this, &CrosNetworkFunctionsLibcrosTest::OnSetNetworkPropertyGValue));
230 const bool kBool = true; 231 const bool kBool = true;
231 const base::FundamentalValue value(kBool); 232 const base::FundamentalValue value(kBool);
232 CrosSetNetworkDeviceProperty(device_path, property, value); 233 CrosSetNetworkDeviceProperty(device_path, property, value);
233 EXPECT_EQ(kBool, g_value_get_boolean(argument_gvalue_.get())); 234 EXPECT_EQ(kBool, g_value_get_boolean(argument_gvalue_.get()));
234 } 235 }
235 236
236 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkIPConfigProperty) { 237 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkIPConfigProperty) {
237 const char ipconfig_path[] = "/"; 238 const std::string ipconfig_path = "/";
238 const char property[] = "property"; 239 const std::string property = "property";
239 EXPECT_CALL( 240 EXPECT_CALL(
240 *MockChromeOSNetwork::Get(), 241 *MockChromeOSNetwork::Get(),
241 SetNetworkIPConfigPropertyGValue(ipconfig_path, property, _)) 242 SetNetworkIPConfigPropertyGValue(StrEq(ipconfig_path),
243 StrEq(property), _))
242 .WillOnce(Invoke( 244 .WillOnce(Invoke(
243 this, &CrosNetworkFunctionsLibcrosTest::OnSetNetworkPropertyGValue)); 245 this, &CrosNetworkFunctionsLibcrosTest::OnSetNetworkPropertyGValue));
244 const int kInt = 1234; 246 const int kInt = 1234;
245 const base::FundamentalValue value(kInt); 247 const base::FundamentalValue value(kInt);
246 CrosSetNetworkIPConfigProperty(ipconfig_path, property, value); 248 CrosSetNetworkIPConfigProperty(ipconfig_path, property, value);
247 EXPECT_EQ(kInt, g_value_get_int(argument_gvalue_.get())); 249 EXPECT_EQ(kInt, g_value_get_int(argument_gvalue_.get()));
248 } 250 }
249 251
250 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkManagerProperty) { 252 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkManagerProperty) {
251 const char property[] = "property"; 253 const std::string property = "property";
252 EXPECT_CALL( 254 EXPECT_CALL(
253 *MockChromeOSNetwork::Get(), 255 *MockChromeOSNetwork::Get(),
254 SetNetworkManagerPropertyGValue(property, _)) 256 SetNetworkManagerPropertyGValue(StrEq(property), _))
255 .WillOnce(Invoke( 257 .WillOnce(Invoke(
256 this, 258 this,
257 &CrosNetworkFunctionsLibcrosTest::OnSetNetworkManagerPropertyGValue)); 259 &CrosNetworkFunctionsLibcrosTest::OnSetNetworkManagerPropertyGValue));
258 const std::string kString = "string"; 260 const std::string str = "string";
259 const base::StringValue value(kString); 261 const base::StringValue value(str);
260 CrosSetNetworkManagerProperty(property, value); 262 CrosSetNetworkManagerProperty(property, value);
261 EXPECT_EQ(kString, g_value_get_string(argument_gvalue_.get())); 263 EXPECT_EQ(str, g_value_get_string(argument_gvalue_.get()));
262 } 264 }
263 265
264 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestCellularDataPlanUpdate) { 266 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestCellularDataPlanUpdate) {
265 const char kModemServicePath[] = "/modem/service/path"; 267 const std::string modem_service_path = "/modem/service/path";
266 EXPECT_CALL(*MockChromeOSNetwork::Get(), 268 EXPECT_CALL(*MockChromeOSNetwork::Get(),
267 RequestCellularDataPlanUpdate(kModemServicePath)).Times(1); 269 RequestCellularDataPlanUpdate(StrEq(modem_service_path)))
268 CrosRequestCellularDataPlanUpdate(kModemServicePath); 270 .Times(1);
271 CrosRequestCellularDataPlanUpdate(modem_service_path);
269 } 272 }
270 273
271 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorNetworkManagerProperties) { 274 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorNetworkManagerProperties) {
272 const std::string path = "path"; 275 const std::string path = "path";
273 const std::string key = "key"; 276 const std::string key = "key";
274 const int kValue = 42; 277 const int kValue = 42;
275 const base::FundamentalValue value(kValue); 278 const base::FundamentalValue value(kValue);
276 279
277 // Start monitoring. 280 // Start monitoring.
278 EXPECT_CALL(*MockChromeOSNetwork::Get(), 281 EXPECT_CALL(*MockChromeOSNetwork::Get(),
(...skipping 17 matching lines...) Expand all
296 } 299 }
297 300
298 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorNetworkServiceProperties) { 301 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorNetworkServiceProperties) {
299 const std::string path = "path"; 302 const std::string path = "path";
300 const std::string key = "key"; 303 const std::string key = "key";
301 const int kValue = 42; 304 const int kValue = 42;
302 const base::FundamentalValue value(kValue); 305 const base::FundamentalValue value(kValue);
303 306
304 // Start monitoring. 307 // Start monitoring.
305 EXPECT_CALL(*MockChromeOSNetwork::Get(), 308 EXPECT_CALL(*MockChromeOSNetwork::Get(),
306 MonitorNetworkServiceProperties(_, path.c_str(), _)) 309 MonitorNetworkServiceProperties(_, StrEq(path), _))
307 .WillOnce(Invoke( 310 .WillOnce(Invoke(
308 this, 311 this,
309 &CrosNetworkFunctionsLibcrosTest::OnMonitorNetworkProperties)); 312 &CrosNetworkFunctionsLibcrosTest::OnMonitorNetworkProperties));
310 CrosNetworkWatcher* watcher = CrosMonitorNetworkServiceProperties( 313 CrosNetworkWatcher* watcher = CrosMonitorNetworkServiceProperties(
311 MockNetworkPropertiesWatcherCallback::CreateCallback(path, key, value), 314 MockNetworkPropertiesWatcherCallback::CreateCallback(path, key, value),
312 path); 315 path);
313 316
314 // Call callback. 317 // Call callback.
315 ScopedGValue gvalue(new GValue()); 318 ScopedGValue gvalue(new GValue());
316 g_value_init(gvalue.get(), G_TYPE_INT); 319 g_value_init(gvalue.get(), G_TYPE_INT);
317 g_value_set_int(gvalue.get(), kValue); 320 g_value_set_int(gvalue.get(), kValue);
318 property_changed_callback_.Run(path.c_str(), key.c_str(), gvalue.get()); 321 property_changed_callback_.Run(path.c_str(), key.c_str(), gvalue.get());
319 322
320 // Stop monitoring. 323 // Stop monitoring.
321 EXPECT_CALL(*MockChromeOSNetwork::Get(), 324 EXPECT_CALL(*MockChromeOSNetwork::Get(),
322 DisconnectNetworkPropertiesMonitor(_)).Times(1); 325 DisconnectNetworkPropertiesMonitor(_)).Times(1);
323 delete watcher; 326 delete watcher;
324 } 327 }
325 328
326 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorNetworkDeviceProperties) { 329 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorNetworkDeviceProperties) {
327 const std::string path = "path"; 330 const std::string path = "path";
328 const std::string key = "key"; 331 const std::string key = "key";
329 const int kValue = 42; 332 const int kValue = 42;
330 const base::FundamentalValue value(kValue); 333 const base::FundamentalValue value(kValue);
331 334
332 // Start monitoring. 335 // Start monitoring.
333 EXPECT_CALL(*MockChromeOSNetwork::Get(), 336 EXPECT_CALL(*MockChromeOSNetwork::Get(),
334 MonitorNetworkDeviceProperties(_, path.c_str(), _)) 337 MonitorNetworkDeviceProperties(_, StrEq(path), _))
335 .WillOnce(Invoke( 338 .WillOnce(Invoke(
336 this, 339 this,
337 &CrosNetworkFunctionsLibcrosTest::OnMonitorNetworkProperties)); 340 &CrosNetworkFunctionsLibcrosTest::OnMonitorNetworkProperties));
338 CrosNetworkWatcher* watcher = CrosMonitorNetworkDeviceProperties( 341 CrosNetworkWatcher* watcher = CrosMonitorNetworkDeviceProperties(
339 MockNetworkPropertiesWatcherCallback::CreateCallback(path, key, value), 342 MockNetworkPropertiesWatcherCallback::CreateCallback(path, key, value),
340 path); 343 path);
341 344
342 // Call callback. 345 // Call callback.
343 ScopedGValue gvalue(new GValue()); 346 ScopedGValue gvalue(new GValue());
344 g_value_init(gvalue.get(), G_TYPE_INT); 347 g_value_init(gvalue.get(), G_TYPE_INT);
(...skipping 23 matching lines...) Expand all
368 } 371 }
369 372
370 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorSMS) { 373 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorSMS) {
371 const std::string modem_device_path = "/modem/device/path"; 374 const std::string modem_device_path = "/modem/device/path";
372 MonitorSMSCallback callback = 375 MonitorSMSCallback callback =
373 reinterpret_cast<MonitorSMSCallback>(42); // Dummy value. 376 reinterpret_cast<MonitorSMSCallback>(42); // Dummy value.
374 void* object = reinterpret_cast<void*>(84); // Dummy value. 377 void* object = reinterpret_cast<void*>(84); // Dummy value.
375 378
376 // Start monitoring. 379 // Start monitoring.
377 EXPECT_CALL(*MockChromeOSNetwork::Get(), 380 EXPECT_CALL(*MockChromeOSNetwork::Get(),
378 MonitorSMS(modem_device_path.c_str(), callback, object)).Times(1); 381 MonitorSMS(StrEq(modem_device_path), callback, object))
382 .Times(1);
379 CrosNetworkWatcher* watcher = CrosMonitorSMS( 383 CrosNetworkWatcher* watcher = CrosMonitorSMS(
380 modem_device_path, callback, object); 384 modem_device_path, callback, object);
381 385
382 // Stop monitoring. 386 // Stop monitoring.
383 EXPECT_CALL(*MockChromeOSNetwork::Get(), 387 EXPECT_CALL(*MockChromeOSNetwork::Get(),
384 DisconnectSMSMonitor(_)).Times(1); 388 DisconnectSMSMonitor(_)).Times(1);
385 delete watcher; 389 delete watcher;
386 } 390 }
387 391
388 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkManagerProperties) { 392 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkManagerProperties) {
(...skipping 26 matching lines...) Expand all
415 const std::string value2 = "value2"; 419 const std::string value2 = "value2";
416 // Create result value. 420 // Create result value.
417 base::DictionaryValue result; 421 base::DictionaryValue result;
418 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 422 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1));
419 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 423 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2));
420 result_ghash_table_.reset( 424 result_ghash_table_.reset(
421 ConvertDictionaryValueToStringValueGHashTable(result)); 425 ConvertDictionaryValueToStringValueGHashTable(result));
422 // Set expectations. 426 // Set expectations.
423 EXPECT_CALL( 427 EXPECT_CALL(
424 *MockChromeOSNetwork::Get(), 428 *MockChromeOSNetwork::Get(),
425 RequestNetworkServiceProperties(service_path.c_str(), _, _)) 429 RequestNetworkServiceProperties(StrEq(service_path), _, _))
426 .WillOnce(Invoke( 430 .WillOnce(Invoke(
427 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties3)); 431 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties3));
428 432
429 CrosRequestNetworkServiceProperties( 433 CrosRequestNetworkServiceProperties(
430 service_path.c_str(), 434 service_path,
431 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); 435 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result));
432 } 436 }
433 437
434 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkDeviceProperties) { 438 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkDeviceProperties) {
435 const std::string device_path = "device path"; 439 const std::string device_path = "device path";
436 const std::string key1 = "key1"; 440 const std::string key1 = "key1";
437 const std::string value1 = "value1"; 441 const std::string value1 = "value1";
438 const std::string key2 = "key.2."; 442 const std::string key2 = "key.2.";
439 const std::string value2 = "value2"; 443 const std::string value2 = "value2";
440 // Create result value. 444 // Create result value.
441 base::DictionaryValue result; 445 base::DictionaryValue result;
442 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 446 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1));
443 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 447 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2));
444 result_ghash_table_.reset( 448 result_ghash_table_.reset(
445 ConvertDictionaryValueToStringValueGHashTable(result)); 449 ConvertDictionaryValueToStringValueGHashTable(result));
446 // Set expectations. 450 // Set expectations.
447 EXPECT_CALL( 451 EXPECT_CALL(
448 *MockChromeOSNetwork::Get(), 452 *MockChromeOSNetwork::Get(),
449 RequestNetworkDeviceProperties(device_path.c_str(), _, _)) 453 RequestNetworkDeviceProperties(StrEq(device_path), _, _))
450 .WillOnce(Invoke( 454 .WillOnce(Invoke(
451 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties3)); 455 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties3));
452 456
453 CrosRequestNetworkDeviceProperties( 457 CrosRequestNetworkDeviceProperties(
454 device_path.c_str(), 458 device_path,
455 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); 459 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result));
456 } 460 }
457 461
458 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkProfileProperties) { 462 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkProfileProperties) {
459 const std::string profile_path = "profile path"; 463 const std::string profile_path = "profile path";
460 const std::string key1 = "key1"; 464 const std::string key1 = "key1";
461 const std::string value1 = "value1"; 465 const std::string value1 = "value1";
462 const std::string key2 = "key.2."; 466 const std::string key2 = "key.2.";
463 const std::string value2 = "value2"; 467 const std::string value2 = "value2";
464 // Create result value. 468 // Create result value.
465 base::DictionaryValue result; 469 base::DictionaryValue result;
466 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 470 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1));
467 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 471 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2));
468 result_ghash_table_.reset( 472 result_ghash_table_.reset(
469 ConvertDictionaryValueToStringValueGHashTable(result)); 473 ConvertDictionaryValueToStringValueGHashTable(result));
470 // Set expectations. 474 // Set expectations.
471 EXPECT_CALL( 475 EXPECT_CALL(
472 *MockChromeOSNetwork::Get(), 476 *MockChromeOSNetwork::Get(),
473 RequestNetworkProfileProperties(profile_path.c_str(), _, _)) 477 RequestNetworkProfileProperties(StrEq(profile_path), _, _))
474 .WillOnce(Invoke( 478 .WillOnce(Invoke(
475 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties3)); 479 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties3));
476 480
477 CrosRequestNetworkProfileProperties( 481 CrosRequestNetworkProfileProperties(
478 profile_path.c_str(), 482 profile_path,
479 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); 483 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result));
480 } 484 }
481 485
482 TEST_F(CrosNetworkFunctionsLibcrosTest, 486 TEST_F(CrosNetworkFunctionsLibcrosTest,
483 CrosRequestNetworkProfileEntryProperties) { 487 CrosRequestNetworkProfileEntryProperties) {
484 const std::string profile_path = "profile path"; 488 const std::string profile_path = "profile path";
485 const std::string profile_entry_path = "profile entry path"; 489 const std::string profile_entry_path = "profile entry path";
486 const std::string key1 = "key1"; 490 const std::string key1 = "key1";
487 const std::string value1 = "value1"; 491 const std::string value1 = "value1";
488 const std::string key2 = "key.2."; 492 const std::string key2 = "key.2.";
489 const std::string value2 = "value2"; 493 const std::string value2 = "value2";
490 // Create result value. 494 // Create result value.
491 base::DictionaryValue result; 495 base::DictionaryValue result;
492 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 496 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1));
493 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 497 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2));
494 result_ghash_table_.reset( 498 result_ghash_table_.reset(
495 ConvertDictionaryValueToStringValueGHashTable(result)); 499 ConvertDictionaryValueToStringValueGHashTable(result));
496 // Set expectations. 500 // Set expectations.
497 EXPECT_CALL( 501 EXPECT_CALL(
498 *MockChromeOSNetwork::Get(), 502 *MockChromeOSNetwork::Get(),
499 RequestNetworkProfileEntryProperties(profile_path.c_str(), 503 RequestNetworkProfileEntryProperties(
500 profile_entry_path.c_str(), _, _)) 504 StrEq(profile_path), StrEq(profile_entry_path), _, _))
501 .WillOnce(Invoke( 505 .WillOnce(Invoke(
502 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties4)); 506 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties4));
503 507
504 CrosRequestNetworkProfileEntryProperties( 508 CrosRequestNetworkProfileEntryProperties(
505 profile_path.c_str(), 509 profile_path,
506 profile_entry_path.c_str(), 510 profile_entry_path,
507 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); 511 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result));
508 } 512 }
509 513
510 TEST_F(CrosNetworkFunctionsLibcrosTest, 514 TEST_F(CrosNetworkFunctionsLibcrosTest,
511 CrosRequestHiddenWifiNetworkProperties) { 515 CrosRequestHiddenWifiNetworkProperties) {
512 const std::string ssid = "ssid"; 516 const std::string ssid = "ssid";
513 const std::string security = "security"; 517 const std::string security = "security";
514 const std::string key1 = "key1"; 518 const std::string key1 = "key1";
515 const std::string value1 = "value1"; 519 const std::string value1 = "value1";
516 const std::string key2 = "key.2."; 520 const std::string key2 = "key.2.";
517 const std::string value2 = "value2"; 521 const std::string value2 = "value2";
518 // Create result value. 522 // Create result value.
519 base::DictionaryValue result; 523 base::DictionaryValue result;
520 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 524 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1));
521 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 525 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2));
522 result_ghash_table_.reset( 526 result_ghash_table_.reset(
523 ConvertDictionaryValueToStringValueGHashTable(result)); 527 ConvertDictionaryValueToStringValueGHashTable(result));
524 // Set expectations. 528 // Set expectations.
525 EXPECT_CALL( 529 EXPECT_CALL(
526 *MockChromeOSNetwork::Get(), 530 *MockChromeOSNetwork::Get(),
527 RequestHiddenWifiNetworkProperties(ssid.c_str(), security.c_str(), _, _)) 531 RequestHiddenWifiNetworkProperties(
532 StrEq(ssid), StrEq(security), _, _))
528 .WillOnce(Invoke( 533 .WillOnce(Invoke(
529 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties4)); 534 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties4));
530 535
531 CrosRequestHiddenWifiNetworkProperties( 536 CrosRequestHiddenWifiNetworkProperties(
532 ssid.c_str(), security.c_str(), 537 ssid, security,
533 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); 538 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result));
534 } 539 }
535 540
536 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestVirtualNetworkProperties) { 541 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestVirtualNetworkProperties) {
537 const std::string service_name = "service name"; 542 const std::string service_name = "service name";
538 const std::string server_hostname = "server hostname"; 543 const std::string server_hostname = "server hostname";
539 const std::string provider_name = "provider name"; 544 const std::string provider_name = "provider name";
540 const std::string key1 = "key1"; 545 const std::string key1 = "key1";
541 const std::string value1 = "value1"; 546 const std::string value1 = "value1";
542 const std::string key2 = "key.2."; 547 const std::string key2 = "key.2.";
543 const std::string value2 = "value2"; 548 const std::string value2 = "value2";
544 // Create result value. 549 // Create result value.
545 base::DictionaryValue result; 550 base::DictionaryValue result;
546 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 551 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1));
547 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 552 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2));
548 result_ghash_table_.reset( 553 result_ghash_table_.reset(
549 ConvertDictionaryValueToStringValueGHashTable(result)); 554 ConvertDictionaryValueToStringValueGHashTable(result));
550 // Set expectations. 555 // Set expectations.
551 EXPECT_CALL(*MockChromeOSNetwork::Get(), 556 EXPECT_CALL(*MockChromeOSNetwork::Get(),
552 RequestVirtualNetworkProperties(service_name.c_str(), 557 RequestVirtualNetworkProperties(
553 server_hostname.c_str(), 558 StrEq(service_name), StrEq(server_hostname),
554 provider_name.c_str(), _, _)) 559 StrEq(provider_name), _, _))
555 .WillOnce(Invoke( 560 .WillOnce(Invoke(
556 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties5)); 561 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties5));
557 562
558 CrosRequestVirtualNetworkProperties( 563 CrosRequestVirtualNetworkProperties(
559 service_name.c_str(), 564 service_name,
560 server_hostname.c_str(), 565 server_hostname,
561 provider_name.c_str(), 566 provider_name,
562 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); 567 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result));
563 } 568 }
564 569
565 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkServiceDisconnect) { 570 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkServiceDisconnect) {
566 const char kServicePath[] = "/service/path"; 571 const std::string service_path = "/service/path";
567 EXPECT_CALL(*MockChromeOSNetwork::Get(), 572 EXPECT_CALL(*MockChromeOSNetwork::Get(),
568 RequestNetworkServiceDisconnect(kServicePath)).Times(1); 573 RequestNetworkServiceDisconnect(StrEq(service_path))).Times(1);
569 CrosRequestNetworkServiceDisconnect(kServicePath); 574 CrosRequestNetworkServiceDisconnect(service_path);
570 } 575 }
571 576
572 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestRemoveNetworkService) { 577 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestRemoveNetworkService) {
573 const char kServicePath[] = "/service/path"; 578 const std::string service_path = "/service/path";
574 EXPECT_CALL(*MockChromeOSNetwork::Get(), 579 EXPECT_CALL(*MockChromeOSNetwork::Get(),
575 RequestRemoveNetworkService(kServicePath)).Times(1); 580 RequestRemoveNetworkService(StrEq(service_path))).Times(1);
576 CrosRequestRemoveNetworkService(kServicePath); 581 CrosRequestRemoveNetworkService(service_path);
577 } 582 }
578 583
579 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkScan) { 584 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkScan) {
580 EXPECT_CALL(*MockChromeOSNetwork::Get(), 585 EXPECT_CALL(*MockChromeOSNetwork::Get(),
581 RequestNetworkScan(flimflam::kTypeWifi)).Times(1); 586 RequestNetworkScan(StrEq(flimflam::kTypeWifi))).Times(1);
582 CrosRequestNetworkScan(flimflam::kTypeWifi); 587 CrosRequestNetworkScan(flimflam::kTypeWifi);
583 } 588 }
584 589
585 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkDeviceEnable) { 590 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkDeviceEnable) {
586 const bool kEnable = true; 591 const bool kEnable = true;
587 EXPECT_CALL(*MockChromeOSNetwork::Get(), 592 EXPECT_CALL(*MockChromeOSNetwork::Get(),
588 RequestNetworkDeviceEnable(flimflam::kTypeWifi, kEnable)) 593 RequestNetworkDeviceEnable(StrEq(flimflam::kTypeWifi), kEnable))
589 .Times(1); 594 .Times(1);
590 CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kEnable); 595 CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kEnable);
591 } 596 }
592 597
593 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRemoveIPConfig) { 598 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRemoveIPConfig) {
594 IPConfig config = {}; 599 IPConfig config = {};
595 config.path = "/path"; 600 config.path = "/path";
596 EXPECT_CALL(*MockChromeOSNetwork::Get(), 601 EXPECT_CALL(*MockChromeOSNetwork::Get(),
597 RemoveIPConfig(&config)).Times(1); 602 RemoveIPConfig(&config)).Times(1);
598 CrosRemoveIPConfig(&config); 603 CrosRemoveIPConfig(&config);
599 } 604 }
600 605
601 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosConfigureService) { 606 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosConfigureService) {
602 EXPECT_CALL(*MockChromeOSNetwork::Get(), 607 EXPECT_CALL(*MockChromeOSNetwork::Get(),
603 ConfigureService(_, _, _, _)) 608 ConfigureService(_, _, _, _))
604 .WillOnce(Invoke( 609 .WillOnce(Invoke(
605 this, &CrosNetworkFunctionsLibcrosTest::OnConfigureService)); 610 this, &CrosNetworkFunctionsLibcrosTest::OnConfigureService));
606 const char key1[] = "key1"; 611 const std::string key1 = "key1";
607 const std::string string1 = "string1"; 612 const std::string string1 = "string1";
608 const char key2[] = "key2"; 613 const std::string key2 = "key2";
609 const std::string string2 = "string2"; 614 const std::string string2 = "string2";
610 base::DictionaryValue value; 615 base::DictionaryValue value;
611 value.SetString(key1, string1); 616 value.SetString(key1, string1);
612 value.SetString(key2, string2); 617 value.SetString(key2, string2);
613 CrosConfigureService(value); 618 CrosConfigureService(value);
614 619
615 // Check the argument GHashTable. 620 // Check the argument GHashTable.
616 const GValue* string1_gvalue = static_cast<const GValue*>( 621 const GValue* string1_gvalue = static_cast<const GValue*>(
617 g_hash_table_lookup(argument_ghash_table_.get(), key1)); 622 g_hash_table_lookup(argument_ghash_table_.get(), key1.c_str()));
618 EXPECT_EQ(string1, g_value_get_string(string1_gvalue)); 623 EXPECT_EQ(string1, g_value_get_string(string1_gvalue));
619 const GValue* string2_gvalue = static_cast<const GValue*>( 624 const GValue* string2_gvalue = static_cast<const GValue*>(
620 g_hash_table_lookup(argument_ghash_table_.get(), key2)); 625 g_hash_table_lookup(argument_ghash_table_.get(), key2.c_str()));
621 EXPECT_EQ(string2, g_value_get_string(string2_gvalue)); 626 EXPECT_EQ(string2, g_value_get_string(string2_gvalue));
622 } 627 }
623 628
624 // Test for cros_network_functions.cc without Libcros. 629 // Test for cros_network_functions.cc without Libcros.
625 class CrosNetworkFunctionsTest : public testing::Test { 630 class CrosNetworkFunctionsTest : public testing::Test {
626 public: 631 public:
627 CrosNetworkFunctionsTest() : mock_profile_client_(NULL), 632 CrosNetworkFunctionsTest() : mock_profile_client_(NULL),
628 dictionary_value_result_(NULL) {} 633 dictionary_value_result_(NULL) {}
629 634
630 virtual void SetUp() { 635 virtual void SetUp() {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 MockCashewClient* mock_cashew_client_; 679 MockCashewClient* mock_cashew_client_;
675 MockFlimflamDeviceClient* mock_device_client_; 680 MockFlimflamDeviceClient* mock_device_client_;
676 MockFlimflamIPConfigClient* mock_ipconfig_client_; 681 MockFlimflamIPConfigClient* mock_ipconfig_client_;
677 MockFlimflamManagerClient* mock_manager_client_; 682 MockFlimflamManagerClient* mock_manager_client_;
678 MockFlimflamProfileClient* mock_profile_client_; 683 MockFlimflamProfileClient* mock_profile_client_;
679 MockFlimflamServiceClient* mock_service_client_; 684 MockFlimflamServiceClient* mock_service_client_;
680 const base::DictionaryValue* dictionary_value_result_; 685 const base::DictionaryValue* dictionary_value_result_;
681 }; 686 };
682 687
683 TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkServiceProperty) { 688 TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkServiceProperty) {
684 const char service_path[] = "/"; 689 const std::string service_path = "/";
685 const char property[] = "property"; 690 const std::string property = "property";
686 const char key1[] = "key1"; 691 const std::string key1 = "key1";
687 const std::string string1 = "string1"; 692 const std::string string1 = "string1";
688 const char key2[] = "key2"; 693 const std::string key2 = "key2";
689 const std::string string2 = "string2"; 694 const std::string string2 = "string2";
690 base::DictionaryValue value; 695 base::DictionaryValue value;
691 value.SetString(key1, string1); 696 value.SetString(key1, string1);
692 value.SetString(key2, string2); 697 value.SetString(key2, string2);
693 EXPECT_CALL(*mock_service_client_, 698 EXPECT_CALL(*mock_service_client_,
694 SetProperty(dbus::ObjectPath(service_path), property, 699 SetProperty(dbus::ObjectPath(service_path), property,
695 IsEqualTo(&value), _)).Times(1); 700 IsEqualTo(&value), _)).Times(1);
696 701
697 CrosSetNetworkServiceProperty(service_path, property, value); 702 CrosSetNetworkServiceProperty(service_path, property, value);
698 } 703 }
699 704
700 TEST_F(CrosNetworkFunctionsTest, CrosClearNetworkServiceProperty) { 705 TEST_F(CrosNetworkFunctionsTest, CrosClearNetworkServiceProperty) {
701 const char service_path[] = "/"; 706 const std::string service_path = "/";
702 const char property[] = "property"; 707 const std::string property = "property";
703 EXPECT_CALL(*mock_service_client_, 708 EXPECT_CALL(*mock_service_client_,
704 ClearProperty(dbus::ObjectPath(service_path), property, _)) 709 ClearProperty(dbus::ObjectPath(service_path), property, _))
705 .Times(1); 710 .Times(1);
706 711
707 CrosClearNetworkServiceProperty(service_path, property); 712 CrosClearNetworkServiceProperty(service_path, property);
708 } 713 }
709 714
710 TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkDeviceProperty) { 715 TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkDeviceProperty) {
711 const char device_path[] = "/"; 716 const std::string device_path = "/";
712 const char property[] = "property"; 717 const std::string property = "property";
713 const bool kBool = true; 718 const bool kBool = true;
714 const base::FundamentalValue value(kBool); 719 const base::FundamentalValue value(kBool);
715 EXPECT_CALL(*mock_device_client_, 720 EXPECT_CALL(*mock_device_client_,
716 SetProperty(dbus::ObjectPath(device_path), property, 721 SetProperty(dbus::ObjectPath(device_path), StrEq(property),
717 IsEqualTo(&value), _)).Times(1); 722 IsEqualTo(&value), _)).Times(1);
718 723
719 CrosSetNetworkDeviceProperty(device_path, property, value); 724 CrosSetNetworkDeviceProperty(device_path, property, value);
720 } 725 }
721 726
722 TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkIPConfigProperty) { 727 TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkIPConfigProperty) {
723 const char ipconfig_path[] = "/"; 728 const std::string ipconfig_path = "/";
724 const char property[] = "property"; 729 const std::string property = "property";
725 const int kInt = 1234; 730 const int kInt = 1234;
726 const base::FundamentalValue value(kInt); 731 const base::FundamentalValue value(kInt);
727 EXPECT_CALL(*mock_ipconfig_client_, 732 EXPECT_CALL(*mock_ipconfig_client_,
728 SetProperty(dbus::ObjectPath(ipconfig_path), property, 733 SetProperty(dbus::ObjectPath(ipconfig_path), property,
729 IsEqualTo(&value), _)).Times(1); 734 IsEqualTo(&value), _)).Times(1);
730 CrosSetNetworkIPConfigProperty(ipconfig_path, property, value); 735 CrosSetNetworkIPConfigProperty(ipconfig_path, property, value);
731 } 736 }
732 737
733 TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkManagerProperty) { 738 TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkManagerProperty) {
734 const char property[] = "property"; 739 const std::string property = "property";
735 const std::string kString = "string"; 740 const base::StringValue value("string");
736 const base::StringValue value(kString);
737 EXPECT_CALL(*mock_manager_client_, 741 EXPECT_CALL(*mock_manager_client_,
738 SetProperty(property, IsEqualTo(&value), _)).Times(1); 742 SetProperty(property, IsEqualTo(&value), _)).Times(1);
739 743
740 CrosSetNetworkManagerProperty(property, value); 744 CrosSetNetworkManagerProperty(property, value);
741 } 745 }
742 746
743 TEST_F(CrosNetworkFunctionsTest, CrosDeleteServiceFromProfile) { 747 TEST_F(CrosNetworkFunctionsTest, CrosDeleteServiceFromProfile) {
744 const std::string profile_path("/profile/path"); 748 const std::string profile_path("/profile/path");
745 const std::string service_path("/service/path"); 749 const std::string service_path("/service/path");
746 EXPECT_CALL(*mock_profile_client_, 750 EXPECT_CALL(*mock_profile_client_,
747 DeleteEntry(dbus::ObjectPath(profile_path), service_path, _)) 751 DeleteEntry(dbus::ObjectPath(profile_path), service_path, _))
748 .Times(1); 752 .Times(1);
749 CrosDeleteServiceFromProfile(profile_path.c_str(), service_path.c_str()); 753 CrosDeleteServiceFromProfile(profile_path, service_path);
750 } 754 }
751 755
752 TEST_F(CrosNetworkFunctionsTest, CrosRequestCellularDataPlanUpdate) { 756 TEST_F(CrosNetworkFunctionsTest, CrosRequestCellularDataPlanUpdate) {
753 const char kModemServicePath[] = "/modem/service/path"; 757 const std::string modem_service_path = "/modem/service/path";
754 EXPECT_CALL(*mock_cashew_client_, 758 EXPECT_CALL(*mock_cashew_client_,
755 RequestDataPlansUpdate(kModemServicePath)).Times(1); 759 RequestDataPlansUpdate(modem_service_path)).Times(1);
756 CrosRequestCellularDataPlanUpdate(kModemServicePath); 760 CrosRequestCellularDataPlanUpdate(modem_service_path);
757 } 761 }
758 762
759 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkManagerProperties) { 763 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkManagerProperties) {
760 const std::string key = "key"; 764 const std::string key = "key";
761 const int kValue = 42; 765 const int kValue = 42;
762 const base::FundamentalValue value(kValue); 766 const base::FundamentalValue value(kValue);
763 // Start monitoring. 767 // Start monitoring.
764 FlimflamClientHelper::PropertyChangedHandler handler; 768 FlimflamClientHelper::PropertyChangedHandler handler;
765 EXPECT_CALL(*mock_manager_client_, SetPropertyChangedHandler(_)) 769 EXPECT_CALL(*mock_manager_client_, SetPropertyChangedHandler(_))
766 .WillOnce(SaveArg<0>(&handler)); 770 .WillOnce(SaveArg<0>(&handler));
(...skipping 10 matching lines...) Expand all
777 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkServiceProperties) { 781 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkServiceProperties) {
778 const dbus::ObjectPath path("/path"); 782 const dbus::ObjectPath path("/path");
779 const std::string key = "key"; 783 const std::string key = "key";
780 const int kValue = 42; 784 const int kValue = 42;
781 const base::FundamentalValue value(kValue); 785 const base::FundamentalValue value(kValue);
782 // Start monitoring. 786 // Start monitoring.
783 FlimflamClientHelper::PropertyChangedHandler handler; 787 FlimflamClientHelper::PropertyChangedHandler handler;
784 EXPECT_CALL(*mock_service_client_, SetPropertyChangedHandler(path, _)) 788 EXPECT_CALL(*mock_service_client_, SetPropertyChangedHandler(path, _))
785 .WillOnce(SaveArg<1>(&handler)); 789 .WillOnce(SaveArg<1>(&handler));
786 NetworkPropertiesWatcherCallback callback = 790 NetworkPropertiesWatcherCallback callback =
787 MockNetworkPropertiesWatcherCallback::CreateCallback(path.value().c_str(), 791 MockNetworkPropertiesWatcherCallback::CreateCallback(path.value(),
788 key, value); 792 key, value);
789 CrosNetworkWatcher* watcher = CrosMonitorNetworkServiceProperties( 793 CrosNetworkWatcher* watcher = CrosMonitorNetworkServiceProperties(
790 callback, path.value().c_str()); 794 callback, path.value());
791 // Call callback. 795 // Call callback.
792 handler.Run(key, value); 796 handler.Run(key, value);
793 // Stop monitoring. 797 // Stop monitoring.
794 EXPECT_CALL(*mock_service_client_, 798 EXPECT_CALL(*mock_service_client_,
795 ResetPropertyChangedHandler(path)).Times(1); 799 ResetPropertyChangedHandler(path)).Times(1);
796 delete watcher; 800 delete watcher;
797 } 801 }
798 802
799 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkDeviceProperties) { 803 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkDeviceProperties) {
800 const dbus::ObjectPath path("/path"); 804 const dbus::ObjectPath path("/path");
801 const std::string key = "key"; 805 const std::string key = "key";
802 const int kValue = 42; 806 const int kValue = 42;
803 const base::FundamentalValue value(kValue); 807 const base::FundamentalValue value(kValue);
804 // Start monitoring. 808 // Start monitoring.
805 FlimflamClientHelper::PropertyChangedHandler handler; 809 FlimflamClientHelper::PropertyChangedHandler handler;
806 EXPECT_CALL(*mock_device_client_, SetPropertyChangedHandler(path, _)) 810 EXPECT_CALL(*mock_device_client_, SetPropertyChangedHandler(path, _))
807 .WillOnce(SaveArg<1>(&handler)); 811 .WillOnce(SaveArg<1>(&handler));
808 NetworkPropertiesWatcherCallback callback = 812 NetworkPropertiesWatcherCallback callback =
809 MockNetworkPropertiesWatcherCallback::CreateCallback(path.value().c_str(), 813 MockNetworkPropertiesWatcherCallback::CreateCallback(path.value(),
810 key, value); 814 key, value);
811 CrosNetworkWatcher* watcher = CrosMonitorNetworkDeviceProperties( 815 CrosNetworkWatcher* watcher = CrosMonitorNetworkDeviceProperties(
812 callback, path.value().c_str()); 816 callback, path.value());
813 // Call callback. 817 // Call callback.
814 handler.Run(key, value); 818 handler.Run(key, value);
815 // Stop monitoring. 819 // Stop monitoring.
816 EXPECT_CALL(*mock_device_client_, 820 EXPECT_CALL(*mock_device_client_,
817 ResetPropertyChangedHandler(path)).Times(1); 821 ResetPropertyChangedHandler(path)).Times(1);
818 delete watcher; 822 delete watcher;
819 } 823 }
820 824
821 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkManagerProperties) { 825 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkManagerProperties) {
822 const std::string key1 = "key1"; 826 const std::string key1 = "key1";
(...skipping 26 matching lines...) Expand all
849 base::DictionaryValue result; 853 base::DictionaryValue result;
850 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 854 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1));
851 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 855 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2));
852 // Set expectations. 856 // Set expectations.
853 dictionary_value_result_ = &result; 857 dictionary_value_result_ = &result;
854 EXPECT_CALL(*mock_service_client_, 858 EXPECT_CALL(*mock_service_client_,
855 GetProperties(dbus::ObjectPath(service_path), _)).WillOnce( 859 GetProperties(dbus::ObjectPath(service_path), _)).WillOnce(
856 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); 860 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties));
857 861
858 CrosRequestNetworkServiceProperties( 862 CrosRequestNetworkServiceProperties(
859 service_path.c_str(), 863 service_path,
860 MockNetworkPropertiesCallback::CreateCallback(service_path.c_str(), 864 MockNetworkPropertiesCallback::CreateCallback(service_path, result));
861 result));
862 } 865 }
863 866
864 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkDeviceProperties) { 867 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkDeviceProperties) {
865 const std::string device_path = "/device/path"; 868 const std::string device_path = "/device/path";
866 const std::string key1 = "key1"; 869 const std::string key1 = "key1";
867 const std::string value1 = "value1"; 870 const std::string value1 = "value1";
868 const std::string key2 = "key.2."; 871 const std::string key2 = "key.2.";
869 const std::string value2 = "value2"; 872 const std::string value2 = "value2";
870 // Create result value. 873 // Create result value.
871 base::DictionaryValue result; 874 base::DictionaryValue result;
872 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 875 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1));
873 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 876 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2));
874 // Set expectations. 877 // Set expectations.
875 dictionary_value_result_ = &result; 878 dictionary_value_result_ = &result;
876 EXPECT_CALL(*mock_device_client_, 879 EXPECT_CALL(*mock_device_client_,
877 GetProperties(dbus::ObjectPath(device_path), _)).WillOnce( 880 GetProperties(dbus::ObjectPath(device_path), _)).WillOnce(
878 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); 881 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties));
879 882
880 CrosRequestNetworkDeviceProperties( 883 CrosRequestNetworkDeviceProperties(
881 device_path.c_str(), 884 device_path,
882 MockNetworkPropertiesCallback::CreateCallback(device_path.c_str(), 885 MockNetworkPropertiesCallback::CreateCallback(device_path, result));
883 result));
884 } 886 }
885 887
886 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileProperties) { 888 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileProperties) {
887 const std::string profile_path = "/profile/path"; 889 const std::string profile_path = "/profile/path";
888 const std::string key1 = "key1"; 890 const std::string key1 = "key1";
889 const std::string value1 = "value1"; 891 const std::string value1 = "value1";
890 const std::string key2 = "key.2."; 892 const std::string key2 = "key.2.";
891 const std::string value2 = "value2"; 893 const std::string value2 = "value2";
892 // Create result value. 894 // Create result value.
893 base::DictionaryValue result; 895 base::DictionaryValue result;
894 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 896 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1));
895 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 897 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2));
896 // Set expectations. 898 // Set expectations.
897 dictionary_value_result_ = &result; 899 dictionary_value_result_ = &result;
898 EXPECT_CALL(*mock_profile_client_, 900 EXPECT_CALL(*mock_profile_client_,
899 GetProperties(dbus::ObjectPath(profile_path), _)).WillOnce( 901 GetProperties(dbus::ObjectPath(profile_path), _)).WillOnce(
900 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); 902 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties));
901 903
902 CrosRequestNetworkProfileProperties( 904 CrosRequestNetworkProfileProperties(
903 profile_path.c_str(), 905 profile_path,
904 MockNetworkPropertiesCallback::CreateCallback(profile_path.c_str(), 906 MockNetworkPropertiesCallback::CreateCallback(profile_path, result));
905 result));
906 } 907 }
907 908
908 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileEntryProperties) { 909 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileEntryProperties) {
909 const std::string profile_path = "profile path"; 910 const std::string profile_path = "profile path";
910 const std::string profile_entry_path = "profile entry path"; 911 const std::string profile_entry_path = "profile entry path";
911 const std::string key1 = "key1"; 912 const std::string key1 = "key1";
912 const std::string value1 = "value1"; 913 const std::string value1 = "value1";
913 const std::string key2 = "key.2."; 914 const std::string key2 = "key.2.";
914 const std::string value2 = "value2"; 915 const std::string value2 = "value2";
915 // Create result value. 916 // Create result value.
916 base::DictionaryValue result; 917 base::DictionaryValue result;
917 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 918 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1));
918 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 919 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2));
919 // Set expectations. 920 // Set expectations.
920 dictionary_value_result_ = &result; 921 dictionary_value_result_ = &result;
921 EXPECT_CALL(*mock_profile_client_, 922 EXPECT_CALL(*mock_profile_client_,
922 GetEntry(dbus::ObjectPath(profile_path), profile_entry_path, _)) 923 GetEntry(dbus::ObjectPath(profile_path), profile_entry_path, _))
923 .WillOnce(Invoke(this, &CrosNetworkFunctionsTest::OnGetEntry)); 924 .WillOnce(Invoke(this, &CrosNetworkFunctionsTest::OnGetEntry));
924 925
925 CrosRequestNetworkProfileEntryProperties( 926 CrosRequestNetworkProfileEntryProperties(
926 profile_path.c_str(), profile_entry_path.c_str(), 927 profile_path, profile_entry_path,
927 MockNetworkPropertiesCallback::CreateCallback(profile_entry_path.c_str(), 928 MockNetworkPropertiesCallback::CreateCallback(profile_entry_path,
928 result)); 929 result));
929 } 930 }
930 931
931 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkServiceDisconnect) { 932 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkServiceDisconnect) {
932 const char kServicePath[] = "/service/path"; 933 const std::string service_path = "/service/path";
933 EXPECT_CALL(*mock_service_client_, 934 EXPECT_CALL(*mock_service_client_,
934 Disconnect(dbus::ObjectPath(kServicePath), _)).Times(1); 935 Disconnect(dbus::ObjectPath(service_path), _)).Times(1);
935 CrosRequestNetworkServiceDisconnect(kServicePath); 936 CrosRequestNetworkServiceDisconnect(service_path);
936 } 937 }
937 938
938 TEST_F(CrosNetworkFunctionsTest, CrosRequestRemoveNetworkService) { 939 TEST_F(CrosNetworkFunctionsTest, CrosRequestRemoveNetworkService) {
939 const char kServicePath[] = "/service/path"; 940 const std::string service_path = "/service/path";
940 EXPECT_CALL(*mock_service_client_, 941 EXPECT_CALL(*mock_service_client_,
941 Remove(dbus::ObjectPath(kServicePath), _)).Times(1); 942 Remove(dbus::ObjectPath(service_path), _)).Times(1);
942 CrosRequestRemoveNetworkService(kServicePath); 943 CrosRequestRemoveNetworkService(service_path);
943 } 944 }
944 945
945 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkScan) { 946 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkScan) {
946 EXPECT_CALL(*mock_manager_client_, 947 EXPECT_CALL(*mock_manager_client_,
947 RequestScan(flimflam::kTypeWifi, _)).Times(1); 948 RequestScan(flimflam::kTypeWifi, _)).Times(1);
948 CrosRequestNetworkScan(flimflam::kTypeWifi); 949 CrosRequestNetworkScan(flimflam::kTypeWifi);
949 } 950 }
950 951
951 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkDeviceEnable) { 952 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkDeviceEnable) {
952 const bool kEnable = true; 953 const bool kEnable = true;
953 EXPECT_CALL(*mock_manager_client_, 954 EXPECT_CALL(*mock_manager_client_,
954 EnableTechnology(flimflam::kTypeWifi, _)).Times(1); 955 EnableTechnology(flimflam::kTypeWifi, _)).Times(1);
955 CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kEnable); 956 CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kEnable);
956 957
957 const bool kDisable = false; 958 const bool kDisable = false;
958 EXPECT_CALL(*mock_manager_client_, 959 EXPECT_CALL(*mock_manager_client_,
959 DisableTechnology(flimflam::kTypeWifi, _)).Times(1); 960 DisableTechnology(flimflam::kTypeWifi, _)).Times(1);
960 CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kDisable); 961 CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kDisable);
961 } 962 }
962 963
963 TEST_F(CrosNetworkFunctionsTest, CrosRemoveIPConfig) { 964 TEST_F(CrosNetworkFunctionsTest, CrosRemoveIPConfig) {
964 IPConfig config = {}; 965 IPConfig config = {};
965 config.path = "/path"; 966 config.path = "/path";
966 EXPECT_CALL(*mock_ipconfig_client_, 967 EXPECT_CALL(*mock_ipconfig_client_,
967 CallRemoveAndBlock(dbus::ObjectPath(config.path))).Times(1); 968 CallRemoveAndBlock(dbus::ObjectPath(config.path))).Times(1);
968 CrosRemoveIPConfig(&config); 969 CrosRemoveIPConfig(&config);
969 } 970 }
970 971
971 TEST_F(CrosNetworkFunctionsTest, CrosConfigureService) { 972 TEST_F(CrosNetworkFunctionsTest, CrosConfigureService) {
972 const char key1[] = "key1"; 973 const std::string key1 = "key1";
973 const std::string string1 = "string1"; 974 const std::string string1 = "string1";
974 const char key2[] = "key2"; 975 const std::string key2 = "key2";
975 const std::string string2 = "string2"; 976 const std::string string2 = "string2";
976 base::DictionaryValue value; 977 base::DictionaryValue value;
977 value.SetString(key1, string1); 978 value.SetString(key1, string1);
978 value.SetString(key2, string2); 979 value.SetString(key2, string2);
979 EXPECT_CALL(*mock_manager_client_, ConfigureService(IsEqualTo(&value), _)) 980 EXPECT_CALL(*mock_manager_client_, ConfigureService(IsEqualTo(&value), _))
980 .Times(1); 981 .Times(1);
981 CrosConfigureService(value); 982 CrosConfigureService(value);
982 } 983 }
983 984
984 } // namespace chromeos 985 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/cros_network_functions.cc ('k') | chrome/browser/chromeos/cros/network_library_impl_cros.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698