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. 4from telemetry.util import wpr_modes 5 6from page_sets.rendering import rendering_shared_state 7from page_sets.rendering import rendering_story 8from page_sets.rendering import story_tags 9from page_sets.system_health import platforms 10from page_sets.login_helpers import linkedin_login 11from page_sets.login_helpers import google_login 12 13 14class ToughPinchZoomPage(rendering_story.RenderingStory): 15 ABSTRACT_STORY = True 16 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY 17 TAGS = [story_tags.GPU_RASTERIZATION, story_tags.TOUGH_PINCH_ZOOM] 18 19 def __init__(self, 20 page_set, 21 name_suffix='', 22 shared_page_state_class=( 23 rendering_shared_state.DesktopRenderingSharedState), 24 extra_browser_args=None): 25 super(ToughPinchZoomPage, self).__init__( 26 page_set=page_set, 27 name_suffix=name_suffix, 28 extra_browser_args=extra_browser_args, 29 shared_page_state_class=shared_page_state_class) 30 31 self.target_scale_factor = page_set.target_scale_factor 32 33 def RunPinchGesture(self, action_runner, left_anchor_ratio=0.5, 34 top_anchor_ratio=0.5, scale_factor=None, 35 speed_in_pixels_per_second=800): 36 with action_runner.CreateGestureInteraction('PinchAction', 37 repeatable=True): 38 action_runner.PinchPage( 39 left_anchor_ratio=left_anchor_ratio, 40 top_anchor_ratio=top_anchor_ratio, 41 scale_factor=scale_factor, 42 speed_in_pixels_per_second=speed_in_pixels_per_second) 43 44 def RunPageInteractions(self, action_runner): 45 action_runner.tab.WaitForDocumentReadyStateToBeInteractiveOrBetter() 46 for _ in xrange(0, 3): 47 current_scale_factor = self.target_scale_factor 48 self.RunPinchGesture(action_runner, scale_factor=current_scale_factor) 49 while current_scale_factor > 1.0: 50 current_scale_factor *= 1/2.0 51 self.RunPinchGesture(action_runner, scale_factor=1/2.0) 52 53 54class GoogleSearchPinchZoom2018Page(ToughPinchZoomPage): 55 56 """ Why: top google property; a google tab is often open. """ 57 58 BASE_NAME = 'google_search_pinch' 59 YEAR = '2018' 60 URL = 'https://www.google.com/#hl=en&q=barack+obama' 61 62 def RunNavigateSteps(self, action_runner): 63 super(GoogleSearchPinchZoom2018Page, self).RunNavigateSteps(action_runner) 64 action_runner.WaitForElement(text='Next') 65 66 67class GmailPinchZoom2018Page(ToughPinchZoomPage): 68 69 """ Why: productivity, top google properties """ 70 71 BASE_NAME = 'gmail_pinch' 72 YEAR = '2018' 73 URL = 'https://mail.google.com/mail/' 74 75 def RunNavigateSteps(self, action_runner): 76 if self.wpr_mode != wpr_modes.WPR_REPLAY: 77 google_login.NewLoginGoogleAccount(action_runner, 'googletest') 78 super(GmailPinchZoom2018Page, self).RunNavigateSteps(action_runner) 79 action_runner.WaitForJavaScriptCondition( 80 'window.gmonkey !== undefined &&' 81 'document.getElementById("gb") !== null') 82 83 84class GoogleCalendarPinchZoom2018Page(ToughPinchZoomPage): 85 86 """ Why: productivity, top google properties """ 87 88 BASE_NAME = 'google_calendar_pinch' 89 YEAR = '2018' 90 URL = 'https://www.google.com/calendar/' 91 92 def RunNavigateSteps(self, action_runner): 93 if self.wpr_mode != wpr_modes.WPR_REPLAY: 94 google_login.NewLoginGoogleAccount(action_runner, 'googletest') 95 super(GoogleCalendarPinchZoom2018Page, self).RunNavigateSteps( 96 action_runner) 97 action_runner.WaitForElement('span[class~="sm8sCf"]') 98 99 100class GoogleImagePinchZoom2018Page(ToughPinchZoomPage): 101 102 """ Why: tough image case; top google properties """ 103 104 BASE_NAME = 'google_image_pinch' 105 YEAR = '2018' 106 URL = 'https://www.google.com/search?q=cats&tbm=isch' 107 108 109class YoutubePinchZoom2018Page(ToughPinchZoomPage): 110 111 """ Why: #3 (Alexa global) """ 112 113 BASE_NAME = 'youtube_pinch' 114 YEAR = '2018' 115 URL = 'http://www.youtube.com' 116 117 def RunNavigateSteps(self, action_runner): 118 super(YoutubePinchZoom2018Page, self).RunNavigateSteps(action_runner) 119 action_runner.WaitForElement(selector='#buttons') 120 121 122class BlogSpotPinchZoom2018Page(ToughPinchZoomPage): 123 124 """ 125 Why: #11 (Alexa global), google property; some blogger layouts have infinite 126 scroll but more interesting 127 """ 128 129 BASE_NAME = 'blogspot_pinch' 130 YEAR = '2018' 131 URL = 'http://googlewebmastercentral.blogspot.com/' 132 133 def RunNavigateSteps(self, action_runner): 134 super(BlogSpotPinchZoom2018Page, self).RunNavigateSteps(action_runner) 135 action_runner.WaitForElement('div[class="searchBox"]') 136 137 138class FacebookPinchZoom2018Page(ToughPinchZoomPage): 139 140 """ Why: top social,Public profile """ 141 142 BASE_NAME = 'facebook_pinch' 143 YEAR = '2018' 144 URL = 'http://www.facebook.com/barackobama' 145 146 def RunNavigateSteps(self, action_runner): 147 super(FacebookPinchZoom2018Page, self).RunNavigateSteps(action_runner) 148 action_runner.WaitForElement(text='Videos') 149 150 151class LinkedinPinchZoom2018Page(ToughPinchZoomPage): 152 153 """ Why: #12 (Alexa global),Public profile """ 154 155 BASE_NAME = 'linkedin_pinch' 156 YEAR = '2018' 157 URL = 'http://www.linkedin.com/in/linustorvalds' 158 159 def RunNavigateSteps(self, action_runner): 160 if self.wpr_mode != wpr_modes.WPR_REPLAY: 161 linkedin_login.LoginDesktopAccount(action_runner, 'linkedin') 162 super(LinkedinPinchZoom2018Page, self).RunNavigateSteps(action_runner) 163 164 165class TwitterPinchZoom2018Page(ToughPinchZoomPage): 166 167 """ Why: #8 (Alexa global),Picked an interesting page """ 168 169 BASE_NAME = 'twitter_pinch' 170 YEAR = '2018' 171 URL = 'https://twitter.com/katyperry' 172 173 174 def RunNavigateSteps(self, action_runner): 175 super(TwitterPinchZoom2018Page, self).RunNavigateSteps(action_runner) 176 action_runner.WaitForElement(selector='.ProfileNav') 177 178 179class ESPNPinchZoom2018Page(ToughPinchZoomPage): 180 181 """ Why: #1 sports """ 182 183 BASE_NAME = 'espn_pinch' 184 YEAR = '2018' 185 URL = 'http://espn.go.com/nba' 186 187 188class AccuWeatherPinchZoom2018Page(ToughPinchZoomPage): 189 """ Why: #2 weather according to Alexa """ 190 BASE_NAME = 'accu_weather_pinch' 191 YEAR = '2018' 192 URL = 'https://www.accuweather.com/en/us/new-york-ny/10017/weather-forecast/349727' 193 194 195class TwitchPinchZoom2018Page(ToughPinchZoomPage): 196 """ Why: #1 games according to Alexa """ 197 BASE_NAME = 'twitch_pinch' 198 YEAR = '2018' 199 URL = 'https://www.twitch.tv' 200 201 202class YahooNewsPinchZoom2018Page(ToughPinchZoomPage): 203 204 """ Why: #1 news worldwide (Alexa global) """ 205 206 BASE_NAME = 'yahoo_news_pinch' 207 YEAR = '2018' 208 URL = 'http://news.yahoo.com' 209 210 211class CnnPinchZoom2018Page(ToughPinchZoomPage): 212 213 """ Why: #2 news worldwide """ 214 215 BASE_NAME = 'cnn_pinch' 216 YEAR = '2018' 217 URL = 'http://www.cnn.com' 218 219 220class AmazonPinchZoom2018Page(ToughPinchZoomPage): 221 222 """ 223 Why: #1 world commerce website by visits; #3 commerce in the US by 224 time spent 225 """ 226 227 BASE_NAME = 'amazon_pinch' 228 YEAR = '2018' 229 URL = 'http://www.amazon.com' 230 231 232class EBayPinchZoom2018Page(ToughPinchZoomPage): 233 234 """ Why: #1 commerce website by time spent by users in US""" 235 236 BASE_NAME = 'ebay_pinch' 237 YEAR = '2018' 238 URL = 'http://www.ebay.com' 239 240 241class BookingPinchZoom2018Page(ToughPinchZoomPage): 242 243 """ Why: #1 Alexa recreation""" 244 245 BASE_NAME = 'booking_pinch' 246 YEAR = '2018' 247 URL = 'http://booking.com' 248 249 250class YahooSportsPinchZoom2018Page(ToughPinchZoomPage): 251 252 """ Why: #1 Alexa sports""" 253 BASE_NAME = 'yahoo_sports_pinch' 254 YEAR = '2018' 255 URL = 'http://sports.yahoo.com/' 256