Home | History | Annotate | Download | only in video_WebRtcResolutionSwitching
      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 from autotest_lib.client.bin import test
      6 from autotest_lib.client.common_lib import error
      7 from autotest_lib.client.common_lib.cros import test_webrtc_peer_connection
      8 
      9 EXTRA_BROWSER_ARGS = ['--use-fake-ui-for-media-stream',
     10                       '--use-fake-device-for-media-stream']
     11 
     12 class video_WebRtcResolutionSwitching(test.test):
     13     """Tests multiple peerconnections that randomly change resolution."""
     14     version = 1
     15 
     16     def run_once(self, mode = 'functional'):
     17         """
     18         Runs the test.
     19 
     20         @param mode: 'functional' or 'performance' depending on desired mode.
     21         """
     22         kwargs = {
     23                 'own_script': 'resolution-switching.js',
     24                 'common_script': 'loopback-peerconnection.js',
     25                 'bindir': self.bindir,
     26                 'tmpdir': self.tmpdir,
     27                 'debugdir': self.debugdir,
     28                 'num_peer_connections': 5,
     29                 'iteration_delay_millis': 300
     30         }
     31 
     32         if mode == 'functional':
     33             test = test_webrtc_peer_connection.WebRtcPeerConnectionTest(
     34                     title = 'Resolution Switching',
     35                     **kwargs)
     36             test.run_test()
     37         elif mode == 'performance':
     38             test = test_webrtc_peer_connection\
     39                     .WebRtcPeerConnectionPerformanceTest(
     40                             title = 'Resolution Switching Performance Test',
     41                             **kwargs)
     42             test.run_test()
     43             test.collector.write_metrics(self.output_perf_value)
     44         else:
     45             raise error.TestError('mode must be "functional" or "performance"')
     46 
     47