OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 '''Unit tests for <structure> nodes. | 6 '''Unit tests for <structure> nodes. |
7 ''' | 7 ''' |
8 | 8 |
9 import os | 9 import os |
10 import os.path | 10 import os.path |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 self.failUnless(node.RunCommandOnCurrentPlatform()) | 42 self.failUnless(node.RunCommandOnCurrentPlatform()) |
43 node.attrs['run_command_on_platforms'] = 'Nosuch' | 43 node.attrs['run_command_on_platforms'] = 'Nosuch' |
44 self.failIf(node.RunCommandOnCurrentPlatform()) | 44 self.failIf(node.RunCommandOnCurrentPlatform()) |
45 node.attrs['run_command_on_platforms'] = ( | 45 node.attrs['run_command_on_platforms'] = ( |
46 'Nosuch,%s,Othernot' % platform.system()) | 46 'Nosuch,%s,Othernot' % platform.system()) |
47 self.failUnless(node.RunCommandOnCurrentPlatform()) | 47 self.failUnless(node.RunCommandOnCurrentPlatform()) |
48 | 48 |
49 def testVariables(self): | 49 def testVariables(self): |
50 grd = util.ParseGrdForUnittest(''' | 50 grd = util.ParseGrdForUnittest(''' |
51 <structures> | 51 <structures> |
52 <structure type="chrome_html" name="hello_tmpl" file="structure_variab
les.html" expand_variables="true" variables="GREETING=Hello,THINGS=foo,, bar,, b
az,EQUATION=2+2==4"></structure> | 52 <structure type="chrome_html" name="hello_tmpl" file="structure_variab
les.html" expand_variables="true" variables="GREETING=Hello,THINGS=foo,, bar,, b
az,EQUATION=2+2==4,filename=simple" flattenhtml="true"></structure> |
53 </structures>''', base_dir=util.PathFromRoot('grit/testdata')) | 53 </structures>''', base_dir=util.PathFromRoot('grit/testdata')) |
54 grd.SetOutputLanguage('en') | 54 grd.SetOutputLanguage('en') |
55 grd.RunGatherers() | 55 grd.RunGatherers() |
56 node, = grd.GetChildrenOfType(structure.StructureNode) | 56 node, = grd.GetChildrenOfType(structure.StructureNode) |
57 filename = node.Process(tempfile.gettempdir()) | 57 filename = node.Process(tempfile.gettempdir()) |
58 with open(os.path.join(tempfile.gettempdir(), filename)) as f: | 58 with open(os.path.join(tempfile.gettempdir(), filename)) as f: |
59 result = f.read() | 59 result = f.read() |
60 self.failUnless(result == ('<h1>Hello!</h1>\n' | 60 self.failUnlessEqual(('<h1>Hello!</h1>\n' |
61 'Some cool things are foo, bar, baz.\n' | 61 'Some cool things are foo, bar, baz.\n' |
62 'Did you know that 2+2==4?\n')) | 62 'Did you know that 2+2==4?\n' |
| 63 '<p>\n' |
| 64 ' Hello!\n' |
| 65 '</p>\n'), result) |
63 | 66 |
64 | 67 |
65 if __name__ == '__main__': | 68 if __name__ == '__main__': |
66 unittest.main() | 69 unittest.main() |
OLD | NEW |