Skip to content

Commit

Permalink
Replace misc. network and power stub flags with more flexible ones
Browse files Browse the repository at this point in the history
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
  • Loading branch information
stevenjb@chromium.org committed Mar 6, 2014
1 parent eb2f39c commit 33eb0cc
Show file tree
Hide file tree
Showing 17 changed files with 449 additions and 354 deletions.
2 changes: 0 additions & 2 deletions chromeos/chromeos.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
35 changes: 17 additions & 18 deletions chromeos/chromeos_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 2 additions & 4 deletions chromeos/chromeos_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand All @@ -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[];
Expand All @@ -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[];
Expand Down
3 changes: 1 addition & 2 deletions chromeos/dbus/dbus_thread_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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";
}

Expand Down
6 changes: 4 additions & 2 deletions chromeos/dbus/dbus_thread_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions chromeos/dbus/fake_dbus_thread_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ void FakeDBusThreadManager::SetFakeShillClients() {
scoped_ptr<ShillProfileClient>(new FakeShillProfileClient));
}

void FakeDBusThreadManager::SetupDefaultEnvironment() {
ShillManagerClient::TestInterface* manager =
shill_manager_client_->GetTestInterface();
if (manager)
manager->SetupDefaultEnvironment();
}

void FakeDBusThreadManager::SetBluetoothAdapterClient(
scoped_ptr<BluetoothAdapterClient> client) {
bluetooth_adapter_client_ = client.Pass();
Expand Down
3 changes: 3 additions & 0 deletions chromeos/dbus/fake_dbus_thread_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<BluetoothAdapterClient> client);
void SetBluetoothAgentManagerClient(
scoped_ptr<BluetoothAgentManagerClient> client);
Expand Down
Loading

0 comments on commit 33eb0cc

Please sign in to comment.