# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from autotest_lib.server import utils

AUTHOR = "Chrome OS Team"
NAME = "power_ChargeStatus"
PURPOSE = "Servo based ChromeOS functional tests."
CRITERIA = """
This test will fail if:
1. "power_supply_info" state value reports "Discharging" when AC plugged or
    online value is "no".
2. "power_supply_info" state value reports "Charging" when AC Unplugged or
    online value is "yes".

The Command line args to run this test is as follow:
1. If DUT is connected to RPM(default), No need to pass any command line args.
2. If DUT is connected to USB powerstrip(servoj10), Need to pass
   --args=power_control="servoj10".
3. If DUT is not connected to either RPM or Servo and to run Manual, Need to
   pass --args=power_control="manual".
"""
TIME = "SHORT"
TEST_CATEGORY = "Power"
TEST_CLASS = "power"
TEST_TYPE = "server"
DEPENDENCIES = "rpm"

DOC = """
This test is used to verify the power_supply_info 'status' of the DUT on
turning power ON/OFF of charge.
"""

args_dict = utils.args_to_dict(args)
servo_args = hosts.CrosHost.get_servo_arguments(args_dict)

def run_chargestatus(machine):
    host = hosts.create_host(machine, servo_args=servo_args)
    job.run_test("power_ChargeStatus", host=host, disable_sysinfo=True,
                 cmdline_args=args)

parallel_simple(run_chargestatus, machines)