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

Side by Side Diff: grit/node/misc_unittest.py

Issue 1320683002: Write sources from flattenhtml to depfiles. (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « grit/node/misc.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 misc.GritNode''' 6 '''Unit tests for misc.GritNode'''
7 7
8 8
9 import os 9 import os
10 import sys 10 import sys
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 src_dir, id_dict = misc._ReadFirstIdsFromFile( 49 src_dir, id_dict = misc._ReadFirstIdsFromFile(
50 test_resource_ids, 50 test_resource_ids,
51 { 51 {
52 'SHARED_INTERMEDIATE_DIR': '/outside/src_dir', 52 'SHARED_INTERMEDIATE_DIR': '/outside/src_dir',
53 }) 53 })
54 self.assertEqual({}, id_dict.get('devtools.grd', None)) 54 self.assertEqual({}, id_dict.get('devtools.grd', None))
55 55
56 # Verifies that GetInputFiles() returns the correct list of files 56 # Verifies that GetInputFiles() returns the correct list of files
57 # corresponding to ChromeScaledImage nodes when assets are missing. 57 # corresponding to ChromeScaledImage nodes when assets are missing.
58 def testGetInputFilesChromeScaledImage(self): 58 def testGetInputFilesChromeScaledImage(self):
59 chrome_html_path = util.PathFromRoot('grit/testdata/chrome_html.html')
59 xml = '''<?xml version="1.0" encoding="utf-8"?> 60 xml = '''<?xml version="1.0" encoding="utf-8"?>
60 <grit latest_public_release="0" current_release="1"> 61 <grit latest_public_release="0" current_release="1">
61 <outputs> 62 <outputs>
62 <output filename="default.pak" type="data_package" context="default_10 0_percent" /> 63 <output filename="default.pak" type="data_package" context="default_10 0_percent" />
63 <output filename="special.pak" type="data_package" context="special_10 0_percent" fallback_to_default_layout="false" /> 64 <output filename="special.pak" type="data_package" context="special_10 0_percent" fallback_to_default_layout="false" />
64 </outputs> 65 </outputs>
65 <release seq="1"> 66 <release seq="1">
66 <structures fallback_to_low_resolution="true"> 67 <structures fallback_to_low_resolution="true">
67 <structure type="chrome_scaled_image" name="IDR_A" file="a.png" /> 68 <structure type="chrome_scaled_image" name="IDR_A" file="a.png" />
68 <structure type="chrome_scaled_image" name="IDR_B" file="b.png" /> 69 <structure type="chrome_scaled_image" name="IDR_B" file="b.png" />
70 <structure type="chrome_html" name="HTML_FILE1" file="%s" flattenhtm l="true" />
69 </structures> 71 </structures>
70 </release> 72 </release>
71 </grit>''' 73 </grit>''' % chrome_html_path
72 74
73 grd = grd_reader.Parse(StringIO.StringIO(xml), util.PathFromRoot('grit/testd ata')) 75 grd = grd_reader.Parse(StringIO.StringIO(xml), util.PathFromRoot('grit/testd ata'))
74 expected = ['default_100_percent/a.png', 'default_100_percent/b.png', 'speci al_100_percent/a.png'] 76 expected = ['chrome_html.html', 'default_100_percent/a.png',
77 'default_100_percent/b.png', 'included_sample.html',
78 'special_100_percent/a.png']
75 actual = [os.path.relpath(path, util.PathFromRoot('grit/testdata')) for path in grd.GetInputFiles()] 79 actual = [os.path.relpath(path, util.PathFromRoot('grit/testdata')) for path in grd.GetInputFiles()]
76 # Convert path separator for Windows paths. 80 # Convert path separator for Windows paths.
77 actual = [path.replace('\\', '/') for path in actual] 81 actual = [path.replace('\\', '/') for path in actual]
78 self.assertEquals(expected, actual) 82 self.assertEquals(expected, actual)
79 83
80 84
81 class IfNodeUnittest(unittest.TestCase): 85 class IfNodeUnittest(unittest.TestCase):
82 def testIffyness(self): 86 def testIffyness(self):
83 grd = grd_reader.Parse(StringIO.StringIO(''' 87 grd = grd_reader.Parse(StringIO.StringIO('''
84 <grit latest_public_release="2" source_lang_id="en-US" current_release="3" base_dir="."> 88 <grit latest_public_release="2" source_lang_id="en-US" current_release="3" base_dir=".">
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 # a pseudo language should fail, but they do not fail and the test was 445 # a pseudo language should fail, but they do not fail and the test was
442 # broken and failed to catch it. Fix this. 446 # broken and failed to catch it. Fix this.
443 447
444 # Should not raise an exception since pseudo is allowed 448 # Should not raise an exception since pseudo is allowed
445 rc.FormatMessage(bingo, 'xyz-pseudo') 449 rc.FormatMessage(bingo, 'xyz-pseudo')
446 rc.FormatStructure(menu, 'xyz-pseudo', '.') 450 rc.FormatStructure(menu, 'xyz-pseudo', '.')
447 451
448 452
449 if __name__ == '__main__': 453 if __name__ == '__main__':
450 unittest.main() 454 unittest.main()
OLDNEW
« no previous file with comments | « grit/node/misc.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698