| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 from telemetry.page import page as page_module | 4 from telemetry.page import page as page_module |
| 5 from telemetry.page import shared_page_state | 5 from telemetry.page import shared_page_state |
| 6 from telemetry import story | 6 from telemetry import story |
| 7 | 7 |
| 8 | 8 |
| 9 class NoOpPage(page_module.Page): | 9 class NoOpPage(page_module.Page): |
| 10 | 10 |
| 11 def __init__(self, url, page_set): | 11 def __init__(self, url, page_set): |
| 12 super(NoOpPage, self).__init__( | 12 super(NoOpPage, self).__init__( |
| 13 url=url, | 13 url=url, |
| 14 page_set=page_set, | 14 page_set=page_set, |
| 15 shared_page_state_class=shared_page_state.SharedMobilePageState) | 15 shared_page_state_class=shared_page_state.SharedMobilePageState, |
| 16 name=url.split('/')[-1]) |
| 16 | 17 |
| 17 def RunNavigateSteps(self, action_runner): | 18 def RunNavigateSteps(self, action_runner): |
| 18 super(NoOpPage, self).RunNavigateSteps(action_runner) | 19 super(NoOpPage, self).RunNavigateSteps(action_runner) |
| 19 # Let load activity settle. | 20 # Let load activity settle. |
| 20 action_runner.Wait(2) | 21 action_runner.Wait(2) |
| 21 | 22 |
| 22 def RunPageInteractions(self, action_runner): | 23 def RunPageInteractions(self, action_runner): |
| 23 # The default page interaction is simply waiting in an idle state. | 24 # The default page interaction is simply waiting in an idle state. |
| 24 with action_runner.CreateInteraction('IdleWaiting'): | 25 with action_runner.CreateInteraction('IdleWaiting'): |
| 25 action_runner.Wait(5) | 26 action_runner.Wait(5) |
| 26 | 27 |
| 27 | 28 |
| 28 class NoOpTouchScrollPage(NoOpPage): | 29 class NoOpTouchScrollPage(NoOpPage): |
| 29 def __init__(self, url, page_set): | 30 def __init__(self, url, page_set): |
| 30 super(NoOpTouchScrollPage, self).__init__(url=url, page_set=page_set) | 31 super(NoOpTouchScrollPage, self).__init__(url=url, page_set=page_set) |
| 31 | 32 |
| 32 def RunPageInteractions(self, action_runner): | 33 def RunPageInteractions(self, action_runner): |
| 33 # The noop touch motion should last ~5 seconds. | 34 # The noop touch motion should last ~5 seconds. |
| 34 with action_runner.CreateGestureInteraction('ScrollAction'): | 35 with action_runner.CreateGestureInteraction('ScrollAction'): |
| 35 action_runner.ScrollPage(direction='down', use_touch=True, | 36 action_runner.ScrollPage(direction='down', use_touch=True, |
| 36 speed_in_pixels_per_second=300, distance=1500) | 37 speed_in_pixels_per_second=300, distance=1500) |
| 37 | 38 |
| 38 | 39 |
| 39 class KeyNoOpCasesPageSet(story.StorySet): | 40 class KeyNoOpCasesPageSet(story.StorySet): |
| 40 | 41 |
| 41 """ Key no-op cases """ | 42 """ Key no-op cases """ |
| 42 | 43 |
| 43 def __init__(self): | 44 def __init__(self): |
| 44 super(KeyNoOpCasesPageSet, self).__init__() | 45 super(KeyNoOpCasesPageSet, self).__init__(verify_names=True) |
| 45 | 46 |
| 46 # Why: An infinite rAF loop which does not modify the page should incur | 47 # Why: An infinite rAF loop which does not modify the page should incur |
| 47 # minimal activity. | 48 # minimal activity. |
| 48 self.AddStory(NoOpPage('file://key_noop_cases/no_op_raf.html', self)) | 49 self.AddStory(NoOpPage('file://key_noop_cases/no_op_raf.html', self)) |
| 49 | 50 |
| 50 # Why: An infinite setTimeout loop which does not modify the page should | 51 # Why: An infinite setTimeout loop which does not modify the page should |
| 51 # incur minimal activity. | 52 # incur minimal activity. |
| 52 self.AddStory(NoOpPage('file://key_noop_cases/no_op_settimeout.html', self)) | 53 self.AddStory(NoOpPage('file://key_noop_cases/no_op_settimeout.html', self)) |
| 53 | 54 |
| 54 # Why: Scrolling an empty, unscrollable page should have no expensive side | 55 # Why: Scrolling an empty, unscrollable page should have no expensive side |
| 55 # effects, as overscroll is suppressed in such cases. | 56 # effects, as overscroll is suppressed in such cases. |
| 56 self.AddStory(NoOpTouchScrollPage( | 57 self.AddStory(NoOpTouchScrollPage( |
| 57 'file://key_noop_cases/no_op_scroll.html', self)) | 58 'file://key_noop_cases/no_op_scroll.html', self)) |
| 58 | 59 |
| 59 # Why: Feeding a stream of touch events to a no-op handler should be cheap. | 60 # Why: Feeding a stream of touch events to a no-op handler should be cheap. |
| 60 self.AddStory(NoOpTouchScrollPage( | 61 self.AddStory(NoOpTouchScrollPage( |
| 61 'file://key_noop_cases/no_op_touch_handler.html', self)) | 62 'file://key_noop_cases/no_op_touch_handler.html', self)) |
| OLD | NEW |