From 33eb0ccc628c6b2ef3f0adb168c83336899900af Mon Sep 17 00:00:00 2001 From: "stevenjb@chromium.org" Date: Thu, 6 Mar 2014 20:50:44 +0000 Subject: Replace misc. network and power stub flags with more flexible ones This replaces the following flags: --default-stub-network-state-idle --enable-stub-interactive (for Shill only) --enable-stub-portalled-wifi --enabled-stub-network-types With: --shill-stub={options} Specific option values are commented in the code. BUG=345033 R=pneubeck@chromium.org Review URL: https://codereview.chromium.org/181413006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255422 0039d316-1c4b-4281-b951-d872f2087c98 --- chromeos/chromeos.gyp | 2 - chromeos/chromeos_switches.cc | 35 +- chromeos/chromeos_switches.h | 6 +- chromeos/dbus/dbus_thread_manager.cc | 3 +- chromeos/dbus/dbus_thread_manager.h | 6 +- chromeos/dbus/fake_dbus_thread_manager.cc | 7 + chromeos/dbus/fake_dbus_thread_manager.h | 3 + chromeos/dbus/fake_shill_manager_client.cc | 422 ++++++++++++++++++--- chromeos/dbus/fake_shill_manager_client.h | 19 + chromeos/dbus/fake_shill_service_client.cc | 39 +- chromeos/dbus/shill_manager_client.h | 7 + chromeos/dbus/shill_stub_helper.cc | 202 ---------- chromeos/dbus/shill_stub_helper.h | 22 -- chromeos/dbus/sms_client.cc | 2 - chromeos/network/network_state_handler.cc | 6 +- chromeos/network/network_state_handler_unittest.cc | 8 +- .../network/shill_property_handler_unittest.cc | 14 +- 17 files changed, 449 insertions(+), 354 deletions(-) delete mode 100644 chromeos/dbus/shill_stub_helper.cc delete mode 100644 chromeos/dbus/shill_stub_helper.h diff --git a/chromeos/chromeos.gyp b/chromeos/chromeos.gyp index 602d6a8..79a091e 100644 --- a/chromeos/chromeos.gyp +++ b/chromeos/chromeos.gyp @@ -180,8 +180,6 @@ 'dbus/shill_profile_client.h', 'dbus/shill_service_client.cc', 'dbus/shill_service_client.h', - 'dbus/shill_stub_helper.cc', - 'dbus/shill_stub_helper.h', 'dbus/image_burner_client.cc', 'dbus/image_burner_client.h', 'dbus/introspectable_client.cc', diff --git a/chromeos/chromeos_switches.cc b/chromeos/chromeos_switches.cc index 9696c8c..386c034 100644 --- a/chromeos/chromeos_switches.cc +++ b/chromeos/chromeos_switches.cc @@ -21,15 +21,15 @@ const char kAuthExtensionPath[] = "auth-ext-path"; // Forces the stub implementation of dbus clients. const char kDbusStub[] = "dbus-stub"; -// All stub networks are idle by default. -const char kDefaultStubNetworkStateIdle[] = "default-stub-network-state-idle"; - // Time before a machine at OOBE is considered derelict const char kDerelictDetectionTimeout[] = "derelict-detection-timeout"; // Time before a derelict machines starts demo mode. const char kDerelictIdleTimeout[] = "derelict-idle-timeout"; +// Integer flag that sets the DeviceRegistered local state pref. +const char kDeviceRegistered[] = "device-registered"; + // Disables wallpaper boot animation (except of OOBE case). const char kDisableBootAnimation[] = "disable-boot-animation"; @@ -93,25 +93,13 @@ const char kEnableCarrierSwitching[] = "enable-carrier-switching"; const char kEnableNetworkPortalNotification[] = "enable-network-portal-notification"; -// Enable "interactive" mode for stub implemenations (e.g. NetworkStateHandler) +// Enable "interactive" mode for stub implemenations (e.g. PowerManagerClient) const char kEnableStubInteractive[] = "enable-stub-interactive"; -// Enable stub portalled wifi network for testing. -const char kEnableStubPortalledWifi[] = "enable-stub-portalled-wifi"; - // Enables touchpad three-finger-click as middle button. const char kEnableTouchpadThreeFingerClick[] = "enable-touchpad-three-finger-click"; -// Specifies stub network types to be enabled. If this switch is not specified, -// ethernet, wifi and vpn are enabled by default. -// -// Examples: -// Disable all network types: --enabled-stub-network-types='' -// Enable wifi only: --enabled-stub-network-types=wifi -// Enable ethernet and wifi: --enabled-stub-network-types=ethernet,wifi -const char kEnabledStubNetworkTypes[] = "enabled-stub-network-types"; - // Enable Kiosk mode for ChromeOS. Note this switch refers to retail mode rather // than the kiosk app mode. const char kEnableKioskMode[] = "enable-kiosk-mode"; @@ -187,8 +175,19 @@ const char kOobeSkipPostLogin[] = "oobe-skip-postlogin"; // Interval at which we check for total time on OOBE. const char kOobeTimerInterval[] = "oobe-timer-interval"; -// Integer flag that sets the DeviceRegistered local state pref. -const char kDeviceRegistered[] = "device-registered"; +// Specifies network stub behavior. If this switch is not specified, +// ethernet, wifi and vpn are enabled by default, and transitions occur +// instantaneously. Multiple options can be comma separated (no spaces). +// See FakeShillManagerClient::SetInitialNetworkState for implementation. +// Examples: +// 'wifi=on' - A wifi network is initially connected ('1' also works) +// 'wifi=off' - Wifi networks are all initially disconnected ('0' also works) +// 'wifi=disabled' - Wifi is initially disabled +// 'wifi=none' - Wifi is unavailable +// 'wifi=portal' - Wifi connection will be in Portal state +// 'cellular=1' - Cellular is initially connected +// 'interactive=3' - Interactive mode, connect/scan/etc requests take 3 secs +const char kShillStub[] = "shill-stub"; // Skips the machine hwid check. Useful for running in VMs because they have no // hwid. diff --git a/chromeos/chromeos_switches.h b/chromeos/chromeos_switches.h index 7132910..22aea33 100644 --- a/chromeos/chromeos_switches.h +++ b/chromeos/chromeos_switches.h @@ -24,9 +24,9 @@ CHROMEOS_EXPORT extern const char kAppOemManifestFile[]; CHROMEOS_EXPORT extern const char kAshWebUIInit[]; CHROMEOS_EXPORT extern const char kAuthExtensionPath[]; CHROMEOS_EXPORT extern const char kDbusStub[]; -CHROMEOS_EXPORT extern const char kDefaultStubNetworkStateIdle[]; CHROMEOS_EXPORT extern const char kDerelictDetectionTimeout[]; CHROMEOS_EXPORT extern const char kDerelictIdleTimeout[]; +CHROMEOS_EXPORT extern const char kDeviceRegistered[]; CHROMEOS_EXPORT extern const char kDisableBootAnimation[]; CHROMEOS_EXPORT extern const char kDisableDemoMode[]; CHROMEOS_EXPORT extern const char kDisableEnterpriseUserReporting[]; @@ -48,9 +48,7 @@ CHROMEOS_EXPORT extern const char kEnableKioskMode[]; CHROMEOS_EXPORT extern const char kEnableNetworkPortalNotification[]; CHROMEOS_EXPORT extern const char kEnableRequestTabletSite[]; CHROMEOS_EXPORT extern const char kEnableStubInteractive[]; -CHROMEOS_EXPORT extern const char kEnableStubPortalledWifi[]; CHROMEOS_EXPORT extern const char kEnableTouchpadThreeFingerClick[]; -CHROMEOS_EXPORT extern const char kEnabledStubNetworkTypes[]; CHROMEOS_EXPORT extern const char kEnterpriseEnrollmentInitialModulus[]; CHROMEOS_EXPORT extern const char kEnterpriseEnrollmentModulusLimit[]; CHROMEOS_EXPORT extern const char kEnterpriseEnrollmentSkipRobotAuth[]; @@ -70,7 +68,7 @@ CHROMEOS_EXPORT extern const char kLoginUser[]; CHROMEOS_EXPORT extern const char kNaturalScrollDefault[]; CHROMEOS_EXPORT extern const char kOobeSkipPostLogin[]; CHROMEOS_EXPORT extern const char kOobeTimerInterval[]; -CHROMEOS_EXPORT extern const char kDeviceRegistered[]; +CHROMEOS_EXPORT extern const char kShillStub[]; CHROMEOS_EXPORT extern const char kSkipHWIDCheck[]; CHROMEOS_EXPORT extern const char kSmsTestMessages[]; CHROMEOS_EXPORT extern const char kStubCrosSettings[]; diff --git a/chromeos/dbus/dbus_thread_manager.cc b/chromeos/dbus/dbus_thread_manager.cc index 64279ad..1d84074 100644 --- a/chromeos/dbus/dbus_thread_manager.cc +++ b/chromeos/dbus/dbus_thread_manager.cc @@ -41,7 +41,6 @@ #include "chromeos/dbus/shill_manager_client.h" #include "chromeos/dbus/shill_profile_client.h" #include "chromeos/dbus/shill_service_client.h" -#include "chromeos/dbus/shill_stub_helper.h" #include "chromeos/dbus/sms_client.h" #include "chromeos/dbus/system_clock_client.h" #include "chromeos/dbus/update_engine_client.h" @@ -469,7 +468,7 @@ void DBusThreadManager::InitializeWithStub() { fake_dbus_thread_manager->SetFakeClients(); g_dbus_thread_manager = fake_dbus_thread_manager; InitializeClients(); - shill_stub_helper::SetupDefaultEnvironment(); + fake_dbus_thread_manager->SetupDefaultEnvironment(); VLOG(1) << "DBusThreadManager initialized with stub implementation"; } diff --git a/chromeos/dbus/dbus_thread_manager.h b/chromeos/dbus/dbus_thread_manager.h index c36ddc3..513a59fe 100644 --- a/chromeos/dbus/dbus_thread_manager.h +++ b/chromeos/dbus/dbus_thread_manager.h @@ -94,10 +94,12 @@ class CHROMEOS_EXPORT DBusThreadManager { // Similar to Initialize(), but injects an alternative // DBusThreadManager using SetInstanceForTest first. The injected // object will be owned by the internal pointer and deleted by - // Shutdown(). + // Shutdown(). Does not create any Fake client implementations. static void InitializeForTesting(DBusThreadManager* dbus_thread_manager); - // Initialize with stub implementations for tests based on stubs. + // Initialize with stub implementations for tests, creating a complete set + // of fake/stub client implementations. Also initializes a default set of + // fake Shill devices and services, customizable with switches::kShillStub. static void InitializeWithStub(); // Returns true if DBusThreadManager has been initialized. Call this to diff --git a/chromeos/dbus/fake_dbus_thread_manager.cc b/chromeos/dbus/fake_dbus_thread_manager.cc index a57a7c2..b5bb787 100644 --- a/chromeos/dbus/fake_dbus_thread_manager.cc +++ b/chromeos/dbus/fake_dbus_thread_manager.cc @@ -117,6 +117,13 @@ void FakeDBusThreadManager::SetFakeShillClients() { scoped_ptr(new FakeShillProfileClient)); } +void FakeDBusThreadManager::SetupDefaultEnvironment() { + ShillManagerClient::TestInterface* manager = + shill_manager_client_->GetTestInterface(); + if (manager) + manager->SetupDefaultEnvironment(); +} + void FakeDBusThreadManager::SetBluetoothAdapterClient( scoped_ptr client) { bluetooth_adapter_client_ = client.Pass(); diff --git a/chromeos/dbus/fake_dbus_thread_manager.h b/chromeos/dbus/fake_dbus_thread_manager.h index b541ffb..74ab40d 100644 --- a/chromeos/dbus/fake_dbus_thread_manager.h +++ b/chromeos/dbus/fake_dbus_thread_manager.h @@ -34,6 +34,9 @@ class CHROMEOS_EXPORT FakeDBusThreadManager : public DBusThreadManager { // Creates and sets all fake Shill DBusClients. void SetFakeShillClients(); + // Sets up any default environment for fake clients, e.g. for UI testing. + void SetupDefaultEnvironment(); + void SetBluetoothAdapterClient(scoped_ptr client); void SetBluetoothAgentManagerClient( scoped_ptr client); diff --git a/chromeos/dbus/fake_shill_manager_client.cc b/chromeos/dbus/fake_shill_manager_client.cc index beafbcd..8c8c2b8 100644 --- a/chromeos/dbus/fake_shill_manager_client.cc +++ b/chromeos/dbus/fake_shill_manager_client.cc @@ -7,6 +7,9 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/message_loop/message_loop.h" +#include "base/strings/string_number_conversions.h" +#include "base/strings/string_split.h" +#include "base/strings/string_util.h" #include "base/values.h" #include "chromeos/chromeos_switches.h" #include "chromeos/dbus/dbus_thread_manager.h" @@ -83,10 +86,23 @@ bool IsConnectedState(const std::string& state) { state == shill::kStateReady; } +void UpdatePortaledWifiState(const std::string& service_path) { + DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface() + ->SetServiceProperty(service_path, + shill::kStateProperty, + base::StringValue(shill::kStatePortal)); +} + +const char* kTechnologyUnavailable = "unavailable"; +const char* kNetworkActivated = "activated"; +const char* kNetworkDisabled = "disabled"; + } // namespace FakeShillManagerClient::FakeShillManagerClient() - : weak_ptr_factory_(this) { + : interactive_delay_(0), + weak_ptr_factory_(this) { + ParseCommandLineSwitch(); } FakeShillManagerClient::~FakeShillManagerClient() {} @@ -143,21 +159,16 @@ void FakeShillManagerClient::RequestScan(const std::string& type, DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface(); std::string device_path = device_client->GetDevicePathForType(device_type); if (!device_path.empty()) { - device_client->SetDeviceProperty(device_path, - shill::kScanningProperty, - base::FundamentalValue(true)); - } - const int kScanDurationSeconds = 3; - int scan_duration_seconds = kScanDurationSeconds; - if (!CommandLine::ForCurrentProcess()->HasSwitch( - chromeos::switches::kEnableStubInteractive)) { - scan_duration_seconds = 0; + device_client->SetDeviceProperty( + device_path, shill::kScanningProperty, base::FundamentalValue(true)); } base::MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind(&FakeShillManagerClient::ScanCompleted, - weak_ptr_factory_.GetWeakPtr(), device_path, callback), - base::TimeDelta::FromSeconds(scan_duration_seconds)); + weak_ptr_factory_.GetWeakPtr(), + device_path, + callback), + base::TimeDelta::FromSeconds(interactive_delay_)); } void FakeShillManagerClient::EnableTechnology( @@ -166,24 +177,21 @@ void FakeShillManagerClient::EnableTechnology( const ErrorCallback& error_callback) { base::ListValue* enabled_list = NULL; if (!stub_properties_.GetListWithoutPathExpansion( - shill::kEnabledTechnologiesProperty, &enabled_list)) { + shill::kAvailableTechnologiesProperty, &enabled_list)) { base::MessageLoop::current()->PostTask(FROM_HERE, callback); base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(error_callback, "StubError", "Property not found")); return; } - if (CommandLine::ForCurrentProcess()->HasSwitch( - chromeos::switches::kEnableStubInteractive)) { - const int kEnableTechnologyDelaySeconds = 3; - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&FakeShillManagerClient::SetTechnologyEnabled, - weak_ptr_factory_.GetWeakPtr(), type, callback, true), - base::TimeDelta::FromSeconds(kEnableTechnologyDelaySeconds)); - } else { - SetTechnologyEnabled(type, callback, true); - } + base::MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::Bind(&FakeShillManagerClient::SetTechnologyEnabled, + weak_ptr_factory_.GetWeakPtr(), + type, + callback, + true), + base::TimeDelta::FromSeconds(interactive_delay_)); } void FakeShillManagerClient::DisableTechnology( @@ -192,23 +200,20 @@ void FakeShillManagerClient::DisableTechnology( const ErrorCallback& error_callback) { base::ListValue* enabled_list = NULL; if (!stub_properties_.GetListWithoutPathExpansion( - shill::kEnabledTechnologiesProperty, &enabled_list)) { + shill::kAvailableTechnologiesProperty, &enabled_list)) { base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(error_callback, "StubError", "Property not found")); return; } - if (CommandLine::ForCurrentProcess()->HasSwitch( - chromeos::switches::kEnableStubInteractive)) { - const int kDisableTechnologyDelaySeconds = 3; - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&FakeShillManagerClient::SetTechnologyEnabled, - weak_ptr_factory_.GetWeakPtr(), type, callback, false), - base::TimeDelta::FromSeconds(kDisableTechnologyDelaySeconds)); - } else { - SetTechnologyEnabled(type, callback, false); - } + base::MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::Bind(&FakeShillManagerClient::SetTechnologyEnabled, + weak_ptr_factory_.GetWeakPtr(), + type, + callback, + false), + base::TimeDelta::FromSeconds(interactive_delay_)); } void FakeShillManagerClient::ConfigureService( @@ -222,7 +227,7 @@ void FakeShillManagerClient::ConfigureService( std::string type; if (!properties.GetString(shill::kGuidProperty, &guid) || !properties.GetString(shill::kTypeProperty, &type)) { - LOG(ERROR) << "ConfigureService requies GUID and Type to be defined"; + LOG(ERROR) << "ConfigureService requires GUID and Type to be defined"; // If the properties aren't filled out completely, then just return an empty // object path. base::MessageLoop::current()->PostTask( @@ -316,8 +321,8 @@ void FakeShillManagerClient::VerifyAndEncryptData( const std::string& data, const StringCallback& callback, const ErrorCallback& error_callback) { - base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(callback, "encrypted_data")); + base::MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(callback, "encrypted_data")); } void FakeShillManagerClient::ConnectToBestServices( @@ -397,6 +402,26 @@ void FakeShillManagerClient::SetTechnologyInitializing(const std::string& type, } } +void FakeShillManagerClient::AddGeoNetwork( + const std::string& technology, + const base::DictionaryValue& network) { + base::ListValue* list_value = NULL; + if (!stub_geo_networks_.GetListWithoutPathExpansion(technology, + &list_value)) { + list_value = new base::ListValue; + stub_geo_networks_.SetWithoutPathExpansion(technology, list_value); + } + list_value->Append(network.DeepCopy()); +} + +void FakeShillManagerClient::AddProfile(const std::string& profile_path) { + const char* key = shill::kProfilesProperty; + if (GetListProperty(key) + ->AppendIfNotPresent(new base::StringValue(profile_path))) { + CallNotifyObserversPropertyChanged(key); + } +} + void FakeShillManagerClient::ClearProperties() { stub_properties_.Clear(); } @@ -513,26 +538,194 @@ void FakeShillManagerClient::SortManagerServices() { } } -void FakeShillManagerClient::AddGeoNetwork( - const std::string& technology, - const base::DictionaryValue& network) { - base::ListValue* list_value = NULL; - if (!stub_geo_networks_.GetListWithoutPathExpansion( - technology, &list_value)) { - list_value = new base::ListValue; - stub_geo_networks_.SetWithoutPathExpansion(technology, list_value); - } - list_value->Append(network.DeepCopy()); + +int FakeShillManagerClient::GetInteractiveDelay() const { + return interactive_delay_; } -void FakeShillManagerClient::AddProfile(const std::string& profile_path) { - const char* key = shill::kProfilesProperty; - if (GetListProperty(key)->AppendIfNotPresent( - new base::StringValue(profile_path))) { - CallNotifyObserversPropertyChanged(key); +void FakeShillManagerClient::SetupDefaultEnvironment() { + DBusThreadManager* dbus_manager = DBusThreadManager::Get(); + ShillServiceClient::TestInterface* services = + dbus_manager->GetShillServiceClient()->GetTestInterface(); + ShillProfileClient::TestInterface* profiles = + dbus_manager->GetShillProfileClient()->GetTestInterface(); + ShillDeviceClient::TestInterface* devices = + dbus_manager->GetShillDeviceClient()->GetTestInterface(); + if (!services || !profiles || !devices) + return; + + const std::string shared_profile = ShillProfileClient::GetSharedProfilePath(); + profiles->AddProfile(shared_profile, std::string()); + + const bool add_to_visible = true; + const bool add_to_watchlist = true; + + bool enabled; + std::string state; + + // Ethernet + state = GetInitialStateForType(shill::kTypeEthernet, &enabled); + if (state == shill::kStateOnline) { + AddTechnology(shill::kTypeEthernet, enabled); + devices->AddDevice( + "/device/eth1", shill::kTypeEthernet, "stub_eth_device1"); + services->AddService("eth1", "eth1", + shill::kTypeEthernet, + state, + add_to_visible, add_to_watchlist); + profiles->AddService(shared_profile, "eth1"); + } + + // Wifi + state = GetInitialStateForType(shill::kTypeWifi, &enabled); + if (state != kTechnologyUnavailable) { + bool portaled = false; + if (state == shill::kStatePortal) { + portaled = true; + state = shill::kStateIdle; + } + AddTechnology(shill::kTypeWifi, enabled); + devices->AddDevice("/device/wifi1", shill::kTypeWifi, "stub_wifi_device1"); + + services->AddService("wifi1", + "wifi1", + shill::kTypeWifi, + state, + add_to_visible, add_to_watchlist); + services->SetServiceProperty("wifi1", + shill::kSecurityProperty, + base::StringValue(shill::kSecurityWep)); + profiles->AddService(shared_profile, "wifi1"); + + services->AddService("wifi2", + "wifi2_PSK", + shill::kTypeWifi, + shill::kStateIdle, + add_to_visible, add_to_watchlist); + services->SetServiceProperty("wifi2", + shill::kSecurityProperty, + base::StringValue(shill::kSecurityPsk)); + + base::FundamentalValue strength_value(80); + services->SetServiceProperty( + "wifi2", shill::kSignalStrengthProperty, strength_value); + profiles->AddService(shared_profile, "wifi2"); + + if (portaled) { + const std::string kPortaledWifiPath = "portaled_wifi"; + services->AddService(kPortaledWifiPath, + "Portaled Wifi", + shill::kTypeWifi, + shill::kStatePortal, + add_to_visible, add_to_watchlist); + services->SetServiceProperty(kPortaledWifiPath, + shill::kSecurityProperty, + base::StringValue(shill::kSecurityNone)); + services->SetConnectBehavior(kPortaledWifiPath, + base::Bind(&UpdatePortaledWifiState, + "portaled_wifi")); + services->SetServiceProperty(kPortaledWifiPath, + shill::kConnectableProperty, + base::FundamentalValue(true)); + profiles->AddService(shared_profile, kPortaledWifiPath); + } + } + + // Wimax + state = GetInitialStateForType(shill::kTypeWimax, &enabled); + if (state != kTechnologyUnavailable) { + AddTechnology(shill::kTypeWimax, enabled); + devices->AddDevice( + "/device/wimax1", shill::kTypeWimax, "stub_wimax_device1"); + + services->AddService("wimax1", + "wimax1", + shill::kTypeWimax, + state, + add_to_visible, add_to_watchlist); + services->SetServiceProperty( + "wimax1", shill::kConnectableProperty, base::FundamentalValue(true)); + } + + // Cellular + state = GetInitialStateForType(shill::kTypeCellular, &enabled); + if (state != kTechnologyUnavailable) { + bool activated = false; + if (state == kNetworkActivated) { + activated = true; + state = shill::kStateIdle; + } + AddTechnology(shill::kTypeCellular, enabled); + devices->AddDevice( + "/device/cellular1", shill::kTypeCellular, "stub_cellular_device1"); + devices->SetDeviceProperty("/device/cellular1", + shill::kCarrierProperty, + base::StringValue(shill::kCarrierSprint)); + + services->AddService("cellular1", + "cellular1", + shill::kTypeCellular, + state, + add_to_visible, add_to_watchlist); + base::StringValue technology_value(shill::kNetworkTechnologyGsm); + services->SetServiceProperty( + "cellular1", shill::kNetworkTechnologyProperty, technology_value); + + if (activated) { + services->SetServiceProperty( + "cellular1", + shill::kActivationStateProperty, + base::StringValue(shill::kActivationStateActivated)); + services->SetServiceProperty("cellular1", + shill::kConnectableProperty, + base::FundamentalValue(true)); + } else { + services->SetServiceProperty( + "cellular1", + shill::kActivationStateProperty, + base::StringValue(shill::kActivationStateNotActivated)); + } + + services->SetServiceProperty("cellular1", + shill::kRoamingStateProperty, + base::StringValue(shill::kRoamingStateHome)); + } + + // VPN + state = GetInitialStateForType(shill::kTypeVPN, &enabled); + if (state != kTechnologyUnavailable) { + // Set the "Provider" dictionary properties. Note: when setting these in + // Shill, "Provider.Type", etc keys are used, but when reading the values + // "Provider" . "Type", etc keys are used. Here we are setting the values + // that will be read (by the UI, tests, etc). + base::DictionaryValue provider_properties; + provider_properties.SetString(shill::kTypeProperty, + shill::kProviderOpenVpn); + provider_properties.SetString(shill::kHostProperty, "vpn_host"); + + services->AddService("vpn1", + "vpn1", + shill::kTypeVPN, + state, + add_to_visible, add_to_watchlist); + services->SetServiceProperty( + "vpn1", shill::kProviderProperty, provider_properties); + profiles->AddService(shared_profile, "vpn1"); + + services->AddService("vpn2", + "vpn2", + shill::kTypeVPN, + shill::kStateIdle, + add_to_visible, add_to_watchlist); + services->SetServiceProperty( + "vpn2", shill::kProviderProperty, provider_properties); } + + SortManagerServices(); } +// Private methods + void FakeShillManagerClient::AddServiceToWatchList( const std::string& service_path) { // Remove and insert the service, moving it to the front of the watch list. @@ -635,10 +828,8 @@ void FakeShillManagerClient::SetTechnologyEnabled( const std::string& type, const base::Closure& callback, bool enabled) { - base::ListValue* enabled_list = NULL; - stub_properties_.GetListWithoutPathExpansion( - shill::kEnabledTechnologiesProperty, &enabled_list); - DCHECK(enabled_list); + base::ListValue* enabled_list = + GetListProperty(shill::kEnabledTechnologiesProperty); if (enabled) enabled_list->AppendIfNotPresent(new base::StringValue(type)); else @@ -693,4 +884,119 @@ void FakeShillManagerClient::ScanCompleted(const std::string& device_path, base::MessageLoop::current()->PostTask(FROM_HERE, callback); } +void FakeShillManagerClient::ParseCommandLineSwitch() { + CommandLine* command_line = CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kShillStub)) { + std::string option_str = + command_line->GetSwitchValueASCII(switches::kShillStub); + base::StringPairs string_pairs; + base::SplitStringIntoKeyValuePairs(option_str, '=', ',', &string_pairs); + for (base::StringPairs::iterator iter = string_pairs.begin(); + iter != string_pairs.end(); ++iter) { + ParseOption((*iter).first, (*iter).second); + } + return; + } + // Default setup + SetInitialNetworkState(shill::kTypeEthernet, shill::kStateOnline); + SetInitialNetworkState(shill::kTypeWifi, shill::kStateOnline); + SetInitialNetworkState(shill::kTypeCellular, shill::kStateIdle); + SetInitialNetworkState(shill::kTypeVPN, shill::kStateIdle); +} + +bool FakeShillManagerClient::ParseOption(const std::string& arg0, + const std::string& arg1) { + if (arg0 == "interactive") { + int seconds = 3; + if (!arg1.empty()) + base::StringToInt(arg1, &seconds); + interactive_delay_ = seconds; + return true; + } + return SetInitialNetworkState(arg0, arg1); +} + +bool FakeShillManagerClient::SetInitialNetworkState(std::string type_arg, + std::string state_arg) { + std::string state; + state_arg = StringToLowerASCII(state_arg); + if (state_arg.empty() || state_arg == "1" || state_arg == "on" || + state_arg == "enabled" || state_arg == "connected" || + state_arg == "online") { + // Enabled and connected (default value) + state = shill::kStateOnline; + } else if (state_arg == "0" || state_arg == "off" || + state_arg == "inactive" || state_arg == shill::kStateIdle) { + // Technology enabled, services are created but are not connected. + state = shill::kStateIdle; + } else if (state_arg == "disabled" || state_arg == "disconnect") { + // Technology disabled but available, services created but not connected. + state = kNetworkDisabled; + } else if (state_arg == "none" || state_arg == "offline") { + // Technology not available, do not create services. + state = kTechnologyUnavailable; + } else if (state_arg == "portal") { + // Technology is enabled, a service is connected and in Portal state. + state = shill::kStatePortal; + } else if (state_arg == "active" || state_arg == "activated") { + // Technology is enabled, a service is connected and Activated. + state = kNetworkActivated; + } else { + LOG(ERROR) << "Unrecognized initial state: " << state_arg; + return false; + } + + type_arg = StringToLowerASCII(type_arg); + // Special cases + if (type_arg == "wireless") { + shill_initial_state_map_[shill::kTypeWifi] = state; + shill_initial_state_map_[shill::kTypeCellular] = state; + return true; + } + // Convenience synonyms. + if (type_arg == "eth") + type_arg = shill::kTypeEthernet; + + if (type_arg != shill::kTypeEthernet && + type_arg != shill::kTypeWifi && + type_arg != shill::kTypeCellular && + type_arg != shill::kTypeWimax && + type_arg != shill::kTypeVPN) { + LOG(WARNING) << "Unrecognized Shill network type: " << type_arg; + return false; + } + + // Unconnected or disabled ethernet is the same as unavailable. + if (type_arg == shill::kTypeEthernet && + (state == shill::kStateIdle || state == kNetworkDisabled)) { + state = kTechnologyUnavailable; + } + + shill_initial_state_map_[type_arg] = state; + return true; +} + +std::string FakeShillManagerClient::GetInitialStateForType( + const std::string& type, + bool* enabled) { + std::map::const_iterator iter = + shill_initial_state_map_.find(type); + if (iter == shill_initial_state_map_.end()) { + *enabled = false; + return kTechnologyUnavailable; + } + std::string state = iter->second; + if (state == kNetworkDisabled) { + *enabled = false; + return shill::kStateIdle; + } + *enabled = true; + if ((state == shill::kStatePortal && type != shill::kTypeWifi) || + (state == kNetworkActivated && type != shill::kTypeCellular)) { + LOG(WARNING) << "Invalid state: " << state << " for " << type; + return shill::kStateIdle; + } + return state; +} + } // namespace chromeos diff --git a/chromeos/dbus/fake_shill_manager_client.h b/chromeos/dbus/fake_shill_manager_client.h index cbcc404..339e0d1 100644 --- a/chromeos/dbus/fake_shill_manager_client.h +++ b/chromeos/dbus/fake_shill_manager_client.h @@ -101,6 +101,8 @@ class CHROMEOS_EXPORT FakeShillManagerClient virtual void ServiceStateChanged(const std::string& service_path, const std::string& state) OVERRIDE; virtual void SortManagerServices() OVERRIDE; + virtual void SetupDefaultEnvironment() OVERRIDE; + virtual int GetInteractiveDelay() const OVERRIDE; private: void AddServiceToWatchList(const std::string& service_path); @@ -118,11 +120,28 @@ class CHROMEOS_EXPORT FakeShillManagerClient void ScanCompleted(const std::string& device_path, const base::Closure& callback); + // Parses the command line for Shill stub switches and sets initial states. + // Uses comma-separated name-value pairs (see SplitStringIntoKeyValuePairs): + // interactive={delay} - sets delay in seconds for interactive UI + // {wifi,cellular,etc}={on,off,disabled,none} - sets initial state for type + void ParseCommandLineSwitch(); + bool ParseOption(const std::string& arg0, const std::string& arg1); + bool SetInitialNetworkState(std::string type_arg, std::string state_arg); + std::string GetInitialStateForType(const std::string& type, + bool* enabled); + // Dictionary of property name -> property value base::DictionaryValue stub_properties_; + // Dictionary of technology -> list of property dictionaries base::DictionaryValue stub_geo_networks_; + // Seconds to delay interactive actions + int interactive_delay_; + + // Initial state for fake services. + std::map shill_initial_state_map_; + ObserverList observer_list_; // Note: This should remain the last member so it'll be destroyed and diff --git a/chromeos/dbus/fake_shill_service_client.cc b/chromeos/dbus/fake_shill_service_client.cc index ed47b28..30673f3 100644 --- a/chromeos/dbus/fake_shill_service_client.cc +++ b/chromeos/dbus/fake_shill_service_client.cc @@ -6,17 +6,14 @@ #include "base/bind.h" #include "base/bind_helpers.h" -#include "base/command_line.h" #include "base/message_loop/message_loop.h" #include "base/stl_util.h" #include "base/strings/string_util.h" #include "base/values.h" -#include "chromeos/chromeos_switches.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/shill_device_client.h" #include "chromeos/dbus/shill_manager_client.h" #include "chromeos/dbus/shill_property_changed_observer.h" -#include "chromeos/dbus/shill_stub_helper.h" #include "chromeos/network/shill_property_util.h" #include "dbus/bus.h" #include "dbus/message.h" @@ -44,6 +41,11 @@ void CallSortManagerServices() { SortManagerServices(); } +int GetInteractiveDelay() { + return DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> + GetInteractiveDelay(); +} + } // namespace FakeShillServiceClient::FakeShillServiceClient() : weak_ptr_factory_(this) { @@ -193,18 +195,12 @@ void FakeShillServiceClient::Connect(const dbus::ObjectPath& service_path, associating_value); // Stay Associating until the state is changed again after a delay. - base::TimeDelta delay; - if (CommandLine::ForCurrentProcess()->HasSwitch( - chromeos::switches::kEnableStubInteractive)) { - const int kConnectDelaySeconds = 5; - delay = base::TimeDelta::FromSeconds(kConnectDelaySeconds); - } base::MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind(&FakeShillServiceClient::ContinueConnect, weak_ptr_factory_.GetWeakPtr(), service_path.value()), - delay); + base::TimeDelta::FromSeconds(GetInteractiveDelay())); callback.Run(); } @@ -217,12 +213,6 @@ void FakeShillServiceClient::Disconnect(const dbus::ObjectPath& service_path, error_callback.Run("Error.InvalidService", "Invalid Service"); return; } - base::TimeDelta delay; - if (CommandLine::ForCurrentProcess()->HasSwitch( - chromeos::switches::kEnableStubInteractive)) { - const int kConnectDelaySeconds = 2; - delay = base::TimeDelta::FromSeconds(kConnectDelaySeconds); - } // Set Idle after a delay base::StringValue idle_value(shill::kStateIdle); base::MessageLoop::current()->PostDelayedTask( @@ -234,7 +224,7 @@ void FakeShillServiceClient::Disconnect(const dbus::ObjectPath& service_path, idle_value, base::Bind(&base::DoNothing), error_callback), - delay); + base::TimeDelta::FromSeconds(GetInteractiveDelay())); callback.Run(); } @@ -258,12 +248,6 @@ void FakeShillServiceClient::ActivateCellularModem( SetServiceProperty(service_path.value(), shill::kActivationStateProperty, base::StringValue(shill::kActivationStateActivating)); - base::TimeDelta delay; - if (CommandLine::ForCurrentProcess()->HasSwitch( - chromeos::switches::kEnableStubInteractive)) { - const int kConnectDelaySeconds = 2; - delay = base::TimeDelta::FromSeconds(kConnectDelaySeconds); - } // Set Activated after a delay base::MessageLoop::current()->PostDelayedTask( FROM_HERE, @@ -271,7 +255,7 @@ void FakeShillServiceClient::ActivateCellularModem( weak_ptr_factory_.GetWeakPtr(), service_path, error_callback), - delay); + base::TimeDelta::FromSeconds(GetInteractiveDelay())); base::MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -324,12 +308,7 @@ void FakeShillServiceClient::AddService(const std::string& service_path, const std::string& state, bool add_to_visible_list, bool add_to_watch_list) { - std::string nstate = state; - if (CommandLine::ForCurrentProcess()->HasSwitch( - chromeos::switches::kDefaultStubNetworkStateIdle)) { - nstate = shill::kStateIdle; - } - AddServiceWithIPConfig(service_path, name, type, nstate, "", + AddServiceWithIPConfig(service_path, name, type, state, "", add_to_visible_list, add_to_watch_list); } diff --git a/chromeos/dbus/shill_manager_client.h b/chromeos/dbus/shill_manager_client.h index 90373ba..d64772b 100644 --- a/chromeos/dbus/shill_manager_client.h +++ b/chromeos/dbus/shill_manager_client.h @@ -79,6 +79,13 @@ class CHROMEOS_EXPORT ShillManagerClient : public DBusClient { // Inactive State, then by Type. virtual void SortManagerServices() = 0; + // Sets up the default fake environment based on default initial states + // or states provided by the command line. + virtual void SetupDefaultEnvironment() = 0; + + // Returns the interactive delay specified on the command line, 0 for none. + virtual int GetInteractiveDelay() const = 0; + protected: virtual ~TestInterface() {} }; diff --git a/chromeos/dbus/shill_stub_helper.cc b/chromeos/dbus/shill_stub_helper.cc deleted file mode 100644 index 9f2dcda..0000000 --- a/chromeos/dbus/shill_stub_helper.cc +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chromeos/dbus/shill_stub_helper.h" - -#include "base/bind.h" -#include "base/command_line.h" -#include "base/strings/string_tokenizer.h" -#include "chromeos/chromeos_switches.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/shill_device_client.h" -#include "chromeos/dbus/shill_manager_client.h" -#include "chromeos/dbus/shill_profile_client.h" -#include "chromeos/dbus/shill_service_client.h" -#include "third_party/cros_system_api/dbus/service_constants.h" - -namespace chromeos { -namespace shill_stub_helper { - -namespace { - -void UpdatePortalledWifiState(const std::string& service_path) { - ShillServiceClient::TestInterface* services = - DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); - - services->SetServiceProperty(service_path, - shill::kStateProperty, - base::StringValue(shill::kStatePortal)); -} - -// Returns true if |network_type| is found in the comma separated list given -// with kEnabledStubNetworkTypes switch. -bool IsStubNetworkTypeEnabled(const std::string& network_type) { - CommandLine* command_line = CommandLine::ForCurrentProcess(); - // If the switch is not present, enabled by default. - if (!command_line->HasSwitch(switches::kEnabledStubNetworkTypes)) - return true; - - const std::string value = - command_line->GetSwitchValueASCII(switches::kEnabledStubNetworkTypes); - base::StringTokenizer tokenizer(value, ","); - while (tokenizer.GetNext()) { - if (tokenizer.token() == network_type) - return true; - } - return false; -} - -} // namespace - -void SetupDefaultEnvironment() { - ShillServiceClient::TestInterface* services = - DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); - ShillProfileClient::TestInterface* profiles = - DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface(); - ShillManagerClient::TestInterface* manager = - DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface(); - ShillDeviceClient::TestInterface* devices = - DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface(); - if (!services || !profiles || !manager | !devices) - return; - - // Stub Technologies. - manager->AddTechnology(shill::kTypeEthernet, true); - manager->AddTechnology(shill::kTypeWifi, true); - manager->AddTechnology(shill::kTypeCellular, true); - manager->AddTechnology(shill::kTypeWimax, true); - - std::string shared_profile = ShillProfileClient::GetSharedProfilePath(); - profiles->AddProfile(shared_profile, std::string()); - - devices->AddDevice("/device/eth1", shill::kTypeEthernet, "stub_eth_device1"); - devices->AddDevice("/device/wifi1", shill::kTypeWifi, "stub_wifi_device1"); - - devices->AddDevice( - "/device/cellular1", shill::kTypeCellular, "stub_cellular_device1"); - devices->SetDeviceProperty("/device/cellular1", - shill::kCarrierProperty, - base::StringValue(shill::kCarrierSprint)); - - devices->AddDevice("/device/wimax1", shill::kTypeWimax, "stub_wimax_device1"); - - const bool add_to_visible = true; - const bool add_to_watchlist = true; - - // On real devices, service is not added for ethernet if cable is disconneted. - if (IsStubNetworkTypeEnabled(shill::kTypeEthernet)) { - services->AddService("eth1", "eth1", - shill::kTypeEthernet, - shill::kStateOnline, - add_to_visible, add_to_watchlist); - profiles->AddService(shared_profile, "eth1"); - } - - // Wifi - - services->AddService("wifi1", - "wifi1", - shill::kTypeWifi, - IsStubNetworkTypeEnabled(shill::kTypeWifi) ? - shill::kStateOnline : shill::kStateIdle, - add_to_visible, add_to_watchlist); - services->SetServiceProperty("wifi1", - shill::kSecurityProperty, - base::StringValue(shill::kSecurityWep)); - profiles->AddService(shared_profile, "wifi1"); - - services->AddService("wifi2", - "wifi2_PSK", - shill::kTypeWifi, - shill::kStateIdle, - add_to_visible, add_to_watchlist); - services->SetServiceProperty("wifi2", - shill::kSecurityProperty, - base::StringValue(shill::kSecurityPsk)); - base::FundamentalValue strength_value(80); - services->SetServiceProperty( - "wifi2", shill::kSignalStrengthProperty, strength_value); - profiles->AddService(shared_profile, "wifi2"); - - if (CommandLine::ForCurrentProcess()->HasSwitch( - chromeos::switches::kEnableStubPortalledWifi)) { - const std::string kPortalledWifiPath = "portalled_wifi"; - services->AddService(kPortalledWifiPath, - "Portalled Wifi", - shill::kTypeWifi, - shill::kStatePortal, - add_to_visible, add_to_watchlist); - services->SetServiceProperty(kPortalledWifiPath, - shill::kSecurityProperty, - base::StringValue(shill::kSecurityNone)); - services->SetConnectBehavior(kPortalledWifiPath, - base::Bind(&UpdatePortalledWifiState, - kPortalledWifiPath)); - services->SetServiceProperty(kPortalledWifiPath, - shill::kConnectableProperty, - base::FundamentalValue(true)); - profiles->AddService(shared_profile, kPortalledWifiPath); - } - - // Wimax - - services->AddService("wimax1", - "wimax1", - shill::kTypeWimax, - shill::kStateIdle, - add_to_visible, add_to_watchlist); - services->SetServiceProperty( - "wimax1", shill::kConnectableProperty, base::FundamentalValue(true)); - - // Cellular - - services->AddService("cellular1", - "cellular1", - shill::kTypeCellular, - shill::kStateIdle, - add_to_visible, add_to_watchlist); - base::StringValue technology_value(shill::kNetworkTechnologyGsm); - services->SetServiceProperty( - "cellular1", shill::kNetworkTechnologyProperty, technology_value); - services->SetServiceProperty( - "cellular1", - shill::kActivationStateProperty, - base::StringValue(shill::kActivationStateNotActivated)); - services->SetServiceProperty("cellular1", - shill::kRoamingStateProperty, - base::StringValue(shill::kRoamingStateHome)); - - // VPN - - // Set the "Provider" dictionary properties. Note: when setting these in - // Shill, "Provider.Type", etc keys are used, but when reading the values - // "Provider" . "Type", etc keys are used. Here we are setting the values - // that will be read (by the UI, tests, etc). - base::DictionaryValue provider_properties; - provider_properties.SetString(shill::kTypeProperty, shill::kProviderOpenVpn); - provider_properties.SetString(shill::kHostProperty, "vpn_host"); - - services->AddService("vpn1", - "vpn1", - shill::kTypeVPN, - IsStubNetworkTypeEnabled(shill::kTypeVPN) ? - shill::kStateOnline : shill::kStateIdle, - add_to_visible, add_to_watchlist); - services->SetServiceProperty( - "vpn1", shill::kProviderProperty, provider_properties); - profiles->AddService(shared_profile, "vpn1"); - - services->AddService("vpn2", - "vpn2", - shill::kTypeVPN, - shill::kStateIdle, - add_to_visible, add_to_watchlist); - services->SetServiceProperty( - "vpn2", shill::kProviderProperty, provider_properties); - - manager->SortManagerServices(); -} - -} // namespace shill_stub_helper -} // namespace chromeos diff --git a/chromeos/dbus/shill_stub_helper.h b/chromeos/dbus/shill_stub_helper.h deleted file mode 100644 index dce7991..0000000 --- a/chromeos/dbus/shill_stub_helper.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROMEOS_DBUS_SHILL_STUB_HELPER_H_ -#define CHROMEOS_DBUS_SHILL_STUB_HELPER_H_ - -#include - -#include "chromeos/chromeos_export.h" - -namespace chromeos { -namespace shill_stub_helper { - -// Add default devices, services and profiles. This works only if -// DBusThreadManager was initialized with the FakeShill*Clients. -void SetupDefaultEnvironment(); - -} // namespace shill_stub_helper -} // namespace chromeos - -#endif // CHROMEOS_DBUS_SHILL_STUB_HELPER_H_ diff --git a/chromeos/dbus/sms_client.cc b/chromeos/dbus/sms_client.cc index 2e7b971..52f28ea 100644 --- a/chromeos/dbus/sms_client.cc +++ b/chromeos/dbus/sms_client.cc @@ -7,7 +7,6 @@ #include #include "base/bind.h" -#include "base/command_line.h" #include "base/location.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" @@ -15,7 +14,6 @@ #include "base/stl_util.h" #include "base/strings/stringprintf.h" #include "base/values.h" -#include "chromeos/chromeos_switches.h" #include "dbus/bus.h" #include "dbus/message.h" #include "dbus/object_proxy.h" diff --git a/chromeos/network/network_state_handler.cc b/chromeos/network/network_state_handler.cc index c0912714..972b675 100644 --- a/chromeos/network/network_state_handler.cc +++ b/chromeos/network/network_state_handler.cc @@ -191,8 +191,10 @@ const FavoriteState* NetworkStateHandler::DefaultFavoriteNetwork() const { return NULL; const FavoriteState* default_favorite = GetFavoriteState(default_network->path()); - DCHECK(default_favorite); - DCHECK(default_favorite->update_received()); + DCHECK(default_network->type() != shill::kTypeWifi || + default_favorite) << "No favorite for: " << default_network->path(); + DCHECK(!default_favorite || default_favorite->update_received()) + << "No update received for: " << default_network->path(); return default_favorite; } diff --git a/chromeos/network/network_state_handler_unittest.cc b/chromeos/network/network_state_handler_unittest.cc index cdbc4bf..8530935 100644 --- a/chromeos/network/network_state_handler_unittest.cc +++ b/chromeos/network/network_state_handler_unittest.cc @@ -320,7 +320,9 @@ TEST_F(NetworkStateHandlerTest, TechnologyState) { TEST_F(NetworkStateHandlerTest, ServicePropertyChanged) { // Set a service property. const std::string eth1 = kShillManagerClientStubDefaultService; - EXPECT_EQ("", network_state_handler_->GetNetworkState(eth1)->security()); + const NetworkState* ethernet = network_state_handler_->GetNetworkState(eth1); + ASSERT_TRUE(ethernet); + EXPECT_EQ("", ethernet->security()); EXPECT_EQ(1, test_observer_->PropertyUpdatesForService(eth1)); base::StringValue security_value("TestSecurity"); DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( @@ -328,8 +330,8 @@ TEST_F(NetworkStateHandlerTest, ServicePropertyChanged) { shill::kSecurityProperty, security_value, base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); message_loop_.RunUntilIdle(); - EXPECT_EQ("TestSecurity", - network_state_handler_->GetNetworkState(eth1)->security()); + ethernet = network_state_handler_->GetNetworkState(eth1); + EXPECT_EQ("TestSecurity", ethernet->security()); EXPECT_EQ(2, test_observer_->PropertyUpdatesForService(eth1)); // Changing a service to the existing value should not trigger an update. diff --git a/chromeos/network/shill_property_handler_unittest.cc b/chromeos/network/shill_property_handler_unittest.cc index a287012..a6b7b8e 100644 --- a/chromeos/network/shill_property_handler_unittest.cc +++ b/chromeos/network/shill_property_handler_unittest.cc @@ -309,29 +309,29 @@ TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerTechnologyChanged) { const int initial_technology_updates = 2; // Available and Enabled lists EXPECT_EQ(initial_technology_updates, listener_->technology_list_updates()); - // Remove a technology. Updates both the Available and Enabled lists. - manager_test_->RemoveTechnology(shill::kTypeWimax); + // Remove an enabled technology. Updates both the Available and Enabled lists. + manager_test_->RemoveTechnology(shill::kTypeWifi); message_loop_.RunUntilIdle(); EXPECT_EQ(initial_technology_updates + 2, listener_->technology_list_updates()); // Add a disabled technology. - manager_test_->AddTechnology(shill::kTypeWimax, false); + manager_test_->AddTechnology(shill::kTypeWifi, false); message_loop_.RunUntilIdle(); EXPECT_EQ(initial_technology_updates + 3, listener_->technology_list_updates()); EXPECT_TRUE(shill_property_handler_->IsTechnologyAvailable( - shill::kTypeWimax)); - EXPECT_FALSE(shill_property_handler_->IsTechnologyEnabled(shill::kTypeWimax)); + shill::kTypeWifi)); + EXPECT_FALSE(shill_property_handler_->IsTechnologyEnabled(shill::kTypeWifi)); // Enable the technology. DBusThreadManager::Get()->GetShillManagerClient()->EnableTechnology( - shill::kTypeWimax, + shill::kTypeWifi, base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); message_loop_.RunUntilIdle(); EXPECT_EQ(initial_technology_updates + 4, listener_->technology_list_updates()); - EXPECT_TRUE(shill_property_handler_->IsTechnologyEnabled(shill::kTypeWimax)); + EXPECT_TRUE(shill_property_handler_->IsTechnologyEnabled(shill::kTypeWifi)); EXPECT_EQ(0, listener_->errors()); } -- cgit v1.1