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 telemetry.page.actions import page_action | 5 from telemetry.page.actions import page_action |
6 from telemetry.page.actions import wait | 6 from telemetry.page.actions import wait |
7 from telemetry import decorators | 7 from telemetry import decorators |
8 from telemetry.page.actions import action_runner | 8 from telemetry.page.actions import action_runner |
9 from telemetry.web_perf import timeline_interaction_record as tir_module | 9 from telemetry.web_perf import timeline_interaction_record as tir_module |
10 | 10 |
11 class GestureAction(page_action.PageAction): | 11 class GestureAction(page_action.PageAction): |
12 def __init__(self, attributes=None): | 12 def __init__(self, attributes=None): |
13 super(GestureAction, self).__init__(attributes) | 13 super(GestureAction, self).__init__(attributes) |
| 14 if not hasattr(self, 'automatically_record_interaction'): |
| 15 self.automatically_record_interaction = True |
| 16 |
14 if hasattr(self, 'wait_after'): | 17 if hasattr(self, 'wait_after'): |
15 self.wait_action = wait.WaitAction(self.wait_after) | 18 self.wait_action = wait.WaitAction(self.wait_after) |
16 else: | 19 else: |
17 self.wait_action = None | 20 self.wait_action = None |
18 | 21 |
19 assert self.wait_until is None or self.wait_action is None, ( | 22 assert self.wait_until is None or self.wait_action is None, ( |
20 'gesture cannot have wait_after and wait_until at the same time.') | 23 'gesture cannot have wait_after and wait_until at the same time.') |
21 | 24 |
22 def RunAction(self, page, tab): | 25 def RunAction(self, page, tab): |
23 runner = action_runner.ActionRunner(None, tab) | 26 runner = action_runner.ActionRunner(None, tab) |
24 if self.wait_action: | 27 if self.wait_action: |
25 interaction_name = 'Action_%s' % self.__class__.__name__ | 28 interaction_name = 'Action_%s' % self.__class__.__name__ |
26 else: | 29 else: |
27 interaction_name = 'Gesture_%s' % self.__class__.__name__ | 30 interaction_name = 'Gesture_%s' % self.__class__.__name__ |
28 runner.BeginInteraction(interaction_name, [tir_module.IS_SMOOTH]) | 31 |
| 32 if self.automatically_record_interaction: |
| 33 runner.BeginInteraction(interaction_name, [tir_module.IS_SMOOTH]) |
| 34 |
29 self.RunGesture(page, tab) | 35 self.RunGesture(page, tab) |
30 if self.wait_action: | 36 if self.wait_action: |
31 self.wait_action.RunAction(page, tab) | 37 self.wait_action.RunAction(page, tab) |
32 runner.EndInteraction(interaction_name, [tir_module.IS_SMOOTH]) | 38 |
| 39 if self.automatically_record_interaction: |
| 40 runner.EndInteraction(interaction_name, [tir_module.IS_SMOOTH]) |
33 | 41 |
34 def RunGesture(self, page, tab): | 42 def RunGesture(self, page, tab): |
35 raise NotImplementedError() | 43 raise NotImplementedError() |
36 | 44 |
37 @staticmethod | 45 @staticmethod |
38 def GetGestureSourceTypeFromOptions(tab): | 46 def GetGestureSourceTypeFromOptions(tab): |
39 gesture_source_type = tab.browser.synthetic_gesture_source_type | 47 gesture_source_type = tab.browser.synthetic_gesture_source_type |
40 return 'chrome.gpuBenchmarking.' + gesture_source_type.upper() + '_INPUT' | 48 return 'chrome.gpuBenchmarking.' + gesture_source_type.upper() + '_INPUT' |
41 | 49 |
42 @staticmethod | 50 @staticmethod |
43 @decorators.Cache | 51 @decorators.Cache |
44 def IsGestureSourceTypeSupported(tab, gesture_source_type): | 52 def IsGestureSourceTypeSupported(tab, gesture_source_type): |
45 # TODO(dominikg): remove once support for | 53 # TODO(dominikg): remove once support for |
46 # 'chrome.gpuBenchmarking.gestureSourceTypeSupported' has | 54 # 'chrome.gpuBenchmarking.gestureSourceTypeSupported' has |
47 # been rolled into reference build. | 55 # been rolled into reference build. |
48 if tab.EvaluateJavaScript(""" | 56 if tab.EvaluateJavaScript(""" |
49 typeof chrome.gpuBenchmarking.gestureSourceTypeSupported === | 57 typeof chrome.gpuBenchmarking.gestureSourceTypeSupported === |
50 'undefined'"""): | 58 'undefined'"""): |
51 return True | 59 return True |
52 | 60 |
53 return tab.EvaluateJavaScript(""" | 61 return tab.EvaluateJavaScript(""" |
54 chrome.gpuBenchmarking.gestureSourceTypeSupported( | 62 chrome.gpuBenchmarking.gestureSourceTypeSupported( |
55 chrome.gpuBenchmarking.%s_INPUT)""" | 63 chrome.gpuBenchmarking.%s_INPUT)""" |
56 % (gesture_source_type.upper())) | 64 % (gesture_source_type.upper())) |
OLD | NEW |