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.
7 from api_categorizer
import APICategorizer
8 from compiled_file_system
import CompiledFileSystem
9 from extensions_paths
import CHROME_EXTENSIONS
10 from object_store_creator
import ObjectStoreCreator
11 from test_file_system
import TestFileSystem
15 '''Transforms |obj| into test data by turning a list of files into an object
16 mapping that file to its contents (derived from its name).
18 return dict((name
, name
) for name
in obj
)
23 '_api_features.json': '{}',
24 '_manifest_features.json': '{}',
25 '_permission_features.json': '{}',
30 'api_availabilities.json': '{}',
31 'manifest.json': '{}',
32 'permissions.json': '{}',
38 'experimental_bluetooth.html',
39 'experimental_power.html',
43 'extensions': _ToTestData([
46 'experimental_history.html',
47 'experimental_power.html',
58 class APICategorizerTest(unittest
.TestCase
):
60 self
._test
_file
_system
= TestFileSystem(
61 _TEST_DATA
, relative_to
=CHROME_EXTENSIONS
)
62 self
._compiled
_file
_system
= CompiledFileSystem
.Factory(
63 ObjectStoreCreator
.ForTest())
65 def testGetAPICategory(self
):
66 def assertGetEqual(expected
, category
, only_on
=None):
67 for platform
in ('apps', 'extensions'):
68 get_category
= APICategorizer(
69 self
._test
_file
_system
,
70 self
._compiled
_file
_system
,
71 platform
if only_on
is None else only_on
).GetCategory(category
)
72 self
.assertEqual(expected
, get_category
)
74 assertGetEqual('chrome', 'alarms')
75 assertGetEqual('private', 'musicManagerPrivate')
76 assertGetEqual('private', 'notDocumentedApi')
77 assertGetEqual('experimental', 'experimental.bluetooth', only_on
='apps')
78 assertGetEqual('experimental', 'experimental.history', only_on
='extensions')
81 if __name__
== '__main__':