Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: grit/format/resource_map_unittest.py

Issue 444053003: Respect output_all_resource_defines when generating resource maps. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« grit/format/resource_map.py ('K') | « grit/format/resource_map.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 const GritResourceMap kTheRcHeader[] = { 87 const GritResourceMap kTheRcHeader[] = {
88 {"grit/testdata/klonk.rc", IDC_KLONKMENU}, 88 {"grit/testdata/klonk.rc", IDC_KLONKMENU},
89 {"abc", IDS_FIRSTPRESENT}, 89 {"abc", IDS_FIRSTPRESENT},
90 {"def", IDS_MISSING}, 90 {"def", IDS_MISSING},
91 {"ghi", IDS_LANGUAGESPECIFIC}, 91 {"ghi", IDS_LANGUAGESPECIFIC},
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 testFormatResourceMapOutputAllEqualsFalse(self):
98 grd = grd_reader.Parse(StringIO.StringIO(
99 '''<?xml version="1.0" encoding="UTF-8"?>
100 <grit latest_public_release="2" source_lang_id="en" current_release="3"
101 base_dir="." output_all_resource_defines="false">
102 <outputs>
103 <output type="rc_header" filename="the_rc_header.h" />
104 <output type="resource_map_header"
105 filename="the_resource_map_header.h" />
106 </outputs>
107 <release seq="3">
108 <structures first_id="300">
109 <structure type="menu" name="IDC_KLONKMENU"
110 file="grit\\testdata\\klonk.rc" encoding="utf-16" />
111 <if expr="False">
112 <structure type="menu" name="IDC_MISSING"
113 file="grit\\testdata\\source.rc" encoding="utf-16" />
114 </if>
115 </structures>
116 </release>
117 </grit>'''), util.PathFromRoot('.'))
118 grd.SetOutputLanguage('en')
119 grd.RunGatherers()
120 output = util.StripBlankLinesAndComments(''.join(
121 resource_map.GetFormatter('resource_map_header')(grd, 'en', '.')))
122 self.assertEqual('''\
123 #include <stddef.h>
124 #ifndef GRIT_RESOURCE_MAP_STRUCT_
125 #define GRIT_RESOURCE_MAP_STRUCT_
126 struct GritResourceMap {
127 const char* const name;
128 int value;
129 };
130 #endif // GRIT_RESOURCE_MAP_STRUCT_
131 extern const GritResourceMap kTheRcHeader[];
132 extern const size_t kTheRcHeaderSize;''', output)
133 output = util.StripBlankLinesAndComments(''.join(
134 resource_map.GetFormatter('resource_map_source')(grd, 'en', '.')))
135 self.assertEqual('''\
136 #include "the_resource_map_header.h"
137 #include "base/basictypes.h"
138 #include "the_rc_header.h"
139 const GritResourceMap kTheRcHeader[] = {
140 {"IDC_KLONKMENU", IDC_KLONKMENU},
141 };
142 const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output)
143 output = util.StripBlankLinesAndComments(''.join(
144 resource_map.GetFormatter('resource_file_map_source')(grd, 'en', '.')))
145 self.assertEqual('''\
146 #include "the_resource_map_header.h"
147 #include "base/basictypes.h"
148 #include "the_rc_header.h"
149 const GritResourceMap kTheRcHeader[] = {
150 {"grit/testdata/klonk.rc", IDC_KLONKMENU},
151 };
152 const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output)
153
97 def testFormatStringResourceMap(self): 154 def testFormatStringResourceMap(self):
98 grd = grd_reader.Parse(StringIO.StringIO( 155 grd = grd_reader.Parse(StringIO.StringIO(
99 '''<?xml version="1.0" encoding="UTF-8"?> 156 '''<?xml version="1.0" encoding="UTF-8"?>
100 <grit latest_public_release="2" source_lang_id="en" current_release="3" 157 <grit latest_public_release="2" source_lang_id="en" current_release="3"
101 base_dir="."> 158 base_dir=".">
102 <outputs> 159 <outputs>
103 <output type="rc_header" filename="the_rc_header.h" /> 160 <output type="rc_header" filename="the_rc_header.h" />
104 <output type="resource_map_header" filename="the_rc_map_header.h" /> 161 <output type="resource_map_header" filename="the_rc_map_header.h" />
105 <output type="resource_map_source" filename="the_rc_map_source.cc" /> 162 <output type="resource_map_source" filename="the_rc_map_source.cc" />
106 </outputs> 163 </outputs>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 #include "the_rc_header.h" 204 #include "the_rc_header.h"
148 const GritResourceMap kTheRcHeader[] = { 205 const GritResourceMap kTheRcHeader[] = {
149 {"IDS_PRODUCT_NAME", IDS_PRODUCT_NAME}, 206 {"IDS_PRODUCT_NAME", IDS_PRODUCT_NAME},
150 {"IDS_DEFAULT_TAB_TITLE_TITLE_CASE", IDS_DEFAULT_TAB_TITLE_TITLE_CASE}, 207 {"IDS_DEFAULT_TAB_TITLE_TITLE_CASE", IDS_DEFAULT_TAB_TITLE_TITLE_CASE},
151 }; 208 };
152 const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output) 209 const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output)
153 210
154 211
155 if __name__ == '__main__': 212 if __name__ == '__main__':
156 unittest.main() 213 unittest.main()
OLDNEW
« grit/format/resource_map.py ('K') | « grit/format/resource_map.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698