1# Copyright 2018 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 5"""Server side test that controls charging the DUT with Servo v4.""" 6 7from autotest_lib.server import autotest 8from autotest_lib.server import test 9from autotest_lib.server.cros.power import servo_charger 10 11# Max number of hours the DUT can charge for. 12_MAX_HOURS = 3 13 14 15class power_BatteryChargeControl(test.test): 16 """Server side test that controls charging the DUT. 17 18 This server side test first makes sure that the attached Servo v4 can 19 control charging the DUT, then puts the DUT on AC to charge, and finally 20 disconnect DUT from AC. 21 """ 22 version = 1 23 24 def run_once(self, host, percent_charge_to_add, percent_target_charge): 25 """Running the test. 26 27 @param host: CrosHost object representing the DUT. 28 @param percent_charge_to_add: percentage of the charge capacity charge 29 to add. The target charge will be capped at the charge capacity. 30 @param percent_target_charge: percentage of the charge capacity target 31 charge. The target charge will be capped at the charge capacity. 32 """ 33 servo = host.servo 34 charge_manager = servo_charger.ServoV4ChargeManager(host, servo) 35 charge_manager.start_charging() 36 37 time_limit = _MAX_HOURS * 60 * 60 38 autotest_client = autotest.Autotest(host) 39 autotest_client.run_test('power_BatteryCharge', 40 max_run_time=time_limit, 41 percent_charge_to_add=percent_charge_to_add, 42 percent_target_charge=percent_target_charge, 43 use_design_charge_capacity=False) 44 45 charge_manager.restore_original_setting() 46