• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2019 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.
4from autotest_lib.client.common_lib import error
5from autotest_lib.client.cros.enterprise import enterprise_policy_base
6from autotest_lib.client.common_lib import utils
7
8KIOSK_MODE = 'Starting kiosk mode...'
9
10
11class policy_KioskModeEnabled(
12        enterprise_policy_base.EnterprisePolicyTest):
13    """Test for verifying that the DUT entered kiosk mode."""
14    version = 1
15
16
17    def run_once(self):
18        """Entry point of this test."""
19
20        # ID of the kiosk app to start.
21        kId = 'afhcomalholahplbjhnmahkoekoijban'
22
23        self.DEVICE_POLICIES = {
24        'DeviceLocalAccounts':[
25            {'account_id': kId, 'kiosk_app':{'app_id': kId}, 'type': 1}],
26        'DeviceLocalAccountAutoLoginId':kId
27        }
28
29        self.setup_case(
30            device_policies=self.DEVICE_POLICIES,
31            enroll=True,
32            kiosk_mode=True,
33            auto_login=False)
34        running_apps = utils.system_output(
35            'cat /var/log/messages | grep kiosk')
36        # Currently this is the best way I can think of to check if DUT entered
37        # kiosk mode. This isn't ideal but it's better than what we have now.
38        # TODO(rzakarian): Find another way to verify that kiosk mode is up.
39        # crbug.com/934500.
40        if KIOSK_MODE not in running_apps:
41            raise error.TestFail(
42                'DUT did not enter kiosk mode. and it should have.')
43