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.format.resource_map''' | 6 '''Unit tests for grit.format.resource_map''' |
7 | 7 |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 if __name__ == '__main__': | 10 if __name__ == '__main__': |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 extern const size_t kTheRcHeaderSize;''', output) | 66 extern const size_t kTheRcHeaderSize;''', output) |
67 output = util.StripBlankLinesAndComments(''.join( | 67 output = util.StripBlankLinesAndComments(''.join( |
68 resource_map.GetFormatter('resource_map_source')(grd, 'en', '.'))) | 68 resource_map.GetFormatter('resource_map_source')(grd, 'en', '.'))) |
69 self.assertEqual('''\ | 69 self.assertEqual('''\ |
70 #include "the_resource_map_header.h" | 70 #include "the_resource_map_header.h" |
71 #include "base/basictypes.h" | 71 #include "base/basictypes.h" |
72 #include "the_rc_header.h" | 72 #include "the_rc_header.h" |
73 const GritResourceMap kTheRcHeader[] = { | 73 const GritResourceMap kTheRcHeader[] = { |
74 {"IDC_KLONKMENU", IDC_KLONKMENU}, | 74 {"IDC_KLONKMENU", IDC_KLONKMENU}, |
75 {"IDS_FIRSTPRESENT", IDS_FIRSTPRESENT}, | 75 {"IDS_FIRSTPRESENT", IDS_FIRSTPRESENT}, |
| 76 {"IDS_LANGUAGESPECIFIC", IDS_LANGUAGESPECIFIC}, |
76 {"IDS_MISSING", IDS_MISSING}, | 77 {"IDS_MISSING", IDS_MISSING}, |
77 {"IDS_LANGUAGESPECIFIC", IDS_LANGUAGESPECIFIC}, | |
78 {"IDS_THIRDPRESENT", IDS_THIRDPRESENT}, | 78 {"IDS_THIRDPRESENT", IDS_THIRDPRESENT}, |
79 }; | 79 }; |
80 const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output) | 80 const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output) |
81 output = util.StripBlankLinesAndComments(''.join( | 81 output = util.StripBlankLinesAndComments(''.join( |
82 resource_map.GetFormatter('resource_file_map_source')(grd, 'en', '.'))) | 82 resource_map.GetFormatter('resource_file_map_source')(grd, 'en', '.'))) |
83 self.assertEqual('''\ | 83 self.assertEqual('''\ |
84 #include "the_resource_map_header.h" | 84 #include "the_resource_map_header.h" |
85 #include "base/basictypes.h" | 85 #include "base/basictypes.h" |
86 #include "the_rc_header.h" | 86 #include "the_rc_header.h" |
87 const GritResourceMap kTheRcHeader[] = { | 87 const GritResourceMap kTheRcHeader[] = { |
88 {"grit/testdata/klonk.rc", IDC_KLONKMENU}, | |
89 {"abc", IDS_FIRSTPRESENT}, | 88 {"abc", IDS_FIRSTPRESENT}, |
90 {"def", IDS_MISSING}, | 89 {"def", IDS_MISSING}, |
91 {"ghi", IDS_LANGUAGESPECIFIC}, | 90 {"ghi", IDS_LANGUAGESPECIFIC}, |
| 91 {"grit/testdata/klonk.rc", IDC_KLONKMENU}, |
92 {"jkl", IDS_LANGUAGESPECIFIC}, | 92 {"jkl", IDS_LANGUAGESPECIFIC}, |
93 {"mno", IDS_THIRDPRESENT}, | 93 {"mno", IDS_THIRDPRESENT}, |
94 }; | 94 }; |
95 const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output) | 95 const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output) |
96 | 96 |
97 def testFormatResourceMapWithOutputAllEqualsFalseForStructures(self): | 97 def testFormatResourceMapWithOutputAllEqualsFalseForStructures(self): |
98 grd = grd_reader.Parse(StringIO.StringIO( | 98 grd = grd_reader.Parse(StringIO.StringIO( |
99 '''<?xml version="1.0" encoding="UTF-8"?> | 99 '''<?xml version="1.0" encoding="UTF-8"?> |
100 <grit latest_public_release="2" source_lang_id="en" current_release="3" | 100 <grit latest_public_release="2" source_lang_id="en" current_release="3" |
101 base_dir="." output_all_resource_defines="false"> | 101 base_dir="." output_all_resource_defines="false"> |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 {"IDS_THIRDPRESENT", IDS_THIRDPRESENT}, | 204 {"IDS_THIRDPRESENT", IDS_THIRDPRESENT}, |
205 }; | 205 }; |
206 const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output) | 206 const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output) |
207 output = util.StripBlankLinesAndComments(''.join( | 207 output = util.StripBlankLinesAndComments(''.join( |
208 resource_map.GetFormatter('resource_file_map_source')(grd, 'en', '.'))) | 208 resource_map.GetFormatter('resource_file_map_source')(grd, 'en', '.'))) |
209 self.assertEqual('''\ | 209 self.assertEqual('''\ |
210 #include "the_resource_map_header.h" | 210 #include "the_resource_map_header.h" |
211 #include "base/basictypes.h" | 211 #include "base/basictypes.h" |
212 #include "the_rc_header.h" | 212 #include "the_rc_header.h" |
213 const GritResourceMap kTheRcHeader[] = { | 213 const GritResourceMap kTheRcHeader[] = { |
| 214 {"abc", IDS_FIRSTPRESENT}, |
214 {"grit/testdata/klonk.rc", IDC_KLONKMENU}, | 215 {"grit/testdata/klonk.rc", IDC_KLONKMENU}, |
215 {"abc", IDS_FIRSTPRESENT}, | |
216 {"mno", IDS_THIRDPRESENT}, | 216 {"mno", IDS_THIRDPRESENT}, |
217 }; | 217 }; |
218 const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output) | 218 const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output) |
219 | 219 |
220 def testFormatStringResourceMap(self): | 220 def testFormatStringResourceMap(self): |
221 grd = grd_reader.Parse(StringIO.StringIO( | 221 grd = grd_reader.Parse(StringIO.StringIO( |
222 '''<?xml version="1.0" encoding="UTF-8"?> | 222 '''<?xml version="1.0" encoding="UTF-8"?> |
223 <grit latest_public_release="2" source_lang_id="en" current_release="3" | 223 <grit latest_public_release="2" source_lang_id="en" current_release="3" |
224 base_dir="."> | 224 base_dir="."> |
225 <outputs> | 225 <outputs> |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 #endif // GRIT_RESOURCE_MAP_STRUCT_ | 262 #endif // GRIT_RESOURCE_MAP_STRUCT_ |
263 extern const GritResourceMap kTheRcHeader[]; | 263 extern const GritResourceMap kTheRcHeader[]; |
264 extern const size_t kTheRcHeaderSize;''', output) | 264 extern const size_t kTheRcHeaderSize;''', output) |
265 output = util.StripBlankLinesAndComments(''.join( | 265 output = util.StripBlankLinesAndComments(''.join( |
266 resource_map.GetFormatter('resource_map_source')(grd, 'en', '.'))) | 266 resource_map.GetFormatter('resource_map_source')(grd, 'en', '.'))) |
267 self.assertEqual('''\ | 267 self.assertEqual('''\ |
268 #include "the_rc_map_header.h" | 268 #include "the_rc_map_header.h" |
269 #include "base/basictypes.h" | 269 #include "base/basictypes.h" |
270 #include "the_rc_header.h" | 270 #include "the_rc_header.h" |
271 const GritResourceMap kTheRcHeader[] = { | 271 const GritResourceMap kTheRcHeader[] = { |
| 272 {"IDS_DEFAULT_TAB_TITLE_TITLE_CASE", IDS_DEFAULT_TAB_TITLE_TITLE_CASE}, |
272 {"IDS_PRODUCT_NAME", IDS_PRODUCT_NAME}, | 273 {"IDS_PRODUCT_NAME", IDS_PRODUCT_NAME}, |
273 {"IDS_DEFAULT_TAB_TITLE_TITLE_CASE", IDS_DEFAULT_TAB_TITLE_TITLE_CASE}, | |
274 }; | 274 }; |
275 const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output) | 275 const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output) |
276 | 276 |
277 | 277 |
278 if __name__ == '__main__': | 278 if __name__ == '__main__': |
279 unittest.main() | 279 unittest.main() |
OLD | NEW |