Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2017 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 shared_page_state | |
| 7 from telemetry import story | |
| 8 | |
| 9 | |
| 10 class _IdleSharedState(shared_page_state.SharedPageState): | |
| 11 def __init__(self, test, finder_options, story_set): | |
| 12 super(_IdleSharedState, self).__init__(test, finder_options, story_set) | |
| 13 self._current_story = None | |
| 14 | |
| 15 def WillRunStory(self, current_story): | |
| 16 self._current_story = current_story | |
| 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. | |
|
nednguyen
2017/03/30 22:01:40
We don't need to worry about supporting this for l
rnephew (Reviews Here)
2017/04/03 16:25:35
Done.
| |
| 22 self.platform.tracing_controller.ClearStateIfNeeded() | |
| 23 | |
| 24 def RunStory(self, _): | |
| 25 self._current_story.Run(self) | |
| 26 | |
| 27 def DidRunStory(self, _): | |
| 28 self._current_story = None | |
| 29 | |
| 30 | |
| 31 class IdleStory(story.Story): | |
|
nednguyen
2017/03/30 22:07:56
make this private: _IdleStory
rnephew (Reviews Here)
2017/04/03 16:25:35
Done.
| |
| 32 def __init__(self, name, duration=30): | |
|
nednguyen
2017/03/30 22:07:55
No need to set a default param here if this is onl
rnephew (Reviews Here)
2017/04/03 16:25:35
Done.
| |
| 33 super(IdleStory, self).__init__( | |
| 34 shared_state_class=_IdleSharedState, name=name) | |
| 35 self._duration = duration | |
| 36 | |
| 37 def Run(self, shared_state): | |
| 38 time.sleep(self._duration) | |
| 39 | |
| 40 | |
| 41 class IdleStorySet(story.StorySet): | |
| 42 def __init__(self): | |
| 43 super(IdleStorySet, self).__init__( | |
| 44 archive_data_file=None) | |
| 45 self.AddStory(IdleStory('Idle Platform')) | |
|
nednguyen
2017/03/30 22:07:56
Can you create 3 stories:
self.AddStory(IdleStory
rnephew (Reviews Here)
2017/04/03 16:25:35
Done.
| |
| OLD | NEW |