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 from compiled_file_system import CompiledFileSystem | 6 from compiled_file_system import CompiledFileSystem |
7 from path_canonicalizer import PathCanonicalizer | 7 from path_canonicalizer import PathCanonicalizer |
8 import svn_constants | 8 import svn_constants |
9 from object_store_creator import ObjectStoreCreator | 9 from object_store_creator import ObjectStoreCreator |
10 from test_file_system import TestFileSystem | 10 from test_file_system import TestFileSystem |
11 import unittest | 11 import unittest |
12 | 12 |
13 _TEST_DATA = TestFileSystem.MoveTo(svn_constants.PUBLIC_TEMPLATE_PATH, { | 13 _TEST_DATA = TestFileSystem.MoveTo(svn_constants.PUBLIC_TEMPLATE_PATH, { |
14 'extensions': { | 14 'extensions': { |
15 'browserAction.html': 'yo', | 15 'browserAction.html': 'yo', |
16 'storage.html': 'dawg', | 16 'storage.html': 'dawg', |
17 }, | 17 }, |
18 'apps': { | 18 'apps': { |
19 'bluetooth': 'hey', | 19 'bluetooth': 'hey', |
20 'storage.html': 'wassup', | 20 'storage.html': 'wassup', |
21 } | 21 } |
22 }) | 22 }) |
23 | 23 |
24 class PathCanonicalizerTest(unittest.TestCase): | 24 class PathCanonicalizerTest(unittest.TestCase): |
25 def setUp(self): | 25 def setUp(self): |
26 test_fs = TestFileSystem(_TEST_DATA) | 26 test_fs = TestFileSystem(_TEST_DATA) |
27 compiled_fs_factory = CompiledFileSystem.Factory( | 27 compiled_fs_factory = CompiledFileSystem.Factory( |
28 test_fs, | 28 test_fs, |
29 ObjectStoreCreator.TestFactory()) | 29 ObjectStoreCreator.ForTest()) |
30 self._path_canonicalizer = PathCanonicalizer('stable', compiled_fs_factory) | 30 self._path_canonicalizer = PathCanonicalizer('stable', compiled_fs_factory) |
31 | 31 |
32 def _assertIdentity(self, path): | 32 def _assertIdentity(self, path): |
33 self.assertEqual(path, self._path_canonicalizer.Canonicalize(path)) | 33 self.assertEqual(path, self._path_canonicalizer.Canonicalize(path)) |
34 | 34 |
35 def testExtensions(self): | 35 def testExtensions(self): |
36 self._assertIdentity('extensions/browserAction.html') | 36 self._assertIdentity('extensions/browserAction.html') |
37 self._assertIdentity('extensions/storage.html') | 37 self._assertIdentity('extensions/storage.html') |
38 self._assertIdentity('extensions/bluetooth.html') | 38 self._assertIdentity('extensions/bluetooth.html') |
39 self._assertIdentity('extensions/blah.html') | 39 self._assertIdentity('extensions/blah.html') |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 # paths are more likely to be for extensions. | 85 # paths are more likely to be for extensions. |
86 self.assertEqual( | 86 self.assertEqual( |
87 'extensions/blah.html', | 87 'extensions/blah.html', |
88 self._path_canonicalizer.Canonicalize('blah.html')) | 88 self._path_canonicalizer.Canonicalize('blah.html')) |
89 self.assertEqual( | 89 self.assertEqual( |
90 'stable/extensions/blah.html', | 90 'stable/extensions/blah.html', |
91 self._path_canonicalizer.Canonicalize('stable/blah.html')) | 91 self._path_canonicalizer.Canonicalize('stable/blah.html')) |
92 | 92 |
93 if __name__ == '__main__': | 93 if __name__ == '__main__': |
94 unittest.main() | 94 unittest.main() |
OLD | NEW |