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 from telemetry.page import page as page_module | 4 from telemetry.page import page as page_module |
5 from telemetry.page import page_set as page_set_module | 5 from telemetry.page import page_set as page_set_module |
6 | 6 |
7 from page_sets import key_mobile_sites_pages | 7 from page_sets import key_mobile_sites_pages |
8 | 8 |
9 | 9 |
10 def _IssueMarkerAndScroll(action_runner): | 10 def _IssueMarkerAndScroll(action_runner): |
11 interaction = action_runner.BeginGestureInteraction( | 11 interaction = action_runner.BeginGestureInteraction( |
12 'ScrollAction', is_smooth=True) | 12 'ScrollAction') |
13 action_runner.ScrollPage() | 13 action_runner.ScrollPage() |
14 interaction.End() | 14 interaction.End() |
15 | 15 |
16 | 16 |
17 def _CreatePageClassWithSmoothInteractions(page_cls): | 17 def _CreatePageClassWithSmoothInteractions(page_cls): |
18 class DerivedSmoothPage(page_cls): # pylint: disable=W0232 | 18 class DerivedSmoothPage(page_cls): # pylint: disable=W0232 |
19 | 19 |
20 def RunPageInteractions(self, action_runner): | 20 def RunPageInteractions(self, action_runner): |
21 _IssueMarkerAndScroll(action_runner) | 21 _IssueMarkerAndScroll(action_runner) |
22 return DerivedSmoothPage | 22 return DerivedSmoothPage |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 super(WowwikiSmoothPage, self).RunNavigateSteps(action_runner) | 67 super(WowwikiSmoothPage, self).RunNavigateSteps(action_runner) |
68 action_runner.ScrollPage() | 68 action_runner.ScrollPage() |
69 action_runner.ReloadPage() | 69 action_runner.ReloadPage() |
70 super(WowwikiSmoothPage, self).RunNavigateSteps(action_runner) | 70 super(WowwikiSmoothPage, self).RunNavigateSteps(action_runner) |
71 | 71 |
72 | 72 |
73 class GmailSmoothPage(key_mobile_sites_pages.GmailPage): | 73 class GmailSmoothPage(key_mobile_sites_pages.GmailPage): |
74 | 74 |
75 def RunPageInteractions(self, action_runner): | 75 def RunPageInteractions(self, action_runner): |
76 interaction = action_runner.BeginGestureInteraction( | 76 interaction = action_runner.BeginGestureInteraction( |
77 'ScrollAction', is_smooth=True) | 77 'ScrollAction') |
78 action_runner.ScrollElement(element_function=( | 78 action_runner.ScrollElement(element_function=( |
79 'document.getElementById("views").childNodes[1].firstChild')) | 79 'document.getElementById("views").childNodes[1].firstChild')) |
80 interaction.End() | 80 interaction.End() |
81 interaction = action_runner.BeginGestureInteraction( | 81 interaction = action_runner.BeginGestureInteraction( |
82 'ScrollAction', is_smooth=True) | 82 'ScrollAction') |
83 action_runner.ScrollElement(element_function=( | 83 action_runner.ScrollElement(element_function=( |
84 'document.getElementById("views").childNodes[1].firstChild')) | 84 'document.getElementById("views").childNodes[1].firstChild')) |
85 interaction.End() | 85 interaction.End() |
86 | 86 |
87 | 87 |
88 class GroupClonedSmoothPage(key_mobile_sites_pages.GroupClonedPage): | 88 class GroupClonedSmoothPage(key_mobile_sites_pages.GroupClonedPage): |
89 | 89 |
90 def RunPageInteractions(self, action_runner): | 90 def RunPageInteractions(self, action_runner): |
91 interaction = action_runner.BeginGestureInteraction( | 91 interaction = action_runner.BeginGestureInteraction( |
92 'ScrollAction', is_smooth=True) | 92 'ScrollAction') |
93 action_runner.ScrollPage( | 93 action_runner.ScrollPage( |
94 distance_expr=''' | 94 distance_expr=''' |
95 Math.max(0, 1250 + document.getElementById("element-19") | 95 Math.max(0, 1250 + document.getElementById("element-19") |
96 .contentDocument | 96 .contentDocument |
97 .getElementById("element-22") | 97 .getElementById("element-22") |
98 .getBoundingClientRect().top);''', | 98 .getBoundingClientRect().top);''', |
99 use_touch=True) | 99 use_touch=True) |
100 interaction.End() | 100 interaction.End() |
101 | 101 |
102 | 102 |
103 class GroupClonedListImagesPage( | 103 class GroupClonedListImagesPage( |
104 key_mobile_sites_pages.GroupClonedListImagesPage): | 104 key_mobile_sites_pages.GroupClonedListImagesPage): |
105 | 105 |
106 def RunPageInteractions(self, action_runner): | 106 def RunPageInteractions(self, action_runner): |
107 interaction = action_runner.BeginGestureInteraction( | 107 interaction = action_runner.BeginGestureInteraction( |
108 'ScrollAction', is_smooth=True) | 108 'ScrollAction') |
109 action_runner.ScrollPage( | 109 action_runner.ScrollPage( |
110 distance_expr=''' | 110 distance_expr=''' |
111 Math.max(0, 1250 + | 111 Math.max(0, 1250 + |
112 document.getElementById("element-5") | 112 document.getElementById("element-5") |
113 .getBoundingClientRect().top);''', | 113 .getBoundingClientRect().top);''', |
114 use_touch=True) | 114 use_touch=True) |
115 interaction.End() | 115 interaction.End() |
116 | 116 |
117 class GoogleNewsMobile2SmoothPage( | 117 class GoogleNewsMobile2SmoothPage( |
118 key_mobile_sites_pages.GoogleNewsMobile2Page): | 118 key_mobile_sites_pages.GoogleNewsMobile2Page): |
119 | 119 |
120 def RunPageInteractions(self, action_runner): | 120 def RunPageInteractions(self, action_runner): |
121 interaction = action_runner.BeginGestureInteraction( | 121 interaction = action_runner.BeginGestureInteraction( |
122 'ScrollAction', is_smooth=True) | 122 'ScrollAction') |
123 action_runner.ScrollElement( | 123 action_runner.ScrollElement( |
124 element_function='document.getElementById(":5")', | 124 element_function='document.getElementById(":5")', |
125 distance_expr=''' | 125 distance_expr=''' |
126 Math.max(0, 2500 + | 126 Math.max(0, 2500 + |
127 document.getElementById(':h').getBoundingClientRect().top)''', | 127 document.getElementById(':h').getBoundingClientRect().top)''', |
128 use_touch=True) | 128 use_touch=True) |
129 interaction.End() | 129 interaction.End() |
130 | 130 |
131 | 131 |
132 class AmazonNicolasCageSmoothPage( | 132 class AmazonNicolasCageSmoothPage( |
133 key_mobile_sites_pages.AmazonNicolasCagePage): | 133 key_mobile_sites_pages.AmazonNicolasCagePage): |
134 | 134 |
135 def RunPageInteractions(self, action_runner): | 135 def RunPageInteractions(self, action_runner): |
136 interaction = action_runner.BeginGestureInteraction( | 136 interaction = action_runner.BeginGestureInteraction( |
137 'ScrollAction', is_smooth=True) | 137 'ScrollAction') |
138 action_runner.ScrollElement( | 138 action_runner.ScrollElement( |
139 selector='#search', | 139 selector='#search', |
140 distance_expr='document.body.scrollHeight - window.innerHeight') | 140 distance_expr='document.body.scrollHeight - window.innerHeight') |
141 interaction.End() | 141 interaction.End() |
142 | 142 |
143 | 143 |
144 class KeyMobileSitesSmoothPageSet(page_set_module.PageSet): | 144 class KeyMobileSitesSmoothPageSet(page_set_module.PageSet): |
145 | 145 |
146 """ Key mobile sites with smooth interactions. """ | 146 """ Key mobile sites with smooth interactions. """ |
147 | 147 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 ('http://www.baidu.com/s?wd=barack+obama&rsv_bp=0&rsv_spt=3&rsv_sug3=9&' | 294 ('http://www.baidu.com/s?wd=barack+obama&rsv_bp=0&rsv_spt=3&rsv_sug3=9&' |
295 'rsv_sug=0&rsv_sug4=3824&rsv_sug1=3&inputT=4920'), | 295 'rsv_sug=0&rsv_sug4=3824&rsv_sug1=3&inputT=4920'), |
296 # Why: Top search engine | 296 # Why: Top search engine |
297 'http://www.bing.com/search?q=sloths', | 297 'http://www.bing.com/search?q=sloths', |
298 # Why: Good example of poor initial scrolling | 298 # Why: Good example of poor initial scrolling |
299 'http://ftw.usatoday.com/2014/05/spelling-bee-rules-shenanigans' | 299 'http://ftw.usatoday.com/2014/05/spelling-bee-rules-shenanigans' |
300 ] | 300 ] |
301 | 301 |
302 for url in urls_list: | 302 for url in urls_list: |
303 self.AddUserStory(KeyMobileSitesSmoothPage(url, self)) | 303 self.AddUserStory(KeyMobileSitesSmoothPage(url, self)) |
OLD | NEW |