| 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 grit.tool.android2grd''' | 6 '''Unit tests for grit.tool.android2grd''' |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 import sys | 9 import sys |
| 10 if __name__ == '__main__': | 10 if __name__ == '__main__': |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 self.assertEqual(len(messages), 5) | 106 self.assertEqual(len(messages), 5) |
| 107 | 107 |
| 108 # Check that a message node is constructed correctly. | 108 # Check that a message node is constructed correctly. |
| 109 msg = filter(lambda x: x.GetTextualIds()[0] == "IDS_PLACEHOLDERS", messages) | 109 msg = filter(lambda x: x.GetTextualIds()[0] == "IDS_PLACEHOLDERS", messages) |
| 110 self.assertTrue(msg) | 110 self.assertTrue(msg) |
| 111 msg = msg[0] | 111 msg = msg[0] |
| 112 | 112 |
| 113 self.assertTrue(msg.IsTranslateable()) | 113 self.assertTrue(msg.IsTranslateable()) |
| 114 self.assertEqual(msg.attrs["desc"], "A string with placeholder.") | 114 self.assertEqual(msg.attrs["desc"], "A string with placeholder.") |
| 115 | 115 |
| 116 def testProductAttribute(self): | |
| 117 grd = self.__ParseAndroidXml([]) | |
| 118 messages = grd.GetChildrenOfType(message.MessageNode) | |
| 119 msg = filter(lambda x: x.GetTextualIds()[0] == | |
| 120 "IDS_SIMPLE_product_nosdcard", | |
| 121 messages) | |
| 122 self.assertTrue(msg) | |
| 123 | |
| 124 def testTranslatableAttribute(self): | 116 def testTranslatableAttribute(self): |
| 125 grd = self.__ParseAndroidXml([]) | 117 grd = self.__ParseAndroidXml([]) |
| 126 messages = grd.GetChildrenOfType(message.MessageNode) | 118 messages = grd.GetChildrenOfType(message.MessageNode) |
| 127 msgs = filter(lambda x: x.GetTextualIds()[0] == "IDS_CONSTANT", messages) | 119 msgs = filter(lambda x: x.GetTextualIds()[0] == "IDS_CONSTANT", messages) |
| 128 self.assertTrue(msgs) | 120 self.assertTrue(msgs) |
| 129 self.assertFalse(msgs[0].IsTranslateable()) | 121 self.assertFalse(msgs[0].IsTranslateable()) |
| 130 | 122 |
| 131 def testTranslations(self): | 123 def testTranslations(self): |
| 132 grd = self.__ParseAndroidXml(['--languages', 'en-US,en-GB,ru,id']) | 124 grd = self.__ParseAndroidXml(['--languages', 'en-US,en-GB,ru,id']) |
| 133 | 125 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 self.assertTrue(us_rc) | 171 self.assertTrue(us_rc) |
| 180 self.assertTrue(us_xml) | 172 self.assertTrue(us_xml) |
| 181 self.assertEqual(util.normpath(us_rc[0].GetFilename()), | 173 self.assertEqual(util.normpath(us_rc[0].GetFilename()), |
| 182 util.normpath('rc/dir/chrome_android_strings_en-US.rc')) | 174 util.normpath('rc/dir/chrome_android_strings_en-US.rc')) |
| 183 self.assertEqual(util.normpath(us_xml[0].GetFilename()), | 175 self.assertEqual(util.normpath(us_xml[0].GetFilename()), |
| 184 util.normpath('xml/dir/values-en-rUS/strings.xml')) | 176 util.normpath('xml/dir/values-en-rUS/strings.xml')) |
| 185 | 177 |
| 186 | 178 |
| 187 if __name__ == '__main__': | 179 if __name__ == '__main__': |
| 188 unittest.main() | 180 unittest.main() |
| OLD | NEW |