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

Unified Diff: grit/grd_reader_unittest.py

Issue 118663003: Set target platform on root node earlier. (Closed) Base URL: https://grit-i18n.googlecode.com/svn/trunk
Patch Set: Remove code duplication. Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « grit/grd_reader.py ('k') | grit/node/base.py » ('j') | grit/node/base.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: grit/grd_reader_unittest.py
diff --git a/grit/grd_reader_unittest.py b/grit/grd_reader_unittest.py
index 5a4c7c3fa5f1041f4ee9853875c2e53f34d71ee4..065d280740983e5e1adc9fa0b349f2ba3f705382 100644
--- a/grit/grd_reader_unittest.py
+++ b/grit/grd_reader_unittest.py
@@ -16,6 +16,7 @@ import StringIO
from grit import exception
from grit import grd_reader
from grit import util
+from grit.node import base
from grit.node import empty
@@ -285,6 +286,37 @@ class GrdReaderUnittest(unittest.TestCase):
with util.TempDir({'bad.grp': data}) as temp_dir:
self.assertRaises(raises, grd_reader.Parse, top_grd, temp_dir.GetPath())
+ def testEarlyEnoughPlatformSpecification(self):
+ # This is a regression test for issue
+ # https://code.google.com/p/grit-i18n/issues/detail?id=23
+ #
+ # This test only works on platforms for which one of the is_xyz
+ # shortcuts in .grd expressions is true. If this string remains
+ # empty, abort the test.
+ platform = base.Node.GetPlatformAssertion(sys.platform)
+ if not platform:
+ return
+
+ grd_text = u'''<?xml version="1.0" encoding="UTF-8"?>
+ <grit latest_public_release="1" current_release="1">
+ <release seq="1">
+ <messages>
+ <if expr="not pp_ifdef('use_titlecase')">
+ <message name="IDS_XYZ">foo</message>
+ </if>
+ <!-- The assumption is that use_titlecase is never true for
+ this platform. When the platform isn't set to 'android'
+ early enough, we get a duplicate message name. -->
+ <if expr="%s">
+ <message name="IDS_XYZ">boo</message>
+ </if>
+ </messages>
+ </release>
+ </grit>''' % platform
+ with util.TempDir({}) as temp_dir:
+ grd_reader.Parse(StringIO.StringIO(grd_text), temp_dir.GetPath(),
+ target_platform='android')
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « grit/grd_reader.py ('k') | grit/node/base.py » ('j') | grit/node/base.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698