• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2014 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
5import logging
6
7from autotest_lib.client.bin import utils
8from autotest_lib.client.common_lib.cros import chrome
9from autotest_lib.client.cros.cellular import test_environment
10from autotest_lib.client.cros.ui import ui_test_base
11from autotest_lib.client.common_lib import error
12from telemetry.util import image_util
13
14class ui_SettingsPage(ui_test_base.ui_TestBase):
15    """
16    Collects screenshots of the settings page.
17    See comments on parent class for overview of how things flow.
18
19    """
20
21    def capture_screenshot(self, filepath):
22        """
23        Takes a screenshot of the settings page.
24
25        A mask is then drawn over the profile picture. This test runs only
26        on link at the moment so the dimensions provided are link specific.
27
28        Implements the abstract method capture_screenshot.
29
30        @param filepath: string, complete path to save screenshot to.
31
32        """
33        with chrome.Chrome() as cr:
34            tab = cr.browser.tabs[0]
35            tab.Navigate('chrome://settings')
36            tab.WaitForDocumentReadyStateToBeComplete()
37
38            if not tab.screenshot_supported:
39                raise error.TestError('Tab did not support taking screenshots')
40
41            screenshot = tab.Screenshot()
42            if screenshot is None:
43                raise error.TestFailure('Could not capture screenshot')
44
45            image_util.WritePngFile(screenshot, filepath)
46
47    def run_once(self, mask_points):
48        # Emulate a modem on the device.
49        test_env = test_environment.CellularPseudoMMTestEnvironment(
50                pseudomm_args=({'family': '3GPP'},),
51                use_backchannel=False,
52                shutdown_other_devices=False)
53
54        with test_env:
55            self.mask_points = mask_points
56
57            # Check if we should find mobile data in settings
58            # This should always return true now, since the modem is software
59            # emulated.
60            modem_status = utils.system_output('modem status')
61            if modem_status:
62                logging.info('Modem found')
63                logging.info(modem_status)
64                self.tagged_testname += '.mobile'
65            else:
66                logging.info('Modem not found')
67            self.run_screenshot_comparison_test()
68