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 5"""This is a server side test to check nodes created for internal card.""" 6 7import logging 8import os 9import time 10 11from autotest_lib.client.common_lib import error 12from autotest_lib.client.cros.chameleon import audio_test_utils 13from autotest_lib.client.cros.chameleon import chameleon_audio_ids 14from autotest_lib.client.cros.chameleon import chameleon_audio_helper 15from autotest_lib.server.cros.audio import audio_test 16 17 18class audio_InternalCardNodes(audio_test.AudioTest): 19 """Server side test to check audio nodes for internal card. 20 21 This test talks to a Chameleon board and a Cros device to verify 22 audio nodes created for internal cards are correct. 23 24 """ 25 version = 1 26 DELAY_AFTER_PLUGGING = 2 27 DELAY_AFTER_UNPLUGGING = 2 28 29 def run_once(self, host): 30 chameleon_board = host.chameleon 31 factory = self.create_remote_facade_factory(host) 32 audio_facade = factory.create_audio_facade() 33 34 chameleon_board.reset() 35 36 jack_plugger = chameleon_board.get_audio_board().get_jack_plugger() 37 38 expected_plugged_nodes_without_audio_jack = ( 39 [], 40 ['POST_DSP_LOOPBACK', 41 'POST_MIX_LOOPBACK']) 42 43 expected_plugged_nodes_with_audio_jack = ( 44 ['HEADPHONE'], 45 ['MIC', 'POST_DSP_LOOPBACK', 46 'POST_MIX_LOOPBACK']) 47 48 if audio_test_utils.has_internal_speaker(host): 49 expected_plugged_nodes_without_audio_jack[0].append( 50 'INTERNAL_SPEAKER') 51 expected_plugged_nodes_with_audio_jack[0].append( 52 'INTERNAL_SPEAKER') 53 54 if audio_test_utils.has_internal_microphone(host): 55 expected_plugged_nodes_without_audio_jack[1].append( 56 'INTERNAL_MIC') 57 expected_plugged_nodes_with_audio_jack[1].append( 58 'INTERNAL_MIC') 59 60 # Modify expected nodes for special boards. 61 board_name = host.get_board().split(':')[1] 62 63 if board_name == 'link': 64 expected_plugged_nodes_without_audio_jack[1].append('KEYBOARD_MIC') 65 expected_plugged_nodes_with_audio_jack[1].append('KEYBOARD_MIC') 66 67 if board_name == 'samus': 68 expected_plugged_nodes_without_audio_jack[1].append('AOKR') 69 expected_plugged_nodes_with_audio_jack[1].append('AOKR') 70 71 audio_test_utils.check_plugged_nodes( 72 audio_facade, expected_plugged_nodes_without_audio_jack) 73 74 try: 75 jack_plugger.plug() 76 time.sleep(self.DELAY_AFTER_PLUGGING) 77 78 audio_test_utils.dump_cros_audio_logs( 79 host, audio_facade, self.resultsdir) 80 81 audio_test_utils.check_plugged_nodes( 82 audio_facade, expected_plugged_nodes_with_audio_jack) 83 84 finally: 85 jack_plugger.unplug() 86 time.sleep(self.DELAY_AFTER_UNPLUGGING) 87 88 audio_test_utils.check_plugged_nodes( 89 audio_facade, expected_plugged_nodes_without_audio_jack) 90 91