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 | |
| 9 | |
| 8 from telemetry import decorators | 10 from telemetry import decorators |
| 9 | 11 |
| 10 | 12 |
| 11 class _BrowsingStory(system_health_story.SystemHealthStory): | 13 class _BrowsingStory(system_health_story.SystemHealthStory): |
| 12 """Abstract base class for browsing stories. | 14 """Abstract base class for browsing stories. |
| 13 | 15 |
| 14 A browsing story visits items on the main page. Subclasses provide | 16 A browsing story visits items on the main page. Subclasses provide |
| 15 CSS selector to identify the items and implement interaction using | 17 CSS selector to identify the items and implement interaction using |
| 16 the helper methods of this class. | 18 the helper methods of this class. |
| 17 """ | 19 """ |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 A media story imitates browsing a website with photo or video content: | 229 A media story imitates browsing a website with photo or video content: |
| 228 1. Load a page showing a media item | 230 1. Load a page showing a media item |
| 229 2. Click on the next link to go to the next media item | 231 2. Click on the next link to go to the next media item |
| 230 3. etc. | 232 3. etc. |
| 231 """ | 233 """ |
| 232 | 234 |
| 233 ABSTRACT_STORY = True | 235 ABSTRACT_STORY = True |
| 234 ITEM_VIEW_TIME_IN_SECONDS = 3 | 236 ITEM_VIEW_TIME_IN_SECONDS = 3 |
| 235 ITEMS_TO_VISIT = 15 | 237 ITEMS_TO_VISIT = 15 |
| 236 ITEM_SELECTOR_INDEX = 0 | 238 ITEM_SELECTOR_INDEX = 0 |
| 239 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.
| |
| 237 | 240 |
| 238 def _DidLoadDocument(self, action_runner): | 241 def _DidLoadDocument(self, action_runner): |
| 242 index = self.ITEM_SELECTOR_INDEX | |
| 239 for _ in xrange(self.ITEMS_TO_VISIT): | 243 for _ in xrange(self.ITEMS_TO_VISIT): |
| 240 self._NavigateToItem(action_runner, self.ITEM_SELECTOR_INDEX) | 244 self._NavigateToItem(action_runner, index) |
| 241 self._ViewMediaItem(action_runner) | 245 self._ViewMediaItem(action_runner) |
| 246 if self.INCREMENT_INDEX: | |
| 247 index += 1 | |
| 242 | 248 |
| 243 def _ViewMediaItem(self, action_runner): | 249 def _ViewMediaItem(self, action_runner): |
| 244 action_runner.tab.WaitForDocumentReadyStateToBeComplete() | 250 action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
| 245 action_runner.Wait(self.ITEM_VIEW_TIME_IN_SECONDS) | 251 action_runner.Wait(self.ITEM_VIEW_TIME_IN_SECONDS) |
| 246 | 252 |
| 247 | 253 |
| 248 class ImgurMobileStory(_MediaBrowsingStory): | 254 class ImgurMobileStory(_MediaBrowsingStory): |
| 249 NAME = 'browse:media:imgur' | 255 NAME = 'browse:media:imgur' |
| 250 URL = 'http://imgur.com/gallery/5UlBN' | 256 URL = 'http://imgur.com/gallery/5UlBN' |
| 251 ITEM_SELECTOR = '.Navbar-customAction' | 257 ITEM_SELECTOR = '.Navbar-customAction' |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 294 | 300 |
| 295 class FacebookPhotosDesktopStory(_MediaBrowsingStory): | 301 class FacebookPhotosDesktopStory(_MediaBrowsingStory): |
| 296 NAME = 'browse:media:facebook_photos' | 302 NAME = 'browse:media:facebook_photos' |
| 297 URL = ( | 303 URL = ( |
| 298 'https://www.facebook.com/rihanna/photos/a.207477806675.138795.10092511675 /10153911739606676/?type=3&theater') | 304 'https://www.facebook.com/rihanna/photos/a.207477806675.138795.10092511675 /10153911739606676/?type=3&theater') |
| 299 ITEM_SELECTOR = '.snowliftPager.next' | 305 ITEM_SELECTOR = '.snowliftPager.next' |
| 300 # Recording currently does not work. The page gets stuck in the | 306 # Recording currently does not work. The page gets stuck in the |
| 301 # theater viewer. | 307 # theater viewer. |
| 302 SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS | 308 SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS |
| 303 IS_SINGLE_PAGE_APP = True | 309 IS_SINGLE_PAGE_APP = True |
| 310 | |
| 311 | |
| 312 class TumblrDesktopStory(_MediaBrowsingStory): | |
| 313 NAME = 'browse:media:tumblr' | |
| 314 URL = 'https://tumblr.com/search/gifs' | |
| 315 ITEM_SELECTOR = '.photo' | |
| 316 IS_SINGLE_PAGE_APP = True | |
| 317 ITEMS_TO_VISIT = 2 # Increase when crbug.com/651909 is implemented. | |
| 318 ITEM_VIEW_TIME_IN_SECONDS = 5 | |
| 319 INCREMENT_INDEX = True | |
| 320 SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS # crbug.com/651909. | |
| 321 | |
| 322 def _ViewMediaItem(self, action_runner): | |
| 323 super(TumblrDesktopStory, self)._ViewMediaItem(action_runner) | |
| 324 action_runner.MouseClick(selector='#tumblr_lightbox_center_image') | |
| 325 | |
| 326 | |
| 327 class PinterestDesktopStory(_MediaBrowsingStory): | |
| 328 NAME = 'browse:media:pinterest' | |
| 329 URL = 'https://pinterest.com' | |
| 330 ITEM_SELECTOR = '.pinImageDim' | |
| 331 IS_SINGLE_PAGE_APP = True | |
| 332 ITEMS_TO_VISIT = 5 # Increase when crbug.com/651909 is implemented. | |
| 333 ITEM_VIEW_TIME_IN_SECONDS = 5 | |
| 334 INCREMENT_INDEX = True | |
| 335 | |
| 336 def _Login(self, action_runner): | |
| 337 pinterest_login.LoginDesktopAccount(action_runner, 'googletest', | |
| 338 self.credentials_path) | |
| 339 | |
| 340 def _ViewMediaItem(self, action_runner): | |
| 341 super(PinterestDesktopStory, self)._ViewMediaItem(action_runner) | |
| 342 # To imitate real user interaction, we do not want to pin every post. | |
| 343 # We will only pin every other post. | |
| 344 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
| |
| 345 # Pin the selection. | |
| 346 save_function = ('document.querySelector(' | |
| 347 '".Button.Module.ShowModalButton.btn.hasIcon.hasText.' | |
| 348 'isBrioFlat.medium.primary.primaryOnHover.repin.' | |
| 349 'pinActionBarButton.isBrioFlat.rounded")') | |
| 350 action_runner.ClickElement(element_function=save_function) | |
| 351 action_runner.Wait(1) # Wait to make navigation realistic. | |
| 352 # Select which board to pin to. | |
| 353 inner_save_function = 'document.querySelector(".nameAndIcons")' | |
| 354 action_runner.WaitForElement(element_function=inner_save_function) | |
| 355 action_runner.ClickElement(element_function=inner_save_function) | |
| 356 action_runner.Wait(1) # Wait to make navigation realistic. | |
| 357 | |
| 358 # Close selection. | |
| 359 x_element_function = ('document.querySelector(' | |
| 360 '".Button.borderless.close.visible")') | |
| 361 action_runner.ClickElement(element_function=x_element_function) | |
| 362 action_runner.Wait(1) # Wait to make navigation realistic. | |
| OLD | NEW |