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
5import collections
6import re
7
8
9Tag = collections.namedtuple('Tag', ['name', 'description'])
10
11
12# Below are tags that describe various aspect of system health stories.
13# A story can have multiple tags. All the tags should be noun.
14
15ACCESSIBILITY = Tag(
16    'accessibility', 'Story tests performance when accessibility is enabled.')
17AUDIO_PLAYBACK = Tag(
18    'audio_playback', 'Story has audio playing.')
19CANVAS_ANIMATION = Tag(
20    'canvas_animation', 'Story has animations that are implemented using '
21    'html5 canvas.')
22CSS_ANIMATION = Tag(
23    'css_animation', 'Story has animations that are implemented using CSS.')
24EXTENSION = Tag(
25    'extension', 'Story has browser with extension installed.')
26HEALTH_CHECK = Tag(  # See go/health_check_stories for details.
27    'health_check', 'Story belongs to a collection chosen to have a wide '
28    'coverage but low running time.')
29IMAGES = Tag(
30    'images', 'Story has sites with heavy uses of images.')
31INFINITE_SCROLL = Tag('infinite_scroll', 'Story has infinite scroll action.')
32INTERNATIONAL = Tag(
33    'international', 'Story has navigations to websites with content in non '
34    'English languages.')
35EMERGING_MARKET = Tag(
36    'emerging_market', 'Story has significant usage in emerging markets with '
37    'low-end mobile devices and slow network connections.')
38JAVASCRIPT_HEAVY = Tag(
39    'javascript_heavy', 'Story has navigations to websites with heavy usages '
40    'of JavaScript. The story uses 20Mb+ memory for javascript and local '
41    'run with "v8" category enabled also shows the trace has js slices across '
42    'the whole run.')
43KEYBOARD_INPUT = Tag(
44    'keyboard_input', 'Story does keyboard input.')
45SCROLL = Tag(
46    'scroll', 'Story has scroll gestures & scroll animation.')
47PINCH_ZOOM = Tag(
48    'pinch_zoom', 'Story has pinch zoom gestures & pinch zoom animation.')
49TABS_SWITCHING = Tag(
50    'tabs_switching', 'Story has multi tabs and tabs switching action.')
51VIDEO_PLAYBACK = Tag(
52    'video_playback', 'Story has video playing.')
53WEBASSEMBLY = Tag('wasm', 'Story with heavy usages of WebAssembly')
54WEBGL = Tag(
55    'webgl', 'Story has sites with heavy uses of WebGL.')
56WEB_STORAGE = Tag(
57    'web_storage', 'Story has sites with heavy uses of Web storage.')
58
59# Tags by year.
60YEAR_2016 = Tag('2016', 'Story was created or updated in 2016.')
61YEAR_2017 = Tag('2017', 'Story was created or updated in 2017.')
62YEAR_2018 = Tag('2018', 'Story was created or updated in 2018.')
63YEAR_2019 = Tag('2019', 'Story was created or updated in 2019.')
64YEAR_2020 = Tag('2020', 'Story was created or updated in 2020.')
65
66
67def _ExtractAllTags():
68  all_tag_names = set()
69  all_tags = set()
70  # Collect all the tags defined in this module. Also assert that there is no
71  # duplicate tag names.
72  for obj in globals().values():
73    if isinstance(obj, Tag):
74      all_tags.add(obj)
75      assert obj.name not in all_tag_names, 'Duplicate tag name: %s' % obj.name
76      all_tag_names.add(obj.name)
77  return all_tags
78
79def _ExtractYearTags():
80  year_tags = set()
81  pattern = re.compile('^[0-9]{4}$')
82  for obj in globals().values():
83    if isinstance(obj, Tag) and pattern.match(obj.name):
84      year_tags.add(obj)
85  return year_tags
86
87ALL_TAGS = _ExtractAllTags()
88YEAR_TAGS = _ExtractYearTags()
89