Chromium Code Reviews| 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 grd_reader package''' | 6 '''Unit tests for grd_reader package''' |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 import sys | 9 import sys |
| 10 if __name__ == '__main__': | 10 if __name__ == '__main__': |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 (exception.MissingElement, u'<output filename="x" type="y" />'), | 282 (exception.MissingElement, u'<output filename="x" type="y" />'), |
| 283 ] | 283 ] |
| 284 for raises, data in gritpart_failures: | 284 for raises, data in gritpart_failures: |
| 285 top_grd = StringIO.StringIO(template % u'<part file="bad.grp" />') | 285 top_grd = StringIO.StringIO(template % u'<part file="bad.grp" />') |
| 286 with util.TempDir({'bad.grp': data}) as temp_dir: | 286 with util.TempDir({'bad.grp': data}) as temp_dir: |
| 287 self.assertRaises(raises, grd_reader.Parse, top_grd, temp_dir.GetPath()) | 287 self.assertRaises(raises, grd_reader.Parse, top_grd, temp_dir.GetPath()) |
| 288 | 288 |
| 289 def testEarlyEnoughPlatformSpecification(self): | 289 def testEarlyEnoughPlatformSpecification(self): |
| 290 # This is a regression test for issue | 290 # This is a regression test for issue |
| 291 # https://code.google.com/p/grit-i18n/issues/detail?id=23 | 291 # https://code.google.com/p/grit-i18n/issues/detail?id=23 |
| 292 # | |
| 293 # This test only works on platforms for which one of the is_xyz | |
| 294 # shortcuts in .grd expressions is true. If this string remains | |
| 295 # empty, abort the test. | |
| 296 platform = base.Node.GetPlatformAssertion(sys.platform) | |
| 297 if not platform: | |
| 298 return | |
| 299 | |
| 300 grd_text = u'''<?xml version="1.0" encoding="UTF-8"?> | 292 grd_text = u'''<?xml version="1.0" encoding="UTF-8"?> |
| 301 <grit latest_public_release="1" current_release="1"> | 293 <grit latest_public_release="1" current_release="1"> |
| 302 <release seq="1"> | 294 <release seq="1"> |
| 303 <messages> | 295 <messages> |
| 304 <if expr="not pp_ifdef('use_titlecase')"> | 296 <if expr="not pp_ifdef('use_titlecase')"> |
| 305 <message name="IDS_XYZ">foo</message> | 297 <message name="IDS_XYZ">foo</message> |
| 306 </if> | 298 </if> |
| 307 <!-- The assumption is that use_titlecase is never true for | 299 <!-- The assumption is that use_titlecase is never true for |
| 308 this platform. When the platform isn't set to 'android' | 300 this platform. When the platform isn't set to 'android' |
| 309 early enough, we get a duplicate message name. --> | 301 early enough, we get a duplicate message name. --> |
| 310 <if expr="%s"> | 302 <if expr="os == '%s'"> |
| 311 <message name="IDS_XYZ">boo</message> | 303 <message name="IDS_XYZ">boo</message> |
| 312 </if> | 304 </if> |
| 313 </messages> | 305 </messages> |
| 314 </release> | 306 </release> |
| 315 </grit>''' % platform | 307 </grit>''' % sys.platform |
|
Jói
2014/02/07 10:53:12
This test is intended to be a regression test for
newt (away)
2014/02/07 17:24:45
Yes, the test currently passes, but if I revert th
| |
| 316 with util.TempDir({}) as temp_dir: | 308 with util.TempDir({}) as temp_dir: |
| 317 grd_reader.Parse(StringIO.StringIO(grd_text), temp_dir.GetPath(), | 309 grd_reader.Parse(StringIO.StringIO(grd_text), temp_dir.GetPath(), |
| 318 target_platform='android') | 310 target_platform='android') |
| 319 | 311 |
| 320 | 312 |
| 321 if __name__ == '__main__': | 313 if __name__ == '__main__': |
| 322 unittest.main() | 314 unittest.main() |
| OLD | NEW |