Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4188)

Unified Diff: chrome/common/extensions/docs/server2/features_bundle_test.py

Issue 23867003: Docserver: Consolidate features caching and access. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: let's try this again, shall we? Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/features_bundle_test.py
diff --git a/chrome/common/extensions/docs/server2/features_bundle_test.py b/chrome/common/extensions/docs/server2/features_bundle_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..842ee0922f7e0cc733c646e5b6ead4b1aa6653ad
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/features_bundle_test.py
@@ -0,0 +1,260 @@
+#!/usr/bin/env python
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import json
+import unittest
+
+from server_instance import ServerInstance
+from test_file_system import TestFileSystem
+
+_TEST_FILESYSTEM = {
+ 'api': {
+ '_api_features.json': json.dumps({
+ 'audioCapture': {
+ 'channel': 'stable',
+ 'extension_types': ['platform_app']
+ },
+ 'background': [
+ {
+ 'channel': 'stable',
+ 'extension_types': ['extension']
+ },
+ {
+ 'channel': 'stable',
+ 'extension_types': ['platform_app'],
+ 'whitelist': ['im not here']
+ }
+ ],
+ 'omnibox': {
+ 'dependencies': ['manifest:omnibox'],
+ 'contexts': ['blessed_extension']
+ },
+ 'syncFileSystem': {
+ 'dependencies': ['permission:syncFileSystem'],
+ 'contexts': ['blessed_extension']
+ },
+ 'tabs': {
+ 'channel': 'stable',
+ 'extension_types': ['extension', 'legacy_packaged_app'],
+ 'contexts': ['blessed_extension']
+ },
+ 'test': {
+ 'channel': 'stable',
+ 'extension_types': 'all',
+ 'contexts': [
+ 'blessed_extension', 'unblessed_extension', 'content_script']
+ },
+ 'windows': {
+ 'dependencies': ['api:tabs'],
+ 'contexts': ['blessed_extension']
+ }
+ }),
+ '_manifest_features.json': json.dumps({
+ 'app.content_security_policy': {
+ 'channel': 'stable',
+ 'extension_types': ['platform_app'],
+ 'min_manifest_version': 2,
+ 'whitelist': ['this isnt happening']
+ },
+ 'background': {
+ 'channel': 'stable',
+ 'extension_types': ['extension', 'legacy_packaged_app', 'hosted_app']
+ },
+ 'manifest_version': {
+ 'channel': 'stable',
+ 'extension_types': 'all'
+ },
+ 'omnibox': {
+ 'channel': 'stable',
+ 'extension_types': ['extension']
+ },
+ 'page_action': {
+ 'channel': 'stable',
+ 'extension_types': ['extension']
+ },
+ 'sockets': {
+ 'channel': 'dev',
+ 'extension_types': ['platform_app']
+ }
+ }),
+ '_permission_features.json': json.dumps({
+ 'bluetooth': {
+ 'channel': 'dev',
+ 'extension_types': ['platform_app']
+ },
+ 'power': {
+ 'channel': 'stable',
+ 'extension_types': [
+ 'extension', 'legacy_packaged_app', 'platform_app'
+ ]
+ },
+ 'syncFileSystem': {
+ 'channel': 'stable',
+ 'extension_types': ['platform_app']
+ },
+ 'tabs': {
+ 'channel': 'stable',
+ 'extension_types': ['extension']
+ }
+ })
+ },
+ 'docs': {
+ 'templates': {
+ 'json': {
+ 'manifest.json': json.dumps({
+ 'background': {
+ 'documentation': 'background_pages.html'
+ },
+ 'manifest_version': {
+ 'documentation': 'manifest/manifest_version.html',
+ 'example': 2,
+ 'level': 'required'
+ },
+ 'page_action': {
+ 'documentation': 'pageAction.html',
+ 'example': {},
+ 'level': 'only_one'
+ }
+ }),
+ 'permissions.json': json.dumps({
+ 'fakeUnsupportedFeature': {},
+ 'syncFileSystem': {
+ 'partial': 'permissions/sync_file_system.html'
+ },
+ 'tabs': {
+ 'partial': 'permissions/tabs.html'
+ },
+ })
+ }
+ }
+ }
+}
+
+class FeaturesBundleTest(unittest.TestCase):
+ def setUp(self):
+ self._server = ServerInstance.ForTest(TestFileSystem(_TEST_FILESYSTEM))
+
+ def testManifestFeatures(self):
+ expected_features = {
+ 'background': {
+ 'name': 'background',
+ 'channel': 'stable',
+ 'platforms': ['extensions'],
+ 'documentation': 'background_pages.html'
+ },
+ 'manifest_version': {
+ 'name': 'manifest_version',
+ 'channel': 'stable',
+ 'platforms': ['apps', 'extensions'],
+ 'documentation': 'manifest/manifest_version.html',
+ 'level': 'required',
+ 'example': 2
+ },
+ 'omnibox': {
+ 'name': 'omnibox',
+ 'channel': 'stable',
+ 'platforms': ['extensions']
+ },
+ 'page_action': {
+ 'name': 'page_action',
+ 'channel': 'stable',
+ 'platforms': ['extensions'],
+ 'documentation': 'pageAction.html',
+ 'level': 'only_one',
+ 'example': {}
+ },
+ 'sockets': {
+ 'name': 'sockets',
+ 'channel': 'dev',
+ 'platforms': ['apps']
+ }
+ }
+ self.assertEqual(
+ expected_features,
+ self._server.features_bundle.GetManifestFeatures())
+
+ def testPermissionFeatures(self):
+ expected_features = {
+ 'bluetooth': {
+ 'name': 'bluetooth',
+ 'channel': 'dev',
+ 'platforms': ['apps'],
+ },
+ 'fakeUnsupportedFeature': {
+ 'name': 'fakeUnsupportedFeature',
+ 'platforms': []
+ },
+ 'power': {
+ 'name': 'power',
+ 'channel': 'stable',
+ 'platforms': ['apps', 'extensions'],
+ },
+ 'syncFileSystem': {
+ 'name': 'syncFileSystem',
+ 'channel': 'stable',
+ 'platforms': ['apps'],
+ 'partial': 'permissions/sync_file_system.html'
+ },
+ 'tabs': {
+ 'name': 'tabs',
+ 'channel': 'stable',
+ 'platforms': ['extensions'],
+ 'partial': 'permissions/tabs.html'
+ }
+ }
+ self.assertEqual(
+ expected_features,
+ self._server.features_bundle.GetPermissionFeatures())
+
+ def testAPIFeatures(self):
+ expected_features = {
+ 'audioCapture': {
+ 'name': 'audioCapture',
+ 'channel': 'stable',
+ 'platforms': ['apps']
+ },
+ 'background': {
+ 'name': 'background',
+ 'channel': 'stable',
+ 'platforms': ['extensions']
+ },
+ 'omnibox': {
+ 'name': 'omnibox',
+ 'platforms': ['extensions'],
+ 'contexts': ['blessed_extension'],
+ 'dependencies': ['manifest:omnibox']
+ },
+ 'syncFileSystem': {
+ 'name': 'syncFileSystem',
+ 'platforms': ['apps'],
+ 'contexts': ['blessed_extension'],
+ 'dependencies': ['permission:syncFileSystem']
+ },
+ 'tabs': {
+ 'name': 'tabs',
+ 'channel': 'stable',
+ 'platforms': ['extensions'],
+ 'contexts': ['blessed_extension'],
+ },
+ 'test': {
+ 'name': 'test',
+ 'channel': 'stable',
+ 'platforms': ['apps', 'extensions'],
+ 'contexts': [
+ 'blessed_extension', 'unblessed_extension', 'content_script'],
+ },
+ 'windows': {
+ 'name': 'windows',
+ 'platforms': ['extensions'],
+ 'contexts': ['blessed_extension'],
+ 'dependencies': ['api:tabs']
+ }
+ }
+ self.assertEqual(
+ expected_features,
+ self._server.features_bundle.GetAPIFeatures())
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « chrome/common/extensions/docs/server2/features_bundle.py ('k') | chrome/common/extensions/docs/server2/features_utility.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698