/[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 601 - (show annotations)
Fri Mar 17 06:18:25 2006 UTC (13 years, 7 months ago) by gross
File MIME type: text/x-python
File size: 6866 byte(s)
directories are moved around to match escript convention
1 # Copyright (C) 2004 Paul Cochrane
2 #
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # $Id: test_renderer.py,v 1.5 2005/09/20 05:57:40 paultcochrane Exp $
18
19 ## @file test_plot.py
20
21 import unittest
22 import sys,os
23 from string import *
24 here = os.getcwd() + '/../../'
25 sys.path.append(here)
26 import pyvisi # this should import all of the pyvisi stuff needed
27
28 """
29 Class and functions for testing the Renderer class
30 """
31
32 class TestRenderer(unittest.TestCase):
33 """
34 Test the renderer object at the base pyvisi level
35 """
36
37 def setUp(self):
38 self.ren = pyvisi.Renderer()
39
40 def testInit(self):
41 """
42 Tests initialisation of the Renderer object
43 """
44 classStr = self.ren.__class__.__name__
45 self.assertEqual('Renderer', classStr)
46
47 def testExactlyOneArgument(self):
48 """
49 Check that method only accepts one argument
50 """
51 # check setRenderWindowHeight
52 self.assertRaises(TypeError, self.ren.setRenderWindowHeight)
53 self.assertRaises(TypeError, self.ren.setRenderWindowHeight, 10, 20)
54
55 # check setRenderWindowWidth
56 self.assertRaises(TypeError, self.ren.setRenderWindowWidth)
57 self.assertRaises(TypeError, self.ren.setRenderWindowWidth, 10, 20)
58
59 # check addToEvalStack
60 self.assertRaises(TypeError, self.ren.addToEvalStack)
61 self.assertRaises(TypeError, self.ren.addToEvalStack, "moo", "baa")
62
63 # check addToInitStack
64 self.assertRaises(TypeError, self.ren.addToInitStack)
65 self.assertRaises(TypeError, self.ren.addToInitStack, "moo", "baa")
66
67 def testExactlyTwoArguments(self):
68 """
69 Check that method only accepts two arguments
70 """
71 self.assertRaises(TypeError, \
72 self.ren.setRenderWindowDimensions)
73 self.assertRaises(TypeError, \
74 self.ren.setRenderWindowDimensions, 12)
75 self.assertRaises(TypeError, \
76 self.ren.setRenderWindowDimensions, 12, 14, 16)
77
78 def testRenderWindowDefaultDims(self):
79 """
80 Check render window default width and height
81 """
82 self.assertEqual(640, self.ren.renderWindowWidth) # width
83 self.assertEqual(480, self.ren.renderWindowHeight) # height
84
85 def testGetRenderWindowWidth(self):
86 """
87 Check getting the render window width
88 """
89 width = self.ren.getRenderWindowWidth()
90 self.assertEqual(self.ren.renderWindowWidth, width)
91
92 def testSetRenderWindowWidth(self):
93 """
94 Test setting the render window width
95 """
96 width = 720
97 self.ren.setRenderWindowWidth(width)
98 self.assertEqual(self.ren.getRenderWindowWidth(), width)
99
100 def testGetRenderWindowHeight(self):
101 """
102 Check getting the render window height
103 """
104 height = self.ren.getRenderWindowHeight()
105 self.assertEqual(self.ren.renderWindowHeight, height)
106
107 def testSetRenderWindowHeight(self):
108 """
109 Test setting the render window height
110 """
111 height = 593
112 self.ren.setRenderWindowHeight(height)
113 self.assertEqual(self.ren.getRenderWindowHeight(), height)
114
115 def testGetRenderWindowDimensions(self):
116 """
117 Test getting the render window width and height
118 """
119 (width, height) = self.ren.getRenderWindowDimensions()
120 self.assertEqual((640,480), (width, height))
121
122 def testSetRenderWindowDimensions(self):
123 """
124 Test setting the render window width and height
125 """
126 width = 123
127 height = 456
128 self.ren.setRenderWindowDimensions(width, height)
129 self.assertEqual(self.ren.getRenderWindowDimensions(), (width,height))
130
131 def testIntegerArgsToSet(self):
132 """
133 Test setting of integer arguments
134 """
135 self.assertRaises(AssertionError, \
136 self.ren.setRenderWindowWidth, "moo")
137 self.assertRaises(AssertionError, \
138 self.ren.setRenderWindowHeight, "moo")
139 self.assertRaises(AssertionError, \
140 self.ren.setRenderWindowDimensions, "moo", "baa")
141
142 def testStringArgsToSet(self):
143 """
144 Test setting of string arguments
145 """
146 self.assertRaises(AssertionError, self.ren.addToEvalStack, 10)
147 self.assertRaises(AssertionError, self.ren.addToInitStack, 10)
148
149 def testGetEvalStack(self):
150 """
151 Test getting the evaluation stack
152 """
153 # it should be the null string on initialisation
154 self.assertEqual("", self.ren.getEvalStack())
155
156 def testAddToEvalStack(self):
157 """
158 Test adding a string to the evaluation stack
159 """
160 inString = "my string"
161 outString = inString + '\n'
162 self.ren.addToEvalStack(inString)
163 self.assertEqual(self.ren.getEvalStack(), outString)
164
165 def testGetInitStack(self):
166 """
167 Test getting the initialisation stack
168 """
169 # should be the null string initially
170 self.assertEqual("", self.ren.getInitStack())
171
172 def testAddToInitStack(self):
173 """
174 Test adding a string to the initialisation stack
175 """
176 inString = "my string"
177 outString = inString + '\n'
178 self.ren.addToInitStack(inString)
179 self.assertEqual(self.ren.getInitStack(), outString)
180
181 def testResetEvalStack(self):
182 """
183 Test resetting the evaluation stack
184 """
185 # set the stack to something
186 inString = "my string"
187 self.ren.addToEvalStack(inString)
188 # reset the stack
189 self.ren.resetEvalStack()
190 # now check that it's the null string again
191 self.assertEqual("", self.ren.getEvalStack())
192
193 def testResetInitStack(self):
194 """
195 Test resetting the initialisation stack
196 """
197 # set the stack to something
198 inString = "my string"
199 self.ren.addToInitStack(inString)
200 # reset the stack
201 self.ren.resetInitStack()
202 # now check that it's the null string again
203 self.assertEqual("", self.ren.getInitStack())
204
205 if __name__ == '__main__':
206 unittest.main()
207
208 # vim: expandtab shiftwidth=4:

  ViewVC Help
Powered by ViewVC 1.1.26