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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1068 - (show annotations)
Wed Mar 28 22:26:00 2007 UTC (13 years, 4 months ago) by jongui
File MIME type: text/x-python
File size: 1634 byte(s)
Added test for the velocity module.
1 from esys.pyvisi import Scene
2 from esys.pyvisi.constant import *
3 import unittest, os
4 from stat import ST_SIZE
5
6 PYVISI_TEST_SCENE_IMAGES_PATH = "data_sample_images/scene/"
7 MIN_IMAGE_SIZE = 100
8 X_SIZE = 400
9 Y_SIZE = 400
10
11 JPG_RENDERER = Renderer.OFFLINE_JPG
12
13 class TestScene:
14 def tearDown(self):
15 del self.scene
16
17 def render(self, file):
18 self.scene.render(image_name = \
19 PYVISI_TEST_SCENE_IMAGES_PATH + file)
20
21 self.failUnless(os.stat(PYVISI_TEST_SCENE_IMAGES_PATH + \
22 file)[ST_SIZE] > MIN_IMAGE_SIZE)
23
24 def setBackground(self, c):
25 self.scene.setBackground(color = c)
26
27 class TestSceneOneViewport(unittest.TestCase, TestScene):
28 def setUp(self):
29 self.scene = \
30 Scene(renderer = JPG_RENDERER, num_viewport = 1,
31 x_size = X_SIZE, y_size = Y_SIZE)
32
33 def testRender(self):
34 file = "TestSceneOneViewport_testRender.jpg"
35 self.render(file)
36
37 def testSetBackground(self):
38 self.setBackground(Color.GREEN)
39 file = "TestSceneOneViewport_testSetBackground.jpg"
40 self.render(file)
41
42 class TestSceneFourViewports(unittest.TestCase, TestScene):
43 def setUp(self):
44 self.scene = \
45 Scene(renderer = JPG_RENDERER, num_viewport = 4, x_size = 800,
46 y_size = 800)
47
48 def testRender(self):
49 file = "TestSceneFourViewport_testRender.jpg"
50 self.render(file)
51
52
53 ###############################################################################
54
55
56 if __name__ == '__main__':
57 suite = unittest.TestSuite()
58 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestSceneOneViewport))
59 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestSceneFourViewports))
60 unittest.TextTestRunner(verbosity=2).run(suite)

  ViewVC Help
Powered by ViewVC 1.1.26