Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 | 4 |
| 5 from page_sets.system_health import platforms | 5 from page_sets.system_health import platforms |
| 6 from page_sets.system_health import system_health_story | 6 from page_sets.system_health import system_health_story |
| 7 | 7 |
| 8 from page_sets.login_helpers import pinterest_login | 8 from page_sets.login_helpers import pinterest_login |
| 9 | 9 |
| 10 from telemetry import decorators | 10 from telemetry import decorators |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 ITEM_SELECTOR = NotImplemented | 22 ITEM_SELECTOR = NotImplemented |
| 23 ABSTRACT_STORY = True | 23 ABSTRACT_STORY = True |
| 24 | 24 |
| 25 def _WaitForNavigation(self, action_runner): | 25 def _WaitForNavigation(self, action_runner): |
| 26 if not self.IS_SINGLE_PAGE_APP: | 26 if not self.IS_SINGLE_PAGE_APP: |
| 27 action_runner.WaitForNavigate() | 27 action_runner.WaitForNavigate() |
| 28 | 28 |
| 29 def _NavigateToItem(self, action_runner, index): | 29 def _NavigateToItem(self, action_runner, index): |
| 30 item_selector = 'document.querySelectorAll("%s")[%d]' % ( | 30 item_selector = 'document.querySelectorAll("%s")[%d]' % ( |
| 31 self.ITEM_SELECTOR, index) | 31 self.ITEM_SELECTOR, index) |
| 32 # Only scrolls if element is not currently in viewport. | |
| 33 action_runner.ScrollPageToElement(element_function=item_selector) | |
| 32 self._ClickLink(action_runner, item_selector) | 34 self._ClickLink(action_runner, item_selector) |
| 33 | 35 |
| 34 def _ClickLink(self, action_runner, element_function): | 36 def _ClickLink(self, action_runner, element_function): |
| 35 action_runner.WaitForElement(element_function=element_function) | 37 action_runner.WaitForElement(element_function=element_function) |
| 36 action_runner.ClickElement(element_function=element_function) | 38 action_runner.ClickElement(element_function=element_function) |
| 37 self._WaitForNavigation(action_runner) | 39 self._WaitForNavigation(action_runner) |
| 38 | 40 |
| 39 def _NavigateBack(self, action_runner): | 41 def _NavigateBack(self, action_runner): |
| 40 action_runner.ExecuteJavaScript('window.history.back()') | 42 action_runner.ExecuteJavaScript('window.history.back()') |
| 41 self._WaitForNavigation(action_runner) | 43 self._WaitForNavigation(action_runner) |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 # theater viewer. | 310 # theater viewer. |
| 309 SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS | 311 SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS |
| 310 IS_SINGLE_PAGE_APP = True | 312 IS_SINGLE_PAGE_APP = True |
| 311 | 313 |
| 312 | 314 |
| 313 class TumblrDesktopStory(_MediaBrowsingStory): | 315 class TumblrDesktopStory(_MediaBrowsingStory): |
| 314 NAME = 'browse:media:tumblr' | 316 NAME = 'browse:media:tumblr' |
| 315 URL = 'https://tumblr.com/search/gifs' | 317 URL = 'https://tumblr.com/search/gifs' |
| 316 ITEM_SELECTOR = '.photo' | 318 ITEM_SELECTOR = '.photo' |
| 317 IS_SINGLE_PAGE_APP = True | 319 IS_SINGLE_PAGE_APP = True |
| 318 ITEMS_TO_VISIT = 2 # Increase when crbug.com/651909 is implemented. | 320 ITEMS_TO_VISIT = 8 |
|
rnephew (Reviews Here)
2016/10/14 22:52:52
Should I just use the default 15 here?
petrcermak
2016/10/17 08:51:37
Unless it makes the story too long or less stable,
rnephew (Reviews Here)
2016/10/17 18:48:19
After some local experimenting it does seem to mak
| |
| 319 ITEM_VIEW_TIME_IN_SECONDS = 5 | 321 ITEM_VIEW_TIME_IN_SECONDS = 5 |
| 320 INCREMENT_INDEX_AFTER_EACH_ITEM = True | 322 INCREMENT_INDEX_AFTER_EACH_ITEM = True |
| 321 SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS # crbug.com/651909. | 323 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| 322 | 324 |
| 323 def _ViewMediaItem(self, action_runner, index): | 325 def _ViewMediaItem(self, action_runner, index): |
| 324 super(TumblrDesktopStory, self)._ViewMediaItem(action_runner, index) | 326 super(TumblrDesktopStory, self)._ViewMediaItem(action_runner, index) |
| 325 action_runner.MouseClick(selector='#tumblr_lightbox_center_image') | 327 action_runner.MouseClick(selector='#tumblr_lightbox_center_image') |
| 326 | 328 action_runner.Wait(1) # To make browsing more realistic. |
|
petrcermak
2016/10/17 08:51:37
nit: There should be two spaces before a comment.
rnephew (Reviews Here)
2016/10/17 18:48:19
Done.
| |
| 327 | 329 |
| 328 class PinterestDesktopStory(_MediaBrowsingStory): | 330 class PinterestDesktopStory(_MediaBrowsingStory): |
| 329 NAME = 'browse:media:pinterest' | 331 NAME = 'browse:media:pinterest' |
| 330 URL = 'https://pinterest.com' | 332 URL = 'https://pinterest.com' |
| 331 ITEM_SELECTOR = '.pinImageDim' | 333 ITEM_SELECTOR = '.pinImageDim' |
| 332 IS_SINGLE_PAGE_APP = True | 334 IS_SINGLE_PAGE_APP = True |
| 333 ITEMS_TO_VISIT = 5 # Increase when crbug.com/651909 is implemented. | 335 ITEMS_TO_VISIT = 8 |
| 334 ITEM_VIEW_TIME_IN_SECONDS = 5 | 336 ITEM_VIEW_TIME_IN_SECONDS = 5 |
| 335 INCREMENT_INDEX_AFTER_EACH_ITEM = True | 337 INCREMENT_INDEX_AFTER_EACH_ITEM = True |
| 336 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY | 338 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| 337 | 339 |
| 338 def _Login(self, action_runner): | 340 def _Login(self, action_runner): |
| 339 pinterest_login.LoginDesktopAccount(action_runner, 'googletest', | 341 pinterest_login.LoginDesktopAccount(action_runner, 'googletest', |
| 340 self.credentials_path) | 342 self.credentials_path) |
| 341 | 343 |
| 342 def _ViewMediaItem(self, action_runner, index): | 344 def _ViewMediaItem(self, action_runner, index): |
| 343 super(PinterestDesktopStory, self)._ViewMediaItem(action_runner, index) | 345 super(PinterestDesktopStory, self)._ViewMediaItem(action_runner, index) |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 355 inner_save_function = 'document.querySelector(".nameAndIcons")' | 357 inner_save_function = 'document.querySelector(".nameAndIcons")' |
| 356 action_runner.WaitForElement(element_function=inner_save_function) | 358 action_runner.WaitForElement(element_function=inner_save_function) |
| 357 action_runner.ClickElement(element_function=inner_save_function) | 359 action_runner.ClickElement(element_function=inner_save_function) |
| 358 action_runner.Wait(1) # Wait to make navigation realistic. | 360 action_runner.Wait(1) # Wait to make navigation realistic. |
| 359 | 361 |
| 360 # Close selection. | 362 # Close selection. |
| 361 x_element_function = ('document.querySelector(' | 363 x_element_function = ('document.querySelector(' |
| 362 '".Button.borderless.close.visible")') | 364 '".Button.borderless.close.visible")') |
| 363 action_runner.ClickElement(element_function=x_element_function) | 365 action_runner.ClickElement(element_function=x_element_function) |
| 364 action_runner.Wait(1) # Wait to make navigation realistic. | 366 action_runner.Wait(1) # Wait to make navigation realistic. |
| OLD | NEW |