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