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

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

Issue 2872028: Modified grit to support <if expr="..."> tags within included html files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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/rc.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(
« no previous file with comments | « tools/grit/grit/format/rc.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698