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

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

Issue 2314853004: Remove calls to deprecated MessageLoop methods in chromeos. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/network/shill_property_handler.h" 5 #include "chromeos/network/shill_property_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/run_loop.h"
17 #include "base/values.h" 18 #include "base/values.h"
18 #include "chromeos/dbus/dbus_thread_manager.h" 19 #include "chromeos/dbus/dbus_thread_manager.h"
19 #include "chromeos/dbus/shill_device_client.h" 20 #include "chromeos/dbus/shill_device_client.h"
20 #include "chromeos/dbus/shill_ipconfig_client.h" 21 #include "chromeos/dbus/shill_ipconfig_client.h"
21 #include "chromeos/dbus/shill_manager_client.h" 22 #include "chromeos/dbus/shill_manager_client.h"
22 #include "chromeos/dbus/shill_profile_client.h" 23 #include "chromeos/dbus/shill_profile_client.h"
23 #include "chromeos/dbus/shill_service_client.h" 24 #include "chromeos/dbus/shill_service_client.h"
24 #include "dbus/object_path.h" 25 #include "dbus/object_path.h"
25 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
26 #include "third_party/cros_system_api/dbus/service_constants.h" 27 #include "third_party/cros_system_api/dbus/service_constants.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 device_test_ = 181 device_test_ =
181 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface(); 182 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface();
182 ASSERT_TRUE(device_test_); 183 ASSERT_TRUE(device_test_);
183 service_test_ = 184 service_test_ =
184 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); 185 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface();
185 ASSERT_TRUE(service_test_); 186 ASSERT_TRUE(service_test_);
186 profile_test_ = 187 profile_test_ =
187 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface(); 188 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface();
188 ASSERT_TRUE(profile_test_); 189 ASSERT_TRUE(profile_test_);
189 SetupShillPropertyHandler(); 190 SetupShillPropertyHandler();
190 message_loop_.RunUntilIdle(); 191 base::RunLoop().RunUntilIdle();
191 } 192 }
192 193
193 void TearDown() override { 194 void TearDown() override {
194 shill_property_handler_.reset(); 195 shill_property_handler_.reset();
195 listener_.reset(); 196 listener_.reset();
196 DBusThreadManager::Shutdown(); 197 DBusThreadManager::Shutdown();
197 } 198 }
198 199
199 void AddDevice(const std::string& type, const std::string& id) { 200 void AddDevice(const std::string& type, const std::string& id) {
200 ASSERT_TRUE(IsValidType(type)); 201 ASSERT_TRUE(IsValidType(type));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 type == shill::kTypeEthernetEap || 267 type == shill::kTypeEthernetEap ||
267 type == shill::kTypeWifi || 268 type == shill::kTypeWifi ||
268 type == shill::kTypeWimax || 269 type == shill::kTypeWimax ||
269 type == shill::kTypeBluetooth || 270 type == shill::kTypeBluetooth ||
270 type == shill::kTypeCellular || 271 type == shill::kTypeCellular ||
271 type == shill::kTypeVPN); 272 type == shill::kTypeVPN);
272 } 273 }
273 274
274 protected: 275 protected:
275 void SetupDefaultShillState() { 276 void SetupDefaultShillState() {
276 message_loop_.RunUntilIdle(); // Process any pending updates 277 base::RunLoop().RunUntilIdle(); // Process any pending updates
277 device_test_->ClearDevices(); 278 device_test_->ClearDevices();
278 AddDevice(shill::kTypeWifi, "stub_wifi_device1"); 279 AddDevice(shill::kTypeWifi, "stub_wifi_device1");
279 AddDevice(shill::kTypeCellular, "stub_cellular_device1"); 280 AddDevice(shill::kTypeCellular, "stub_cellular_device1");
280 service_test_->ClearServices(); 281 service_test_->ClearServices();
281 AddService(shill::kTypeEthernet, "stub_ethernet", shill::kStateOnline); 282 AddService(shill::kTypeEthernet, "stub_ethernet", shill::kStateOnline);
282 AddService(shill::kTypeWifi, "stub_wifi1", shill::kStateOnline); 283 AddService(shill::kTypeWifi, "stub_wifi1", shill::kStateOnline);
283 AddService(shill::kTypeWifi, "stub_wifi2", shill::kStateIdle); 284 AddService(shill::kTypeWifi, "stub_wifi2", shill::kStateIdle);
284 AddService(shill::kTypeCellular, "stub_cellular1", shill::kStateIdle); 285 AddService(shill::kTypeCellular, "stub_cellular1", shill::kStateIdle);
285 } 286 }
286 287
287 base::MessageLoopForUI message_loop_; 288 base::MessageLoopForUI message_loop_;
armansito 2016/09/06 22:04:32 ditto
288 std::unique_ptr<TestListener> listener_; 289 std::unique_ptr<TestListener> listener_;
289 std::unique_ptr<internal::ShillPropertyHandler> shill_property_handler_; 290 std::unique_ptr<internal::ShillPropertyHandler> shill_property_handler_;
290 ShillManagerClient::TestInterface* manager_test_; 291 ShillManagerClient::TestInterface* manager_test_;
291 ShillDeviceClient::TestInterface* device_test_; 292 ShillDeviceClient::TestInterface* device_test_;
292 ShillServiceClient::TestInterface* service_test_; 293 ShillServiceClient::TestInterface* service_test_;
293 ShillProfileClient::TestInterface* profile_test_; 294 ShillProfileClient::TestInterface* profile_test_;
294 295
295 private: 296 private:
296 DISALLOW_COPY_AND_ASSIGN(ShillPropertyHandlerTest); 297 DISALLOW_COPY_AND_ASSIGN(ShillPropertyHandlerTest);
297 }; 298 };
(...skipping 11 matching lines...) Expand all
309 EXPECT_EQ(0, listener_->errors()); 310 EXPECT_EQ(0, listener_->errors());
310 } 311 }
311 312
312 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerTechnologyChanged) { 313 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerTechnologyChanged) {
313 const int initial_technology_updates = 2; // Available and Enabled lists 314 const int initial_technology_updates = 2; // Available and Enabled lists
314 EXPECT_EQ(initial_technology_updates, listener_->technology_list_updates()); 315 EXPECT_EQ(initial_technology_updates, listener_->technology_list_updates());
315 316
316 // Remove an enabled technology. Updates both the Available and Enabled lists. 317 // Remove an enabled technology. Updates both the Available and Enabled lists.
317 listener_->reset_list_updates(); 318 listener_->reset_list_updates();
318 manager_test_->RemoveTechnology(shill::kTypeWifi); 319 manager_test_->RemoveTechnology(shill::kTypeWifi);
319 message_loop_.RunUntilIdle(); 320 base::RunLoop().RunUntilIdle();
320 EXPECT_EQ(2, listener_->technology_list_updates()); 321 EXPECT_EQ(2, listener_->technology_list_updates());
321 322
322 // Add a disabled technology. 323 // Add a disabled technology.
323 listener_->reset_list_updates(); 324 listener_->reset_list_updates();
324 manager_test_->AddTechnology(shill::kTypeWifi, false); 325 manager_test_->AddTechnology(shill::kTypeWifi, false);
325 message_loop_.RunUntilIdle(); 326 base::RunLoop().RunUntilIdle();
326 EXPECT_EQ(1, listener_->technology_list_updates()); 327 EXPECT_EQ(1, listener_->technology_list_updates());
327 EXPECT_TRUE(shill_property_handler_->IsTechnologyAvailable( 328 EXPECT_TRUE(shill_property_handler_->IsTechnologyAvailable(
328 shill::kTypeWifi)); 329 shill::kTypeWifi));
329 EXPECT_FALSE(shill_property_handler_->IsTechnologyEnabled(shill::kTypeWifi)); 330 EXPECT_FALSE(shill_property_handler_->IsTechnologyEnabled(shill::kTypeWifi));
330 331
331 // Enable the technology. 332 // Enable the technology.
332 listener_->reset_list_updates(); 333 listener_->reset_list_updates();
333 DBusThreadManager::Get()->GetShillManagerClient()->EnableTechnology( 334 DBusThreadManager::Get()->GetShillManagerClient()->EnableTechnology(
334 shill::kTypeWifi, 335 shill::kTypeWifi,
335 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); 336 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction));
336 message_loop_.RunUntilIdle(); 337 base::RunLoop().RunUntilIdle();
337 EXPECT_EQ(1, listener_->technology_list_updates()); 338 EXPECT_EQ(1, listener_->technology_list_updates());
338 EXPECT_TRUE(shill_property_handler_->IsTechnologyEnabled(shill::kTypeWifi)); 339 EXPECT_TRUE(shill_property_handler_->IsTechnologyEnabled(shill::kTypeWifi));
339 340
340 EXPECT_EQ(0, listener_->errors()); 341 EXPECT_EQ(0, listener_->errors());
341 } 342 }
342 343
343 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerDevicePropertyChanged) { 344 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerDevicePropertyChanged) {
344 const size_t kNumShillManagerClientStubImplDevices = 2; 345 const size_t kNumShillManagerClientStubImplDevices = 2;
345 EXPECT_EQ(kNumShillManagerClientStubImplDevices, 346 EXPECT_EQ(kNumShillManagerClientStubImplDevices,
346 listener_->entries(shill::kDevicesProperty).size()); 347 listener_->entries(shill::kDevicesProperty).size());
347 // Add a device. 348 // Add a device.
348 listener_->reset_list_updates(); 349 listener_->reset_list_updates();
349 const std::string kTestDevicePath("test_wifi_device1"); 350 const std::string kTestDevicePath("test_wifi_device1");
350 AddDevice(shill::kTypeWifi, kTestDevicePath); 351 AddDevice(shill::kTypeWifi, kTestDevicePath);
351 message_loop_.RunUntilIdle(); 352 base::RunLoop().RunUntilIdle();
352 EXPECT_EQ(1, listener_->list_updates(shill::kDevicesProperty)); 353 EXPECT_EQ(1, listener_->list_updates(shill::kDevicesProperty));
353 EXPECT_EQ(kNumShillManagerClientStubImplDevices + 1, 354 EXPECT_EQ(kNumShillManagerClientStubImplDevices + 1,
354 listener_->entries(shill::kDevicesProperty).size()); 355 listener_->entries(shill::kDevicesProperty).size());
355 356
356 // Remove a device 357 // Remove a device
357 listener_->reset_list_updates(); 358 listener_->reset_list_updates();
358 RemoveDevice(kTestDevicePath); 359 RemoveDevice(kTestDevicePath);
359 message_loop_.RunUntilIdle(); 360 base::RunLoop().RunUntilIdle();
360 EXPECT_EQ(1, listener_->list_updates(shill::kDevicesProperty)); 361 EXPECT_EQ(1, listener_->list_updates(shill::kDevicesProperty));
361 EXPECT_EQ(kNumShillManagerClientStubImplDevices, 362 EXPECT_EQ(kNumShillManagerClientStubImplDevices,
362 listener_->entries(shill::kDevicesProperty).size()); 363 listener_->entries(shill::kDevicesProperty).size());
363 364
364 EXPECT_EQ(0, listener_->errors()); 365 EXPECT_EQ(0, listener_->errors());
365 } 366 }
366 367
367 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServicePropertyChanged) { 368 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServicePropertyChanged) {
368 const size_t kNumShillManagerClientStubImplServices = 4; 369 const size_t kNumShillManagerClientStubImplServices = 4;
369 EXPECT_EQ(kNumShillManagerClientStubImplServices, 370 EXPECT_EQ(kNumShillManagerClientStubImplServices,
370 listener_->entries(shill::kServiceCompleteListProperty).size()); 371 listener_->entries(shill::kServiceCompleteListProperty).size());
371 372
372 // Add a service. 373 // Add a service.
373 listener_->reset_list_updates(); 374 listener_->reset_list_updates();
374 const std::string kTestServicePath("test_wifi_service1"); 375 const std::string kTestServicePath("test_wifi_service1");
375 AddService(shill::kTypeWifi, kTestServicePath, shill::kStateIdle); 376 AddService(shill::kTypeWifi, kTestServicePath, shill::kStateIdle);
376 message_loop_.RunUntilIdle(); 377 base::RunLoop().RunUntilIdle();
377 // Add should trigger a service list update and update entries. 378 // Add should trigger a service list update and update entries.
378 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty)); 379 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty));
379 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1, 380 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1,
380 listener_->entries(shill::kServiceCompleteListProperty).size()); 381 listener_->entries(shill::kServiceCompleteListProperty).size());
381 // Service receives an initial property update. 382 // Service receives an initial property update.
382 EXPECT_EQ(1, listener_->initial_property_updates( 383 EXPECT_EQ(1, listener_->initial_property_updates(
383 shill::kServiceCompleteListProperty)[kTestServicePath]); 384 shill::kServiceCompleteListProperty)[kTestServicePath]);
384 // Change a property. 385 // Change a property.
385 base::FundamentalValue scan_interval(3); 386 base::FundamentalValue scan_interval(3);
386 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( 387 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty(
387 dbus::ObjectPath(kTestServicePath), 388 dbus::ObjectPath(kTestServicePath),
388 shill::kScanIntervalProperty, 389 shill::kScanIntervalProperty,
389 scan_interval, 390 scan_interval,
390 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); 391 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction));
391 message_loop_.RunUntilIdle(); 392 base::RunLoop().RunUntilIdle();
392 // Property change triggers an update (but not a service list update). 393 // Property change triggers an update (but not a service list update).
393 EXPECT_EQ(1, listener_->property_updates( 394 EXPECT_EQ(1, listener_->property_updates(
394 shill::kServiceCompleteListProperty)[kTestServicePath]); 395 shill::kServiceCompleteListProperty)[kTestServicePath]);
395 396
396 // Change the visibility of a service. This will trigger a service list 397 // Change the visibility of a service. This will trigger a service list
397 // updates. 398 // updates.
398 listener_->reset_list_updates(); 399 listener_->reset_list_updates();
399 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( 400 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty(
400 dbus::ObjectPath(kTestServicePath), 401 dbus::ObjectPath(kTestServicePath),
401 shill::kVisibleProperty, 402 shill::kVisibleProperty,
402 base::FundamentalValue(false), 403 base::FundamentalValue(false),
403 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); 404 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction));
404 message_loop_.RunUntilIdle(); 405 base::RunLoop().RunUntilIdle();
405 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty)); 406 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty));
406 407
407 // Remove a service. This will update the entries and signal a service list 408 // Remove a service. This will update the entries and signal a service list
408 // update. 409 // update.
409 listener_->reset_list_updates(); 410 listener_->reset_list_updates();
410 RemoveService(kTestServicePath); 411 RemoveService(kTestServicePath);
411 message_loop_.RunUntilIdle(); 412 base::RunLoop().RunUntilIdle();
412 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty)); 413 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty));
413 EXPECT_EQ(kNumShillManagerClientStubImplServices, 414 EXPECT_EQ(kNumShillManagerClientStubImplServices,
414 listener_->entries(shill::kServiceCompleteListProperty).size()); 415 listener_->entries(shill::kServiceCompleteListProperty).size());
415 416
416 EXPECT_EQ(0, listener_->errors()); 417 EXPECT_EQ(0, listener_->errors());
417 } 418 }
418 419
419 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerIPConfigPropertyChanged) { 420 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerIPConfigPropertyChanged) {
420 // Set the properties for an IP Config object. 421 // Set the properties for an IP Config object.
421 const std::string kTestIPConfigPath("test_ip_config_path"); 422 const std::string kTestIPConfigPath("test_ip_config_path");
(...skipping 13 matching lines...) Expand all
435 base::FundamentalValue prefixlen(8); 436 base::FundamentalValue prefixlen(8);
436 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty( 437 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty(
437 dbus::ObjectPath(kTestIPConfigPath), 438 dbus::ObjectPath(kTestIPConfigPath),
438 shill::kPrefixlenProperty, prefixlen, 439 shill::kPrefixlenProperty, prefixlen,
439 base::Bind(&DoNothingWithCallStatus)); 440 base::Bind(&DoNothingWithCallStatus));
440 base::StringValue gateway("192.0.0.1"); 441 base::StringValue gateway("192.0.0.1");
441 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty( 442 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty(
442 dbus::ObjectPath(kTestIPConfigPath), 443 dbus::ObjectPath(kTestIPConfigPath),
443 shill::kGatewayProperty, gateway, 444 shill::kGatewayProperty, gateway,
444 base::Bind(&DoNothingWithCallStatus)); 445 base::Bind(&DoNothingWithCallStatus));
445 message_loop_.RunUntilIdle(); 446 base::RunLoop().RunUntilIdle();
446 447
447 // Add a service with an empty ipconfig and then update 448 // Add a service with an empty ipconfig and then update
448 // its ipconfig property. 449 // its ipconfig property.
449 const std::string kTestServicePath1("test_wifi_service1"); 450 const std::string kTestServicePath1("test_wifi_service1");
450 AddService(shill::kTypeWifi, kTestServicePath1, shill::kStateIdle); 451 AddService(shill::kTypeWifi, kTestServicePath1, shill::kStateIdle);
451 message_loop_.RunUntilIdle(); 452 base::RunLoop().RunUntilIdle();
452 // This is the initial property update. 453 // This is the initial property update.
453 EXPECT_EQ(1, listener_->initial_property_updates( 454 EXPECT_EQ(1, listener_->initial_property_updates(
454 shill::kServiceCompleteListProperty)[kTestServicePath1]); 455 shill::kServiceCompleteListProperty)[kTestServicePath1]);
455 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( 456 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty(
456 dbus::ObjectPath(kTestServicePath1), 457 dbus::ObjectPath(kTestServicePath1),
457 shill::kIPConfigProperty, 458 shill::kIPConfigProperty,
458 base::StringValue(kTestIPConfigPath), 459 base::StringValue(kTestIPConfigPath),
459 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); 460 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction));
460 message_loop_.RunUntilIdle(); 461 base::RunLoop().RunUntilIdle();
461 // IPConfig property change on the service should trigger an IPConfigs update. 462 // IPConfig property change on the service should trigger an IPConfigs update.
462 EXPECT_EQ(1, listener_->property_updates( 463 EXPECT_EQ(1, listener_->property_updates(
463 shill::kIPConfigsProperty)[kTestIPConfigPath]); 464 shill::kIPConfigsProperty)[kTestIPConfigPath]);
464 465
465 // Now, Add a new service with the IPConfig already set. 466 // Now, Add a new service with the IPConfig already set.
466 const std::string kTestServicePath2("test_wifi_service2"); 467 const std::string kTestServicePath2("test_wifi_service2");
467 AddServiceWithIPConfig(shill::kTypeWifi, kTestServicePath2, 468 AddServiceWithIPConfig(shill::kTypeWifi, kTestServicePath2,
468 shill::kStateIdle, kTestIPConfigPath); 469 shill::kStateIdle, kTestIPConfigPath);
469 message_loop_.RunUntilIdle(); 470 base::RunLoop().RunUntilIdle();
470 // A service with the IPConfig property already set should trigger an 471 // A service with the IPConfig property already set should trigger an
471 // additional IPConfigs update. 472 // additional IPConfigs update.
472 EXPECT_EQ(2, listener_->property_updates( 473 EXPECT_EQ(2, listener_->property_updates(
473 shill::kIPConfigsProperty)[kTestIPConfigPath]); 474 shill::kIPConfigsProperty)[kTestIPConfigPath]);
474 } 475 }
475 476
476 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServiceList) { 477 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServiceList) {
477 // Add an entry to the profile only. 478 // Add an entry to the profile only.
478 const std::string kTestServicePath1("stub_wifi_profile_only1"); 479 const std::string kTestServicePath1("stub_wifi_profile_only1");
479 AddServiceToProfile(shill::kTypeWifi, kTestServicePath1, false /* visible */); 480 AddServiceToProfile(shill::kTypeWifi, kTestServicePath1, false /* visible */);
480 message_loop_.RunUntilIdle(); 481 base::RunLoop().RunUntilIdle();
481 482
482 // Update the Manager properties. This should trigger a single list update, 483 // Update the Manager properties. This should trigger a single list update,
483 // an initial property update, and a regular property update. 484 // an initial property update, and a regular property update.
484 listener_->reset_list_updates(); 485 listener_->reset_list_updates();
485 shill_property_handler_->UpdateManagerProperties(); 486 shill_property_handler_->UpdateManagerProperties();
486 message_loop_.RunUntilIdle(); 487 base::RunLoop().RunUntilIdle();
487 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty)); 488 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty));
488 EXPECT_EQ(1, listener_->initial_property_updates( 489 EXPECT_EQ(1, listener_->initial_property_updates(
489 shill::kServiceCompleteListProperty)[kTestServicePath1]); 490 shill::kServiceCompleteListProperty)[kTestServicePath1]);
490 EXPECT_EQ(1, listener_->property_updates( 491 EXPECT_EQ(1, listener_->property_updates(
491 shill::kServiceCompleteListProperty)[kTestServicePath1]); 492 shill::kServiceCompleteListProperty)[kTestServicePath1]);
492 493
493 // Add a new entry to the services and the profile; should also trigger a 494 // Add a new entry to the services and the profile; should also trigger a
494 // service list update, and a property update. 495 // service list update, and a property update.
495 listener_->reset_list_updates(); 496 listener_->reset_list_updates();
496 const std::string kTestServicePath2("stub_wifi_profile_only2"); 497 const std::string kTestServicePath2("stub_wifi_profile_only2");
497 AddServiceToProfile(shill::kTypeWifi, kTestServicePath2, true); 498 AddServiceToProfile(shill::kTypeWifi, kTestServicePath2, true);
498 shill_property_handler_->UpdateManagerProperties(); 499 shill_property_handler_->UpdateManagerProperties();
499 message_loop_.RunUntilIdle(); 500 base::RunLoop().RunUntilIdle();
500 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty)); 501 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty));
501 EXPECT_EQ(1, listener_->initial_property_updates( 502 EXPECT_EQ(1, listener_->initial_property_updates(
502 shill::kServiceCompleteListProperty)[kTestServicePath2]); 503 shill::kServiceCompleteListProperty)[kTestServicePath2]);
503 EXPECT_EQ(1, listener_->property_updates( 504 EXPECT_EQ(1, listener_->property_updates(
504 shill::kServiceCompleteListProperty)[kTestServicePath2]); 505 shill::kServiceCompleteListProperty)[kTestServicePath2]);
505 } 506 }
506 507
507 TEST_F(ShillPropertyHandlerTest, ProhibitedTechnologies) { 508 TEST_F(ShillPropertyHandlerTest, ProhibitedTechnologies) {
508 std::vector<std::string> prohibited_technologies; 509 std::vector<std::string> prohibited_technologies;
509 prohibited_technologies.push_back(shill::kTypeEthernet); 510 prohibited_technologies.push_back(shill::kTypeEthernet);
510 EXPECT_TRUE( 511 EXPECT_TRUE(
511 shill_property_handler_->IsTechnologyEnabled(shill::kTypeEthernet)); 512 shill_property_handler_->IsTechnologyEnabled(shill::kTypeEthernet));
512 shill_property_handler_->SetProhibitedTechnologies( 513 shill_property_handler_->SetProhibitedTechnologies(
513 prohibited_technologies, network_handler::ErrorCallback()); 514 prohibited_technologies, network_handler::ErrorCallback());
514 message_loop_.RunUntilIdle(); 515 base::RunLoop().RunUntilIdle();
515 // Disabled 516 // Disabled
516 EXPECT_FALSE( 517 EXPECT_FALSE(
517 shill_property_handler_->IsTechnologyEnabled(shill::kTypeEthernet)); 518 shill_property_handler_->IsTechnologyEnabled(shill::kTypeEthernet));
518 519
519 // Can not enable it back 520 // Can not enable it back
520 shill_property_handler_->SetTechnologyEnabled( 521 shill_property_handler_->SetTechnologyEnabled(
521 shill::kTypeEthernet, true, network_handler::ErrorCallback()); 522 shill::kTypeEthernet, true, network_handler::ErrorCallback());
522 message_loop_.RunUntilIdle(); 523 base::RunLoop().RunUntilIdle();
523 EXPECT_FALSE( 524 EXPECT_FALSE(
524 shill_property_handler_->IsTechnologyEnabled(shill::kTypeEthernet)); 525 shill_property_handler_->IsTechnologyEnabled(shill::kTypeEthernet));
525 526
526 // Can enable it back after policy changes 527 // Can enable it back after policy changes
527 prohibited_technologies.clear(); 528 prohibited_technologies.clear();
528 shill_property_handler_->SetProhibitedTechnologies( 529 shill_property_handler_->SetProhibitedTechnologies(
529 prohibited_technologies, network_handler::ErrorCallback()); 530 prohibited_technologies, network_handler::ErrorCallback());
530 shill_property_handler_->SetTechnologyEnabled( 531 shill_property_handler_->SetTechnologyEnabled(
531 shill::kTypeEthernet, true, network_handler::ErrorCallback()); 532 shill::kTypeEthernet, true, network_handler::ErrorCallback());
532 message_loop_.RunUntilIdle(); 533 base::RunLoop().RunUntilIdle();
533 EXPECT_TRUE( 534 EXPECT_TRUE(
534 shill_property_handler_->IsTechnologyEnabled(shill::kTypeEthernet)); 535 shill_property_handler_->IsTechnologyEnabled(shill::kTypeEthernet));
535 } 536 }
536 537
537 } // namespace chromeos 538 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698