summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus
diff options
context:
space:
mode:
authormichaelpg <michaelpg@chromium.org>2015-12-10 22:16:59 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-11 06:18:01 +0000
commit7dc48c4c43099b3c1f26404fdbb04b3b7911c54c (patch)
treede297940de81deecf8e64f274d1dba1adb6582bb /chromeos/dbus
parent303f0cee736c07826eb4783680119189a2a90125 (diff)
downloadchromium_src-7dc48c4c43099b3c1f26404fdbb04b3b7911c54c.zip
chromium_src-7dc48c4c43099b3c1f26404fdbb04b3b7911c54c.tar.gz
chromium_src-7dc48c4c43099b3c1f26404fdbb04b3b7911c54c.tar.bz2
Add power sources in Device Emulator battery settings
This lets us add fake power sources (A/C adapters, USB adapters, USB TYpe-C devices) for manually testing power UI. BUG=547260 Review URL: https://codereview.chromium.org/1505403002 Cr-Commit-Position: refs/heads/master@{#364631}
Diffstat (limited to 'chromeos/dbus')
-rw-r--r--chromeos/dbus/fake_power_manager_client.cc22
1 files changed, 21 insertions, 1 deletions
diff --git a/chromeos/dbus/fake_power_manager_client.cc b/chromeos/dbus/fake_power_manager_client.cc
index 9db2303..c34ab35 100644
--- a/chromeos/dbus/fake_power_manager_client.cc
+++ b/chromeos/dbus/fake_power_manager_client.cc
@@ -12,6 +12,11 @@
namespace chromeos {
+namespace {
+// Minimum power for a USB power source to be classified as AC.
+const double kUsbMinAcWatts = 24;
+}
+
FakePowerManagerClient::FakePowerManagerClient()
: num_request_restart_calls_(0),
num_request_shutdown_calls_(0),
@@ -111,7 +116,22 @@ void FakePowerManagerClient::SetIsProjecting(bool is_projecting) {
is_projecting_ = is_projecting;
}
-void FakePowerManagerClient::SetPowerSource(const std::string& id) {}
+void FakePowerManagerClient::SetPowerSource(const std::string& id) {
+ props_.set_external_power_source_id(id);
+ props_.set_external_power(
+ power_manager::PowerSupplyProperties_ExternalPower_DISCONNECTED);
+ for (const auto& source : props_.available_external_power_source()) {
+ if (source.id() == id) {
+ props_.set_external_power(
+ !source.active_by_default() || source.max_power() < kUsbMinAcWatts
+ ? power_manager::PowerSupplyProperties_ExternalPower_USB
+ : power_manager::PowerSupplyProperties_ExternalPower_AC);
+ break;
+ }
+ }
+
+ NotifyObservers();
+}
base::Closure FakePowerManagerClient::GetSuspendReadinessCallback() {
++num_pending_suspend_readiness_callbacks_;