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 6 7 8class policy_PrintingEnabled( 9 enterprise_policy_base.EnterprisePolicyTest): 10 """Test effect of PrintingEnabled policy on Chrome OS.""" 11 version = 1 12 13 POLICY_NAME = 'PrintingEnabled' 14 15 def _print_check(self, case): 16 """ 17 Click the dropdown menu in Chrome, check if the print option is greyed 18 out. 19 20 @param case: bool or None, the setting of the PrintingEnabled Policy 21 22 """ 23 self.ui.doDefault_on_obj('Chrome') 24 self.ui.wait_for_ui_obj('/Print/', role='menuItem', isRegex=True) 25 print_disabled = self.ui.is_obj_restricted('/Print/', 26 role='menuItem', 27 isRegex=True) 28 if case is not False and print_disabled: 29 raise error.TestError('Printing not enabled when it should be') 30 elif case is False and not print_disabled: 31 raise error.TestError('Printing enabled when it should not be') 32 33 def run_once(self, case): 34 """ 35 Entry point of the test. 36 37 @param case: Name of the test case to run. 38 39 """ 40 self.setup_case(user_policies={'PrintingEnabled': case}, 41 disable_default_apps=False) 42 43 self.ui.start_ui_root(self.cr) 44 self._print_check(case) 45