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

Unified Diff: tools/grit/grit/format/gen_predetermined_ids_unittest.py

Issue 2696303003: Add a script to GRIT to generate predetermined resource ids file. (Closed)
Patch Set: Address comments. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/grit/grit/format/gen_predetermined_ids.py ('k') | tools/gritsettings/README.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/grit/grit/format/gen_predetermined_ids_unittest.py
diff --git a/tools/grit/grit/format/gen_predetermined_ids_unittest.py b/tools/grit/grit/format/gen_predetermined_ids_unittest.py
new file mode 100755
index 0000000000000000000000000000000000000000..472a09d331fc18c7a520ac021c4131df134ea9dc
--- /dev/null
+++ b/tools/grit/grit/format/gen_predetermined_ids_unittest.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+'''Unit tests for the gen_predetermined_ids module.'''
+
+import os
+import sys
+if __name__ == '__main__':
+ sys.path.append(os.path.join(os.path.dirname(__file__), '../..'))
+
+import StringIO
+import unittest
+
+from grit.format import gen_predetermined_ids
+
+class GenPredeterminedIdsUnittest(unittest.TestCase):
+ def testGenerateResourceMapping(self):
+ original_resources = {200: 'A', 201: 'B', 300: 'C', 350: 'D', 370: 'E'}
+ ordered_resource_ids = [300, 201, 370]
+ mapping = gen_predetermined_ids.GenerateResourceMapping(
+ original_resources, ordered_resource_ids)
+ self.assertEqual({101: 'C', 102: 'B', 103: 'E'}, mapping)
+
+ def testReadResourceIdsFromFile(self):
+ f = StringIO.StringIO('''
+// This file is automatically generated by GRIT. Do not edit.
+
+#pragma once
+
+#define IDS_BOOKMARKS_NO_ITEMS 12500
+#define IDS_BOOKMARK_BAR_IMPORT_LINK _Pragma("whitelisted_resource_12501") 12501
+#define IDS_BOOKMARK_X __pragma(message("whitelisted_resource_12502")) 12502
+''')
+ resources = {}
+ gen_predetermined_ids.ReadResourceIdsFromFile(f, resources)
+ self.assertEqual({12500: 'IDS_BOOKMARKS_NO_ITEMS',
+ 12501: 'IDS_BOOKMARK_BAR_IMPORT_LINK',
+ 12502: 'IDS_BOOKMARK_X'}, resources)
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « tools/grit/grit/format/gen_predetermined_ids.py ('k') | tools/gritsettings/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698