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 import re | |
6 import os | |
7 | |
5 from page_sets.system_health import platforms | 8 from page_sets.system_health import platforms |
6 from page_sets.system_health import loading_stories | 9 from page_sets.system_health import system_health_story |
7 | 10 |
8 from telemetry import story | 11 from telemetry import story |
12 from telemetry.core import discover | |
9 | 13 |
10 | 14 |
11 class _SystemHealthStorySet(story.StorySet): | 15 class SystemHealthStorySet(story.StorySet): |
12 """User stories for the System Health Plan. | 16 """User stories for the System Health Plan. |
13 | 17 |
14 See https://goo.gl/Jek2NL. | 18 See https://goo.gl/Jek2NL. |
15 """ | 19 """ |
16 PLATFORM = NotImplemented | 20 def __init__(self, platform, story_name_regex=r'.*', |
nednguyen
2016/07/14 20:01:49
this story_name_regex is a bit too flexible. I thi
petrcermak
2016/07/15 09:01:43
Done. Note that this means that whenever we add a
nednguyen
2016/07/15 10:48:29
If it's relevant to browsing, why can't they name
| |
21 take_memory_measurement=False): | |
22 super(SystemHealthStorySet, self).__init__( | |
23 archive_data_file=('../data/memory_system_health_%s.json' % platform), | |
24 cloud_storage_bucket=story.PARTNER_BUCKET) | |
17 | 25 |
18 def __init__(self, take_memory_measurement=True): | 26 assert platform in platforms.ALL_PLATFORMS |
19 super(_SystemHealthStorySet, self).__init__( | 27 |
20 archive_data_file=('../data/memory_system_health_%s.json' % | 28 if isinstance(story_name_regex, basestring): |
21 self.PLATFORM), | 29 story_name_regex = re.compile(story_name_regex) |
22 cloud_storage_bucket=story.PARTNER_BUCKET) | 30 |
23 for story_class in loading_stories.IterAllStoryClasses(): | 31 for story_class in _IterAllSystemHealthStoryClasses(): |
24 if self.PLATFORM not in story_class.SUPPORTED_PLATFORMS: | 32 if (story_class.ABSTRACT_STORY or |
33 platform not in story_class.SUPPORTED_PLATFORMS or | |
34 not story_name_regex.match(story_class.NAME)): | |
25 continue | 35 continue |
26 self.AddStory(story_class(self, take_memory_measurement)) | 36 self.AddStory(story_class(self, take_memory_measurement)) |
27 | 37 |
28 | 38 |
29 class DesktopSystemHealthStorySet(_SystemHealthStorySet): | 39 def _IterAllSystemHealthStoryClasses(): |
30 """Desktop user stories for Chrome System Health Plan.""" | 40 start_dir = os.path.dirname(os.path.abspath(__file__)) |
31 PLATFORM = platforms.DESKTOP | 41 # Sort the classes by their names so that their order is stable and |
32 | 42 # deterministic. |
33 | 43 for unused_cls_name, cls in sorted(discover.DiscoverClasses( |
34 class MobileSystemHealthStorySet(_SystemHealthStorySet): | 44 start_dir=start_dir, |
35 """Mobile user stories for Chrome System Health Plan.""" | 45 top_level_dir=os.path.dirname(start_dir), |
36 PLATFORM = platforms.MOBILE | 46 base_class=system_health_story.SystemHealthStory).iteritems()): |
47 yield cls | |
OLD | NEW |