summaryrefslogtreecommitdiffstats
path: root/chrome/test/functional/chromeos_retail_mode.py
blob: 133e6625b542f2fc0b04ea546558a696ecaefc2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import pyauto_functional  # Must come before pyauto (and thus, policy_base).
import policy_base


class ChromeosRetailMode(policy_base.PolicyTestBase):
  """Tests for retail mode."""

  # The inherited setUp() method fakes enterprise enrollment. Setting the mode
  # to 'kiosk' causes enrollment into retail mode instead of the default
  # enterprise mode.
  mode = 'kiosk'
  machine_id = 'KIOSK'

  def ShouldOOBESkipToLogin(self):
    # There's no OOBE to skip.
    return False

  def _CheckOnRetailModeLoginScreen(self):
    """Checks that the retail mode login screen is visible."""
    return self.ExecuteJavascriptInOOBEWebUI(
        """window.domAutomationController.send(
               !!document.getElementById('demo-login-text'));
        """)

  def Login(self):
    """Login to retail mode by simulating a mouse click."""
    self.ExecuteJavascriptInOOBEWebUI(
        """var event = document.createEvent("MouseEvent");
           event.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0,
               false, false, false, false, 0, null);
           window.domAutomationController.send(
              document.getElementById('page').dispatchEvent(event));
        """)

  def testLogin(self):
    """Tests retail mode login."""
    self.assertTrue(self._CheckOnRetailModeLoginScreen(),
                    msg='Expected to be on the retail mode login screen.')

    self.Login()
    self.assertTrue(self.GetLoginInfo()['is_logged_in'],
                    msg='Expected to be logged in.')
    self.Logout()


if __name__ == '__main__':
  pyauto_functional.Main()