OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 # pylint: disable=W0401,W0614 | 4 # pylint: disable=W0401,W0614 |
5 from telemetry.page.actions.all_page_actions import * | 5 from telemetry.page.actions.all_page_actions import * |
6 from telemetry.page import page as page_module | 6 from telemetry.page import page as page_module |
7 from telemetry.page import page_set as page_set_module | 7 from telemetry.page import page_set as page_set_module |
8 | 8 |
9 class PolymerPage(page_module.Page): | 9 class PolymerPage(page_module.Page): |
10 | 10 |
11 def __init__(self, url, page_set): | 11 def __init__(self, url, page_set): |
12 super(PolymerPage, self).__init__( | 12 super(PolymerPage, self).__init__( |
13 url=url, | 13 url=url, |
14 page_set=page_set) | 14 page_set=page_set) |
15 self.archive_data_file = "data/polymer.json" | 15 self.archive_data_file = "data/polymer.json" |
16 self.script_to_evaluate_on_commit = ''' | 16 self.script_to_evaluate_on_commit = ''' |
17 document.addEventListener("polymer-ready", function() { | 17 document.addEventListener("polymer-ready", function() { |
18 window.__polymer_ready = true; | 18 window.__polymer_ready = true; |
19 }); | 19 }); |
20 ''' | 20 ''' |
21 | 21 |
22 def RunNavigateSteps(self, action_runner): | 22 def RunNavigateSteps(self, action_runner): |
23 action_runner.NavigateToPage(self) | 23 action_runner.NavigateToPage(self) |
24 action_runner.RunAction(WaitAction( | 24 action_runner.WaitForJavaScriptCondition( |
25 { 'javascript': "window.__polymer_ready" })) | 25 'window.__polymer_ready') |
26 | 26 |
27 | 27 |
28 class PolymerCalculatorPage(PolymerPage): | 28 class PolymerCalculatorPage(PolymerPage): |
29 | 29 |
30 def __init__(self, page_set): | 30 def __init__(self, page_set): |
31 super(PolymerCalculatorPage, self).__init__( | 31 super(PolymerCalculatorPage, self).__init__( |
32 url='http://localhost:8000/components/paper-calculator/demo.html', | 32 url='http://localhost:8000/components/paper-calculator/demo.html', |
33 page_set=page_set) | 33 page_set=page_set) |
34 | 34 |
35 def RunSmoothness(self, action_runner): | 35 def RunSmoothness(self, action_runner): |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 def __init__(self, page_set): | 88 def __init__(self, page_set): |
89 super(PolymerShadowPage, self).__init__( | 89 super(PolymerShadowPage, self).__init__( |
90 url='http://localhost:8000/components/paper-shadow/demo.html', | 90 url='http://localhost:8000/components/paper-shadow/demo.html', |
91 page_set=page_set) | 91 page_set=page_set) |
92 self.archive_data_file = 'data/polymer.json' | 92 self.archive_data_file = 'data/polymer.json' |
93 | 93 |
94 def RunSmoothness(self, action_runner): | 94 def RunSmoothness(self, action_runner): |
95 action_runner.ExecuteJavaScript( | 95 action_runner.ExecuteJavaScript( |
96 "document.getElementById('fab').scrollIntoView()") | 96 "document.getElementById('fab').scrollIntoView()") |
97 action_runner.RunAction(WaitAction( | 97 action_runner.Wait(5) |
98 { | |
99 'seconds': 5 | |
100 })) | |
101 self.AnimateShadow(action_runner, 'card') | 98 self.AnimateShadow(action_runner, 'card') |
102 self.AnimateShadow(action_runner, 'fab') | 99 self.AnimateShadow(action_runner, 'fab') |
103 | 100 |
104 def AnimateShadow(self, action_runner, eid): | 101 def AnimateShadow(self, action_runner, eid): |
105 for i in range(1, 6): | 102 for i in range(1, 6): |
106 action_runner.ExecuteJavaScript( | 103 action_runner.ExecuteJavaScript( |
107 'document.getElementById("{0}").z = {1}'.format(eid, i)) | 104 'document.getElementById("{0}").z = {1}'.format(eid, i)) |
108 action_runner.RunAction(WaitAction( | 105 action_runner.Wait(1) |
109 { | |
110 'seconds': 1 | |
111 })) | |
112 | 106 |
113 | 107 |
114 class PolymerPageSet(page_set_module.PageSet): | 108 class PolymerPageSet(page_set_module.PageSet): |
115 | 109 |
116 def __init__(self): | 110 def __init__(self): |
117 super(PolymerPageSet, self).__init__( | 111 super(PolymerPageSet, self).__init__( |
118 user_agent_type='mobile', | 112 user_agent_type='mobile', |
119 archive_data_file='data/polymer.json') | 113 archive_data_file='data/polymer.json') |
120 | 114 |
121 self.AddPage(PolymerCalculatorPage(self)) | 115 self.AddPage(PolymerCalculatorPage(self)) |
122 self.AddPage(PolymerShadowPage(self)) | 116 self.AddPage(PolymerShadowPage(self)) |
OLD | NEW |