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 5 6from autotest_lib.client.common_lib.cros import arc 7from autotest_lib.client.cros.enterprise import enterprise_policy_base 8 9 10class policy_ArcAudioCaptureAllowed( 11 enterprise_policy_base.EnterprisePolicyTest): 12 """ 13 Test effect of the ArcAudioCaptureAllowed ChromeOS policy on ARC. 14 15 This test will launch the ARC container via the ArcEnabled policy, then 16 will verify the status of the mic using dumpsys. If mic can't be unmuted 17 then the policy has been set to False. If mic can be unmuted then it's 18 set to True or None. 19 20 """ 21 version = 1 22 23 def _test_microphone_status(self, case): 24 microphone_status = arc.adb_shell("dumpsys | grep microphone") 25 26 if case or case is None: 27 if "no_unmute_microphone" in microphone_status: 28 raise error.TestFail( 29 "Microphone is muted and it shouldn't be.") 30 else: 31 if "no_unmute_microphone" not in microphone_status: 32 raise error.TestFail( 33 "Micprophone isn't muted and it should be.") 34 35 def policy_creator(self, case): 36 pol = {'ArcEnabled': True, 'AudioCaptureAllowed': case} 37 return pol 38 39 def run_once(self, case): 40 """ 41 Setup and run the test configured for the specified test case. 42 43 @param case: Name of the test case to run. 44 45 """ 46 policies = self.policy_creator(case) 47 48 self.setup_case(user_policies=policies, 49 arc_mode='enabled', 50 use_clouddpc_test=False) 51 52 self._test_microphone_status(case) 53