OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 import logging | 5 import logging |
6 import math | 6 import math |
7 | 7 |
8 from telemetry import decorators | 8 from telemetry import decorators |
9 from telemetry.internal.actions import drag | 9 from telemetry.internal.actions import drag |
10 from telemetry.internal.actions import page_action | 10 from telemetry.internal.actions import page_action |
(...skipping 12 matching lines...) Expand all Loading... |
23 def testDragAction(self): | 23 def testDragAction(self): |
24 self.Navigate('draggable.html') | 24 self.Navigate('draggable.html') |
25 | 25 |
26 utils.InjectJavaScript(self._tab, 'gesture_common.js') | 26 utils.InjectJavaScript(self._tab, 'gesture_common.js') |
27 | 27 |
28 div_width = self._tab.EvaluateJavaScript( | 28 div_width = self._tab.EvaluateJavaScript( |
29 '__GestureCommon_GetBoundingVisibleRect(document.body).width') | 29 '__GestureCommon_GetBoundingVisibleRect(document.body).width') |
30 div_height = self._tab.EvaluateJavaScript( | 30 div_height = self._tab.EvaluateJavaScript( |
31 '__GestureCommon_GetBoundingVisibleRect(document.body).height') | 31 '__GestureCommon_GetBoundingVisibleRect(document.body).height') |
32 | 32 |
33 i = drag.DragAction(left_start_ratio=0.5, top_start_ratio=0.5, | 33 i = drag.DragAction(left_start_ratio=0.5, top_start_ratio=0.5, \ |
34 left_end_ratio=0.25, top_end_ratio=0.25) | 34 left_end_ratio=0.25, top_end_ratio=0.25) |
35 try: | 35 try: |
36 i.WillRunAction(self._tab) | 36 i.WillRunAction(self._tab) |
37 except page_action.PageActionNotSupported: | 37 except page_action.PageActionNotSupported: |
38 logging.warning('This browser does not support drag gesture. Please try' | 38 logging.warning('This browser does not support drag gesture. Please try' |
39 ' updating chrome.') | 39 ' updating chrome.') |
40 return | 40 return |
41 | 41 |
42 self._tab.ExecuteJavaScript(''' | 42 self._tab.ExecuteJavaScript(''' |
43 window.__dragAction.beginMeasuringHook = function() { | 43 window.__dragAction.beginMeasuringHook = function() { |
(...skipping 18 matching lines...) Expand all Loading... |
62 error_ratio = 0.1 | 62 error_ratio = 0.1 |
63 | 63 |
64 self.assertTrue( | 64 self.assertTrue( |
65 self.CheckWithinRange(div_position_x, expected_x, error_ratio), | 65 self.CheckWithinRange(div_position_x, expected_x, error_ratio), |
66 msg="Moved element's left coordinate: %d, expected: %d" % | 66 msg="Moved element's left coordinate: %d, expected: %d" % |
67 (div_position_x, expected_x)) | 67 (div_position_x, expected_x)) |
68 self.assertTrue( | 68 self.assertTrue( |
69 self.CheckWithinRange(div_position_y, expected_y, error_ratio), | 69 self.CheckWithinRange(div_position_y, expected_y, error_ratio), |
70 msg="Moved element's top coordinate: %d, expected: %d" % | 70 msg="Moved element's top coordinate: %d, expected: %d" % |
71 (div_position_y, expected_y)) | 71 (div_position_y, expected_y)) |
OLD | NEW |