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 xmb' tool.''' | 6 '''Unit tests for 'grit xmb' tool.''' |
7 | 7 |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 if __name__ == '__main__': | 10 if __name__ == '__main__': |
(...skipping 19 matching lines...) Expand all Loading... |
30 <messages> | 30 <messages> |
31 <message name="GOOD" desc="sub" sub_variable="true"> | 31 <message name="GOOD" desc="sub" sub_variable="true"> |
32 excellent | 32 excellent |
33 </message> | 33 </message> |
34 <message name="IDS_GREETING" desc="Printed to greet the currently lo
gged in user"> | 34 <message name="IDS_GREETING" desc="Printed to greet the currently lo
gged in user"> |
35 Hello <ph name="USERNAME">%s<ex>Joi</ex></ph>, are you doing [GOOD
] today? | 35 Hello <ph name="USERNAME">%s<ex>Joi</ex></ph>, are you doing [GOOD
] today? |
36 </message> | 36 </message> |
37 <message name="IDS_BONGOBINGO"> | 37 <message name="IDS_BONGOBINGO"> |
38 Yibbee | 38 Yibbee |
39 </message> | 39 </message> |
| 40 <message name="IDS_UNICODE"> |
| 41 Ol\xe1, \u4eca\u65e5\u306f! \U0001F60A |
| 42 </message> |
40 </messages> | 43 </messages> |
41 <structures> | 44 <structures> |
42 <structure type="dialog" name="IDD_SPACYBOX" encoding="utf-16" file=
"grit/testdata/klonk.rc" /> | 45 <structure type="dialog" name="IDD_SPACYBOX" encoding="utf-16" file=
"grit/testdata/klonk.rc" /> |
43 </structures> | 46 </structures> |
44 </release> | 47 </release> |
45 </grit>'''), '.') | 48 </grit>'''.encode('utf-8')), '.') |
46 self.xmb_file = StringIO.StringIO() | 49 self.xmb_file = StringIO.StringIO() |
47 | 50 |
48 def testNormalOutput(self): | 51 def testNormalOutput(self): |
49 xmb.OutputXmb().Process(self.res_tree, self.xmb_file) | 52 xmb.OutputXmb().Process(self.res_tree, self.xmb_file) |
50 output = self.xmb_file.getvalue() | 53 output = self.xmb_file.getvalue().decode('utf-8') |
51 self.failUnless(output.count('Joi') and output.count('Yibbee')) | 54 self.failUnless(output.count('Joi')) |
| 55 self.failUnless(output.count('Yibbee')) |
| 56 self.failUnless(output.count(u'Ol\xe1, \u4eca\u65e5\u306f! \U0001F60A')) |
52 | 57 |
53 def testLimitList(self): | 58 def testLimitList(self): |
54 limit_file = StringIO.StringIO( | 59 limit_file = StringIO.StringIO( |
55 'IDS_BONGOBINGO\nIDS_DOES_NOT_EXIST\nIDS_ALSO_DOES_NOT_EXIST') | 60 'IDS_BONGOBINGO\nIDS_DOES_NOT_EXIST\nIDS_ALSO_DOES_NOT_EXIST') |
56 xmb.OutputXmb().Process(self.res_tree, self.xmb_file, limit_file, False) | 61 xmb.OutputXmb().Process(self.res_tree, self.xmb_file, limit_file, False) |
57 output = self.xmb_file.getvalue() | 62 output = self.xmb_file.getvalue() |
58 self.failUnless(output.count('Yibbee')) | 63 self.failUnless(output.count('Yibbee')) |
59 self.failUnless(not output.count('Joi')) | 64 self.failUnless(not output.count('Joi')) |
60 | 65 |
61 def testLimitGrd(self): | 66 def testLimitGrd(self): |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 self.res_tree.SetOutputLanguage('en') | 99 self.res_tree.SetOutputLanguage('en') |
95 os.chdir(util.PathFromRoot('.')) # so it can find klonk.rc | 100 os.chdir(util.PathFromRoot('.')) # so it can find klonk.rc |
96 self.res_tree.RunGatherers() | 101 self.res_tree.RunGatherers() |
97 xmb.OutputXmb().Process(self.res_tree, self.xmb_file) | 102 xmb.OutputXmb().Process(self.res_tree, self.xmb_file) |
98 output = self.xmb_file.getvalue() | 103 output = self.xmb_file.getvalue() |
99 self.failUnless(output.count('OK ? </msg>')) | 104 self.failUnless(output.count('OK ? </msg>')) |
100 | 105 |
101 | 106 |
102 if __name__ == '__main__': | 107 if __name__ == '__main__': |
103 unittest.main() | 108 unittest.main() |
OLD | NEW |