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

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

Issue 148293018: Docserver: Make the .html extension unnecessary for content pages, for example, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: yoz Created 6 years, 10 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/path_canonicalizer_test.py
diff --git a/chrome/common/extensions/docs/server2/path_canonicalizer_test.py b/chrome/common/extensions/docs/server2/path_canonicalizer_test.py
index fbcfc8e4b1c5088e167f9782f7cc03c0fe81fe4c..ab8534cc84800e1a962ff19d1fa3e2b65e4609eb 100755
--- a/chrome/common/extensions/docs/server2/path_canonicalizer_test.py
+++ b/chrome/common/extensions/docs/server2/path_canonicalizer_test.py
@@ -3,61 +3,69 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import posixpath
import unittest
-from compiled_file_system import CompiledFileSystem
from extensions_paths import PUBLIC_TEMPLATES
from local_file_system import LocalFileSystem
from object_store_creator import ObjectStoreCreator
from path_canonicalizer import PathCanonicalizer
+from special_paths import SITE_VERIFICATION_FILE
class PathCanonicalizerTest(unittest.TestCase):
def setUp(self):
self._path_canonicalizer = PathCanonicalizer(
- CompiledFileSystem.Factory(ObjectStoreCreator.ForTest()),
- LocalFileSystem.Create(PUBLIC_TEMPLATES))
+ LocalFileSystem.Create(PUBLIC_TEMPLATES),
+ ObjectStoreCreator.ForTest(),
+ ('.html', '.md'))
def testSpecifyCorrectly(self):
- self._AssertIdentity('extensions/browserAction.html')
- self._AssertIdentity('extensions/storage.html')
- self._AssertIdentity('extensions/blah.html')
- self._AssertIdentity('extensions/index.html')
- self._AssertIdentity('extensions/whats_new.html')
- self._AssertIdentity('apps/storage.html')
- self._AssertIdentity('apps/bluetooth.html')
- self._AssertIdentity('apps/blah.html')
- self._AssertIdentity('apps/tags/webview.html')
+ self._AssertIdentity('extensions/browserAction')
+ self._AssertIdentity('extensions/storage')
+ self._AssertIdentity('extensions/blah')
+ self._AssertIdentity('extensions/index')
+ self._AssertIdentity('extensions/whats_new')
+ self._AssertIdentity('apps/storage')
+ self._AssertIdentity('apps/bluetooth')
+ self._AssertIdentity('apps/blah')
+ self._AssertIdentity('apps/tags/webview')
def testSpecifyIncorrectly(self):
- self._AssertRedirect('extensions/browserAction.html',
- 'apps/browserAction.html')
- self._AssertRedirect('extensions/browserAction.html',
- 'apps/extensions/browserAction.html')
- self._AssertRedirect('apps/bluetooth.html', 'extensions/bluetooth.html')
- self._AssertRedirect('apps/bluetooth.html',
- 'extensions/apps/bluetooth.html')
- self._AssertRedirect('extensions/index.html', 'apps/index.html')
- self._AssertRedirect('extensions/browserAction.html',
- 'static/browserAction.html')
- self._AssertRedirect('apps/tags/webview.html',
- 'apps/webview.html')
- self._AssertRedirect('apps/tags/webview.html',
- 'extensions/webview.html')
- self._AssertRedirect('apps/tags/webview.html',
- 'extensions/tags/webview.html')
+ self._AssertRedirectWithDefaultExtensions(
+ 'extensions/browserAction', 'apps/browserAction')
+ self._AssertRedirectWithDefaultExtensions(
+ 'extensions/browserAction', 'apps/extensions/browserAction')
+ self._AssertRedirectWithDefaultExtensions(
+ 'apps/bluetooth', 'extensions/bluetooth')
+ self._AssertRedirectWithDefaultExtensions(
+ 'apps/bluetooth', 'extensions/apps/bluetooth')
+ self._AssertRedirectWithDefaultExtensions(
+ 'extensions/index', 'apps/index')
+ self._AssertRedirectWithDefaultExtensions(
+ 'extensions/browserAction', 'static/browserAction')
+ self._AssertRedirectWithDefaultExtensions(
+ 'apps/tags/webview', 'apps/webview')
+ self._AssertRedirectWithDefaultExtensions(
+ 'apps/tags/webview', 'extensions/webview')
+ self._AssertRedirectWithDefaultExtensions(
+ 'apps/tags/webview', 'extensions/tags/webview')
+
# These are a little trickier because storage.html is in both directories.
# They must canonicalize to the closest match.
- self._AssertRedirect('extensions/storage.html',
- 'extensions/apps/storage.html')
- self._AssertRedirect('apps/storage.html',
- 'apps/extensions/storage.html')
+ self._AssertRedirectWithDefaultExtensions(
+ 'extensions/storage', 'extensions/apps/storage')
+ self._AssertRedirectWithDefaultExtensions(
+ 'apps/storage', 'apps/extensions/storage')
def testUnspecified(self):
- self._AssertRedirect('extensions/browserAction.html', 'browserAction.html')
- self._AssertRedirect('apps/bluetooth.html', 'bluetooth.html')
+ self._AssertRedirectWithDefaultExtensions(
+ 'extensions/browserAction', 'browserAction')
+ self._AssertRedirectWithDefaultExtensions(
+ 'apps/bluetooth', 'bluetooth')
# Default happens to be apps because it's first alphabetically.
- self._AssertRedirect('apps/storage.html', 'storage.html')
+ self._AssertRedirectWithDefaultExtensions(
+ 'apps/storage', 'storage')
# Nonexistent APIs should be left alone.
self._AssertIdentity('blah.html')
@@ -68,7 +76,7 @@ class PathCanonicalizerTest(unittest.TestCase):
self._AssertIdentity('extensions/')
# No trailing slash should be treated as files not directories, at least
# at least according to PathCanonicalizer.
- self._AssertRedirect('extensions/apps.html', 'apps')
+ self._AssertRedirect('extensions/apps', 'apps')
self._AssertRedirect('extensions', 'extensions')
# Just as tolerant of spelling mistakes.
self._AssertRedirect('apps/', 'Apps/')
@@ -83,10 +91,25 @@ class PathCanonicalizerTest(unittest.TestCase):
'BrowserAction.html', 'browseraction.html', 'Browseraction',
'browser-action', 'Browser.action.html', 'browser_action',
'browser-action.html', 'Browser_Action.html'):
- self._AssertRedirect('extensions/browserAction.html', spelme)
- self._AssertRedirect('extensions/browserAction.html',
- 'extensions/%s' % spelme)
- self._AssertRedirect('extensions/browserAction.html', 'apps/%s' % spelme)
+ self._AssertRedirect('extensions/browserAction', spelme)
+ self._AssertRedirect('extensions/browserAction', 'extensions/%s' % spelme)
+ self._AssertRedirect('extensions/browserAction', 'apps/%s' % spelme)
+
+ def testNonDefaultExtensions(self):
+ # The only example currently of a file with a non-default extension is
+ # the redirects.json file. That shouldn't have its extension stripped since
+ # it's not in the default extensions.
+ self._AssertIdentity('redirects.json')
+ self._AssertRedirect('redirects.json', 'redirects')
+ self._AssertRedirect('redirects.json', 'redirects.html')
+ self._AssertRedirect('redirects.json', 'redirects.js')
+ self._AssertRedirect('redirects.json', 'redirects.md')
+
+ def testSiteVerificationFile(self):
+ # The site verification file should not redirect.
+ self._AssertIdentity(SITE_VERIFICATION_FILE)
+ self._AssertRedirect(SITE_VERIFICATION_FILE,
+ posixpath.splitext(SITE_VERIFICATION_FILE)[0])
def _AssertIdentity(self, path):
self._AssertRedirect(path, path)
@@ -94,6 +117,11 @@ class PathCanonicalizerTest(unittest.TestCase):
def _AssertRedirect(self, to, from_):
self.assertEqual(to, self._path_canonicalizer.Canonicalize(from_))
+ def _AssertRedirectWithDefaultExtensions(self, to, from_):
+ for ext in ('', '.html', '.md'):
+ self._AssertRedirect(
+ to, self._path_canonicalizer.Canonicalize(from_ + ext))
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « chrome/common/extensions/docs/server2/path_canonicalizer.py ('k') | chrome/common/extensions/docs/server2/render_servlet.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698