| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 2013 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 tests for include.IncludeNode''' | |
| 7 | |
| 8 import os | |
| 9 import sys | |
| 10 if __name__ == '__main__': | |
| 11 sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) | |
| 12 | |
| 13 import os | |
| 14 import StringIO | |
| 15 import unittest | |
| 16 | |
| 17 from grit.node import misc | |
| 18 from grit.node import include | |
| 19 from grit.node import empty | |
| 20 from grit import grd_reader | |
| 21 from grit import util | |
| 22 | |
| 23 | |
| 24 class IncludeNodeUnittest(unittest.TestCase): | |
| 25 def testGetPath(self): | |
| 26 root = misc.GritNode() | |
| 27 root.StartParsing(u'grit', None) | |
| 28 root.HandleAttribute(u'latest_public_release', u'0') | |
| 29 root.HandleAttribute(u'current_release', u'1') | |
| 30 root.HandleAttribute(u'base_dir', ur'..\resource') | |
| 31 release = misc.ReleaseNode() | |
| 32 release.StartParsing(u'release', root) | |
| 33 release.HandleAttribute(u'seq', u'1') | |
| 34 root.AddChild(release) | |
| 35 includes = empty.IncludesNode() | |
| 36 includes.StartParsing(u'includes', release) | |
| 37 release.AddChild(includes) | |
| 38 include_node = include.IncludeNode() | |
| 39 include_node.StartParsing(u'include', includes) | |
| 40 include_node.HandleAttribute(u'file', ur'flugel\kugel.pdf') | |
| 41 includes.AddChild(include_node) | |
| 42 root.EndParsing() | |
| 43 | |
| 44 self.assertEqual(root.ToRealPath(include_node.GetInputPath()), | |
| 45 util.normpath( | |
| 46 os.path.join(ur'../resource', ur'flugel/kugel.pdf'))) | |
| 47 | |
| 48 def testGetPathNoBasedir(self): | |
| 49 root = misc.GritNode() | |
| 50 root.StartParsing(u'grit', None) | |
| 51 root.HandleAttribute(u'latest_public_release', u'0') | |
| 52 root.HandleAttribute(u'current_release', u'1') | |
| 53 root.HandleAttribute(u'base_dir', ur'..\resource') | |
| 54 release = misc.ReleaseNode() | |
| 55 release.StartParsing(u'release', root) | |
| 56 release.HandleAttribute(u'seq', u'1') | |
| 57 root.AddChild(release) | |
| 58 includes = empty.IncludesNode() | |
| 59 includes.StartParsing(u'includes', release) | |
| 60 release.AddChild(includes) | |
| 61 include_node = include.IncludeNode() | |
| 62 include_node.StartParsing(u'include', includes) | |
| 63 include_node.HandleAttribute(u'file', ur'flugel\kugel.pdf') | |
| 64 include_node.HandleAttribute(u'use_base_dir', u'false') | |
| 65 includes.AddChild(include_node) | |
| 66 root.EndParsing() | |
| 67 | |
| 68 self.assertEqual(root.ToRealPath(include_node.GetInputPath()), | |
| 69 util.normpath( | |
| 70 os.path.join(ur'../', ur'flugel/kugel.pdf'))) | |
| 71 | |
| 72 | |
| 73 if __name__ == '__main__': | |
| 74 unittest.main() | |
| OLD | NEW |