Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2014 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 import time | |
| 5 | |
| 6 from telemetry.page import page | |
| 7 from telemetry.page import shared_page_state | |
| 8 from telemetry import story | |
| 9 | |
| 10 | |
| 11 class _IdleSharedState(shared_page_state.SharedPageState): | |
| 12 def __init__(self, test, finder_options, story_set, idle_time=30): | |
| 13 super(_IdleSharedState, self).__init__(test, finder_options, story_set) | |
| 14 self._idle_time = idle_time | |
| 15 | |
| 16 def WillRunStory(self, _): | |
| 17 if not self.platform.tracing_controller.is_tracing_running: | |
| 18 # For TimelineBasedMeasurement benchmarks, tracing has already started. | |
| 19 # For PageTest benchmarks, tracing has not yet started. We need to make | |
| 20 # sure no tracing state is left before starting the browser for PageTest | |
| 21 # benchmarks. | |
| 22 self.platform.tracing_controller.ClearStateIfNeeded() | |
| 23 | |
| 24 def RunStory(self, _): | |
| 25 time.sleep(self._idle_time) | |
| 26 | |
| 27 def DidRunStory(self, results): | |
| 28 pass | |
| 29 | |
| 30 class IdlePlatformPage(page.Page): | |
|
nednguyen
2017/03/13 16:33:35
Let inherit this from story, so that you don't nee
rnephew (Reviews Here)
2017/03/13 21:29:18
Done, but now requires https://codereview.chromium
| |
| 31 def __init__(self, url, page_set): | |
| 32 super(IdlePlatformPage, self).__init__( | |
| 33 url=url, page_set=page_set, credentials_path='data/credentials.json', | |
| 34 shared_page_state_class=_IdleSharedState, name='Idle Platform') | |
| 35 | |
| 36 | |
| 37 class IdlePlatformPageSet(story.StorySet): | |
| 38 def __init__(self): | |
| 39 super(IdlePlatformPageSet, self).__init__( | |
| 40 archive_data_file=None, | |
| 41 cloud_storage_bucket=story.PARTNER_BUCKET) | |
| 42 # Page requires URL to be a valid. | |
| 43 self.AddStory(IdlePlatformPage('http://Idle Platform', self)) | |
| OLD | NEW |