OLD | NEW |
---|---|
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 20 matching lines...) Expand all Loading... | |
31 namespace { | 31 namespace { |
32 | 32 |
33 const char kExamplePath[] = "/foo/bar/baz"; | 33 const char kExamplePath[] = "/foo/bar/baz"; |
34 | 34 |
35 // A mock to check arguments of NetworkPropertiesCallback and ensure that the | 35 // A mock to check arguments of NetworkPropertiesCallback and ensure that the |
36 // callback is called exactly once. | 36 // callback is called exactly once. |
37 class MockNetworkPropertiesCallback { | 37 class MockNetworkPropertiesCallback { |
38 public: | 38 public: |
39 // Creates a NetworkPropertiesCallback with expectations. | 39 // Creates a NetworkPropertiesCallback with expectations. |
40 static NetworkPropertiesCallback CreateCallback( | 40 static NetworkPropertiesCallback CreateCallback( |
41 const char* expected_path, | 41 const std::string& expected_path, |
42 const base::DictionaryValue& expected_result) { | 42 const base::DictionaryValue& expected_result) { |
43 MockNetworkPropertiesCallback* mock_callback = | 43 MockNetworkPropertiesCallback* mock_callback = |
44 new MockNetworkPropertiesCallback; | 44 new MockNetworkPropertiesCallback; |
45 | 45 |
46 EXPECT_CALL(*mock_callback, | 46 EXPECT_CALL(*mock_callback, |
47 Run(StrEq(expected_path), Pointee(IsEqualTo(&expected_result)))) | 47 Run(expected_path, Pointee(IsEqualTo(&expected_result)))) |
48 .Times(1); | 48 .Times(1); |
49 | 49 |
50 return base::Bind(&MockNetworkPropertiesCallback::Run, | 50 return base::Bind(&MockNetworkPropertiesCallback::Run, |
51 base::Owned(mock_callback)); | 51 base::Owned(mock_callback)); |
52 } | 52 } |
53 | 53 |
54 MOCK_METHOD2(Run, void(const char* path, | 54 MOCK_METHOD2(Run, void(const std::string& path, |
55 const base::DictionaryValue* result)); | 55 const base::DictionaryValue* result)); |
56 }; | 56 }; |
57 | 57 |
58 // A mock to check arguments of NetworkPropertiesWatcherCallback and ensure that | 58 // A mock to check arguments of NetworkPropertiesWatcherCallback and ensure that |
59 // the callback is called exactly once. | 59 // the callback is called exactly once. |
60 class MockNetworkPropertiesWatcherCallback { | 60 class MockNetworkPropertiesWatcherCallback { |
61 public: | 61 public: |
62 // Creates a NetworkPropertiesWatcherCallback with expectations. | 62 // Creates a NetworkPropertiesWatcherCallback with expectations. |
63 static NetworkPropertiesWatcherCallback CreateCallback( | 63 static NetworkPropertiesWatcherCallback CreateCallback( |
64 const std::string& expected_path, | 64 const std::string& expected_path, |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 base::Callback<void(const char* path, | 181 base::Callback<void(const char* path, |
182 const char* key, | 182 const char* key, |
183 const GValue* gvalue)> property_changed_callback_; | 183 const GValue* gvalue)> property_changed_callback_; |
184 }; | 184 }; |
185 | 185 |
186 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkServiceProperty) { | 186 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkServiceProperty) { |
187 const char service_path[] = "/"; | 187 const char service_path[] = "/"; |
188 const char property[] = "property"; | 188 const char property[] = "property"; |
189 EXPECT_CALL( | 189 EXPECT_CALL( |
190 *MockChromeOSNetwork::Get(), | 190 *MockChromeOSNetwork::Get(), |
191 SetNetworkServicePropertyGValue(service_path, property, _)) | 191 SetNetworkServicePropertyGValue(StrEq(service_path), StrEq(property), _)) |
192 .WillOnce(Invoke( | 192 .WillOnce(Invoke( |
193 this, &CrosNetworkFunctionsLibcrosTest::OnSetNetworkPropertyGValue)); | 193 this, &CrosNetworkFunctionsLibcrosTest::OnSetNetworkPropertyGValue)); |
194 const char key1[] = "key1"; | 194 const char key1[] = "key1"; |
195 const std::string string1 = "string1"; | 195 const std::string string1 = "string1"; |
196 const char key2[] = "key2"; | 196 const char key2[] = "key2"; |
197 const std::string string2 = "string2"; | 197 const std::string string2 = "string2"; |
198 base::DictionaryValue value; | 198 base::DictionaryValue value; |
199 value.SetString(key1, string1); | 199 value.SetString(key1, string1); |
200 value.SetString(key2, string2); | 200 value.SetString(key2, string2); |
201 CrosSetNetworkServiceProperty(service_path, property, value); | 201 CrosSetNetworkServiceProperty(service_path, property, value); |
202 | 202 |
203 // Check the argument GHashTable. | 203 // Check the argument GHashTable. |
204 GHashTable* ghash_table = | 204 GHashTable* ghash_table = |
205 static_cast<GHashTable*>(g_value_get_boxed(argument_gvalue_.get())); | 205 static_cast<GHashTable*>(g_value_get_boxed(argument_gvalue_.get())); |
206 ASSERT_TRUE(ghash_table != NULL); | 206 ASSERT_TRUE(ghash_table != NULL); |
207 EXPECT_EQ(string1, static_cast<const char*>( | 207 EXPECT_EQ(string1, static_cast<const char*>( |
208 g_hash_table_lookup(ghash_table, key1))); | 208 g_hash_table_lookup(ghash_table, key1))); |
209 EXPECT_EQ(string2, static_cast<const char*>( | 209 EXPECT_EQ(string2, static_cast<const char*>( |
210 g_hash_table_lookup(ghash_table, key2))); | 210 g_hash_table_lookup(ghash_table, key2))); |
211 } | 211 } |
212 | 212 |
213 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosClearNetworkServiceProperty) { | 213 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosClearNetworkServiceProperty) { |
214 const char service_path[] = "/"; | 214 const char service_path[] = "/"; |
215 const char property[] = "property"; | 215 const char property[] = "property"; |
stevenjb
2012/04/20 17:18:28
Shouldn't we use std::string here and elsewhere?
hashimoto
2012/04/22 05:44:50
Sounds good.
Done.
| |
216 EXPECT_CALL(*MockChromeOSNetwork::Get(), | 216 EXPECT_CALL(*MockChromeOSNetwork::Get(), |
217 ClearNetworkServiceProperty(service_path, property)).Times(1); | 217 ClearNetworkServiceProperty(StrEq(service_path), |
218 StrEq(property))).Times(1); | |
218 CrosClearNetworkServiceProperty(service_path, property); | 219 CrosClearNetworkServiceProperty(service_path, property); |
219 } | 220 } |
220 | 221 |
221 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkDeviceProperty) { | 222 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkDeviceProperty) { |
222 const char device_path[] = "/"; | 223 const char device_path[] = "/"; |
223 const char property[] = "property"; | 224 const char property[] = "property"; |
224 EXPECT_CALL( | 225 EXPECT_CALL( |
225 *MockChromeOSNetwork::Get(), | 226 *MockChromeOSNetwork::Get(), |
226 SetNetworkDevicePropertyGValue(device_path, property, _)) | 227 SetNetworkDevicePropertyGValue(StrEq(device_path), StrEq(property), _)) |
227 .WillOnce(Invoke( | 228 .WillOnce(Invoke( |
228 this, &CrosNetworkFunctionsLibcrosTest::OnSetNetworkPropertyGValue)); | 229 this, &CrosNetworkFunctionsLibcrosTest::OnSetNetworkPropertyGValue)); |
229 const bool kBool = true; | 230 const bool kBool = true; |
230 const base::FundamentalValue value(kBool); | 231 const base::FundamentalValue value(kBool); |
231 CrosSetNetworkDeviceProperty(device_path, property, value); | 232 CrosSetNetworkDeviceProperty(device_path, property, value); |
232 EXPECT_EQ(kBool, g_value_get_boolean(argument_gvalue_.get())); | 233 EXPECT_EQ(kBool, g_value_get_boolean(argument_gvalue_.get())); |
233 } | 234 } |
234 | 235 |
235 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkIPConfigProperty) { | 236 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkIPConfigProperty) { |
236 const char ipconfig_path[] = "/"; | 237 const char ipconfig_path[] = "/"; |
237 const char property[] = "property"; | 238 const char property[] = "property"; |
238 EXPECT_CALL( | 239 EXPECT_CALL( |
239 *MockChromeOSNetwork::Get(), | 240 *MockChromeOSNetwork::Get(), |
240 SetNetworkIPConfigPropertyGValue(ipconfig_path, property, _)) | 241 SetNetworkIPConfigPropertyGValue(StrEq(ipconfig_path), |
242 StrEq(property), _)) | |
241 .WillOnce(Invoke( | 243 .WillOnce(Invoke( |
242 this, &CrosNetworkFunctionsLibcrosTest::OnSetNetworkPropertyGValue)); | 244 this, &CrosNetworkFunctionsLibcrosTest::OnSetNetworkPropertyGValue)); |
243 const int kInt = 1234; | 245 const int kInt = 1234; |
244 const base::FundamentalValue value(kInt); | 246 const base::FundamentalValue value(kInt); |
245 CrosSetNetworkIPConfigProperty(ipconfig_path, property, value); | 247 CrosSetNetworkIPConfigProperty(ipconfig_path, property, value); |
246 EXPECT_EQ(kInt, g_value_get_int(argument_gvalue_.get())); | 248 EXPECT_EQ(kInt, g_value_get_int(argument_gvalue_.get())); |
247 } | 249 } |
248 | 250 |
249 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkManagerProperty) { | 251 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkManagerProperty) { |
250 const char property[] = "property"; | 252 const char property[] = "property"; |
251 EXPECT_CALL( | 253 EXPECT_CALL( |
252 *MockChromeOSNetwork::Get(), | 254 *MockChromeOSNetwork::Get(), |
253 SetNetworkManagerPropertyGValue(property, _)) | 255 SetNetworkManagerPropertyGValue(StrEq(property), _)) |
254 .WillOnce(Invoke( | 256 .WillOnce(Invoke( |
255 this, | 257 this, |
256 &CrosNetworkFunctionsLibcrosTest::OnSetNetworkManagerPropertyGValue)); | 258 &CrosNetworkFunctionsLibcrosTest::OnSetNetworkManagerPropertyGValue)); |
257 const std::string kString = "string"; | 259 const std::string kString = "string"; |
258 const base::StringValue value(kString); | 260 const base::StringValue value(kString); |
259 CrosSetNetworkManagerProperty(property, value); | 261 CrosSetNetworkManagerProperty(property, value); |
260 EXPECT_EQ(kString, g_value_get_string(argument_gvalue_.get())); | 262 EXPECT_EQ(kString, g_value_get_string(argument_gvalue_.get())); |
261 } | 263 } |
262 | 264 |
263 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestCellularDataPlanUpdate) { | 265 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestCellularDataPlanUpdate) { |
264 const char kModemServicePath[] = "/modem/service/path"; | 266 const char kModemServicePath[] = "/modem/service/path"; |
265 EXPECT_CALL(*MockChromeOSNetwork::Get(), | 267 EXPECT_CALL(*MockChromeOSNetwork::Get(), |
266 RequestCellularDataPlanUpdate(kModemServicePath)).Times(1); | 268 RequestCellularDataPlanUpdate(StrEq(kModemServicePath))).Times(1); |
267 CrosRequestCellularDataPlanUpdate(kModemServicePath); | 269 CrosRequestCellularDataPlanUpdate(kModemServicePath); |
268 } | 270 } |
269 | 271 |
270 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorNetworkManagerProperties) { | 272 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorNetworkManagerProperties) { |
271 const std::string path = "path"; | 273 const std::string path = "path"; |
272 const std::string key = "key"; | 274 const std::string key = "key"; |
273 const int kValue = 42; | 275 const int kValue = 42; |
274 const base::FundamentalValue value(kValue); | 276 const base::FundamentalValue value(kValue); |
275 | 277 |
276 // Start monitoring. | 278 // Start monitoring. |
(...skipping 18 matching lines...) Expand all Loading... | |
295 } | 297 } |
296 | 298 |
297 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorNetworkServiceProperties) { | 299 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorNetworkServiceProperties) { |
298 const std::string path = "path"; | 300 const std::string path = "path"; |
299 const std::string key = "key"; | 301 const std::string key = "key"; |
300 const int kValue = 42; | 302 const int kValue = 42; |
301 const base::FundamentalValue value(kValue); | 303 const base::FundamentalValue value(kValue); |
302 | 304 |
303 // Start monitoring. | 305 // Start monitoring. |
304 EXPECT_CALL(*MockChromeOSNetwork::Get(), | 306 EXPECT_CALL(*MockChromeOSNetwork::Get(), |
305 MonitorNetworkServiceProperties(_, path.c_str(), _)) | 307 MonitorNetworkServiceProperties(_, StrEq(path.c_str()), _)) |
stevenjb
2012/04/20 17:18:28
Do we need to use StrEq and .c_str() here and else
hashimoto
2012/04/22 05:44:50
I didn't know that StrEq can take a std::string as
| |
306 .WillOnce(Invoke( | 308 .WillOnce(Invoke( |
307 this, | 309 this, |
308 &CrosNetworkFunctionsLibcrosTest::OnMonitorNetworkProperties)); | 310 &CrosNetworkFunctionsLibcrosTest::OnMonitorNetworkProperties)); |
309 CrosNetworkWatcher* watcher = CrosMonitorNetworkServiceProperties( | 311 CrosNetworkWatcher* watcher = CrosMonitorNetworkServiceProperties( |
310 MockNetworkPropertiesWatcherCallback::CreateCallback(path, key, value), | 312 MockNetworkPropertiesWatcherCallback::CreateCallback(path, key, value), |
311 path); | 313 path); |
312 | 314 |
313 // Call callback. | 315 // Call callback. |
314 ScopedGValue gvalue(new GValue()); | 316 ScopedGValue gvalue(new GValue()); |
315 g_value_init(gvalue.get(), G_TYPE_INT); | 317 g_value_init(gvalue.get(), G_TYPE_INT); |
316 g_value_set_int(gvalue.get(), kValue); | 318 g_value_set_int(gvalue.get(), kValue); |
317 property_changed_callback_.Run(path.c_str(), key.c_str(), gvalue.get()); | 319 property_changed_callback_.Run(path.c_str(), key.c_str(), gvalue.get()); |
318 | 320 |
319 // Stop monitoring. | 321 // Stop monitoring. |
320 EXPECT_CALL(*MockChromeOSNetwork::Get(), | 322 EXPECT_CALL(*MockChromeOSNetwork::Get(), |
321 DisconnectNetworkPropertiesMonitor(_)).Times(1); | 323 DisconnectNetworkPropertiesMonitor(_)).Times(1); |
322 delete watcher; | 324 delete watcher; |
323 } | 325 } |
324 | 326 |
325 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorNetworkDeviceProperties) { | 327 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorNetworkDeviceProperties) { |
326 const std::string path = "path"; | 328 const std::string path = "path"; |
327 const std::string key = "key"; | 329 const std::string key = "key"; |
328 const int kValue = 42; | 330 const int kValue = 42; |
329 const base::FundamentalValue value(kValue); | 331 const base::FundamentalValue value(kValue); |
330 | 332 |
331 // Start monitoring. | 333 // Start monitoring. |
332 EXPECT_CALL(*MockChromeOSNetwork::Get(), | 334 EXPECT_CALL(*MockChromeOSNetwork::Get(), |
333 MonitorNetworkDeviceProperties(_, path.c_str(), _)) | 335 MonitorNetworkDeviceProperties(_, StrEq(path.c_str()), _)) |
334 .WillOnce(Invoke( | 336 .WillOnce(Invoke( |
335 this, | 337 this, |
336 &CrosNetworkFunctionsLibcrosTest::OnMonitorNetworkProperties)); | 338 &CrosNetworkFunctionsLibcrosTest::OnMonitorNetworkProperties)); |
337 CrosNetworkWatcher* watcher = CrosMonitorNetworkDeviceProperties( | 339 CrosNetworkWatcher* watcher = CrosMonitorNetworkDeviceProperties( |
338 MockNetworkPropertiesWatcherCallback::CreateCallback(path, key, value), | 340 MockNetworkPropertiesWatcherCallback::CreateCallback(path, key, value), |
339 path); | 341 path); |
340 | 342 |
341 // Call callback. | 343 // Call callback. |
342 ScopedGValue gvalue(new GValue()); | 344 ScopedGValue gvalue(new GValue()); |
343 g_value_init(gvalue.get(), G_TYPE_INT); | 345 g_value_init(gvalue.get(), G_TYPE_INT); |
(...skipping 23 matching lines...) Expand all Loading... | |
367 } | 369 } |
368 | 370 |
369 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorSMS) { | 371 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorSMS) { |
370 const std::string modem_device_path = "/modem/device/path"; | 372 const std::string modem_device_path = "/modem/device/path"; |
371 MonitorSMSCallback callback = | 373 MonitorSMSCallback callback = |
372 reinterpret_cast<MonitorSMSCallback>(42); // Dummy value. | 374 reinterpret_cast<MonitorSMSCallback>(42); // Dummy value. |
373 void* object = reinterpret_cast<void*>(84); // Dummy value. | 375 void* object = reinterpret_cast<void*>(84); // Dummy value. |
374 | 376 |
375 // Start monitoring. | 377 // Start monitoring. |
376 EXPECT_CALL(*MockChromeOSNetwork::Get(), | 378 EXPECT_CALL(*MockChromeOSNetwork::Get(), |
377 MonitorSMS(modem_device_path.c_str(), callback, object)).Times(1); | 379 MonitorSMS(StrEq(modem_device_path.c_str()), callback, object)) |
380 .Times(1); | |
378 CrosNetworkWatcher* watcher = CrosMonitorSMS( | 381 CrosNetworkWatcher* watcher = CrosMonitorSMS( |
379 modem_device_path, callback, object); | 382 modem_device_path, callback, object); |
380 | 383 |
381 // Stop monitoring. | 384 // Stop monitoring. |
382 EXPECT_CALL(*MockChromeOSNetwork::Get(), | 385 EXPECT_CALL(*MockChromeOSNetwork::Get(), |
383 DisconnectSMSMonitor(_)).Times(1); | 386 DisconnectSMSMonitor(_)).Times(1); |
384 delete watcher; | 387 delete watcher; |
385 } | 388 } |
386 | 389 |
387 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkManagerProperties) { | 390 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkManagerProperties) { |
(...skipping 26 matching lines...) Expand all Loading... | |
414 const std::string value2 = "value2"; | 417 const std::string value2 = "value2"; |
415 // Create result value. | 418 // Create result value. |
416 base::DictionaryValue result; | 419 base::DictionaryValue result; |
417 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); | 420 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); |
418 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); | 421 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); |
419 result_ghash_table_.reset( | 422 result_ghash_table_.reset( |
420 ConvertDictionaryValueToStringValueGHashTable(result)); | 423 ConvertDictionaryValueToStringValueGHashTable(result)); |
421 // Set expectations. | 424 // Set expectations. |
422 EXPECT_CALL( | 425 EXPECT_CALL( |
423 *MockChromeOSNetwork::Get(), | 426 *MockChromeOSNetwork::Get(), |
424 RequestNetworkServiceProperties(service_path.c_str(), _, _)) | 427 RequestNetworkServiceProperties(StrEq(service_path.c_str()), _, _)) |
425 .WillOnce(Invoke( | 428 .WillOnce(Invoke( |
426 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties3)); | 429 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties3)); |
427 | 430 |
428 CrosRequestNetworkServiceProperties( | 431 CrosRequestNetworkServiceProperties( |
429 service_path.c_str(), | 432 service_path, |
430 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); | 433 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); |
431 } | 434 } |
432 | 435 |
433 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkDeviceProperties) { | 436 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkDeviceProperties) { |
434 const std::string device_path = "device path"; | 437 const std::string device_path = "device path"; |
435 const std::string key1 = "key1"; | 438 const std::string key1 = "key1"; |
436 const std::string value1 = "value1"; | 439 const std::string value1 = "value1"; |
437 const std::string key2 = "key.2."; | 440 const std::string key2 = "key.2."; |
438 const std::string value2 = "value2"; | 441 const std::string value2 = "value2"; |
439 // Create result value. | 442 // Create result value. |
440 base::DictionaryValue result; | 443 base::DictionaryValue result; |
441 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); | 444 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); |
442 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); | 445 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); |
443 result_ghash_table_.reset( | 446 result_ghash_table_.reset( |
444 ConvertDictionaryValueToStringValueGHashTable(result)); | 447 ConvertDictionaryValueToStringValueGHashTable(result)); |
445 // Set expectations. | 448 // Set expectations. |
446 EXPECT_CALL( | 449 EXPECT_CALL( |
447 *MockChromeOSNetwork::Get(), | 450 *MockChromeOSNetwork::Get(), |
448 RequestNetworkDeviceProperties(device_path.c_str(), _, _)) | 451 RequestNetworkDeviceProperties(StrEq(device_path.c_str()), _, _)) |
449 .WillOnce(Invoke( | 452 .WillOnce(Invoke( |
450 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties3)); | 453 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties3)); |
451 | 454 |
452 CrosRequestNetworkDeviceProperties( | 455 CrosRequestNetworkDeviceProperties( |
453 device_path.c_str(), | 456 device_path, |
454 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); | 457 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); |
455 } | 458 } |
456 | 459 |
457 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkProfileProperties) { | 460 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkProfileProperties) { |
458 const std::string profile_path = "profile path"; | 461 const std::string profile_path = "profile path"; |
459 const std::string key1 = "key1"; | 462 const std::string key1 = "key1"; |
460 const std::string value1 = "value1"; | 463 const std::string value1 = "value1"; |
461 const std::string key2 = "key.2."; | 464 const std::string key2 = "key.2."; |
462 const std::string value2 = "value2"; | 465 const std::string value2 = "value2"; |
463 // Create result value. | 466 // Create result value. |
464 base::DictionaryValue result; | 467 base::DictionaryValue result; |
465 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); | 468 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); |
466 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); | 469 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); |
467 result_ghash_table_.reset( | 470 result_ghash_table_.reset( |
468 ConvertDictionaryValueToStringValueGHashTable(result)); | 471 ConvertDictionaryValueToStringValueGHashTable(result)); |
469 // Set expectations. | 472 // Set expectations. |
470 EXPECT_CALL( | 473 EXPECT_CALL( |
471 *MockChromeOSNetwork::Get(), | 474 *MockChromeOSNetwork::Get(), |
472 RequestNetworkProfileProperties(profile_path.c_str(), _, _)) | 475 RequestNetworkProfileProperties(StrEq(profile_path.c_str()), _, _)) |
473 .WillOnce(Invoke( | 476 .WillOnce(Invoke( |
474 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties3)); | 477 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties3)); |
475 | 478 |
476 CrosRequestNetworkProfileProperties( | 479 CrosRequestNetworkProfileProperties( |
477 profile_path.c_str(), | 480 profile_path, |
478 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); | 481 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); |
479 } | 482 } |
480 | 483 |
481 TEST_F(CrosNetworkFunctionsLibcrosTest, | 484 TEST_F(CrosNetworkFunctionsLibcrosTest, |
482 CrosRequestNetworkProfileEntryProperties) { | 485 CrosRequestNetworkProfileEntryProperties) { |
483 const std::string profile_path = "profile path"; | 486 const std::string profile_path = "profile path"; |
484 const std::string profile_entry_path = "profile entry path"; | 487 const std::string profile_entry_path = "profile entry path"; |
485 const std::string key1 = "key1"; | 488 const std::string key1 = "key1"; |
486 const std::string value1 = "value1"; | 489 const std::string value1 = "value1"; |
487 const std::string key2 = "key.2."; | 490 const std::string key2 = "key.2."; |
488 const std::string value2 = "value2"; | 491 const std::string value2 = "value2"; |
489 // Create result value. | 492 // Create result value. |
490 base::DictionaryValue result; | 493 base::DictionaryValue result; |
491 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); | 494 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); |
492 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); | 495 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); |
493 result_ghash_table_.reset( | 496 result_ghash_table_.reset( |
494 ConvertDictionaryValueToStringValueGHashTable(result)); | 497 ConvertDictionaryValueToStringValueGHashTable(result)); |
495 // Set expectations. | 498 // Set expectations. |
496 EXPECT_CALL( | 499 EXPECT_CALL( |
497 *MockChromeOSNetwork::Get(), | 500 *MockChromeOSNetwork::Get(), |
498 RequestNetworkProfileEntryProperties(profile_path.c_str(), | 501 RequestNetworkProfileEntryProperties( |
499 profile_entry_path.c_str(), _, _)) | 502 StrEq(profile_path.c_str()), StrEq(profile_entry_path.c_str()), _, _)) |
500 .WillOnce(Invoke( | 503 .WillOnce(Invoke( |
501 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties4)); | 504 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties4)); |
502 | 505 |
503 CrosRequestNetworkProfileEntryProperties( | 506 CrosRequestNetworkProfileEntryProperties( |
504 profile_path.c_str(), | 507 profile_path, |
505 profile_entry_path.c_str(), | 508 profile_entry_path, |
506 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); | 509 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); |
507 } | 510 } |
508 | 511 |
509 TEST_F(CrosNetworkFunctionsLibcrosTest, | 512 TEST_F(CrosNetworkFunctionsLibcrosTest, |
510 CrosRequestHiddenWifiNetworkProperties) { | 513 CrosRequestHiddenWifiNetworkProperties) { |
511 const std::string ssid = "ssid"; | 514 const std::string ssid = "ssid"; |
512 const std::string security = "security"; | 515 const std::string security = "security"; |
513 const std::string key1 = "key1"; | 516 const std::string key1 = "key1"; |
514 const std::string value1 = "value1"; | 517 const std::string value1 = "value1"; |
515 const std::string key2 = "key.2."; | 518 const std::string key2 = "key.2."; |
516 const std::string value2 = "value2"; | 519 const std::string value2 = "value2"; |
517 // Create result value. | 520 // Create result value. |
518 base::DictionaryValue result; | 521 base::DictionaryValue result; |
519 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); | 522 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); |
520 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); | 523 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); |
521 result_ghash_table_.reset( | 524 result_ghash_table_.reset( |
522 ConvertDictionaryValueToStringValueGHashTable(result)); | 525 ConvertDictionaryValueToStringValueGHashTable(result)); |
523 // Set expectations. | 526 // Set expectations. |
524 EXPECT_CALL( | 527 EXPECT_CALL( |
525 *MockChromeOSNetwork::Get(), | 528 *MockChromeOSNetwork::Get(), |
526 RequestHiddenWifiNetworkProperties(ssid.c_str(), security.c_str(), _, _)) | 529 RequestHiddenWifiNetworkProperties( |
530 StrEq(ssid.c_str()), StrEq(security.c_str()), _, _)) | |
527 .WillOnce(Invoke( | 531 .WillOnce(Invoke( |
528 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties4)); | 532 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties4)); |
529 | 533 |
530 CrosRequestHiddenWifiNetworkProperties( | 534 CrosRequestHiddenWifiNetworkProperties( |
531 ssid.c_str(), security.c_str(), | 535 ssid, security, |
532 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); | 536 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); |
533 } | 537 } |
534 | 538 |
535 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestVirtualNetworkProperties) { | 539 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestVirtualNetworkProperties) { |
536 const std::string service_name = "service name"; | 540 const std::string service_name = "service name"; |
537 const std::string server_hostname = "server hostname"; | 541 const std::string server_hostname = "server hostname"; |
538 const std::string provider_name = "provider name"; | 542 const std::string provider_name = "provider name"; |
539 const std::string key1 = "key1"; | 543 const std::string key1 = "key1"; |
540 const std::string value1 = "value1"; | 544 const std::string value1 = "value1"; |
541 const std::string key2 = "key.2."; | 545 const std::string key2 = "key.2."; |
542 const std::string value2 = "value2"; | 546 const std::string value2 = "value2"; |
543 // Create result value. | 547 // Create result value. |
544 base::DictionaryValue result; | 548 base::DictionaryValue result; |
545 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); | 549 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); |
546 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); | 550 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); |
547 result_ghash_table_.reset( | 551 result_ghash_table_.reset( |
548 ConvertDictionaryValueToStringValueGHashTable(result)); | 552 ConvertDictionaryValueToStringValueGHashTable(result)); |
549 // Set expectations. | 553 // Set expectations. |
550 EXPECT_CALL(*MockChromeOSNetwork::Get(), | 554 EXPECT_CALL(*MockChromeOSNetwork::Get(), |
551 RequestVirtualNetworkProperties(service_name.c_str(), | 555 RequestVirtualNetworkProperties( |
552 server_hostname.c_str(), | 556 StrEq(service_name.c_str()), StrEq(server_hostname.c_str()), |
553 provider_name.c_str(), _, _)) | 557 StrEq(provider_name.c_str()), _, _)) |
554 .WillOnce(Invoke( | 558 .WillOnce(Invoke( |
555 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties5)); | 559 this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties5)); |
556 | 560 |
557 CrosRequestVirtualNetworkProperties( | 561 CrosRequestVirtualNetworkProperties( |
558 service_name.c_str(), | 562 service_name, |
559 server_hostname.c_str(), | 563 server_hostname, |
560 provider_name.c_str(), | 564 provider_name, |
561 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); | 565 MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); |
562 } | 566 } |
563 | 567 |
564 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkServiceDisconnect) { | 568 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkServiceDisconnect) { |
565 const char kServicePath[] = "/service/path"; | 569 const char kServicePath[] = "/service/path"; |
566 EXPECT_CALL(*MockChromeOSNetwork::Get(), | 570 EXPECT_CALL(*MockChromeOSNetwork::Get(), |
567 RequestNetworkServiceDisconnect(kServicePath)).Times(1); | 571 RequestNetworkServiceDisconnect(StrEq(kServicePath))).Times(1); |
568 CrosRequestNetworkServiceDisconnect(kServicePath); | 572 CrosRequestNetworkServiceDisconnect(kServicePath); |
569 } | 573 } |
570 | 574 |
571 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestRemoveNetworkService) { | 575 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestRemoveNetworkService) { |
572 const char kServicePath[] = "/service/path"; | 576 const char kServicePath[] = "/service/path"; |
573 EXPECT_CALL(*MockChromeOSNetwork::Get(), | 577 EXPECT_CALL(*MockChromeOSNetwork::Get(), |
574 RequestRemoveNetworkService(kServicePath)).Times(1); | 578 RequestRemoveNetworkService(StrEq(kServicePath))).Times(1); |
575 CrosRequestRemoveNetworkService(kServicePath); | 579 CrosRequestRemoveNetworkService(kServicePath); |
576 } | 580 } |
577 | 581 |
578 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkScan) { | 582 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkScan) { |
579 EXPECT_CALL(*MockChromeOSNetwork::Get(), | 583 EXPECT_CALL(*MockChromeOSNetwork::Get(), |
580 RequestNetworkScan(flimflam::kTypeWifi)).Times(1); | 584 RequestNetworkScan(StrEq(flimflam::kTypeWifi))).Times(1); |
581 CrosRequestNetworkScan(flimflam::kTypeWifi); | 585 CrosRequestNetworkScan(flimflam::kTypeWifi); |
582 } | 586 } |
583 | 587 |
584 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkDeviceEnable) { | 588 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkDeviceEnable) { |
585 const bool kEnable = true; | 589 const bool kEnable = true; |
586 EXPECT_CALL(*MockChromeOSNetwork::Get(), | 590 EXPECT_CALL(*MockChromeOSNetwork::Get(), |
587 RequestNetworkDeviceEnable(flimflam::kTypeWifi, kEnable)) | 591 RequestNetworkDeviceEnable(StrEq(flimflam::kTypeWifi), kEnable)) |
588 .Times(1); | 592 .Times(1); |
589 CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kEnable); | 593 CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kEnable); |
590 } | 594 } |
591 | 595 |
592 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosConfigureService) { | 596 TEST_F(CrosNetworkFunctionsLibcrosTest, CrosConfigureService) { |
593 const char identifier[] = "identifier"; | 597 const char identifier[] = "identifier"; |
594 EXPECT_CALL(*MockChromeOSNetwork::Get(), | 598 EXPECT_CALL(*MockChromeOSNetwork::Get(), |
595 ConfigureService(identifier, _, &OnNetworkAction, this)) | 599 ConfigureService(StrEq(identifier), _, &OnNetworkAction, this)) |
596 .WillOnce(Invoke( | 600 .WillOnce(Invoke( |
597 this, &CrosNetworkFunctionsLibcrosTest::OnConfigureService)); | 601 this, &CrosNetworkFunctionsLibcrosTest::OnConfigureService)); |
598 const char key1[] = "key1"; | 602 const char key1[] = "key1"; |
599 const std::string string1 = "string1"; | 603 const std::string string1 = "string1"; |
600 const char key2[] = "key2"; | 604 const char key2[] = "key2"; |
601 const std::string string2 = "string2"; | 605 const std::string string2 = "string2"; |
602 base::DictionaryValue value; | 606 base::DictionaryValue value; |
603 value.SetString(key1, string1); | 607 value.SetString(key1, string1); |
604 value.SetString(key2, string2); | 608 value.SetString(key2, string2); |
605 CrosConfigureService(identifier, value, &OnNetworkAction, this); | 609 CrosConfigureService(identifier, value, &OnNetworkAction, this); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
695 | 699 |
696 CrosClearNetworkServiceProperty(service_path, property); | 700 CrosClearNetworkServiceProperty(service_path, property); |
697 } | 701 } |
698 | 702 |
699 TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkDeviceProperty) { | 703 TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkDeviceProperty) { |
700 const char device_path[] = "/"; | 704 const char device_path[] = "/"; |
701 const char property[] = "property"; | 705 const char property[] = "property"; |
702 const bool kBool = true; | 706 const bool kBool = true; |
703 const base::FundamentalValue value(kBool); | 707 const base::FundamentalValue value(kBool); |
704 EXPECT_CALL(*mock_device_client_, | 708 EXPECT_CALL(*mock_device_client_, |
705 SetProperty(dbus::ObjectPath(device_path), property, | 709 SetProperty(dbus::ObjectPath(device_path), StrEq(property), |
706 IsEqualTo(&value), _)).Times(1); | 710 IsEqualTo(&value), _)).Times(1); |
707 | 711 |
708 CrosSetNetworkDeviceProperty(device_path, property, value); | 712 CrosSetNetworkDeviceProperty(device_path, property, value); |
709 } | 713 } |
710 | 714 |
711 TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkManagerProperty) { | 715 TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkManagerProperty) { |
712 const char property[] = "property"; | 716 const char property[] = "property"; |
713 const std::string kString = "string"; | 717 const std::string kString = "string"; |
714 const base::StringValue value(kString); | 718 const base::StringValue value(kString); |
715 EXPECT_CALL(*mock_manager_client_, | 719 EXPECT_CALL(*mock_manager_client_, |
716 SetProperty(property, IsEqualTo(&value), _)).Times(1); | 720 SetProperty(property, IsEqualTo(&value), _)).Times(1); |
717 | 721 |
718 CrosSetNetworkManagerProperty(property, value); | 722 CrosSetNetworkManagerProperty(property, value); |
719 } | 723 } |
720 | 724 |
721 TEST_F(CrosNetworkFunctionsTest, CrosDeleteServiceFromProfile) { | 725 TEST_F(CrosNetworkFunctionsTest, CrosDeleteServiceFromProfile) { |
722 const std::string profile_path("/profile/path"); | 726 const std::string profile_path("/profile/path"); |
723 const std::string service_path("/service/path"); | 727 const std::string service_path("/service/path"); |
724 EXPECT_CALL(*mock_profile_client_, | 728 EXPECT_CALL(*mock_profile_client_, |
725 DeleteEntry(dbus::ObjectPath(profile_path), service_path, _)) | 729 DeleteEntry(dbus::ObjectPath(profile_path), service_path, _)) |
726 .Times(1); | 730 .Times(1); |
727 CrosDeleteServiceFromProfile(profile_path.c_str(), service_path.c_str()); | 731 CrosDeleteServiceFromProfile(profile_path, service_path); |
728 } | 732 } |
729 | 733 |
730 TEST_F(CrosNetworkFunctionsTest, CrosRequestCellularDataPlanUpdate) { | 734 TEST_F(CrosNetworkFunctionsTest, CrosRequestCellularDataPlanUpdate) { |
731 const char kModemServicePath[] = "/modem/service/path"; | 735 const char kModemServicePath[] = "/modem/service/path"; |
732 EXPECT_CALL(*mock_cashew_client_, | 736 EXPECT_CALL(*mock_cashew_client_, |
733 RequestDataPlansUpdate(kModemServicePath)).Times(1); | 737 RequestDataPlansUpdate(kModemServicePath)).Times(1); |
734 CrosRequestCellularDataPlanUpdate(kModemServicePath); | 738 CrosRequestCellularDataPlanUpdate(kModemServicePath); |
735 } | 739 } |
736 | 740 |
737 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkManagerProperties) { | 741 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkManagerProperties) { |
(...skipping 17 matching lines...) Expand all Loading... | |
755 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkServiceProperties) { | 759 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkServiceProperties) { |
756 const dbus::ObjectPath path("/path"); | 760 const dbus::ObjectPath path("/path"); |
757 const std::string key = "key"; | 761 const std::string key = "key"; |
758 const int kValue = 42; | 762 const int kValue = 42; |
759 const base::FundamentalValue value(kValue); | 763 const base::FundamentalValue value(kValue); |
760 // Start monitoring. | 764 // Start monitoring. |
761 FlimflamClientHelper::PropertyChangedHandler handler; | 765 FlimflamClientHelper::PropertyChangedHandler handler; |
762 EXPECT_CALL(*mock_service_client_, SetPropertyChangedHandler(path, _)) | 766 EXPECT_CALL(*mock_service_client_, SetPropertyChangedHandler(path, _)) |
763 .WillOnce(SaveArg<1>(&handler)); | 767 .WillOnce(SaveArg<1>(&handler)); |
764 NetworkPropertiesWatcherCallback callback = | 768 NetworkPropertiesWatcherCallback callback = |
765 MockNetworkPropertiesWatcherCallback::CreateCallback(path.value().c_str(), | 769 MockNetworkPropertiesWatcherCallback::CreateCallback(path.value(), |
766 key, value); | 770 key, value); |
767 CrosNetworkWatcher* watcher = CrosMonitorNetworkServiceProperties( | 771 CrosNetworkWatcher* watcher = CrosMonitorNetworkServiceProperties( |
768 callback, path.value().c_str()); | 772 callback, path.value()); |
769 // Call callback. | 773 // Call callback. |
770 handler.Run(key, value); | 774 handler.Run(key, value); |
771 // Stop monitoring. | 775 // Stop monitoring. |
772 EXPECT_CALL(*mock_service_client_, | 776 EXPECT_CALL(*mock_service_client_, |
773 ResetPropertyChangedHandler(path)).Times(1); | 777 ResetPropertyChangedHandler(path)).Times(1); |
774 delete watcher; | 778 delete watcher; |
775 } | 779 } |
776 | 780 |
777 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkDeviceProperties) { | 781 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkDeviceProperties) { |
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_device_client_, SetPropertyChangedHandler(path, _)) | 788 EXPECT_CALL(*mock_device_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 = CrosMonitorNetworkDeviceProperties( | 793 CrosNetworkWatcher* watcher = CrosMonitorNetworkDeviceProperties( |
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_device_client_, | 798 EXPECT_CALL(*mock_device_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, CrosRequestNetworkManagerProperties) { | 803 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkManagerProperties) { |
800 const std::string key1 = "key1"; | 804 const std::string key1 = "key1"; |
(...skipping 26 matching lines...) Expand all Loading... | |
827 base::DictionaryValue result; | 831 base::DictionaryValue result; |
828 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); | 832 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); |
829 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); | 833 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); |
830 // Set expectations. | 834 // Set expectations. |
831 dictionary_value_result_ = &result; | 835 dictionary_value_result_ = &result; |
832 EXPECT_CALL(*mock_service_client_, | 836 EXPECT_CALL(*mock_service_client_, |
833 GetProperties(dbus::ObjectPath(service_path), _)).WillOnce( | 837 GetProperties(dbus::ObjectPath(service_path), _)).WillOnce( |
834 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); | 838 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); |
835 | 839 |
836 CrosRequestNetworkServiceProperties( | 840 CrosRequestNetworkServiceProperties( |
837 service_path.c_str(), | 841 service_path, |
838 MockNetworkPropertiesCallback::CreateCallback(service_path.c_str(), | 842 MockNetworkPropertiesCallback::CreateCallback(service_path, result)); |
839 result)); | |
840 } | 843 } |
841 | 844 |
842 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkDeviceProperties) { | 845 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkDeviceProperties) { |
843 const std::string device_path = "/device/path"; | 846 const std::string device_path = "/device/path"; |
844 const std::string key1 = "key1"; | 847 const std::string key1 = "key1"; |
845 const std::string value1 = "value1"; | 848 const std::string value1 = "value1"; |
846 const std::string key2 = "key.2."; | 849 const std::string key2 = "key.2."; |
847 const std::string value2 = "value2"; | 850 const std::string value2 = "value2"; |
848 // Create result value. | 851 // Create result value. |
849 base::DictionaryValue result; | 852 base::DictionaryValue result; |
850 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); | 853 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); |
851 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); | 854 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); |
852 // Set expectations. | 855 // Set expectations. |
853 dictionary_value_result_ = &result; | 856 dictionary_value_result_ = &result; |
854 EXPECT_CALL(*mock_device_client_, | 857 EXPECT_CALL(*mock_device_client_, |
855 GetProperties(dbus::ObjectPath(device_path), _)).WillOnce( | 858 GetProperties(dbus::ObjectPath(device_path), _)).WillOnce( |
856 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); | 859 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); |
857 | 860 |
858 CrosRequestNetworkDeviceProperties( | 861 CrosRequestNetworkDeviceProperties( |
859 device_path.c_str(), | 862 device_path, |
860 MockNetworkPropertiesCallback::CreateCallback(device_path.c_str(), | 863 MockNetworkPropertiesCallback::CreateCallback(device_path, result)); |
861 result)); | |
862 } | 864 } |
863 | 865 |
864 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileProperties) { | 866 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileProperties) { |
865 const std::string profile_path = "/profile/path"; | 867 const std::string profile_path = "/profile/path"; |
866 const std::string key1 = "key1"; | 868 const std::string key1 = "key1"; |
867 const std::string value1 = "value1"; | 869 const std::string value1 = "value1"; |
868 const std::string key2 = "key.2."; | 870 const std::string key2 = "key.2."; |
869 const std::string value2 = "value2"; | 871 const std::string value2 = "value2"; |
870 // Create result value. | 872 // Create result value. |
871 base::DictionaryValue result; | 873 base::DictionaryValue result; |
872 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); | 874 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); |
873 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); | 875 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); |
874 // Set expectations. | 876 // Set expectations. |
875 dictionary_value_result_ = &result; | 877 dictionary_value_result_ = &result; |
876 EXPECT_CALL(*mock_profile_client_, | 878 EXPECT_CALL(*mock_profile_client_, |
877 GetProperties(dbus::ObjectPath(profile_path), _)).WillOnce( | 879 GetProperties(dbus::ObjectPath(profile_path), _)).WillOnce( |
878 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); | 880 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); |
879 | 881 |
880 CrosRequestNetworkProfileProperties( | 882 CrosRequestNetworkProfileProperties( |
881 profile_path.c_str(), | 883 profile_path, |
882 MockNetworkPropertiesCallback::CreateCallback(profile_path.c_str(), | 884 MockNetworkPropertiesCallback::CreateCallback(profile_path, result)); |
883 result)); | |
884 } | 885 } |
885 | 886 |
886 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileEntryProperties) { | 887 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileEntryProperties) { |
887 const std::string profile_path = "profile path"; | 888 const std::string profile_path = "profile path"; |
888 const std::string profile_entry_path = "profile entry path"; | 889 const std::string profile_entry_path = "profile entry path"; |
889 const std::string key1 = "key1"; | 890 const std::string key1 = "key1"; |
890 const std::string value1 = "value1"; | 891 const std::string value1 = "value1"; |
891 const std::string key2 = "key.2."; | 892 const std::string key2 = "key.2."; |
892 const std::string value2 = "value2"; | 893 const std::string value2 = "value2"; |
893 // Create result value. | 894 // Create result value. |
894 base::DictionaryValue result; | 895 base::DictionaryValue result; |
895 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); | 896 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); |
896 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); | 897 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); |
897 // Set expectations. | 898 // Set expectations. |
898 dictionary_value_result_ = &result; | 899 dictionary_value_result_ = &result; |
899 EXPECT_CALL(*mock_profile_client_, | 900 EXPECT_CALL(*mock_profile_client_, |
900 GetEntry(dbus::ObjectPath(profile_path), profile_entry_path, _)) | 901 GetEntry(dbus::ObjectPath(profile_path), profile_entry_path, _)) |
901 .WillOnce(Invoke(this, &CrosNetworkFunctionsTest::OnGetEntry)); | 902 .WillOnce(Invoke(this, &CrosNetworkFunctionsTest::OnGetEntry)); |
902 | 903 |
903 CrosRequestNetworkProfileEntryProperties( | 904 CrosRequestNetworkProfileEntryProperties( |
904 profile_path.c_str(), profile_entry_path.c_str(), | 905 profile_path, profile_entry_path, |
905 MockNetworkPropertiesCallback::CreateCallback(profile_entry_path.c_str(), | 906 MockNetworkPropertiesCallback::CreateCallback(profile_entry_path, |
906 result)); | 907 result)); |
907 } | 908 } |
908 | 909 |
909 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkServiceDisconnect) { | 910 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkServiceDisconnect) { |
910 const char kServicePath[] = "/service/path"; | 911 const char kServicePath[] = "/service/path"; |
911 EXPECT_CALL(*mock_service_client_, | 912 EXPECT_CALL(*mock_service_client_, |
912 Disconnect(dbus::ObjectPath(kServicePath), _)).Times(1); | 913 Disconnect(dbus::ObjectPath(kServicePath), _)).Times(1); |
913 CrosRequestNetworkServiceDisconnect(kServicePath); | 914 CrosRequestNetworkServiceDisconnect(kServicePath); |
914 } | 915 } |
915 | 916 |
(...skipping 16 matching lines...) Expand all Loading... | |
932 EnableTechnology(flimflam::kTypeWifi, _)).Times(1); | 933 EnableTechnology(flimflam::kTypeWifi, _)).Times(1); |
933 CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kEnable); | 934 CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kEnable); |
934 | 935 |
935 const bool kDisable = false; | 936 const bool kDisable = false; |
936 EXPECT_CALL(*mock_manager_client_, | 937 EXPECT_CALL(*mock_manager_client_, |
937 DisableTechnology(flimflam::kTypeWifi, _)).Times(1); | 938 DisableTechnology(flimflam::kTypeWifi, _)).Times(1); |
938 CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kDisable); | 939 CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kDisable); |
939 } | 940 } |
940 | 941 |
941 } // namespace chromeos | 942 } // namespace chromeos |
OLD | NEW |