Index: tools/perf/perf_tools/scrolling_benchmark.py |
diff --git a/tools/perf/perf_tools/scrolling_benchmark.py b/tools/perf/perf_tools/scrolling_benchmark.py |
index 5eae210625caf8428e4244acc99c631352940676..4bb8a29abb7a2d0389c89dac9100c38df4bfa0d7 100644 |
--- a/tools/perf/perf_tools/scrolling_benchmark.py |
+++ b/tools/perf/perf_tools/scrolling_benchmark.py |
@@ -1,10 +1,8 @@ |
# 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. |
-import os |
- |
+from chrome_remote_control import interaction |
from chrome_remote_control import multi_page_benchmark |
-from chrome_remote_control import util |
class DidNotScrollException(multi_page_benchmark.MeasurementFailure): |
def __init__(self): |
@@ -29,6 +27,7 @@ def CalcScrollResults(rendering_stats_deltas): |
class ScrollingBenchmark(multi_page_benchmark.MultiPageBenchmark): |
def __init__(self): |
super(ScrollingBenchmark, self).__init__() |
+ self._interaction = None |
def AddOptions(self, parser): |
parser.add_option('--no-gpu-benchmarking-extension', action='store_true', |
@@ -38,49 +37,16 @@ class ScrollingBenchmark(multi_page_benchmark.MultiPageBenchmark): |
action='store_true', |
help='Reports all data collected, not just FPS') |
- @staticmethod |
- def ScrollPageFully(page, tab): |
- scroll_js_path = os.path.join(os.path.dirname(__file__), 'scroll.js') |
- scroll_js = open(scroll_js_path, 'r').read() |
- |
- # Run scroll test. |
- tab.runtime.Execute(scroll_js) |
- |
- start_scroll_js = """ |
- window.__renderingStatsDeltas = null; |
- new __ScrollTest(function(rendering_stats_deltas) { |
- window.__renderingStatsDeltas = rendering_stats_deltas; |
- }).start(element); |
- """ |
- # scrollable_element_function is a function that passes the scrollable |
- # element on the page to a callback. For example: |
- # function (callback) { |
- # callback(document.getElementById('foo')); |
- # } |
- if hasattr(page, 'scrollable_element_function'): |
- tab.runtime.Execute('(%s)(function(element) { %s });' % |
- (page.scrollable_element_function, start_scroll_js)) |
- else: |
- tab.runtime.Execute('(function() { var element = document.body; %s})();' % |
- start_scroll_js) |
- |
- # Poll for scroll benchmark completion. |
- util.WaitFor(lambda: tab.runtime.Evaluate( |
- 'window.__renderingStatsDeltas'), 60) |
- |
- rendering_stats_deltas = tab.runtime.Evaluate( |
- 'window.__renderingStatsDeltas') |
- |
- if not (rendering_stats_deltas['numFramesSentToScreen'] > 0): |
- raise DidNotScrollException() |
- return rendering_stats_deltas |
- |
def CustomizeBrowserOptions(self, options): |
- if not options.no_gpu_benchmarking_extension: |
- options.extra_browser_args.append('--enable-gpu-benchmarking') |
+ self._interaction = interaction.FindClassWithName('scroll')( |
+ not options.no_gpu_benchmarking_extension) |
+ self._interaction.CustomizeBrowserOptions(options) |
def MeasurePage(self, page, tab): |
- rendering_stats_deltas = self.ScrollPageFully(page, tab) |
+ self._interaction.PerformInteraction(tab, page) |
+ |
+ def DidPerformInteraction(self, scroll, |
+ page, tab, rendering_stats_deltas): |
scroll_results = CalcScrollResults(rendering_stats_deltas) |
if self.options.report_all_results: |
all_results = {} |