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, 'testdata') for path in grd.GetInputFiles()] | |
flackr
2015/06/26 23:10:32
This seems to be dependent on where you're running
tdanderson
2015/06/29 15:34:13
Done.
| |
76 actual = [path.replace('\\', '/') for path in actual] | |
flackr
2015/06/26 23:10:32
nit: add comment that this is to convert windows p
tdanderson
2015/06/29 15:34:13
Done.
| |
77 self.assertEquals(expected, actual) | |
78 | |
79 | |
56 class IfNodeUnittest(unittest.TestCase): | 80 class IfNodeUnittest(unittest.TestCase): |
57 def testIffyness(self): | 81 def testIffyness(self): |
58 grd = grd_reader.Parse(StringIO.StringIO(''' | 82 grd = grd_reader.Parse(StringIO.StringIO(''' |
59 <grit latest_public_release="2" source_lang_id="en-US" current_release="3" base_dir="."> | 83 <grit latest_public_release="2" source_lang_id="en-US" current_release="3" base_dir="."> |
60 <release seq="3"> | 84 <release seq="3"> |
61 <messages> | 85 <messages> |
62 <if expr="'bingo' in defs"> | 86 <if expr="'bingo' in defs"> |
63 <message name="IDS_BINGO"> | 87 <message name="IDS_BINGO"> |
64 Bingo! | 88 Bingo! |
65 </message> | 89 </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 | 440 # a pseudo language should fail, but they do not fail and the test was |
417 # broken and failed to catch it. Fix this. | 441 # broken and failed to catch it. Fix this. |
418 | 442 |
419 # Should not raise an exception since pseudo is allowed | 443 # Should not raise an exception since pseudo is allowed |
420 rc.FormatMessage(bingo, 'xyz-pseudo') | 444 rc.FormatMessage(bingo, 'xyz-pseudo') |
421 rc.FormatStructure(menu, 'xyz-pseudo', '.') | 445 rc.FormatStructure(menu, 'xyz-pseudo', '.') |
422 | 446 |
423 | 447 |
424 if __name__ == '__main__': | 448 if __name__ == '__main__': |
425 unittest.main() | 449 unittest.main() |
OLD | NEW |