| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 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 | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 '''Unit test that checks preprocessing of files. | |
| 7 Tests preprocessing by adding having the preprocessor | |
| 8 provide the actual rctext data. | |
| 9 ''' | |
| 10 | |
| 11 import os | |
| 12 import sys | |
| 13 if __name__ == '__main__': | |
| 14 sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) | |
| 15 | |
| 16 import unittest | |
| 17 | |
| 18 import grit.tool.preprocess_interface | |
| 19 from grit.tool import rc2grd | |
| 20 | |
| 21 | |
| 22 class PreProcessingUnittest(unittest.TestCase): | |
| 23 | |
| 24 def testPreProcessing(self): | |
| 25 tool = rc2grd.Rc2Grd() | |
| 26 class DummyOpts(object): | |
| 27 verbose = False | |
| 28 extra_verbose = False | |
| 29 tool.o = DummyOpts() | |
| 30 tool.pre_process = 'grit.tool.preprocess_unittest.DummyPreProcessor' | |
| 31 result = tool.Process('', '.\resource.rc') | |
| 32 | |
| 33 self.failUnless( | |
| 34 result.children[2].children[2].children[0].attrs['name'] == 'DUMMY_STRING_
1') | |
| 35 | |
| 36 class DummyPreProcessor(grit.tool.preprocess_interface.PreProcessor): | |
| 37 def Process(self, rctext, rcpath): | |
| 38 rctext = '''STRINGTABLE | |
| 39 BEGIN | |
| 40 DUMMY_STRING_1 "String 1" | |
| 41 // Some random description | |
| 42 DUMMY_STRING_2 "This text was added during preprocessing" | |
| 43 END | |
| 44 ''' | |
| 45 return rctext | |
| 46 | |
| 47 if __name__ == '__main__': | |
| 48 unittest.main() | |
| 49 | |
| OLD | NEW |