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

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

Issue 1002663003: Raises an exception when an unexpected </if> occurs (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 5 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
« 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 source_resources = set() 71 source_resources = set()
72 tmp_dir = util.TempDir(files) 72 tmp_dir = util.TempDir(files)
73 for filename in files: 73 for filename in files:
74 source_resources.add(tmp_dir.GetPath(filename)) 74 source_resources.add(tmp_dir.GetPath(filename))
75 75
76 resources = html_inline.GetResourceFilenames(tmp_dir.GetPath('index.html')) 76 resources = html_inline.GetResourceFilenames(tmp_dir.GetPath('index.html'))
77 resources.add(tmp_dir.GetPath('index.html')) 77 resources.add(tmp_dir.GetPath('index.html'))
78 self.failUnlessEqual(resources, source_resources) 78 self.failUnlessEqual(resources, source_resources)
79 tmp_dir.CleanUp() 79 tmp_dir.CleanUp()
80 80
81 def testUnmatchedEndIfBlock(self):
82 '''Tests that an unmatched </if> raises an exception.'''
83
84 files = {
85 'index.html': '''
86 <!DOCTYPE HTML>
87 <html>
88 <if expr="lang == 'fr'">
89 bonjour
90 </if>
91 </if>
92 </html>
93 ''',
94 }
95
96 tmp_dir = util.TempDir(files)
97
98 with self.assertRaises(Exception) as cm:
99 html_inline.GetResourceFilenames(tmp_dir.GetPath('index.html'))
100 self.failUnlessEqual(cm.exception.message, 'Unmatched </if>')
101 tmp_dir.CleanUp()
102
81 def testCompressedJavaScript(self): 103 def testCompressedJavaScript(self):
82 '''Tests that ".src=" doesn't treat as a tag.''' 104 '''Tests that ".src=" doesn't treat as a tag.'''
83 105
84 files = { 106 files = {
85 'index.js': ''' 107 'index.js': '''
86 if(i<j)a.src="hoge.png"; 108 if(i<j)a.src="hoge.png";
87 ''', 109 ''',
88 } 110 }
89 111
90 source_resources = set() 112 source_resources = set()
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 tmp_dir.GetPath('index.html'), 341 tmp_dir.GetPath('index.html'),
320 None) 342 None)
321 resources = result.inlined_files 343 resources = result.inlined_files
322 resources.add(tmp_dir.GetPath('index.html')) 344 resources.add(tmp_dir.GetPath('index.html'))
323 self.failUnlessEqual(resources, source_resources) 345 self.failUnlessEqual(resources, source_resources)
324 self.failUnlessEqual(expected_inlined, 346 self.failUnlessEqual(expected_inlined,
325 util.FixLineEnd(result.inlined_data, '\n')) 347 util.FixLineEnd(result.inlined_data, '\n'))
326 348
327 if __name__ == '__main__': 349 if __name__ == '__main__':
328 unittest.main() 350 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