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.common_lib.cros import retry 6 7from autotest_lib.client.cros.enterprise import enterprise_policy_base 8 9from py_utils import TimeoutException 10 11 12class policy_VirtualMachinesAllowed( 13 enterprise_policy_base.EnterprisePolicyTest): 14 """ 15 Test for the VirtualMachinesAllowed policy. 16 17 If the policy is set to True then installing linux is allowed. 18 If the policy is set to False/None then installing linux is not allowed. 19 20 """ 21 version = 1 22 _POLICY = 'VirtualMachinesAllowed' 23 24 @retry.retry(TimeoutException, timeout_min=5, delay_sec=10) 25 def _run_setup_case(self, case): 26 self.setup_case(device_policies={self._POLICY: case}, enroll=True) 27 28 def run_once(self, case): 29 """ 30 Entry point of this test. 31 32 @param case: True, False, or None for the value of the policy. 33 34 """ 35 self._run_setup_case(case) 36 self.ui.start_ui_root(self.cr) 37 38 self.cr.autotest_ext.ExecuteJavaScript(''' 39 chrome.autotestPrivate.runCrostiniInstaller(function() {}) 40 ''') 41 42 if case: 43 self.ui.wait_for_ui_obj(name='/Linux/', isRegex=True) 44 else: 45 if not self.ui.did_obj_not_load(name='/Linux/', isRegex=True): 46 raise error.TestFail( 47 'Linux is installing and it should not be.') 48