Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3355)

Unified Diff: chrome/test/functional/media/media_seek_perf.py

Issue 9960063: CNS seek tests for <video>. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: New tests with cached videos. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/functional/media/media_seek_perf.py
diff --git a/chrome/test/functional/media/media_seek_perf.py b/chrome/test/functional/media/media_seek_perf.py
new file mode 100644
index 0000000000000000000000000000000000000000..a6fbcaefb02fb434a800fe86f49b0d5c582f7f9b
--- /dev/null
+++ b/chrome/test/functional/media/media_seek_perf.py
@@ -0,0 +1,100 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Seek performance testing for <video>.
+
+Calculates the short and long seek times for different video formats on
+different network constraints.
+"""
+
+import logging
+import os
+
+import pyauto_media
+import pyauto_utils
+
+import cns_test_base
+import worker_thread
+
+# Number of threads to use during testing.
+_TEST_THREADS = 3
+
+# HTML test path; relative to src/chrome/test/data.
+_TEST_HTML_PATH = os.path.join('media', 'html', 'media_seek.html')
+
+# The media files used for testing.
+# Path under CNS root folder (pyauto_private/media).
+_TEST_VIDEOS = [
+ os.path.join('crowd', name) for name in
+ ['crowd1080.webm', 'crowd720.webm', 'crowd480.webm', 'crowd360.webm']]
+
+# Constraints to run tests on.
+_TESTS_TO_RUN = [
+ cns_test_base.Cable,
+ cns_test_base.Wifi,
+ cns_test_base.NoConstraints]
+
+
+class SeekWorkerThread(worker_thread.WorkerThread):
+ """Worker thread. Runs a test for each task in the queue."""
+
+ Seek_Test_Case = {
DaleCurtis 2012/04/19 19:42:10 No_Naming_Please. :) SEEK_TEST_CASES and CACHED_ST
shadi 2012/04/20 00:17:47 It is tricky! Plus the names here are used for gra
DaleCurtis 2012/04/20 22:37:06 How about instead of constants you have the follow
shadi 2012/04/21 00:32:46 I think I got what you are saying, but how can the
+ 'short_seek': 0,
+ 'long_seek': 1,
+ 'buffered_seek': 2
+ }
+ Cached_State = {
+ 'un_cached': 0,
+ 'cached': 1
+ }
+
+ def RunTask(self, unique_url, task):
+ """Runs the specific task on the url given.
+
+ It is assumed that a tab with the unique_url is already loaded.
+ Args:
+ unique_url: A unique identifier of the test page.
+ task: A (series_name, settings, file_name) tuple to run the test on.
+ """
+ series_name, settings, file_name = task
+
+ video_url = cns_test_base.GetFileURL(
+ file_name, bandwidth=settings[0], latency=settings[1],
+ loss=settings[2])
+
+ # Start the test!
+ self.CallJavascriptFunc('startTest', [video_url], unique_url)
+
+ logging.debug('Running perf test for %s.', video_url)
+ self.WaitUntil(self.GetDOMValue, args=['endTest', unique_url],
+ retry_sleep=5, timeout=180, debug=False)
+ error_msg = self.GetDOMValue('errorMsg', unique_url)
+
+ if error_msg:
+ logging.error('Error while running the tests: %s.', error_msg)
+ else:
+ graph_name = series_name + '_' + os.path.basename(file_name)
+ for state, state_num in SeekWorkerThread.Cached_State.iteritems():
+ for seek_case, seek_num in SeekWorkerThread.Seek_Test_Case.iteritems():
+ results = [float(value) for value in self.GetDOMValue(
+ "seekRecords[%s][%s].join(',')" % (state_num, seek_num),
+ unique_url).split(',')]
+ pyauto_utils.PrintPerfResult('seek', '%s_%s_%s' %
+ (state, seek_case, graph_name),
+ results, 'ms')
+
+
+class MediaSeekPerfTest(cns_test_base.CNSTestBase):
+ """PyAuto test container. See file doc string for more information."""
+
+ def testMediaSeekPerformance(self):
+ """Launches HTML test which plays each video and records seek stats."""
+ tasks = cns_test_base.CreateCNSPerfTasks(_TESTS_TO_RUN, _TEST_VIDEOS)
+ worker_thread.RunWorkerThreads(self, SeekWorkerThread, tasks, _TEST_THREADS,
+ _TEST_HTML_PATH)
+
+
+if __name__ == '__main__':
+ pyauto_media.Main()

Powered by Google App Engine
This is Rietveld 408576698