• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
5from autotest_lib.client.bin import test
6from autotest_lib.client.common_lib.cros import chrome, enrollment
7from autotest_lib.client.common_lib import error
8from py_utils import TimeoutException
9
10
11class enterprise_RemoraRequisitionDisplayUsage(test.test):
12    """Start enrollment and ensure that the window is shown on a Mimo display"""
13    version = 1
14
15    def supports_display_fetching(self, oobe):
16        """Return whether Chromium supports fetching the primary display name"""
17        oobe.WaitForJavaScriptCondition(
18            'typeof Oobe !== \'undefined\'', timeout=10)
19
20        return oobe.EvaluateJavaScript(
21            '"getPrimaryDisplayNameForTesting" in Oobe')
22
23    def assert_mimo_is_primary(self, oobe):
24        """Fails the test if the Mimo is not the primary display"""
25        oobe.ExecuteJavaScript('window.__oobe_display = ""')
26
27        mimo_is_primary = ("Oobe.getPrimaryDisplayNameForTesting().then("
28            "display => window.__oobe_display = display);"
29            "window.__oobe_display.indexOf('MIMO') >= 0")
30
31        try:
32            oobe.WaitForJavaScriptCondition(mimo_is_primary, timeout=10)
33        except TimeoutException:
34            display = oobe.EvaluateJavaScript('window.__oobe_display')
35            raise error.TestFail(
36                'Primary display is {}, not Mimo'.format(display))
37
38    def run_once(self):
39        with chrome.Chrome(auto_login=False) as cr:
40            enrollment.SwitchToRemora(cr.browser)
41
42            if not self.supports_display_fetching(cr.browser.oobe):
43                return
44
45            self.assert_mimo_is_primary(cr.browser.oobe)
46