1# Lint as: python2, python3
2# Copyright (c) 2015 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import logging, time
7
8from autotest_lib.server import autotest, test
9
10
11class cellular_ChromeEndToEnd(test.test):
12    """Reboots the DUT and runs clients side tests to test cellular UI.
13
14    """
15    version = 1
16
17
18    def _cold_reboot_dut(self, boot_id):
19        """Cold reboot the dut.
20
21        @param boot_id: DUT boot_id.
22
23        """
24        self._client.power_off_via_servo()
25        self._client.power_on_via_servo()
26        time.sleep(self._servo.BOOT_DELAY)
27        self._client.wait_for_restart(old_boot_id=boot_id)
28
29
30    def run_once(self, host, test):
31        """Runs the test.
32
33        @param host: A host object representing the DUT.
34        @param test: Cellular UI test to execute.
35
36        """
37
38        self._client = host
39        self._servo = host.servo
40
41        if not self._servo:
42            logging.info('Host %s does not have a servo.', host.hostname)
43            return
44
45        boot_id = self._client.get_boot_id()
46        self._cold_reboot_dut(boot_id)
47
48        client_at = autotest.Autotest(self._client)
49        client_at.run_test('network_ChromeCellularEndToEnd',
50                           test=test, check_client_result=True)
51