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 """Unittest for chrome_messages_json.py. | 6 """Unittest for chrome_messages_json.py. |
7 """ | 7 """ |
8 | 8 |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 \\ | 42 \\ |
43 </message> | 43 </message> |
44 </messages> | 44 </messages> |
45 """) | 45 """) |
46 | 46 |
47 buf = StringIO.StringIO() | 47 buf = StringIO.StringIO() |
48 build.RcBuilder.ProcessNode(root, DummyOutput('chrome_messages_json', 'en'),
buf) | 48 build.RcBuilder.ProcessNode(root, DummyOutput('chrome_messages_json', 'en'),
buf) |
49 output = buf.getvalue() | 49 output = buf.getvalue() |
50 test = u""" | 50 test = u""" |
51 { | 51 { |
52 "IDS_SIMPLE_MESSAGE": { | 52 "SIMPLE_MESSAGE": { |
53 "message": "Simple message." | 53 "message": "Simple message." |
54 }, | 54 }, |
55 "IDS_QUOTES": { | 55 "QUOTES": { |
56 "message": "element\\u2019s \\u201c%s\\u201d attribute" | 56 "message": "element\\u2019s \\u201c%s\\u201d attribute" |
57 }, | 57 }, |
58 "IDS_PLACEHOLDERS": { | 58 "PLACEHOLDERS": { |
59 "message": "%1$d error, %2$d warning" | 59 "message": "%1$d error, %2$d warning" |
60 }, | 60 }, |
61 "IDS_STARTS_WITH_SPACE": { | 61 "STARTS_WITH_SPACE": { |
62 "message": "(%d)" | 62 "message": "(%d)" |
63 }, | 63 }, |
64 "IDS_DOUBLE_QUOTES": { | 64 "DOUBLE_QUOTES": { |
65 "message": "A \\"double quoted\\" message." | 65 "message": "A \\"double quoted\\" message." |
66 }, | 66 }, |
67 "IDS_BACKSLASH": { | 67 "BACKSLASH": { |
68 "message": "\\\\" | 68 "message": "\\\\" |
69 } | 69 } |
70 } | 70 } |
71 """ | 71 """ |
72 self.assertEqual(test.strip(), output.strip()) | 72 self.assertEqual(test.strip(), output.strip()) |
73 | 73 |
74 def testTranslations(self): | 74 def testTranslations(self): |
75 root = util.ParseGrdForUnittest(""" | 75 root = util.ParseGrdForUnittest(""" |
76 <messages> | 76 <messages> |
77 <message name="ID_HELLO">Hello!</message> | 77 <message name="ID_HELLO">Hello!</message> |
(...skipping 29 matching lines...) Expand all Loading... |
107 | 107 |
108 def GetLanguage(self): | 108 def GetLanguage(self): |
109 return self.language | 109 return self.language |
110 | 110 |
111 def GetOutputFilename(self): | 111 def GetOutputFilename(self): |
112 return 'hello.gif' | 112 return 'hello.gif' |
113 | 113 |
114 | 114 |
115 if __name__ == '__main__': | 115 if __name__ == '__main__': |
116 unittest.main() | 116 unittest.main() |
OLD | NEW |