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

Side by Side Diff: grit/gather/chrome_scaled_image_unittest.py

Issue 1194063002: grit: Add fallback_to_default_layout attribute to <output> (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: for landing Created 5 years, 6 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/gather/chrome_scaled_image.py ('k') | grit/node/include.py » ('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 ChromeScaledImage.''' 6 '''Unit tests for ChromeScaledImage.'''
7 7
8 8
9 import re 9 import re
10 import struct 10 import struct
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 def _Structure(name, file, fallback=None): 73 def _Structure(name, file, fallback=None):
74 return '<structure name="%s" file="%s" type="chrome_scaled_image"%s />' % ( 74 return '<structure name="%s" file="%s" type="chrome_scaled_image"%s />' % (
75 name, file, _MakeFallbackAttr(fallback)) 75 name, file, _MakeFallbackAttr(fallback))
76 76
77 77
78 def _If(expr, *body): 78 def _If(expr, *body):
79 return '<if expr="%s">\n%s\n</if>' % (expr, '\n'.join(body)) 79 return '<if expr="%s">\n%s\n</if>' % (expr, '\n'.join(body))
80 80
81 81
82 def _RunBuildTest(self, structures, inputs, expected_outputs, skip_rc=False): 82 def _RunBuildTest(self, structures, inputs, expected_outputs, skip_rc=False, lay out_fallback=''):
83 outputs = '\n'.join('<output filename="out/%s%s" type="%s" context="%s" />' 83 outputs = '\n'.join('<output filename="out/%s%s" type="%s" context="%s"%s />'
84 % (context, ext, type, context) 84 % (context, ext, type, context, layout_fallback)
85 for ext, type in _OUTFILETYPES 85 for ext, type in _OUTFILETYPES
86 for context in expected_outputs) 86 for context in expected_outputs)
87
87 infiles = { 88 infiles = {
88 'in/in.grd': '''<?xml version="1.0" encoding="UTF-8"?> 89 'in/in.grd': '''<?xml version="1.0" encoding="UTF-8"?>
89 <grit latest_public_release="0" current_release="1"> 90 <grit latest_public_release="0" current_release="1">
90 <outputs> 91 <outputs>
91 %s 92 %s
92 </outputs> 93 </outputs>
93 <release seq="1"> 94 <release seq="1">
94 %s 95 %s
95 </release> 96 </release>
96 </grit> 97 </grit>
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 self.assertRaises(exception.FileNotFound, _RunBuildTest, *args) 166 self.assertRaises(exception.FileNotFound, _RunBuildTest, *args)
166 167
167 # Test fallback failure with fallback_to_low_resolution=True 168 # Test fallback failure with fallback_to_low_resolution=True
168 self.assertRaises(exception.FileNotFound, 169 self.assertRaises(exception.FileNotFound,
169 _RunBuildTest, self, 170 _RunBuildTest, self,
170 _Structures(True, 171 _Structures(True,
171 _Structure('IDR_A', 'a.png'), 172 _Structure('IDR_A', 'a.png'),
172 ), 173 ),
173 {}, # no files 174 {}, # no files
174 {'tactile_123_percent': 'should fail before using this'}) 175 {'tactile_123_percent': 'should fail before using this'})
176
177 def testNoFallbackToDefaultLayout(self):
178 d123a = _MakePNG([('AbCd', '')])
179 t123a = _MakePNG([('EfGh', '')])
180 d123b = _MakePNG([('IjKl', '')])
181 _RunBuildTest(self,
182 _Structures(None,
183 _Structure('IDR_A', 'a.png'),
184 _Structure('IDR_B', 'b.png'),
185 ),
186 {'default_123_percent/a.png': d123a,
187 'tactile_123_percent/a.png': t123a,
188 'default_123_percent/b.png': d123b,
189 },
190 {'default_123_percent': set([d123a, d123b]),
191 'tactile_123_percent': set([t123a]),
192 },
193 layout_fallback=' fallback_to_default_layout="false"')
OLDNEW
« no previous file with comments | « grit/gather/chrome_scaled_image.py ('k') | grit/node/include.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698