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

Side by Side Diff: telemetry/telemetry/internal/actions/page_action.py

Issue 2876843002: Simulate interactivity boost for simulated user input events
Patch Set: Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 # Copyright 2012 The Chromium Authors. All rights reserved. 1 # Copyright 2012 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 py_trace_event import trace_event 5 from py_trace_event import trace_event
6 6
7 from telemetry import decorators 7 from telemetry import decorators
8 from telemetry.util import js_template 8 from telemetry.util import js_template
9 9
10 10
11 GESTURE_SOURCE_DEFAULT = 'DEFAULT' 11 GESTURE_SOURCE_DEFAULT = 'DEFAULT'
12 GESTURE_SOURCE_MOUSE = 'MOUSE' 12 GESTURE_SOURCE_MOUSE = 'MOUSE'
13 GESTURE_SOURCE_TOUCH = 'TOUCH' 13 GESTURE_SOURCE_TOUCH = 'TOUCH'
14 SUPPORTED_GESTURE_SOURCES = (GESTURE_SOURCE_DEFAULT, 14 SUPPORTED_GESTURE_SOURCES = (GESTURE_SOURCE_DEFAULT,
15 GESTURE_SOURCE_MOUSE, 15 GESTURE_SOURCE_MOUSE,
16 GESTURE_SOURCE_TOUCH) 16 GESTURE_SOURCE_TOUCH)
17 17
18 class PageActionNotSupported(Exception): 18 class PageActionNotSupported(Exception):
19 pass 19 pass
20 20
21 class PageActionFailed(Exception): 21 class PageActionFailed(Exception):
22 pass 22 pass
23 23
24 24
25 class PageAction(object): 25 class PageAction(object):
26 """Represents an action that a user might try to perform to a page.""" 26 """Represents an action that a user might try to perform to a page."""
27 27
28 __metaclass__ = trace_event.TracedMetaClass 28 __metaclass__ = trace_event.TracedMetaClass
29 29
30 def SimulatesUserInput(self):
31 """On some platforms (e.g. ChromeOS), the kernel provides a frequency boost
32 to the CPUs when an input is received (e.g., keypress, touchpad event).
33 Page actions which simulate a user input therefore need to trigger the
34 same boost in order to accurately simulate normal behaviour.
35
36 This should be overridden by actions which simulate user input.
37 """
38 return False
39
30 def WillRunAction(self, tab): 40 def WillRunAction(self, tab):
31 """Override to do action-specific setup before 41 """Override to do action-specific setup before
32 Test.WillRunAction is called.""" 42 Test.WillRunAction is called."""
33 pass 43 pass
34 44
35 def RunAction(self, tab): 45 def RunAction(self, tab):
36 raise NotImplementedError() 46 raise NotImplementedError()
37 47
38 def CleanUp(self, tab): 48 def CleanUp(self, tab):
39 pass 49 pass
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 if tab.EvaluateJavaScript(""" 145 if tab.EvaluateJavaScript("""
136 typeof chrome.gpuBenchmarking.gestureSourceTypeSupported === 146 typeof chrome.gpuBenchmarking.gestureSourceTypeSupported ===
137 'undefined'"""): 147 'undefined'"""):
138 return (tab.browser.platform.GetOSName() != 'mac' or 148 return (tab.browser.platform.GetOSName() != 'mac' or
139 gesture_source_type.lower() != 'touch') 149 gesture_source_type.lower() != 'touch')
140 150
141 return tab.EvaluateJavaScript(""" 151 return tab.EvaluateJavaScript("""
142 chrome.gpuBenchmarking.gestureSourceTypeSupported( 152 chrome.gpuBenchmarking.gestureSourceTypeSupported(
143 chrome.gpuBenchmarking.{{ @gesture_source_type }}_INPUT)""", 153 chrome.gpuBenchmarking.{{ @gesture_source_type }}_INPUT)""",
144 gesture_source_type=gesture_source_type.upper()) 154 gesture_source_type=gesture_source_type.upper())
OLDNEW
« no previous file with comments | « telemetry/telemetry/internal/actions/mouse_click.py ('k') | telemetry/telemetry/internal/actions/pinch.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698