1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 from telemetry.page.actions import action_runner as action_runner_module
6 from telemetry.page.actions import page_action
7 from telemetry.unittest import tab_test_case
10 class PinchActionTest(tab_test_case.TabTestCase):
12 super(PinchActionTest, self).setUp()
14 def testPinchByApiCalledWithCorrectArguments(self):
15 self.Navigate('blank.html')
16 if not page_action.IsGestureSourceTypeSupported(self._tab, 'touch'):
19 action_runner = action_runner_module.ActionRunner(self._tab)
20 action_runner.ExecuteJavaScript('''
21 chrome.gpuBenchmarking.pinchBy = function(
22 scaleFactor, anchorLeft, anchorTop, callback, speed) {
23 window.__test_scaleFactor = scaleFactor;
24 window.__test_anchorLeft = anchorLeft;
25 window.__test_anchorTop = anchorTop;
26 window.__test_callback = callback;
27 window.__test_speed = speed;
28 window.__pinchActionDone = true;
30 action_runner.PinchPage(scale_factor=2)
32 2, action_runner.EvaluateJavaScript('window.__test_scaleFactor'))
34 action_runner.EvaluateJavaScript('!isNaN(window.__test_anchorLeft)'))
36 action_runner.EvaluateJavaScript('!isNaN(window.__test_anchorTop)'))
38 action_runner.EvaluateJavaScript('!!window.__test_callback'))
40 800, action_runner.EvaluateJavaScript('window.__test_speed'))