Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2016 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 | |
| 5 from page_sets.system_health import platforms | |
| 6 from page_sets.system_health import system_health_story | |
| 7 from page_sets.system_health.loading_stories import LoadGmailMobileStory | |
| 8 | |
| 9 class _BackgroundStory(system_health_story.SystemHealthStory): | |
| 10 """Abstract base class for background stories | |
| 11 | |
| 12 As in _LoadingStory except it puts the browser into the | |
| 13 background before measuring. | |
| 14 """ | |
| 15 ABSTRACT_STORY = True | |
| 16 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
| 17 | |
| 18 def _Measure(self, action_runner): | |
| 19 action_runner.tab.browser.Background() | |
| 20 super(_BackgroundStory, self)._Measure(action_runner) | |
| 21 | |
| 22 | |
| 23 class BackgroundGoogleStory(_BackgroundStory): | |
| 24 NAME = 'background:search:google' | |
| 25 URL = 'https://www.google.co.uk/#q=tom+cruise+movies' | |
| 26 | |
| 27 def _DidLoadDocument(self, action_runner): | |
| 28 # Activte the immersive movie browsing experience | |
| 29 action_runner.WaitForJavaScriptCondition( | |
| 30 'document.querySelector("g-fab") !== null') | |
| 31 action_runner.ExecuteJavaScript( | |
| 32 'document.querySelector("g-fab").click()') | |
|
nednguyen
2016/10/18 15:27:29
ditto
hjd
2016/10/21 16:17:22
Done.
| |
| 33 | |
| 34 | |
| 35 class BackgroundFacebookMobileStory(_BackgroundStory): | |
| 36 NAME = 'background:social:facebook' | |
| 37 URL = 'https://www.facebook.com/rihanna' | |
| 38 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
| 39 | |
| 40 | |
| 41 class BackgroundNytimesMobileStory(_BackgroundStory): | |
| 42 """The third top website in http://www.alexa.com/topsites/category/News""" | |
| 43 NAME = 'background:news:nytimes' | |
| 44 URL = 'http://www.nytimes.com/2016/10/04/us/politics/vice-presidential-debate. html?_r=0' | |
| 45 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
| 46 | |
| 47 def _DidLoadDocument(self, action_runner): | |
| 48 action_runner.WaitForJavaScriptCondition( | |
| 49 'document.querySelector("#additional-content button") !== null') | |
| 50 action_runner.ExecuteJavaScript( | |
| 51 'document.querySelector("#additional-content button").click()') | |
|
nednguyen
2016/10/18 15:27:29
ditto
hjd
2016/10/21 16:17:22
Done.
| |
| 52 | |
| 53 action_runner.WaitForJavaScriptCondition( | |
| 54 'document.querySelector(".nytd-player-poster") !== null') | |
| 55 action_runner.ScrollPageToElement(selector='.nytd-player-poster') | |
| 56 action_runner.ExecuteJavaScript( | |
| 57 'document.querySelector(".nytd-player-poster").click();') | |
|
nednguyen
2016/10/18 15:27:29
nits: use action_runner.TapElement( 'document.quer
hjd
2016/10/21 16:17:22
Done.
| |
| 58 | |
|
nednguyen
2016/10/18 15:27:29
After clicking playing the video, can you add a wa
| |
| 59 | |
| 60 class BackgroundImgurMobileStory(_BackgroundStory): | |
| 61 NAME = 'background:media:imgur' | |
| 62 URL = 'http://imgur.com/gallery/hUita' | |
| 63 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
| 64 | |
| 65 | |
| 66 class BackgroundGmailMobileStory(LoadGmailMobileStory): | |
| 67 NAME = 'background:tools:gmail' | |
| 68 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
| 69 | |
| 70 def _Measure(self, action_runner): | |
| 71 action_runner.tab.browser.Background() | |
| 72 super(BackgroundGmailMobileStory, self)._Measure(action_runner) | |
| 73 | |
| OLD | NEW |