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

Unified Diff: grit/grd_reader_unittest.py

Issue 9802029: Make first_ids_file an optional attribute of the .grd file. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « grit/grd_reader.py ('k') | grit/node/misc.py » ('j') | grit/node/misc.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: grit/grd_reader_unittest.py
===================================================================
--- grit/grd_reader_unittest.py (revision 18)
+++ grit/grd_reader_unittest.py (working copy)
@@ -98,9 +98,10 @@
'This is a very long line with no linebreaks yes yes it '
'stretches on and on and on!')
- def testAssignFirstIds(self):
+ def doTestAssignFirstIds(self, first_ids_path):
input = u'''<?xml version="1.0" encoding="UTF-8"?>
-<grit latest_public_release="2" source_lang_id="en-US" current_release="3" base_dir=".">
+<grit latest_public_release="2" source_lang_id="en-US" current_release="3"
+ base_dir="." first_ids_file="%s">
<release seq="3">
<messages>
<message name="IDS_TEST" desc="test">
@@ -108,26 +109,31 @@
</message>
</messages>
</release>
-</grit>'''
+</grit>''' % first_ids_path
pseudo_file = StringIO.StringIO(input)
- root = grd_reader.Parse(pseudo_file, '.')
grit_root_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)),
'..')
- root.AssignFirstIds(
- os.path.join(grit_root_dir,
- "grit/testdata/chrome/app/generated_resources.grd"),
- os.path.join(grit_root_dir, "grit/testdata/tools/grit/resource_ids"),
- {})
+ fake_input_path = os.path.join(
+ grit_root_dir, "grit/testdata/chrome/app/generated_resources.grd")
+ root = grd_reader.Parse(pseudo_file, os.path.split(fake_input_path)[0])
+ root.AssignFirstIds(fake_input_path, {})
messages_node = root.children[0].children[0]
self.failUnless(isinstance(messages_node, empty.MessagesNode))
self.failUnless(messages_node.attrs["first_id"] !=
empty.MessagesNode().DefaultAttributes()["first_id"])
+ def testAssignFirstIds(self):
+ self.doTestAssignFirstIds("../../tools/grit/resource_ids")
+
+ def testAssignFirstIdsUseGritDir(self):
+ self.doTestAssignFirstIds("GRIT_DIR/grit/testdata/tools/grit/resource_ids")
+
def testAssignFirstIdsMultipleMessages(self):
"""If there are multiple messages sections, the resource_ids file
needs to list multiple first_id values."""
input = u'''<?xml version="1.0" encoding="UTF-8"?>
-<grit latest_public_release="2" source_lang_id="en-US" current_release="3" base_dir=".">
+<grit latest_public_release="2" source_lang_id="en-US" current_release="3"
+ base_dir="." first_ids_file="resource_ids">
<release seq="3">
<messages>
<message name="IDS_TEST" desc="test">
@@ -142,16 +148,12 @@
</release>
</grit>'''
pseudo_file = StringIO.StringIO(input)
- root = grd_reader.Parse(pseudo_file, '.')
grit_root_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)),
'..')
- root.AssignFirstIds(
- # This file does not actually exist, but must use absolute
- # path as resource_ids has '' for SRCDIR (see special handling
- # in grit.node.misc).
- os.path.join(grit_root_dir, "grit/testdata/test.grd"),
- os.path.join(grit_root_dir, "grit/testdata/resource_ids"),
- {})
+ fake_input_path = os.path.join(grit_root_dir, "grit/testdata/test.grd")
+
+ root = grd_reader.Parse(pseudo_file, os.path.split(fake_input_path)[0])
+ root.AssignFirstIds(fake_input_path, {})
messages_node = root.children[0].children[0]
self.assertTrue(isinstance(messages_node, empty.MessagesNode))
self.assertEqual('100', messages_node.attrs["first_id"])
« no previous file with comments | « grit/grd_reader.py ('k') | grit/node/misc.py » ('j') | grit/node/misc.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698