| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from metrics import cpu | 5 from metrics import cpu |
| 6 from metrics import media | 6 from metrics import media |
| 7 from metrics import memory | 7 from metrics import memory |
| 8 from metrics import power | 8 from metrics import power |
| 9 from telemetry.page import page_measurement | 9 from telemetry.page import page_measurement |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 self._add_browser_metrics = False | 23 self._add_browser_metrics = False |
| 24 self._cpu_metric = None | 24 self._cpu_metric = None |
| 25 self._memory_metric = None | 25 self._memory_metric = None |
| 26 self._power_metric = power.PowerMetric() | 26 self._power_metric = power.PowerMetric() |
| 27 | 27 |
| 28 def results_are_the_same_on_every_page(self): | 28 def results_are_the_same_on_every_page(self): |
| 29 """Results can vary from page to page based on media events taking place.""" | 29 """Results can vary from page to page based on media events taking place.""" |
| 30 return False | 30 return False |
| 31 | 31 |
| 32 def CustomizeBrowserOptions(self, options): | 32 def CustomizeBrowserOptions(self, options): |
| 33 # Needed to run media actions in JS on touch-based devices as on Android. |
| 34 options.AppendExtraBrowserArgs( |
| 35 '--disable-gesture-requirement-for-media-playback') |
| 33 memory.MemoryMetric.CustomizeBrowserOptions(options) | 36 memory.MemoryMetric.CustomizeBrowserOptions(options) |
| 34 power.PowerMetric.CustomizeBrowserOptions(options) | 37 power.PowerMetric.CustomizeBrowserOptions(options) |
| 35 | 38 |
| 36 def DidNavigateToPage(self, page, tab): | 39 def DidNavigateToPage(self, page, tab): |
| 37 """Override to do operations right after the page is navigated.""" | 40 """Override to do operations right after the page is navigated.""" |
| 38 self._media_metric = media.MediaMetric(tab) | 41 self._media_metric = media.MediaMetric(tab) |
| 39 self._media_metric.Start(page, tab) | 42 self._media_metric.Start(page, tab) |
| 40 self._power_metric.Start(page, tab) | 43 self._power_metric.Start(page, tab) |
| 41 | 44 |
| 42 # Reset to false for every page. | 45 # Reset to false for every page. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 55 """Measure the page's performance.""" | 58 """Measure the page's performance.""" |
| 56 self._power_metric.Stop(page, tab) | 59 self._power_metric.Stop(page, tab) |
| 57 self._media_metric.Stop(page, tab) | 60 self._media_metric.Stop(page, tab) |
| 58 trace_name = self._media_metric.AddResults(tab, results) | 61 trace_name = self._media_metric.AddResults(tab, results) |
| 59 self._power_metric.AddResults(tab, results) | 62 self._power_metric.AddResults(tab, results) |
| 60 if self._add_browser_metrics: | 63 if self._add_browser_metrics: |
| 61 self._cpu_metric.Stop(page, tab) | 64 self._cpu_metric.Stop(page, tab) |
| 62 self._cpu_metric.AddResults(tab, results, trace_name=trace_name) | 65 self._cpu_metric.AddResults(tab, results, trace_name=trace_name) |
| 63 self._memory_metric.Stop(page, tab) | 66 self._memory_metric.Stop(page, tab) |
| 64 self._memory_metric.AddResults(tab, results, trace_name=trace_name) | 67 self._memory_metric.AddResults(tab, results, trace_name=trace_name) |
| OLD | NEW |