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 "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> |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 EXPECT_EQ(kNumShillManagerClientStubImplServices, | 413 EXPECT_EQ(kNumShillManagerClientStubImplServices, |
414 listener_->entries(shill::kServiceCompleteListProperty).size()); | 414 listener_->entries(shill::kServiceCompleteListProperty).size()); |
415 | 415 |
416 EXPECT_EQ(0, listener_->errors()); | 416 EXPECT_EQ(0, listener_->errors()); |
417 } | 417 } |
418 | 418 |
419 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerIPConfigPropertyChanged) { | 419 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerIPConfigPropertyChanged) { |
420 // Set the properties for an IP Config object. | 420 // Set the properties for an IP Config object. |
421 const std::string kTestIPConfigPath("test_ip_config_path"); | 421 const std::string kTestIPConfigPath("test_ip_config_path"); |
422 | 422 |
423 base::StringValue ip_address("192.168.1.1"); | 423 base::Value ip_address("192.168.1.1"); |
424 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty( | 424 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty( |
425 dbus::ObjectPath(kTestIPConfigPath), | 425 dbus::ObjectPath(kTestIPConfigPath), |
426 shill::kAddressProperty, ip_address, | 426 shill::kAddressProperty, ip_address, |
427 base::Bind(&DoNothingWithCallStatus)); | 427 base::Bind(&DoNothingWithCallStatus)); |
428 base::ListValue dns_servers; | 428 base::ListValue dns_servers; |
429 dns_servers.AppendString("192.168.1.100"); | 429 dns_servers.AppendString("192.168.1.100"); |
430 dns_servers.AppendString("192.168.1.101"); | 430 dns_servers.AppendString("192.168.1.101"); |
431 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty( | 431 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty( |
432 dbus::ObjectPath(kTestIPConfigPath), | 432 dbus::ObjectPath(kTestIPConfigPath), |
433 shill::kNameServersProperty, dns_servers, | 433 shill::kNameServersProperty, dns_servers, |
434 base::Bind(&DoNothingWithCallStatus)); | 434 base::Bind(&DoNothingWithCallStatus)); |
435 base::Value prefixlen(8); | 435 base::Value prefixlen(8); |
436 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty( | 436 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty( |
437 dbus::ObjectPath(kTestIPConfigPath), | 437 dbus::ObjectPath(kTestIPConfigPath), |
438 shill::kPrefixlenProperty, prefixlen, | 438 shill::kPrefixlenProperty, prefixlen, |
439 base::Bind(&DoNothingWithCallStatus)); | 439 base::Bind(&DoNothingWithCallStatus)); |
440 base::StringValue gateway("192.0.0.1"); | 440 base::Value gateway("192.0.0.1"); |
441 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty( | 441 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty( |
442 dbus::ObjectPath(kTestIPConfigPath), | 442 dbus::ObjectPath(kTestIPConfigPath), |
443 shill::kGatewayProperty, gateway, | 443 shill::kGatewayProperty, gateway, |
444 base::Bind(&DoNothingWithCallStatus)); | 444 base::Bind(&DoNothingWithCallStatus)); |
445 base::RunLoop().RunUntilIdle(); | 445 base::RunLoop().RunUntilIdle(); |
446 | 446 |
447 // Add a service with an empty ipconfig and then update | 447 // Add a service with an empty ipconfig and then update |
448 // its ipconfig property. | 448 // its ipconfig property. |
449 const std::string kTestServicePath1("test_wifi_service1"); | 449 const std::string kTestServicePath1("test_wifi_service1"); |
450 AddService(shill::kTypeWifi, kTestServicePath1, shill::kStateIdle); | 450 AddService(shill::kTypeWifi, kTestServicePath1, shill::kStateIdle); |
451 base::RunLoop().RunUntilIdle(); | 451 base::RunLoop().RunUntilIdle(); |
452 // This is the initial property update. | 452 // This is the initial property update. |
453 EXPECT_EQ(1, listener_->initial_property_updates( | 453 EXPECT_EQ(1, listener_->initial_property_updates( |
454 shill::kServiceCompleteListProperty)[kTestServicePath1]); | 454 shill::kServiceCompleteListProperty)[kTestServicePath1]); |
455 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( | 455 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( |
456 dbus::ObjectPath(kTestServicePath1), | 456 dbus::ObjectPath(kTestServicePath1), shill::kIPConfigProperty, |
457 shill::kIPConfigProperty, | 457 base::Value(kTestIPConfigPath), base::Bind(&base::DoNothing), |
458 base::StringValue(kTestIPConfigPath), | 458 base::Bind(&ErrorCallbackFunction)); |
459 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); | |
460 base::RunLoop().RunUntilIdle(); | 459 base::RunLoop().RunUntilIdle(); |
461 // IPConfig property change on the service should trigger an IPConfigs update. | 460 // IPConfig property change on the service should trigger an IPConfigs update. |
462 EXPECT_EQ(1, listener_->property_updates( | 461 EXPECT_EQ(1, listener_->property_updates( |
463 shill::kIPConfigsProperty)[kTestIPConfigPath]); | 462 shill::kIPConfigsProperty)[kTestIPConfigPath]); |
464 | 463 |
465 // Now, Add a new service with the IPConfig already set. | 464 // Now, Add a new service with the IPConfig already set. |
466 const std::string kTestServicePath2("test_wifi_service2"); | 465 const std::string kTestServicePath2("test_wifi_service2"); |
467 AddServiceWithIPConfig(shill::kTypeWifi, kTestServicePath2, | 466 AddServiceWithIPConfig(shill::kTypeWifi, kTestServicePath2, |
468 shill::kStateIdle, kTestIPConfigPath); | 467 shill::kStateIdle, kTestIPConfigPath); |
469 base::RunLoop().RunUntilIdle(); | 468 base::RunLoop().RunUntilIdle(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 shill_property_handler_->SetProhibitedTechnologies( | 527 shill_property_handler_->SetProhibitedTechnologies( |
529 prohibited_technologies, network_handler::ErrorCallback()); | 528 prohibited_technologies, network_handler::ErrorCallback()); |
530 shill_property_handler_->SetTechnologyEnabled( | 529 shill_property_handler_->SetTechnologyEnabled( |
531 shill::kTypeEthernet, true, network_handler::ErrorCallback()); | 530 shill::kTypeEthernet, true, network_handler::ErrorCallback()); |
532 base::RunLoop().RunUntilIdle(); | 531 base::RunLoop().RunUntilIdle(); |
533 EXPECT_TRUE( | 532 EXPECT_TRUE( |
534 shill_property_handler_->IsTechnologyEnabled(shill::kTypeEthernet)); | 533 shill_property_handler_->IsTechnologyEnabled(shill::kTypeEthernet)); |
535 } | 534 } |
536 | 535 |
537 } // namespace chromeos | 536 } // namespace chromeos |
OLD | NEW |