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.page import shared_page_state 5 6from page_sets.rendering import rendering_story 7from page_sets.rendering import story_tags 8from page_sets.system_health import platforms 9from page_sets.login_helpers import linkedin_login 10 11 12class ToughPinchZoomMobilePage(rendering_story.RenderingStory): 13 ABSTRACT_STORY = True 14 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY 15 TAGS = [story_tags.TOUGH_PINCH_ZOOM_MOBILE] 16 17 def __init__(self, 18 page_set, 19 name_suffix='', 20 extra_browser_args=None, 21 shared_page_state_class=shared_page_state.SharedMobilePageState): 22 super(ToughPinchZoomMobilePage, self).__init__( 23 page_set=page_set, 24 name_suffix=name_suffix, 25 extra_browser_args=extra_browser_args, 26 shared_page_state_class=shared_page_state_class) 27 28 def RunPinchGesture(self, action_runner, left_anchor_ratio=0.5, 29 top_anchor_ratio=0.5, scale_factor=None, 30 speed_in_pixels_per_second=800): 31 with action_runner.CreateGestureInteraction('PinchAction', 32 repeatable=True): 33 action_runner.PinchPage( 34 left_anchor_ratio=left_anchor_ratio, 35 top_anchor_ratio=top_anchor_ratio, 36 scale_factor=scale_factor, 37 speed_in_pixels_per_second=speed_in_pixels_per_second) 38 39 def RunPageInteractions(self, action_runner): 40 action_runner.tab.WaitForDocumentReadyStateToBeInteractiveOrBetter() 41 for _ in xrange(0, 3): 42 current_scale_factor = 7.0 43 self.RunPinchGesture(action_runner, scale_factor=current_scale_factor) 44 while current_scale_factor > 1.0: 45 current_scale_factor *= 1/2.0 46 self.RunPinchGesture(action_runner, scale_factor=1/2.0) 47 48 49class GoogleSearchPinchZoomMobile2018Page(ToughPinchZoomMobilePage): 50 """ Why: top google property; a google tab is often open. """ 51 BASE_NAME = 'google_search_mobile_pinch' 52 YEAR = '2018' 53 URL = 'https://www.google.com/#hl=en&q=barack+obama' 54 55 56class LinkedinPinchZoomMobile2018Page(ToughPinchZoomMobilePage): 57 """ Why: #12 (Alexa global), Public profile.""" 58 BASE_NAME = 'linkedin_mobile_pinch' 59 YEAR = '2018' 60 URL = 'http://www.linkedin.com/in/linustorvalds' 61 62 # Linkedin has expensive shader compilation so it can benefit from shader 63 # cache from reload. 64 def RunNavigateSteps(self, action_runner): 65 linkedin_login.LoginMobileAccount(action_runner, 'linkedin') 66 super(LinkedinPinchZoomMobile2018Page, 67 self).RunNavigateSteps(action_runner) 68 action_runner.WaitForJavaScriptCondition( 69 'document.getElementById("profile-wrapper") !== null') 70 71 72class AccuWeatherPinchZoomMobile2018Page(ToughPinchZoomMobilePage): 73 """ Why: #2 weather according to Alexa.""" 74 BASE_NAME = 'accu_weather_mobile_pinch' 75 YEAR = '2018' 76 URL = 'https://www.accuweather.com/en/us/new-york-ny/10017/weather-forecast/349727' 77 78 79class TwitchPinchZoomMobile2018Page(ToughPinchZoomMobilePage): 80 """ Why: #1 games according to Alexa.""" 81 BASE_NAME = 'twitch_mobile_pinch' 82 YEAR = '2018' 83 URL = 'https://www.twitch.tv/?no-mobile-redirect=true' 84 85 86class CnnPinchZoomMobile2018Page(ToughPinchZoomMobilePage): 87 """ Why: #2 news worldwide.""" 88 BASE_NAME = 'cnn_mobile_pinch' 89 YEAR = '2018' 90 URL = 'http://www.cnn.com/travel/article/airbus-a330-900-neo-tours-us-airports/index.html' 91 92 93class EBayPinchZoomMobile2018Page(ToughPinchZoomMobilePage): 94 """ Why: #1 commerce website by time spent by users in US.""" 95 BASE_NAME = 'ebay_mobile_pinch' 96 YEAR = '2018' 97 URL = 'http://www.ebay.com' 98