• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2017 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 module provides the test utilities for audio spec."""
6
7_BOARD_TYPE_CHROMEBOX = 'CHROMEBOX'
8_BOARD_TYPE_CHROMEBIT = 'CHROMEBIT'
9_BOARD_WITHOUT_SOUND_CARD = ['gale', 'veyron_rialto']
10
11def has_internal_speaker(board_type, board_name):
12    """Checks if a board has internal speaker.
13
14    @param board_type: board type string. E.g. CHROMEBOX, CHROMEBIT, and etc.
15    @param board_name: board name string.
16
17    @returns: True if the board has internal speaker. False otherwise.
18
19    """
20    if ((board_type == _BOARD_TYPE_CHROMEBOX and board_name != 'stumpy')
21            or board_type == _BOARD_TYPE_CHROMEBIT
22            or board_name in _BOARD_WITHOUT_SOUND_CARD):
23        return False
24    return True
25
26
27def has_internal_microphone(board_type):
28    """Checks if a board has internal microphone.
29
30    @param board_type: board type string. E.g. CHROMEBOX, CHROMEBIT, and etc.
31
32    @returns: True if the board has internal microphone. False otherwise.
33
34    """
35    if (board_type == _BOARD_TYPE_CHROMEBOX
36            or board_type == _BOARD_TYPE_CHROMEBIT):
37        return False
38    return True
39
40
41def has_headphone(board_type):
42    """Checks if a board has headphone.
43
44    @param board_type: board type string. E.g. CHROMEBOX, CHROMEBIT, and etc.
45
46    @returns: True if the board has headphone. False otherwise.
47
48    """
49    if board_type == _BOARD_TYPE_CHROMEBIT:
50        return False
51    return True
52
53
54def has_hotwording(board_name, model_name):
55    """Checks if a board has hotwording.
56
57    @param board_name: board name of the DUT.
58    @param model_name: model name of the DUT.
59
60    @returns: True if the board has hotwording.
61
62    """
63    if board_name in ['coral', 'eve', 'kevin', 'nami', 'pyro', 'samus']:
64        return True
65    return False
66