| Index: chromeos/network/shill_property_handler_unittest.cc
|
| diff --git a/chromeos/network/shill_property_handler_unittest.cc b/chromeos/network/shill_property_handler_unittest.cc
|
| index e151105fe01b84b03a7fca76e28d52a9fa392cbf..9a9501eea45881966eb23f58b208d8405777b87e 100644
|
| --- a/chromeos/network/shill_property_handler_unittest.cc
|
| +++ b/chromeos/network/shill_property_handler_unittest.cc
|
| @@ -14,6 +14,7 @@
|
| #include "base/values.h"
|
| #include "chromeos/dbus/dbus_thread_manager.h"
|
| #include "chromeos/dbus/shill_device_client.h"
|
| +#include "chromeos/dbus/shill_ipconfig_client.h"
|
| #include "chromeos/dbus/shill_manager_client.h"
|
| #include "chromeos/dbus/shill_service_client.h"
|
| #include "dbus/object_path.h"
|
| @@ -24,6 +25,9 @@ namespace chromeos {
|
|
|
| namespace {
|
|
|
| +void DoNothingWithCallStatus(DBusMethodCallStatus call_status) {
|
| +}
|
| +
|
| void ErrorCallbackFunction(const std::string& error_name,
|
| const std::string& error_message) {
|
| LOG(ERROR) << "Shill Error: " << error_name << " : " << error_message;
|
| @@ -64,12 +68,6 @@ class TestListener : public internal::ShillPropertyHandler::Listener {
|
| ++manager_updates_;
|
| }
|
|
|
| - virtual void UpdateNetworkServiceIPAddress(
|
| - const std::string& service_path,
|
| - const std::string& ip_address) OVERRIDE {
|
| - AddPropertyUpdate(flimflam::kServicesProperty, service_path);
|
| - }
|
| -
|
| virtual void ManagedStateListChanged(
|
| ManagedState::ManagedType type) OVERRIDE {
|
| AddStateListUpdate(GetTypeString(type));
|
| @@ -157,6 +155,8 @@ class ShillPropertyHandlerTest : public testing::Test {
|
| service_test_ =
|
| DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface();
|
| ASSERT_TRUE(service_test_);
|
| + SetupShillPropertyHandler();
|
| + message_loop_.RunUntilIdle();
|
| }
|
|
|
| virtual void TearDown() OVERRIDE {
|
| @@ -177,9 +177,11 @@ class ShillPropertyHandlerTest : public testing::Test {
|
| void AddService(const std::string& type,
|
| const std::string& id,
|
| const std::string& state,
|
| + const std::string& ipconfig_path,
|
| bool add_to_watch_list) {
|
| ASSERT_TRUE(IsValidType(type));
|
| - service_test_->AddService(id, id, type, state, add_to_watch_list);
|
| + service_test_->AddService(id, id, type, state, ipconfig_path,
|
| + add_to_watch_list);
|
| }
|
|
|
| void RemoveService(const std::string& id) {
|
| @@ -213,13 +215,13 @@ class ShillPropertyHandlerTest : public testing::Test {
|
| service_test_->ClearServices();
|
| const bool add_to_watchlist = true;
|
| AddService(flimflam::kTypeEthernet, "stub_ethernet",
|
| - flimflam::kStateOnline, add_to_watchlist);
|
| + flimflam::kStateOnline, "", add_to_watchlist);
|
| AddService(flimflam::kTypeWifi, "stub_wifi1",
|
| - flimflam::kStateOnline, add_to_watchlist);
|
| + flimflam::kStateOnline, "", add_to_watchlist);
|
| AddService(flimflam::kTypeWifi, "stub_wifi2",
|
| - flimflam::kStateIdle, add_to_watchlist);
|
| + flimflam::kStateIdle, "", add_to_watchlist);
|
| AddService(flimflam::kTypeCellular, "stub_cellular1",
|
| - flimflam::kStateIdle, add_to_watchlist);
|
| + flimflam::kStateIdle, "", add_to_watchlist);
|
| }
|
|
|
| MessageLoopForUI message_loop_;
|
| @@ -234,8 +236,6 @@ class ShillPropertyHandlerTest : public testing::Test {
|
| };
|
|
|
| TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerStub) {
|
| - SetupShillPropertyHandler();
|
| - message_loop_.RunUntilIdle();
|
| EXPECT_EQ(1, listener_->manager_updates());
|
| EXPECT_TRUE(shill_property_handler_->TechnologyAvailable(
|
| flimflam::kTypeWifi));
|
| @@ -252,8 +252,6 @@ TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerStub) {
|
| }
|
|
|
| TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerTechnologyChanged) {
|
| - SetupShillPropertyHandler();
|
| - message_loop_.RunUntilIdle();
|
| EXPECT_EQ(1, listener_->manager_updates());
|
| // Add a disabled technology.
|
| manager_test_->AddTechnology(flimflam::kTypeWimax, false);
|
| @@ -277,8 +275,6 @@ TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerTechnologyChanged) {
|
| }
|
|
|
| TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerDevicePropertyChanged) {
|
| - SetupShillPropertyHandler();
|
| - message_loop_.RunUntilIdle();
|
| EXPECT_EQ(1, listener_->manager_updates());
|
| EXPECT_EQ(1, listener_->list_updates(flimflam::kDevicesProperty));
|
| const size_t kNumShillManagerClientStubImplDevices = 2;
|
| @@ -304,8 +300,6 @@ TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerDevicePropertyChanged) {
|
| }
|
|
|
| TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServicePropertyChanged) {
|
| - SetupShillPropertyHandler();
|
| - message_loop_.RunUntilIdle();
|
| EXPECT_EQ(1, listener_->manager_updates());
|
| EXPECT_EQ(1, listener_->list_updates(flimflam::kServicesProperty));
|
| const size_t kNumShillManagerClientStubImplServices = 4;
|
| @@ -315,7 +309,7 @@ TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServicePropertyChanged) {
|
| // Add an unwatched service.
|
| const std::string kTestServicePath("test_wifi_service1");
|
| AddService(flimflam::kTypeWifi, kTestServicePath,
|
| - flimflam::kStateIdle, false);
|
| + flimflam::kStateIdle, "", false);
|
| message_loop_.RunUntilIdle();
|
| EXPECT_EQ(1, listener_->manager_updates()); // No new manager updates.
|
| // Only watched services trigger a service list update.
|
| @@ -336,7 +330,7 @@ TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServicePropertyChanged) {
|
|
|
| // Add the existing service to the watch list.
|
| AddService(flimflam::kTypeWifi, kTestServicePath,
|
| - flimflam::kStateIdle, true);
|
| + flimflam::kStateIdle, "", true);
|
| message_loop_.RunUntilIdle();
|
| // Service list update should be received when watch list changes.
|
| EXPECT_EQ(2, listener_->list_updates(flimflam::kServicesProperty));
|
| @@ -368,6 +362,50 @@ TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServicePropertyChanged) {
|
| EXPECT_EQ(0, listener_->errors());
|
| }
|
|
|
| -// TODO(stevenjb): Test IP Configs.
|
| +TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerIPConfigPropertyChanged) {
|
| + // Set the properties for an IP Config object.
|
| + const std::string kTestIPConfigPath("test_ip_config_path");
|
| + base::StringValue ip_address("192.168.1.1");
|
| + DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty(
|
| + dbus::ObjectPath(kTestIPConfigPath),
|
| + flimflam::kAddressProperty,
|
| + ip_address,
|
| + base::Bind(&DoNothingWithCallStatus));
|
| + base::ListValue dns_servers;
|
| + dns_servers.Append(base::Value::CreateStringValue("192.168.1.100"));
|
| + dns_servers.Append(base::Value::CreateStringValue("192.168.1.101"));
|
| + DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty(
|
| + dbus::ObjectPath(kTestIPConfigPath),
|
| + flimflam::kNameServersProperty,
|
| + dns_servers,
|
| + base::Bind(&DoNothingWithCallStatus));
|
| + message_loop_.RunUntilIdle();
|
| +
|
| + // Add a service with an empty ipconfig and then update
|
| + // its ipconfig property.
|
| + const std::string kTestServicePath("test_wifi_service1");
|
| + AddService(flimflam::kTypeWifi, kTestServicePath,
|
| + flimflam::kStateIdle, "", true);
|
| + message_loop_.RunUntilIdle();
|
| + DBusThreadManager::Get()->GetShillServiceClient()->SetProperty(
|
| + dbus::ObjectPath(kTestServicePath),
|
| + shill::kIPConfigProperty,
|
| + base::StringValue(kTestIPConfigPath),
|
| + base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction));
|
| + message_loop_.RunUntilIdle();
|
| + // IPConfig updates should trigger 2 property updates for IP Address
|
| + // and DNS.
|
| + EXPECT_EQ(3, listener_->
|
| + property_updates(flimflam::kServicesProperty)[kTestServicePath]);
|
| + // Now, try adding the service with the IPConfig already set.
|
| + RemoveService(kTestServicePath);
|
| + AddService(flimflam::kTypeWifi, kTestServicePath,
|
| + flimflam::kStateIdle, kTestIPConfigPath, true);
|
| + message_loop_.RunUntilIdle();
|
| + // A watched service with the IPConfig property already set must
|
| + // trigger property updates for IP Address and DNS.
|
| + EXPECT_EQ(3, listener_->
|
| + property_updates(flimflam::kServicesProperty)[kTestServicePath]);
|
| +}
|
|
|
| } // namespace chromeos
|
|
|