• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4
5"""
6This is a server side audio sanity test testing assumptions other audio tests
7rely on.
8"""
9
10from autotest_lib.client.common_lib import error
11from autotest_lib.client.cros.chameleon import audio_test_utils
12from autotest_lib.server.cros.audio import audio_test
13
14class audio_AudioSanityCheck(audio_test.AudioTest):
15    """
16    This test talks to a Cros device to verify if some basic functions that
17    other audio tests rely on still work after a suspension.
18    """
19    version = 1
20
21    def verify_chrome_audio(self):
22        """"Verify if chrome.audio API is available"""
23        if not self.facade.get_chrome_audio_availablity():
24            raise error.TestFail("chrome.audio API is not available")
25
26    def verify_suspend(self):
27        """"Verify and trigger a suspension"""
28        audio_test_utils.suspend_resume_and_verify(self.host, self.factory)
29
30    def run_once(self, suspend_only=False):
31        """Runs Audio sanity test to make sure chrome api works. """
32
33        # The suspend_only flag is for crbug:978593, which causes sanity check
34        # to always fail. however, we still want to check the suspend operation
35        # as it also potentially fails the audio tests. This should be removed
36        # once the blocker is fixed
37        if suspend_only:
38            self.verify_suspend()
39            return
40
41        # Check if the chrome.audio API is available
42        self.verify_chrome_audio()
43        # chrome.audio API should remain available after a suspension
44        self.verify_suspend()
45        self.verify_chrome_audio()
46