Chromium Code Reviews| Index: tools/perf/page_sets/system_health/system_health_story.py |
| diff --git a/tools/perf/page_sets/system_health/system_health_story.py b/tools/perf/page_sets/system_health/system_health_story.py |
| index 394710d3c32945e299f8d5528c94f77fa04be051..6dc4a66dc4d944adf601c898cbf33f5ff6a5a8a0 100644 |
| --- a/tools/perf/page_sets/system_health/system_health_story.py |
| +++ b/tools/perf/page_sets/system_health/system_health_story.py |
| @@ -4,7 +4,9 @@ |
| from page_sets.system_health import platforms |
| +from telemetry import decorators |
| from telemetry.page import page |
| +from telemetry.page import shared_page_state |
| # Extra wait time after the page has loaded required by the loading metric. We |
| @@ -13,6 +15,32 @@ from telemetry.page import page |
| _WAIT_TIME_AFTER_LOAD = 10 |
| +class _SystemHealthSharedState(shared_page_state.SharedPageState): |
| + """Shared state which enables disabling stories on individual platforms. |
| + |
| + This class adds support for enabling/disabling individual stories on |
| + individual platforms using the same approaches as for benchmarks: |
| + |
| + 1. Disabled/Enabled decorator: |
| + |
| + @decorators.Disabled('win') |
| + class Story(system_health_story.SystemHealthStory): |
| + ... |
| + |
| + 2. ShouldDisable method: |
| + |
| + class Story(system_health_story.SystemHealthStory): |
| + ... |
| + |
| + @classmethod |
| + def ShouldDisable(cls, possible_browser): |
| + return possible_browser.platform.GetOSName() == 'win' |
| + """ |
| + |
| + def CanRunStory(self, story): |
| + return story.CanRun(self.browser) |
|
nednguyen
2016/09/07 18:23:51
Hmhh, the api is CanRun(possible_browser), and not
petrcermak
2016/09/08 10:20:44
Yeah. The reason for this is that we are re-using
nednguyen
2016/09/08 12:56:22
We do keep the possible_browser in https://cs.chro
petrcermak
2016/09/08 18:45:10
Done.
|
| + |
| + |
| class _MetaSystemHealthStory(type): |
| """Metaclass for SystemHealthStory.""" |
| @@ -41,11 +69,28 @@ class SystemHealthStory(page.Page): |
| def __init__(self, story_set, take_memory_measurement): |
| case, group, _ = self.NAME.split(':') |
| super(SystemHealthStory, self).__init__( |
| - page_set=story_set, name=self.NAME, url=self.URL, |
| + shared_page_state_class=_SystemHealthSharedState, page_set=story_set, |
| + name=self.NAME, url=self.URL, |
| credentials_path='../data/credentials.json', |
| grouping_keys={'case': case, 'group': group}) |
| self._take_memory_measurement = take_memory_measurement |
| + @classmethod |
| + def CanRun(cls, possible_browser): |
| + if (decorators.ShouldSkip(cls, possible_browser)[0] or |
| + cls.ShouldDisable(possible_browser)): |
| + return False |
| + return True |
| + |
| + @classmethod |
| + def ShouldDisable(cls, possible_browser): |
| + """Override this method to disable a story under specific conditions. |
| + |
| + This method is modelled after telemetry.benchmark.Benchmark.ShouldDisable(). |
| + """ |
| + del possible_browser |
| + return False |
| + |
| def _Measure(self, action_runner): |
| if self._take_memory_measurement: |
| action_runner.MeasureMemory(deterministic_mode=True) |