OLD | NEW |
1 #!/usr/bin/python2.4 | 1 #!/usr/bin/python2.4 |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 test2 | 139 test2 |
140 </message> | 140 </message> |
141 </messages> | 141 </messages> |
142 </release> | 142 </release> |
143 </grit>''' | 143 </grit>''' |
144 pseudo_file = StringIO.StringIO(input) | 144 pseudo_file = StringIO.StringIO(input) |
145 root = grd_reader.Parse(pseudo_file, '.') | 145 root = grd_reader.Parse(pseudo_file, '.') |
146 grit_root_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), | 146 grit_root_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), |
147 '..') | 147 '..') |
148 root.AssignFirstIds( | 148 root.AssignFirstIds( |
149 # This file does not actually exist, but the path must match | 149 # This file does not actually exist, but must use absolute |
150 # the path of the resource_ids file as it has SRCDIR set to "." | 150 # path as resource_ids has '' for SRCDIR (see special handling |
151 os.path.join(grit_root_dir, "grit/testdata/test.grd"), | 151 # in grit.node.misc). |
| 152 os.path.join(grit_root_dir, "/test.grd"), |
152 os.path.join(grit_root_dir, "grit/testdata/resource_ids"), | 153 os.path.join(grit_root_dir, "grit/testdata/resource_ids"), |
153 {}) | 154 {}) |
154 messages_node = root.children[0].children[0] | 155 messages_node = root.children[0].children[0] |
155 self.assertTrue(isinstance(messages_node, empty.MessagesNode)) | 156 self.assertTrue(isinstance(messages_node, empty.MessagesNode)) |
156 self.assertEqual('100', messages_node.attrs["first_id"]) | 157 self.assertEqual('100', messages_node.attrs["first_id"]) |
157 messages_node = root.children[0].children[1] | 158 messages_node = root.children[0].children[1] |
158 self.assertTrue(isinstance(messages_node, empty.MessagesNode)) | 159 self.assertTrue(isinstance(messages_node, empty.MessagesNode)) |
159 self.assertEqual('10000', messages_node.attrs["first_id"]) | 160 self.assertEqual('10000', messages_node.attrs["first_id"]) |
160 | 161 |
161 def testUseNameForIdAndPpIfdef(self): | 162 def testUseNameForIdAndPpIfdef(self): |
(...skipping 12 matching lines...) Expand all Loading... |
174 pseudo_file = StringIO.StringIO(input) | 175 pseudo_file = StringIO.StringIO(input) |
175 root = grd_reader.Parse(pseudo_file, '.', defines={'hello': '1'}) | 176 root = grd_reader.Parse(pseudo_file, '.', defines={'hello': '1'}) |
176 | 177 |
177 # Check if the ID is set to the name. In the past, there was a bug | 178 # Check if the ID is set to the name. In the past, there was a bug |
178 # that caused the ID to be a generated number. | 179 # that caused the ID to be a generated number. |
179 hello = root.GetNodeById('IDS_HELLO') | 180 hello = root.GetNodeById('IDS_HELLO') |
180 self.failUnless(hello.GetCliques()[0].GetId() == 'IDS_HELLO') | 181 self.failUnless(hello.GetCliques()[0].GetId() == 'IDS_HELLO') |
181 | 182 |
182 if __name__ == '__main__': | 183 if __name__ == '__main__': |
183 unittest.main() | 184 unittest.main() |
OLD | NEW |