| Index: tools/grit/grit/flatten_resource_runner_unittest.py
|
| diff --git a/tools/grit/grit/flatten_resource_runner_unittest.py b/tools/grit/grit/flatten_resource_runner_unittest.py
|
| new file mode 100755
|
| index 0000000000000000000000000000000000000000..360464797a16974989606d295ee02c416bd9c416
|
| --- /dev/null
|
| +++ b/tools/grit/grit/flatten_resource_runner_unittest.py
|
| @@ -0,0 +1,47 @@
|
| +#!/usr/bin/env python
|
| +# Copyright 2016 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.
|
| +
|
| +import os
|
| +import sys
|
| +if __name__ == '__main__':
|
| + sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
| +
|
| +import unittest
|
| +import tempfile
|
| +
|
| +from grit import flatten_resource_runner
|
| +
|
| +
|
| +class FlattenResourceRunnerUnitest(unittest.TestCase):
|
| +
|
| + def testIf(self):
|
| + '''Tests that a -D option is correctly handled'''
|
| + with tempfile.NamedTemporaryFile() as input_file,\
|
| + tempfile.NamedTemporaryFile() as output_file:
|
| + input_file.write('Hello <if expr="T1==1"> good</if>'
|
| + '<if expr="T2==2"> bad</if> test')
|
| + input_file.seek(0)
|
| + flatten_resource_runner.Main(['-DT1=1',
|
| + input_file.name,
|
| + output_file.name])
|
| + self.failUnlessEqual('Hello good test', output_file.read())
|
| + pass
|
| +
|
| + def testInclude(self):
|
| + '''Tests that an include is correctly handled'''
|
| + with tempfile.NamedTemporaryFile() as input_file,\
|
| + tempfile.NamedTemporaryFile() as output_file,\
|
| + tempfile.NamedTemporaryFile() as include_file:
|
| + input_file.write('<include src="' + include_file.name + '">')
|
| + input_file.seek(0)
|
| + include_file.write('Hello included')
|
| + include_file.seek(0)
|
| + flatten_resource_runner.Main([input_file.name, output_file.name])
|
| + self.failUnlessEqual('Hello included', output_file.read())
|
| + pass
|
| +
|
| +
|
| +if __name__ == '__main__':
|
| + unittest.main()
|
|
|