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

Unified Diff: grit/format/html_inline_unittest.py

Issue 16539002: GRIT: Enable variable expansion in filenames during HTML inlining. (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: Created 7 years, 6 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: grit/format/html_inline_unittest.py
diff --git a/grit/format/html_inline_unittest.py b/grit/format/html_inline_unittest.py
index 7d546a5eab0c4ae0f56bbeeecac66cbaeda417d3..c869a422b71e930518bbc3b538b7fe866297cb8c 100755
--- a/grit/format/html_inline_unittest.py
+++ b/grit/format/html_inline_unittest.py
@@ -202,6 +202,49 @@ class HtmlInlineUnittest(unittest.TestCase):
self.failUnlessEqual(expected_inlined,
util.FixLineEnd(result.inlined_data, '\n'))
+ def testFilenameVariableExpansion(self):
+ '''Tests that variables are expanded in filenames before inlining.'''
+
+ files = {
+ 'index.html': '''
+ <html>
+ <head>
+ <link rel="stylesheet" href="style[WHICH].css">
+ </head>
+ <include src="tmpl[WHICH].html">
+ </html>
+ ''',
+ 'style1.css': '''h1 {}''',
+ 'tmpl1.html': '''<h1></h1>''',
+ }
+
+ expected_inlined = '''
+ <html>
+ <head>
+ <style>h1 {}</style>
+ </head>
+ <h1></h1>
+ </html>
+ '''
+
+ source_resources = set()
+ tmp_dir = util.TempDir(files)
+ for filename in files:
+ source_resources.add(tmp_dir.GetPath(filename))
+
+ def replacer(var, repl):
+ return lambda filename: filename.replace('[%s]' % var, repl)
+
+ result = html_inline.DoInline(
+ tmp_dir.GetPath('index.html'),
+ None,
+ filename_expansion_function=replacer('WHICH', '1'))
+ resources = result.inlined_files
+ resources.add(tmp_dir.GetPath('index.html'))
+ self.failUnlessEqual(resources, source_resources)
flackr 2013/06/06 14:07:19 It might be worth adding a test which calls DoInli
dconnelly 2013/06/07 09:10:38 Done.
+ self.failUnlessEqual(expected_inlined,
+ util.FixLineEnd(result.inlined_data, '\n'))
+
if __name__ == '__main__':
unittest.main()

Powered by Google App Engine
This is Rietveld 408576698