Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / common / extensions / docs / server2 / features_bundle_test.py
blob50767975bc1ae25f4024e0185a990181d1544b71
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
6 import json
7 import unittest
9 from extensions_paths import EXTENSIONS
10 from server_instance import ServerInstance
11 from test_file_system import TestFileSystem
14 _TEST_FILESYSTEM = {
15 'api': {
16 '_api_features.json': json.dumps({
17 'audioCapture': {
18 'channel': 'stable',
19 'extension_types': ['platform_app']
21 'background': [
23 'channel': 'stable',
24 'extension_types': ['extension']
27 'channel': 'stable',
28 'extension_types': ['platform_app'],
29 'whitelist': ['im not here']
32 'omnibox': {
33 'dependencies': ['manifest:omnibox'],
34 'contexts': ['blessed_extension']
36 'syncFileSystem': {
37 'dependencies': ['permission:syncFileSystem'],
38 'contexts': ['blessed_extension']
40 'tabs': {
41 'channel': 'stable',
42 'extension_types': ['extension', 'legacy_packaged_app'],
43 'contexts': ['blessed_extension']
45 'test': {
46 'channel': 'stable',
47 'extension_types': 'all',
48 'contexts': [
49 'blessed_extension', 'unblessed_extension', 'content_script']
51 'windows': {
52 'dependencies': ['api:tabs'],
53 'contexts': ['blessed_extension']
55 }),
56 '_manifest_features.json': json.dumps({
57 'app.content_security_policy': {
58 'channel': 'stable',
59 'extension_types': ['platform_app'],
60 'min_manifest_version': 2,
61 'whitelist': ['this isnt happening']
63 'background': {
64 'channel': 'stable',
65 'extension_types': ['extension', 'legacy_packaged_app', 'hosted_app']
67 'manifest_version': {
68 'channel': 'stable',
69 'extension_types': 'all'
71 'omnibox': {
72 'channel': 'stable',
73 'extension_types': ['extension']
75 'page_action': {
76 'channel': 'stable',
77 'extension_types': ['extension']
79 'sockets': {
80 'channel': 'dev',
81 'extension_types': ['platform_app']
83 }),
84 '_permission_features.json': json.dumps({
85 'bluetooth': {
86 'channel': 'dev',
87 'extension_types': ['platform_app']
89 'power': {
90 'channel': 'stable',
91 'extension_types': [
92 'extension', 'legacy_packaged_app', 'platform_app'
95 'syncFileSystem': {
96 'channel': 'stable',
97 'extension_types': ['platform_app']
99 'tabs': {
100 'channel': 'stable',
101 'extension_types': ['extension']
105 'docs': {
106 'templates': {
107 'json': {
108 'manifest.json': json.dumps({
109 'background': {
110 'documentation': 'background_pages.html'
112 'manifest_version': {
113 'documentation': 'manifest/manifest_version.html',
114 'example': 2,
115 'level': 'required'
117 'page_action': {
118 'documentation': 'pageAction.html',
119 'example': {},
120 'level': 'only_one'
123 'permissions.json': json.dumps({
124 'fakeUnsupportedFeature': {},
125 'syncFileSystem': {
126 'partial': 'permissions/sync_file_system.html'
128 'tabs': {
129 'partial': 'permissions/tabs.html'
138 class FeaturesBundleTest(unittest.TestCase):
139 def setUp(self):
140 self._server = ServerInstance.ForTest(
141 TestFileSystem(_TEST_FILESYSTEM, relative_to=EXTENSIONS))
143 def testManifestFeatures(self):
144 expected_features = {
145 'background': {
146 'name': 'background',
147 'channel': 'stable',
148 'platforms': ['extensions'],
149 'documentation': 'background_pages.html'
151 'manifest_version': {
152 'name': 'manifest_version',
153 'channel': 'stable',
154 'platforms': ['apps', 'extensions'],
155 'documentation': 'manifest/manifest_version.html',
156 'level': 'required',
157 'example': 2
159 'omnibox': {
160 'name': 'omnibox',
161 'channel': 'stable',
162 'platforms': ['extensions']
164 'page_action': {
165 'name': 'page_action',
166 'channel': 'stable',
167 'platforms': ['extensions'],
168 'documentation': 'pageAction.html',
169 'level': 'only_one',
170 'example': {}
172 'sockets': {
173 'name': 'sockets',
174 'channel': 'dev',
175 'platforms': ['apps']
178 self.assertEqual(
179 expected_features,
180 self._server.features_bundle.GetManifestFeatures().Get())
182 def testPermissionFeatures(self):
183 expected_features = {
184 'bluetooth': {
185 'name': 'bluetooth',
186 'channel': 'dev',
187 'platforms': ['apps'],
189 'fakeUnsupportedFeature': {
190 'name': 'fakeUnsupportedFeature',
191 'platforms': []
193 'power': {
194 'name': 'power',
195 'channel': 'stable',
196 'platforms': ['apps', 'extensions'],
198 'syncFileSystem': {
199 'name': 'syncFileSystem',
200 'channel': 'stable',
201 'platforms': ['apps'],
202 'partial': 'permissions/sync_file_system.html'
204 'tabs': {
205 'name': 'tabs',
206 'channel': 'stable',
207 'platforms': ['extensions'],
208 'partial': 'permissions/tabs.html'
211 self.assertEqual(
212 expected_features,
213 self._server.features_bundle.GetPermissionFeatures().Get())
215 def testAPIFeatures(self):
216 expected_features = {
217 'audioCapture': {
218 'name': 'audioCapture',
219 'channel': 'stable',
220 'platforms': ['apps']
222 'background': {
223 'name': 'background',
224 'channel': 'stable',
225 'platforms': ['extensions']
227 'omnibox': {
228 'name': 'omnibox',
229 'platforms': ['extensions'],
230 'contexts': ['blessed_extension'],
231 'dependencies': ['manifest:omnibox']
233 'syncFileSystem': {
234 'name': 'syncFileSystem',
235 'platforms': ['apps'],
236 'contexts': ['blessed_extension'],
237 'dependencies': ['permission:syncFileSystem']
239 'tabs': {
240 'name': 'tabs',
241 'channel': 'stable',
242 'platforms': ['extensions'],
243 'contexts': ['blessed_extension'],
245 'test': {
246 'name': 'test',
247 'channel': 'stable',
248 'platforms': ['apps', 'extensions'],
249 'contexts': [
250 'blessed_extension', 'unblessed_extension', 'content_script'],
252 'windows': {
253 'name': 'windows',
254 'platforms': ['extensions'],
255 'contexts': ['blessed_extension'],
256 'dependencies': ['api:tabs']
259 self.assertEqual(
260 expected_features,
261 self._server.features_bundle.GetAPIFeatures().Get())
264 if __name__ == '__main__':
265 unittest.main()