OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import json | 6 import json |
7 from operator import itemgetter | 7 from operator import itemgetter |
8 import unittest | 8 import unittest |
9 | 9 |
10 from extensions_paths import CHROME_EXTENSIONS | 10 from extensions_paths import CHROME_EXTENSIONS |
(...skipping 21 matching lines...) Expand all Loading... |
32 }, | 32 }, |
33 # This won't appear for anything because it's private. | 33 # This won't appear for anything because it's private. |
34 'commandLinePrivate': { | 34 'commandLinePrivate': { |
35 'extension_types': ['platform_app', 'extension'] | 35 'extension_types': ['platform_app', 'extension'] |
36 }, | 36 }, |
37 # This will only appear for apps with an auto-generated description because | 37 # This will only appear for apps with an auto-generated description because |
38 # it's an API. | 38 # it's an API. |
39 'cookies': { | 39 'cookies': { |
40 'extension_types': ['platform_app'] | 40 'extension_types': ['platform_app'] |
41 }, | 41 }, |
| 42 'host-permissions': {} |
42 } | 43 } |
43 | 44 |
44 | 45 |
45 _PERMISSIONS_JSON = { | 46 _PERMISSIONS_JSON = { |
46 # This will appear for both apps and extensions with a custom description, | 47 # This will appear for both apps and extensions with a custom description, |
47 # anchor, etc. | 48 # anchor, etc. |
48 'host-permissions': { | 49 'host-permissions': { |
49 'anchor': 'custom-anchor', | 50 'anchor': 'custom-anchor', |
50 'extension_types': ['platform_app', 'extension'], | 51 'extension_types': ['platform_app', 'extension'], |
51 'literal_name': True, | 52 'literal_name': True, |
(...skipping 23 matching lines...) Expand all Loading... |
75 }, | 76 }, |
76 } | 77 } |
77 | 78 |
78 | 79 |
79 class PermissionsDataSourceTest(unittest.TestCase): | 80 class PermissionsDataSourceTest(unittest.TestCase): |
80 def testCreatePermissionsDataSource(self): | 81 def testCreatePermissionsDataSource(self): |
81 expected_extensions = [ | 82 expected_extensions = [ |
82 { | 83 { |
83 'anchor': 'custom-anchor', | 84 'anchor': 'custom-anchor', |
84 'description': 'host permissions', | 85 'description': 'host permissions', |
| 86 'extension_types': ['platform_app', 'extension'], |
85 'literal_name': True, | 87 'literal_name': True, |
86 'name': 'match pattern', | 88 'name': 'match pattern', |
87 'platforms': ['apps', 'extensions'] | 89 'channel': 'stable' |
88 }, | 90 }, |
89 { | 91 { |
90 'anchor': 'activeTab', | 92 'anchor': 'activeTab', |
91 'description': 'active tab', | 93 'description': 'active tab', |
| 94 'extension_types': ['extension'], |
92 'name': 'activeTab', | 95 'name': 'activeTab', |
93 'platforms': ['extensions'], | 96 'channel': 'stable' |
94 }, | 97 }, |
95 { | 98 { |
96 'anchor': 'alarms', | 99 'anchor': 'alarms', |
97 'description': 'generic description', | 100 'description': 'generic description', |
| 101 'extension_types': ['platform_app', 'extension'], |
98 'name': 'alarms', | 102 'name': 'alarms', |
99 'platforms': ['apps', 'extensions'], | 103 'channel': 'stable' |
100 }, | 104 }, |
101 ] | 105 ] |
102 | 106 |
103 expected_apps = [ | 107 expected_apps = [ |
104 { | 108 { |
105 'anchor': 'custom-anchor', | 109 'anchor': 'custom-anchor', |
106 'description': 'host permissions', | 110 'description': 'host permissions', |
| 111 'extension_types': ['platform_app', 'extension'], |
107 'literal_name': True, | 112 'literal_name': True, |
108 'name': 'match pattern', | 113 'name': 'match pattern', |
109 'platforms': ['apps', 'extensions'], | 114 'channel': 'stable' |
110 }, | 115 }, |
111 { | 116 { |
112 'anchor': 'alarms', | 117 'anchor': 'alarms', |
113 'description': 'generic description', | 118 'description': 'generic description', |
| 119 'extension_types': ['platform_app', 'extension'], |
114 'name': 'alarms', | 120 'name': 'alarms', |
115 'platforms': ['apps', 'extensions'], | 121 'channel': 'stable' |
116 }, | 122 }, |
117 { | 123 { |
118 'anchor': 'cookies', | 124 'anchor': 'cookies', |
119 'description': 'generic description', | 125 'description': 'generic description', |
| 126 'extension_types': ['platform_app'], |
120 'name': 'cookies', | 127 'name': 'cookies', |
121 'platforms': ['apps'], | 128 'channel': 'stable' |
122 }, | 129 }, |
123 ] | 130 ] |
124 | 131 |
125 test_file_system = TestFileSystem({ | 132 test_file_system = TestFileSystem({ |
126 'api': { | 133 'api': { |
127 '_api_features.json': json.dumps(_API_FEATURES), | 134 '_api_features.json': json.dumps(_API_FEATURES), |
128 '_manifest_features.json': '{}', | 135 '_manifest_features.json': '{}', |
129 '_permission_features.json': json.dumps(_PERMISSION_FEATURES), | 136 '_permission_features.json': json.dumps(_PERMISSION_FEATURES), |
130 }, | 137 }, |
131 'docs': { | 138 'docs': { |
(...skipping 27 matching lines...) Expand all Loading... |
159 for key, value in mapping.iteritems(): | 166 for key, value in mapping.iteritems(): |
160 if isinstance(value, Handlebar): | 167 if isinstance(value, Handlebar): |
161 mapping[key] = value.Render().text | 168 mapping[key] = value.Render().text |
162 | 169 |
163 self.assertEqual(expected_extensions, actual_extensions) | 170 self.assertEqual(expected_extensions, actual_extensions) |
164 self.assertEqual(expected_apps, actual_apps) | 171 self.assertEqual(expected_apps, actual_apps) |
165 | 172 |
166 | 173 |
167 if __name__ == '__main__': | 174 if __name__ == '__main__': |
168 unittest.main() | 175 unittest.main() |
OLD | NEW |