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

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

Issue 1212703002: grit: Ignore empty file paths when generating input file list (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: test added Created 5 years, 5 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') | grit/testdata/default_100_percent/a.png » ('j') | 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 input_files = grd.GetInputFiles()
75 expected = ['default_100_percent/a.png', 'default_100_percent/b.png', 'speci al_100_percent/a.png']
76 actual = []
77 for file in input_files:
78 split = file.split('/')
79 actual.append(split[-2] + '/' + split[-1])
flackr 2015/06/26 19:45:21 Is this to convert a full path to the last 2 compo
80
81 self.assertEquals(expected, actual)
82
83
56 class IfNodeUnittest(unittest.TestCase): 84 class IfNodeUnittest(unittest.TestCase):
57 def testIffyness(self): 85 def testIffyness(self):
58 grd = grd_reader.Parse(StringIO.StringIO(''' 86 grd = grd_reader.Parse(StringIO.StringIO('''
59 <grit latest_public_release="2" source_lang_id="en-US" current_release="3" base_dir="."> 87 <grit latest_public_release="2" source_lang_id="en-US" current_release="3" base_dir=".">
60 <release seq="3"> 88 <release seq="3">
61 <messages> 89 <messages>
62 <if expr="'bingo' in defs"> 90 <if expr="'bingo' in defs">
63 <message name="IDS_BINGO"> 91 <message name="IDS_BINGO">
64 Bingo! 92 Bingo!
65 </message> 93 </message>
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 # a pseudo language should fail, but they do not fail and the test was 444 # a pseudo language should fail, but they do not fail and the test was
417 # broken and failed to catch it. Fix this. 445 # broken and failed to catch it. Fix this.
418 446
419 # Should not raise an exception since pseudo is allowed 447 # Should not raise an exception since pseudo is allowed
420 rc.FormatMessage(bingo, 'xyz-pseudo') 448 rc.FormatMessage(bingo, 'xyz-pseudo')
421 rc.FormatStructure(menu, 'xyz-pseudo', '.') 449 rc.FormatStructure(menu, 'xyz-pseudo', '.')
422 450
423 451
424 if __name__ == '__main__': 452 if __name__ == '__main__':
425 unittest.main() 453 unittest.main()
OLDNEW
« no previous file with comments | « grit/node/misc.py ('k') | grit/testdata/default_100_percent/a.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698