OLD | NEW |
(Empty) | |
| 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. |
| 4 # pylint: disable=W0401,W0614 |
| 5 from telemetry.page.actions.all_page_actions import * |
| 6 from telemetry.page import page as page_module |
| 7 from telemetry.page import page_set as page_set_module |
| 8 |
| 9 class PolymerCalculatorPage(page_module.PageWithDefaultRunNavigate): |
| 10 |
| 11 def __init__(self, page_set): |
| 12 super(PolymerCalculatorPage, self).__init__( |
| 13 url='http://localhost:8000/components/paper-calculator/demo.html', |
| 14 page_set=page_set) |
| 15 self.user_agent_type = 'mobile' |
| 16 self.archive_data_file = 'data/polymer.json' |
| 17 |
| 18 def RunNavigateSteps(self, action_runner): |
| 19 action_runner.RunAction(NavigateAction()) |
| 20 action_runner.RunAction(WaitAction( |
| 21 { |
| 22 'seconds': 2 |
| 23 })) |
| 24 |
| 25 def RunSmoothness(self, action_runner): |
| 26 self.TapButton(action_runner) |
| 27 self.SlidePanel(action_runner) |
| 28 |
| 29 def TapButton(self, action_runner): |
| 30 action_runner.RunAction(TapAction( |
| 31 { |
| 32 'element_function': ''' |
| 33 function(callback) { |
| 34 callback( |
| 35 document.querySelector( |
| 36 'body /deep/ #outerPanels' |
| 37 ).querySelector( |
| 38 '#standard' |
| 39 ).shadowRoot.querySelector( |
| 40 'paper-calculator-key[label="5"]' |
| 41 ) |
| 42 ); |
| 43 }''', |
| 44 'wait_after': { 'seconds': 2 } |
| 45 })) |
| 46 |
| 47 def SlidePanel(self, action_runner): |
| 48 action_runner.RunAction(SwipeAction( |
| 49 { |
| 50 'left_start_percentage': 0.1, |
| 51 'distance': 300, |
| 52 'direction': 'left', |
| 53 'wait_after': { |
| 54 'javascript': ''' |
| 55 document.querySelector( |
| 56 'body /deep/ #outerPanels' |
| 57 ).hasAttribute('opened') |
| 58 ''' |
| 59 }, |
| 60 'top_start_percentage': 0.2, |
| 61 'element_function': ''' |
| 62 function(callback) { |
| 63 callback( |
| 64 document.querySelector( |
| 65 'body /deep/ #outerPanels' |
| 66 ).querySelector( |
| 67 '#advanced' |
| 68 ).shadowRoot.querySelector( |
| 69 '.handle-bar' |
| 70 ) |
| 71 ); |
| 72 }''', |
| 73 'speed': 5000 |
| 74 })) |
| 75 |
| 76 |
| 77 class PolymerPageSet(page_set_module.PageSet): |
| 78 |
| 79 def __init__(self): |
| 80 super(PolymerPageSet, self).__init__( |
| 81 user_agent_type='mobile', |
| 82 archive_data_file='data/polymer.json') |
| 83 |
| 84 self.AddPage(PolymerCalculatorPage(self)) |
OLD | NEW |