1# Copyright 2015 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. 4"""This is a server side test to check nodes created for internal card.""" 5 6from autotest_lib.client.cros.chameleon import audio_test_utils 7from autotest_lib.server.cros.audio import audio_test 8 9 10class audio_InternalCardNodes(audio_test.AudioTest): 11 """Server side test to check audio nodes for internal card. 12 13 This test talks to a Chameleon board and a Cros device to verify 14 audio nodes created for internal cards are correct. 15 16 """ 17 version = 1 18 _jack_plugger = None 19 20 def cleanup(self): 21 """Cleanup for this test.""" 22 if self._jack_plugger is not None: 23 self._jack_plugger.plug() 24 super(audio_InternalCardNodes, self).cleanup() 25 26 def get_expected_nodes(self, plugged): 27 """Gets expected nodes should should be created for internal cards. 28 29 @param plugged: True for plugged state, false otherwise. 30 @returns: 31 a tuple (output, input) containing lists of expected input and 32 output nodes. 33 """ 34 nodes = ([], ['POST_DSP_LOOPBACK', 'POST_MIX_LOOPBACK']) 35 if plugged: 36 # Checks whether line-out or headphone is detected. 37 hp_jack_node_type = audio_test_utils.check_hp_or_lineout_plugged( 38 self.facade) 39 nodes[0].append(hp_jack_node_type) 40 nodes[1].append('MIC') 41 if audio_test_utils.has_internal_speaker(self.host): 42 nodes[0].append('INTERNAL_SPEAKER') 43 if audio_test_utils.has_internal_microphone(self.host): 44 nodes[1].extend( 45 audio_test_utils.get_plugged_internal_mics(self.host)) 46 if audio_test_utils.has_hotwording(self.host): 47 nodes[1].append('HOTWORD') 48 if audio_test_utils.has_echo_reference(self.host): 49 nodes[1].append('ECHO_REFERENCE') 50 return nodes 51 52 def run_once(self, plug=True): 53 """Runs InternalCardNodes test.""" 54 if not audio_test_utils.has_audio_jack(self.host): 55 audio_test_utils.check_plugged_nodes( 56 self.facade, self.get_expected_nodes(False)) 57 return 58 59 if not plug: 60 self._jack_plugger = self.host.chameleon.get_audio_board( 61 ).get_jack_plugger() 62 self._jack_plugger.unplug() 63 64 audio_test_utils.check_plugged_nodes(self.facade, 65 self.get_expected_nodes(plug)) 66