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

Side by Side Diff: chrome/common/extensions/docs/server2/path_canonicalizer_test.py

Issue 13470005: Refactor the devserver to make it easier to control caching (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cduvall, rebase Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
5
6 from compiled_file_system import CompiledFileSystem
7 from path_canonicalizer import PathCanonicalizer
8 import svn_constants
9 from test_file_system import TestFileSystem
10 import unittest
11
12 _TEST_DATA = TestFileSystem.MoveTo(svn_constants.PUBLIC_TEMPLATE_PATH, {
13 'extensions': {
14 'browserAction.html': 'yo',
15 'storage.html': 'dawg',
16 },
17 'apps': {
18 'bluetooth': 'hey',
19 'storage.html': 'wassup',
20 }
21 })
22
23 class PathCanonicalizerTest(unittest.TestCase):
24 def setUp(self):
25 test_fs = TestFileSystem(_TEST_DATA)
26 compiled_fs_factory = CompiledFileSystem.Factory(test_fs)
27 self._path_canonicalizer = PathCanonicalizer('stable', compiled_fs_factory)
28
29 def _assertIdentity(self, path):
30 self.assertEqual(path, self._path_canonicalizer.Canonicalize(path))
31
32 def testExtensions(self):
33 self._assertIdentity('extensions/browserAction.html')
34 self._assertIdentity('extensions/storage.html')
35 self._assertIdentity('extensions/bluetooth.html')
36 self._assertIdentity('extensions/blah.html')
37 self._assertIdentity('stable/extensions/browserAction.html')
38 self._assertIdentity('stable/extensions/storage.html')
39 self._assertIdentity('stable/extensions/bluetooth.html')
40 self._assertIdentity('stable/extensions/blah.html')
41
42 def testApps(self):
43 self._assertIdentity('apps/browserAction.html')
44 self._assertIdentity('apps/storage.html')
45 self._assertIdentity('apps/bluetooth.html')
46 self._assertIdentity('apps/blah.html')
47 self._assertIdentity('stable/apps/browserAction.html')
48 self._assertIdentity('stable/apps/storage.html')
49 self._assertIdentity('stable/apps/bluetooth.html')
50 self._assertIdentity('stable/apps/blah.html')
51
52 def testStatic(self):
53 self._assertIdentity('static/browserAction.html')
54 self._assertIdentity('static/storage.html')
55 self._assertIdentity('static/bluetooth.html')
56 self._assertIdentity('static/blah.html')
57 self._assertIdentity('stable/static/browserAction.html')
58 self._assertIdentity('stable/static/storage.html')
59 self._assertIdentity('stable/static/bluetooth.html')
60 self._assertIdentity('stable/static/blah.html')
61
62 def testNeither(self):
63 self.assertEqual(
64 'extensions/browserAction.html',
65 self._path_canonicalizer.Canonicalize('browserAction.html'))
66 self.assertEqual(
67 'stable/extensions/browserAction.html',
68 self._path_canonicalizer.Canonicalize('stable/browserAction.html'))
69 self.assertEqual(
70 'extensions/storage.html',
71 self._path_canonicalizer.Canonicalize('storage.html'))
72 self.assertEqual(
73 'stable/extensions/storage.html',
74 self._path_canonicalizer.Canonicalize('stable/storage.html'))
75 self.assertEqual(
76 'apps/bluetooth.html',
77 self._path_canonicalizer.Canonicalize('bluetooth.html'))
78 self.assertEqual(
79 'stable/apps/bluetooth.html',
80 self._path_canonicalizer.Canonicalize('stable/bluetooth.html'))
81 # Assign non-existent paths to extensions because they came first, so such
82 # paths are more likely to be for extensions.
83 self.assertEqual(
84 'extensions/blah.html',
85 self._path_canonicalizer.Canonicalize('blah.html'))
86 self.assertEqual(
87 'stable/extensions/blah.html',
88 self._path_canonicalizer.Canonicalize('stable/blah.html'))
89
90 if __name__ == '__main__':
91 unittest.main()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/path_canonicalizer.py ('k') | chrome/common/extensions/docs/server2/preview.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698