1 # Copyright 2013 The Chromium 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 metrics import media 6 from telemetry.page import page_measurement 7 8 class Media(page_measurement.PageMeasurement): 9 """The MediaMeasurement class gathers media-related metrics on a page set. 10 11 Media metrics recorded are controlled by metrics/media.js. At the end of the 12 test each metric for every media element in the page are reported. 13 """ 14 def __init__(self): 15 super(Media, self).__init__('media_metrics') 16 self._media_metric = None 17 18 def results_are_the_same_on_every_page(self): 19 """Results can vary from page to page based on media events taking place.""" 20 return False 21 22 def DidNavigateToPage(self, page, tab): 23 """Override to do operations right after the page is navigated.""" 24 self._media_metric = media.MediaMetric(tab) 25 self._media_metric.Start(page, tab) 26 27 def MeasurePage(self, page, tab, results): 28 """Measure the page's performance.""" 29 self._media_metric.Stop(page, tab) 30 self._media_metric.AddResults(tab, results) 31