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

Side by Side Diff: grit/format/html_inline_unittest.py

Issue 18568003: Fix LINK and INCLUDE HTML inlining Regexes to Support End Tags on Different Lines (Closed) Base URL: https://grit-i18n.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 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
« no previous file with comments | « grit/format/html_inline.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 '''Unit tests for grit.format.html_inline''' 6 '''Unit tests for grit.format.html_inline'''
7 7
8 8
9 import os 9 import os
10 import re 10 import re
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 # Test names-only inlining. 255 # Test names-only inlining.
256 result = html_inline.DoInline( 256 result = html_inline.DoInline(
257 tmp_dir.GetPath('index.html'), 257 tmp_dir.GetPath('index.html'),
258 None, 258 None,
259 names_only=True, 259 names_only=True,
260 filename_expansion_function=replacer('WHICH', '1')) 260 filename_expansion_function=replacer('WHICH', '1'))
261 resources = result.inlined_files 261 resources = result.inlined_files
262 resources.add(tmp_dir.GetPath('index.html')) 262 resources.add(tmp_dir.GetPath('index.html'))
263 self.failUnlessEqual(resources, source_resources) 263 self.failUnlessEqual(resources, source_resources)
264 264
265 def testWithCloseTags(self):
266 '''Tests that close tags are removed.'''
267
268 files = {
269 'index.html': '''
270 <html>
271 <head>
272 <link rel="stylesheet" href="style1.css"></link>
273 <link rel="stylesheet" href="style2.css">
274 </link>
275 <link rel="stylesheet" href="style2.css"
276 >
277 </link>
278 <script src="script1.js"></script>
279 </head>
280 <include src="tmpl1.html"></include>
281 <include src="tmpl2.html">
282 </include>
283 <include src="tmpl2.html"
284 >
285 </include>
286 <img src="img1.png">
287 </html>
288 ''',
289 'style1.css': '''h1 {}''',
290 'style2.css': '''h2 {}''',
291 'tmpl1.html': '''<h1></h1>''',
292 'tmpl2.html': '''<h2></h2>''',
293 'script1.js': '''console.log('hello');''',
294 'img1.png': '''abc''',
295 }
296
297 expected_inlined = '''
298 <html>
299 <head>
300 <style>h1 {}</style>
301 <style>h2 {}</style>
302 <style>h2 {}</style>
303 <script>console.log('hello');</script>
304 </head>
305 <h1></h1>
306 <h2></h2>
307 <h2></h2>
308 <img src="data:image/png;base64,YWJj">
309 </html>
310 '''
311
312 source_resources = set()
313 tmp_dir = util.TempDir(files)
314 for filename in files:
315 source_resources.add(tmp_dir.GetPath(filename))
316
317 # Test normal inlining.
318 result = html_inline.DoInline(
319 tmp_dir.GetPath('index.html'),
320 None)
321 resources = result.inlined_files
322 resources.add(tmp_dir.GetPath('index.html'))
323 self.failUnlessEqual(resources, source_resources)
324 self.failUnlessEqual(expected_inlined,
325 util.FixLineEnd(result.inlined_data, '\n'))
265 326
266 if __name__ == '__main__': 327 if __name__ == '__main__':
267 unittest.main() 328 unittest.main()
OLDNEW
« no previous file with comments | « grit/format/html_inline.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698