Index: grit/format/resource_map_unittest.py |
diff --git a/grit/format/resource_map_unittest.py b/grit/format/resource_map_unittest.py |
index ea3446584747684b95941a2b21171d8a757e053c..4b3b424be7d5b39a18652f4f98ac2cd1314eec4e 100644 |
--- a/grit/format/resource_map_unittest.py |
+++ b/grit/format/resource_map_unittest.py |
@@ -94,6 +94,63 @@ const GritResourceMap kTheRcHeader[] = { |
}; |
const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output) |
+ def testFormatStringResourceMap(self): |
+ grd = grd_reader.Parse(StringIO.StringIO( |
+ '''<?xml version="1.0" encoding="UTF-8"?> |
+ <grit latest_public_release="2" source_lang_id="en" current_release="3" |
+ base_dir="."> |
+ <outputs> |
+ <output type="rc_header" filename="the_rc_header" /> |
tony
2013/08/13 17:21:22
Nit: Please change the filename to have a .h exten
|
+ <output type="resource_map_header" filename="the_rc_map_header.h" /> |
+ <output type="resource_map_source" filename="the_rc_map_source.h" /> |
tony
2013/08/13 17:21:22
Nit: Please change the map source to have a .cc ex
|
+ </outputs> |
+ <release seq="1" allow_pseudo="false"> |
+ <messages fallback_to_english="true"> |
+ <message name="IDS_PRODUCT_NAME" desc="The application name"> |
+ Application |
+ </message> |
+ <if expr="1"> |
+ <message name="IDS_DEFAULT_TAB_TITLE_TITLE_CASE" |
+ desc="In Title Case: The default title in a tab."> |
+ New Tab |
+ </message> |
+ </if> |
+ <if expr="0"> |
+ <message name="IDS_DEFAULT_TAB_TITLE" |
+ desc="The default title in a tab."> |
+ New tab |
+ </message> |
+ </if> |
+ </messages> |
+ </release> |
+ </grit>'''), util.PathFromRoot('.')) |
+ grd.SetOutputLanguage('en') |
+ grd.RunGatherers() |
+ output = util.StripBlankLinesAndComments(''.join( |
+ resource_map.GetFormatter('resource_map_header')(grd, 'en', '.'))) |
+ self.assertEqual('''\ |
+#include <stddef.h> |
+#ifndef GRIT_RESOURCE_MAP_STRUCT_ |
+#define GRIT_RESOURCE_MAP_STRUCT_ |
+struct GritResourceMap { |
+ const char* const name; |
+ int value; |
+}; |
+#endif // GRIT_RESOURCE_MAP_STRUCT_ |
+extern const GritResourceMap kTheRcHeader[]; |
+extern const size_t kTheRcHeaderSize;''', output) |
+ output = util.StripBlankLinesAndComments(''.join( |
+ resource_map.GetFormatter('resource_map_source')(grd, 'en', '.'))) |
+ self.assertEqual('''\ |
+#include "the_rc_map_header.h" |
+#include "base/basictypes.h" |
+#include "the_rc_header" |
+const GritResourceMap kTheRcHeader[] = { |
+ {"IDS_PRODUCT_NAME", IDS_PRODUCT_NAME}, |
+ {"IDS_DEFAULT_TAB_TITLE_TITLE_CASE", IDS_DEFAULT_TAB_TITLE_TITLE_CASE}, |
+}; |
+const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output) |
+ |
if __name__ == '__main__': |
unittest.main() |