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
._api
_categorizer
= APICategorizer(
61 TestFileSystem(_TEST_DATA
, relative_to
=CHROME_EXTENSIONS
),
62 CompiledFileSystem
.Factory(ObjectStoreCreator
.ForTest()))
64 def testGetAPICategory(self
):
65 get_category
= self
._api
_categorizer
.GetCategory
66 self
.assertEqual('chrome', get_category('apps', 'alarms'))
67 self
.assertEqual('chrome', get_category('extensions', 'alarms'))
68 self
.assertEqual('private', get_category('apps', 'musicManagerPrivate'))
69 self
.assertEqual('private', get_category('extensions', 'notDocumentedApi'))
70 self
.assertEqual('experimental',
71 get_category('apps', 'experimental.bluetooth'))
72 self
.assertEqual('experimental',
73 get_category('extensions', 'experimental.history'))
76 if __name__
== '__main__':