| 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()
|
|
|