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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 self.assertEqual({}, | 46 self.assertEqual({}, |
47 id_dict.get('out/Release/obj/gen/devtools/devtools.grd', None)) | 47 id_dict.get('out/Release/obj/gen/devtools/devtools.grd', None)) |
48 | 48 |
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 |
| 57 # corresponding to ChromeScaledImage nodes when assets are missing. |
| 58 def testGetInputFilesChromeScaledImage(self): |
| 59 xml = '''<?xml version="1.0" encoding="utf-8"?> |
| 60 <grit latest_public_release="0" current_release="1"> |
| 61 <outputs> |
| 62 <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 </outputs> |
| 65 <release seq="1"> |
| 66 <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_B" file="b.png" /> |
| 69 </structures> |
| 70 </release> |
| 71 </grit>''' |
| 72 |
| 73 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'] |
| 75 actual = [os.path.relpath(path, util.PathFromRoot('grit/testdata')) for path
in grd.GetInputFiles()] |
| 76 # Convert path separator for Windows paths. |
| 77 actual = [path.replace('\\', '/') for path in actual] |
| 78 self.assertEquals(expected, actual) |
| 79 |
| 80 |
56 class IfNodeUnittest(unittest.TestCase): | 81 class IfNodeUnittest(unittest.TestCase): |
57 def testIffyness(self): | 82 def testIffyness(self): |
58 grd = grd_reader.Parse(StringIO.StringIO(''' | 83 grd = grd_reader.Parse(StringIO.StringIO(''' |
59 <grit latest_public_release="2" source_lang_id="en-US" current_release="3"
base_dir="."> | 84 <grit latest_public_release="2" source_lang_id="en-US" current_release="3"
base_dir="."> |
60 <release seq="3"> | 85 <release seq="3"> |
61 <messages> | 86 <messages> |
62 <if expr="'bingo' in defs"> | 87 <if expr="'bingo' in defs"> |
63 <message name="IDS_BINGO"> | 88 <message name="IDS_BINGO"> |
64 Bingo! | 89 Bingo! |
65 </message> | 90 </message> |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 # a pseudo language should fail, but they do not fail and the test was | 441 # a pseudo language should fail, but they do not fail and the test was |
417 # broken and failed to catch it. Fix this. | 442 # broken and failed to catch it. Fix this. |
418 | 443 |
419 # Should not raise an exception since pseudo is allowed | 444 # Should not raise an exception since pseudo is allowed |
420 rc.FormatMessage(bingo, 'xyz-pseudo') | 445 rc.FormatMessage(bingo, 'xyz-pseudo') |
421 rc.FormatStructure(menu, 'xyz-pseudo', '.') | 446 rc.FormatStructure(menu, 'xyz-pseudo', '.') |
422 | 447 |
423 | 448 |
424 if __name__ == '__main__': | 449 if __name__ == '__main__': |
425 unittest.main() | 450 unittest.main() |
OLD | NEW |