/[escript]/trunk/pyvisi/test/python/test_renderer.py
ViewVC logotype

Contents of /trunk/pyvisi/test/python/test_renderer.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 637 - (show annotations)
Thu Mar 23 10:55:31 2006 UTC (14 years, 8 months ago) by gross
File MIME type: text/x-python
File size: 6639 byte(s)
more copyright statements added
1 """
2 Class and functions for testing the Renderer class
3
4 @var __author__: name of author
5 @var __license__: licence agreement
6 @var __copyright__: copyrights
7 @var __url__: url entry point on documentation
8 @var __version__: version
9 @var __date__: date of the version
10 """
11
12 __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
13 http://www.access.edu.au
14 Primary Business: Queensland, Australia"""
15 __license__="""Licensed under the Open Software License version 3.0
16 http://www.opensource.org/licenses/osl-3.0.php"""
17 __author__="Paul Cochrane"
18 __url__="http://www.iservo.edu.au/esys"
19 __version__="$Revision$"
20 __date__="$Date$"
21
22
23 import unittest
24 import sys,os
25 from string import *
26 here = os.getcwd() + '/../../'
27 sys.path.append(here)
28 import pyvisi # this should import all of the pyvisi stuff needed
29
30 class TestRenderer(unittest.TestCase):
31 """
32 Test the renderer object at the base pyvisi level
33 """
34
35 def setUp(self):
36 self.ren = pyvisi.Renderer()
37
38 def testInit(self):
39 """
40 Tests initialisation of the Renderer object
41 """
42 classStr = self.ren.__class__.__name__
43 self.assertEqual('Renderer', classStr)
44
45 def testExactlyOneArgument(self):
46 """
47 Check that method only accepts one argument
48 """
49 # check setRenderWindowHeight
50 self.assertRaises(TypeError, self.ren.setRenderWindowHeight)
51 self.assertRaises(TypeError, self.ren.setRenderWindowHeight, 10, 20)
52
53 # check setRenderWindowWidth
54 self.assertRaises(TypeError, self.ren.setRenderWindowWidth)
55 self.assertRaises(TypeError, self.ren.setRenderWindowWidth, 10, 20)
56
57 # check addToEvalStack
58 self.assertRaises(TypeError, self.ren.addToEvalStack)
59 self.assertRaises(TypeError, self.ren.addToEvalStack, "moo", "baa")
60
61 # check addToInitStack
62 self.assertRaises(TypeError, self.ren.addToInitStack)
63 self.assertRaises(TypeError, self.ren.addToInitStack, "moo", "baa")
64
65 def testExactlyTwoArguments(self):
66 """
67 Check that method only accepts two arguments
68 """
69 self.assertRaises(TypeError, \
70 self.ren.setRenderWindowDimensions)
71 self.assertRaises(TypeError, \
72 self.ren.setRenderWindowDimensions, 12)
73 self.assertRaises(TypeError, \
74 self.ren.setRenderWindowDimensions, 12, 14, 16)
75
76 def testRenderWindowDefaultDims(self):
77 """
78 Check render window default width and height
79 """
80 self.assertEqual(640, self.ren.renderWindowWidth) # width
81 self.assertEqual(480, self.ren.renderWindowHeight) # height
82
83 def testGetRenderWindowWidth(self):
84 """
85 Check getting the render window width
86 """
87 width = self.ren.getRenderWindowWidth()
88 self.assertEqual(self.ren.renderWindowWidth, width)
89
90 def testSetRenderWindowWidth(self):
91 """
92 Test setting the render window width
93 """
94 width = 720
95 self.ren.setRenderWindowWidth(width)
96 self.assertEqual(self.ren.getRenderWindowWidth(), width)
97
98 def testGetRenderWindowHeight(self):
99 """
100 Check getting the render window height
101 """
102 height = self.ren.getRenderWindowHeight()
103 self.assertEqual(self.ren.renderWindowHeight, height)
104
105 def testSetRenderWindowHeight(self):
106 """
107 Test setting the render window height
108 """
109 height = 593
110 self.ren.setRenderWindowHeight(height)
111 self.assertEqual(self.ren.getRenderWindowHeight(), height)
112
113 def testGetRenderWindowDimensions(self):
114 """
115 Test getting the render window width and height
116 """
117 (width, height) = self.ren.getRenderWindowDimensions()
118 self.assertEqual((640,480), (width, height))
119
120 def testSetRenderWindowDimensions(self):
121 """
122 Test setting the render window width and height
123 """
124 width = 123
125 height = 456
126 self.ren.setRenderWindowDimensions(width, height)
127 self.assertEqual(self.ren.getRenderWindowDimensions(), (width,height))
128
129 def testIntegerArgsToSet(self):
130 """
131 Test setting of integer arguments
132 """
133 self.assertRaises(AssertionError, \
134 self.ren.setRenderWindowWidth, "moo")
135 self.assertRaises(AssertionError, \
136 self.ren.setRenderWindowHeight, "moo")
137 self.assertRaises(AssertionError, \
138 self.ren.setRenderWindowDimensions, "moo", "baa")
139
140 def testStringArgsToSet(self):
141 """
142 Test setting of string arguments
143 """
144 self.assertRaises(AssertionError, self.ren.addToEvalStack, 10)
145 self.assertRaises(AssertionError, self.ren.addToInitStack, 10)
146
147 def testGetEvalStack(self):
148 """
149 Test getting the evaluation stack
150 """
151 # it should be the null string on initialisation
152 self.assertEqual("", self.ren.getEvalStack())
153
154 def testAddToEvalStack(self):
155 """
156 Test adding a string to the evaluation stack
157 """
158 inString = "my string"
159 outString = inString + '\n'
160 self.ren.addToEvalStack(inString)
161 self.assertEqual(self.ren.getEvalStack(), outString)
162
163 def testGetInitStack(self):
164 """
165 Test getting the initialisation stack
166 """
167 # should be the null string initially
168 self.assertEqual("", self.ren.getInitStack())
169
170 def testAddToInitStack(self):
171 """
172 Test adding a string to the initialisation stack
173 """
174 inString = "my string"
175 outString = inString + '\n'
176 self.ren.addToInitStack(inString)
177 self.assertEqual(self.ren.getInitStack(), outString)
178
179 def testResetEvalStack(self):
180 """
181 Test resetting the evaluation stack
182 """
183 # set the stack to something
184 inString = "my string"
185 self.ren.addToEvalStack(inString)
186 # reset the stack
187 self.ren.resetEvalStack()
188 # now check that it's the null string again
189 self.assertEqual("", self.ren.getEvalStack())
190
191 def testResetInitStack(self):
192 """
193 Test resetting the initialisation stack
194 """
195 # set the stack to something
196 inString = "my string"
197 self.ren.addToInitStack(inString)
198 # reset the stack
199 self.ren.resetInitStack()
200 # now check that it's the null string again
201 self.assertEqual("", self.ren.getInitStack())
202
203 if __name__ == '__main__':
204 unittest.main()
205
206 # vim: expandtab shiftwidth=4:

  ViewVC Help
Powered by ViewVC 1.1.26