OLD | NEW |
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 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')) |
76 expected = ['chrome_html.html', 'default_100_percent/a.png', | 76 expected = ['chrome_html.html', 'default_100_percent/a.png', |
77 'default_100_percent/b.png', 'included_sample.html', | 77 'default_100_percent/b.png', 'included_sample.html', |
78 'special_100_percent/a.png'] | 78 'special_100_percent/a.png'] |
79 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()] |
80 # Convert path separator for Windows paths. | 80 # Convert path separator for Windows paths. |
81 actual = [path.replace('\\', '/') for path in actual] | 81 actual = [path.replace('\\', '/') for path in actual] |
82 self.assertEquals(expected, actual) | 82 self.assertEquals(expected, actual) |
83 | 83 |
| 84 # Verifies that GetInputFiles() returns the correct list of files |
| 85 # when files include other files. |
| 86 def testGetInputFilesFromIncludes(self): |
| 87 chrome_html_path = util.PathFromRoot('grit/testdata/chrome_html.html') |
| 88 xml = '''<?xml version="1.0" encoding="utf-8"?> |
| 89 <grit latest_public_release="0" current_release="1"> |
| 90 <outputs> |
| 91 <output filename="default.pak" type="data_package" context="default_10
0_percent" /> |
| 92 <output filename="special.pak" type="data_package" context="special_10
0_percent" fallback_to_default_layout="false" /> |
| 93 </outputs> |
| 94 <release seq="1"> |
| 95 <includes> |
| 96 <include name="IDR_TESTDATA_CHROME_HTML" file="%s" flattenhtml="true
" |
| 97 allowexternalscript="true" type="BINDATA" /> |
| 98 </includes> |
| 99 </release> |
| 100 </grit>''' % chrome_html_path |
| 101 |
| 102 grd = grd_reader.Parse(StringIO.StringIO(xml), util.PathFromRoot('grit/testd
ata')) |
| 103 expected = ['chrome_html.html', 'included_sample.html'] |
| 104 actual = [os.path.relpath(path, util.PathFromRoot('grit/testdata')) for path
in grd.GetInputFiles()] |
| 105 # Convert path separator for Windows paths. |
| 106 actual = [path.replace('\\', '/') for path in actual] |
| 107 self.assertEquals(expected, actual) |
| 108 |
84 | 109 |
85 class IfNodeUnittest(unittest.TestCase): | 110 class IfNodeUnittest(unittest.TestCase): |
86 def testIffyness(self): | 111 def testIffyness(self): |
87 grd = grd_reader.Parse(StringIO.StringIO(''' | 112 grd = grd_reader.Parse(StringIO.StringIO(''' |
88 <grit latest_public_release="2" source_lang_id="en-US" current_release="3"
base_dir="."> | 113 <grit latest_public_release="2" source_lang_id="en-US" current_release="3"
base_dir="."> |
89 <release seq="3"> | 114 <release seq="3"> |
90 <messages> | 115 <messages> |
91 <if expr="'bingo' in defs"> | 116 <if expr="'bingo' in defs"> |
92 <message name="IDS_BINGO"> | 117 <message name="IDS_BINGO"> |
93 Bingo! | 118 Bingo! |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 # a pseudo language should fail, but they do not fail and the test was | 470 # a pseudo language should fail, but they do not fail and the test was |
446 # broken and failed to catch it. Fix this. | 471 # broken and failed to catch it. Fix this. |
447 | 472 |
448 # Should not raise an exception since pseudo is allowed | 473 # Should not raise an exception since pseudo is allowed |
449 rc.FormatMessage(bingo, 'xyz-pseudo') | 474 rc.FormatMessage(bingo, 'xyz-pseudo') |
450 rc.FormatStructure(menu, 'xyz-pseudo', '.') | 475 rc.FormatStructure(menu, 'xyz-pseudo', '.') |
451 | 476 |
452 | 477 |
453 if __name__ == '__main__': | 478 if __name__ == '__main__': |
454 unittest.main() | 479 unittest.main() |
OLD | NEW |