| Index: tools/grit/grit/format/rc_unittest.py
|
| ===================================================================
|
| --- tools/grit/grit/format/rc_unittest.py (revision 51538)
|
| +++ tools/grit/grit/format/rc_unittest.py (working copy)
|
| @@ -21,15 +21,16 @@
|
| from grit.tool import build
|
|
|
| class DummyOutput(object):
|
| - def __init__(self, type, language):
|
| + def __init__(self, type, language, file = 'hello.gif'):
|
| self.type = type
|
| self.language = language
|
| + self.file = file
|
| def GetType(self):
|
| return self.type
|
| def GetLanguage(self):
|
| return self.language
|
| def GetOutputFilename(self):
|
| - return 'hello.gif'
|
| + return self.file
|
|
|
| class FormatRcUnittest(unittest.TestCase):
|
| def testMessages(self):
|
| @@ -78,7 +79,7 @@
|
| build.RcBuilder.ProcessNode(root, DummyOutput('rc_all', 'en'), buf)
|
| output = buf.getvalue()
|
| self.failUnless(output.strip() == u'''
|
| -IDC_KLONKMENU MENU
|
| +IDC_KLONKMENU MENU
|
| BEGIN
|
| POPUP "&File"
|
| BEGIN
|
| @@ -181,7 +182,39 @@
|
| output = re.sub('"[c-zC-Z]:', '"', output)
|
| self.failUnless(output.strip() == expected)
|
|
|
| + def testRcIncludeFlattenedHtmlFile(self):
|
| + input_file = util.PathFromRoot('grit/test/data/include_test.html')
|
| + output_file = '%s/include_test.html' % tempfile.gettempdir()
|
| + root = grd_reader.Parse(StringIO.StringIO('''
|
| + <includes>
|
| + <include name="HTML_FILE1" flattenhtml="true" file="%s" type="BINDATA" />
|
| + </includes>''' % input_file), flexible_root = True)
|
| + util.FixRootForUnittest(root, tempfile.gettempdir())
|
|
|
| + buf = StringIO.StringIO()
|
| + build.RcBuilder.ProcessNode(root, DummyOutput('rc_all', 'en', output_file),
|
| + buf)
|
| + output = buf.getvalue()
|
| +
|
| + expected = u'HTML_FILE1 BINDATA "include_test.html"'
|
| + # hackety hack to work on win32&lin
|
| + output = re.sub('"[c-zC-Z]:', '"', output)
|
| + self.failUnless(output.strip() == expected)
|
| +
|
| + fo = file(output_file)
|
| + file_contents = fo.read()
|
| + fo.close()
|
| +
|
| + # Check for the content added by the <include> tag.
|
| + self.failUnless(file_contents.find('Hello Include!') != -1)
|
| + # Check for the content that was removed by if tag.
|
| + self.failUnless(file_contents.find('This should not be here anymore') == -1)
|
| + # Check for the content that was kept in place by if.
|
| + self.failUnless(file_contents.find('should be kept') != -1)
|
| + self.failUnless(file_contents.find('in the middle...') != -1)
|
| + self.failUnless(file_contents.find('at the end...') != -1)
|
| +
|
| +
|
| def testStructureNodeOutputfile(self):
|
| input_file = util.PathFromRoot('grit/test/data/simple.html')
|
| root = grd_reader.Parse(StringIO.StringIO(
|
|
|