Chromium Code Reviews| Index: tools/perf/page_sets/system_health/browsing_stories.py |
| diff --git a/tools/perf/page_sets/system_health/browsing_stories.py b/tools/perf/page_sets/system_health/browsing_stories.py |
| index 410714904a788134f4a2b3cb82165b8754cec637..61e172a1fc1f0b9e328d3926b43146a2d8ebce58 100644 |
| --- a/tools/perf/page_sets/system_health/browsing_stories.py |
| +++ b/tools/perf/page_sets/system_health/browsing_stories.py |
| @@ -5,6 +5,8 @@ |
| from page_sets.system_health import platforms |
| from page_sets.system_health import system_health_story |
| +from page_sets.login_helpers import pinterest_login |
| + |
| from telemetry import decorators |
| @@ -234,11 +236,15 @@ class _MediaBrowsingStory(_BrowsingStory): |
| ITEM_VIEW_TIME_IN_SECONDS = 3 |
| ITEMS_TO_VISIT = 15 |
| ITEM_SELECTOR_INDEX = 0 |
| + INCREMENT_INDEX = False |
|
petrcermak
2016/10/04 13:34:21
INCREMENT_INDEX_AFTER_EACH_ITEM might be easier to
rnephew (Reviews Here)
2016/10/04 15:51:12
Done.
|
| def _DidLoadDocument(self, action_runner): |
| + index = self.ITEM_SELECTOR_INDEX |
| for _ in xrange(self.ITEMS_TO_VISIT): |
| - self._NavigateToItem(action_runner, self.ITEM_SELECTOR_INDEX) |
| + self._NavigateToItem(action_runner, index) |
| self._ViewMediaItem(action_runner) |
| + if self.INCREMENT_INDEX: |
| + index += 1 |
| def _ViewMediaItem(self, action_runner): |
| action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
| @@ -301,3 +307,56 @@ class FacebookPhotosDesktopStory(_MediaBrowsingStory): |
| # theater viewer. |
| SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS |
| IS_SINGLE_PAGE_APP = True |
| + |
| + |
| +class TumblrDesktopStory(_MediaBrowsingStory): |
| + NAME = 'browse:media:tumblr' |
| + URL = 'https://tumblr.com/search/gifs' |
| + ITEM_SELECTOR = '.photo' |
| + IS_SINGLE_PAGE_APP = True |
| + ITEMS_TO_VISIT = 2 # Increase when crbug.com/651909 is implemented. |
| + ITEM_VIEW_TIME_IN_SECONDS = 5 |
| + INCREMENT_INDEX = True |
| + SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS # crbug.com/651909. |
| + |
| + def _ViewMediaItem(self, action_runner): |
| + super(TumblrDesktopStory, self)._ViewMediaItem(action_runner) |
| + action_runner.MouseClick(selector='#tumblr_lightbox_center_image') |
| + |
| + |
| +class PinterestDesktopStory(_MediaBrowsingStory): |
| + NAME = 'browse:media:pinterest' |
| + URL = 'https://pinterest.com' |
| + ITEM_SELECTOR = '.pinImageDim' |
| + IS_SINGLE_PAGE_APP = True |
| + ITEMS_TO_VISIT = 5 # Increase when crbug.com/651909 is implemented. |
| + ITEM_VIEW_TIME_IN_SECONDS = 5 |
| + INCREMENT_INDEX = True |
| + |
| + def _Login(self, action_runner): |
| + pinterest_login.LoginDesktopAccount(action_runner, 'googletest', |
| + self.credentials_path) |
| + |
| + def _ViewMediaItem(self, action_runner): |
| + super(PinterestDesktopStory, self)._ViewMediaItem(action_runner) |
| + # To imitate real user interaction, we do not want to pin every post. |
| + # We will only pin every other post. |
| + if self.ITEM_SELECTOR_INDEX % 2 == 0: |
|
petrcermak
2016/10/04 13:34:21
ITEM_SELECTOR_INDEX is now a constant. You'll need
rnephew (Reviews Here)
2016/10/04 15:51:12
I did replay them, I just didn't pay close enough
|
| + # Pin the selection. |
| + save_function = ('document.querySelector(' |
| + '".Button.Module.ShowModalButton.btn.hasIcon.hasText.' |
| + 'isBrioFlat.medium.primary.primaryOnHover.repin.' |
| + 'pinActionBarButton.isBrioFlat.rounded")') |
| + action_runner.ClickElement(element_function=save_function) |
| + action_runner.Wait(1) # Wait to make navigation realistic. |
| + # Select which board to pin to. |
| + inner_save_function = 'document.querySelector(".nameAndIcons")' |
| + action_runner.WaitForElement(element_function=inner_save_function) |
| + action_runner.ClickElement(element_function=inner_save_function) |
| + action_runner.Wait(1) # Wait to make navigation realistic. |
| + |
| + # Close selection. |
| + x_element_function = ('document.querySelector(' |
| + '".Button.borderless.close.visible")') |
| + action_runner.ClickElement(element_function=x_element_function) |
| + action_runner.Wait(1) # Wait to make navigation realistic. |