• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2019 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5from autotest_lib.client.common_lib import utils
6from autotest_lib.server.hosts import cros_host
7
8AUTHOR = 'ncrews'
9DEPENDENCIES = "servo_state:WORKING"
10NAME = 'policy_DeviceChargingServer.BatteryChargeMode'
11TIME = 'LONG'
12TEST_CATEGORY = 'General'
13TEST_CLASS = 'enterprise'
14TEST_TYPE = 'server'
15ATTRIBUTES = "suite:wilco_bve"
16
17DOC = """
18Ensures the DUT's battery level is in a testable range, clears the TPM if
19needed, and then runs the specified client test to verify charging behavior
20is consistent with policies.
21"""
22
23args_dict = utils.args_to_dict(args)
24servo_args = cros_host.CrosHost.get_servo_arguments(args_dict)
25
26client_test = 'policy_DeviceCharging'
27
28# When DeviceBatteryChargeMode is set to BATTERY_CHARGE_PRIMARILY_AC_USE, then
29# the DUT will not charge when above 86%. In order to test this, we need to be
30# above this threshold.
31MIN_BATTERY_LEVEL = 87
32
33# A test case consists of the policies, plus the expected power behavior.
34TEST_CASES = [
35    ({'DeviceBatteryChargeMode': 1}, # BATTERY_CHARGE_STANDARD
36     'ON_AC_AND_CHARGING'),
37    ({'DeviceBatteryChargeMode': 2}, # BATTERY_CHARGE_EXPRESS_CHARGE
38     'ON_AC_AND_CHARGING'),
39    ({'DeviceBatteryChargeMode': 3}, # BATTERY_CHARGE_PRIMARILY_AC_USE
40     'ON_AC_AND_CHARGING'),
41    ({'DeviceBatteryChargeMode': 4}, # `BATTERY_CHARGE_ADAPTIVE
42     'ON_AC_AND_CHARGING'),
43    ({'DeviceBatteryChargeMode': 5, # BATTERY_CHARGE_CUSTOM
44      'DeviceBatteryChargeCustomStartCharging': 50,
45      'DeviceBatteryChargeCustomStopCharging': 60},
46     'ON_AC_AND_NOT_CHARGING'),
47    ({'DeviceBatteryChargeMode': 5, # BATTERY_CHARGE_CUSTOM
48      'DeviceBatteryChargeCustomStartCharging': 50,
49      'DeviceBatteryChargeCustomStopCharging': 100},
50     'ON_AC_AND_CHARGING'),
51]
52
53# These are used to cleanup the DUT and to prep the DUT before each test case.
54# See the test for more info.
55ON_AC_AND_CHARGING_POLICIES = {
56    'DeviceBatteryChargeMode': 1, # BATTERY_CHARGE_STANDARD
57}
58ON_AC_AND_NOT_CHARGING_POLICIES = {
59    'DeviceBatteryChargeMode': 5, # BATTERY_CHARGE_CUSTOM
60    'DeviceBatteryChargeCustomStartCharging': 50,
61    'DeviceBatteryChargeCustomStopCharging': 60,
62}
63PREP_POLICIES = {
64    'ON_AC_AND_CHARGING'         : (ON_AC_AND_NOT_CHARGING_POLICIES,
65                                    'ON_AC_AND_NOT_CHARGING'),
66    'ON_AC_AND_NOT_CHARGING'     : (ON_AC_AND_CHARGING_POLICIES,
67                                    'ON_AC_AND_CHARGING'),
68}
69
70def run(machine):
71    host = hosts.create_host(machine, servo_args=servo_args)
72    job.run_test('policy_DeviceChargingServer',
73                 host=host,
74                 client_test=client_test,
75                 test_cases=TEST_CASES,
76                 min_battery_level=MIN_BATTERY_LEVEL,
77                 prep_policies=PREP_POLICIES)
78
79parallel_simple(run, machines)
80