/[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 1148 - (show annotations)
Wed May 16 22:45:33 2007 UTC (15 years, 3 months ago) by jongui
File MIME type: text/x-python
File size: 2008 byte(s)
Added the updated files for pyvisi and removed some incorrect reference images.
1 from esys.pyvisi import Scene
2 from esys.pyvisi.constant import *
3 import unittest, os
4 from stat import ST_SIZE
5
6 try:
7 PYVISI_WORKDIR=os.environ['PYVISI_WORKDIR']
8 except KeyError:
9 PYVISI_WORKDIR='.'
10 try:
11 PYVISI_TEST_DATA_ROOT=os.environ['PYVISI_TEST_DATA_ROOT']
12 except KeyError:
13 PYVISI_TEST_DATA_ROOT='.'
14
15 PYVISI_TEST_SCENE_REFERENCE_IMAGES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT, \
16 "data_reference_images", "scene")
17 PYVISI_TEST_SCENE_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
18 "data_sample_images", "scene")
19
20 MIN_IMAGE_SIZE = 100
21 X_SIZE = 400
22 Y_SIZE = 400
23 JPG_RENDERER = Renderer.OFFLINE_JPG
24
25 class TestScene:
26 def tearDown(self):
27 del self.scene
28
29 def render(self, file):
30 self.scene.render(image_name = \
31 os.path.join(PYVISI_TEST_SCENE_IMAGES_PATH, file))
32
33 self.failUnless(os.stat(os.path.join(PYVISI_TEST_SCENE_IMAGES_PATH, \
34 file))[ST_SIZE] > MIN_IMAGE_SIZE)
35
36 def setBackground(self, c):
37 self.scene.setBackground(color = c)
38
39 class TestSceneOneViewport(unittest.TestCase, TestScene):
40 def setUp(self):
41 self.scene = \
42 Scene(renderer = JPG_RENDERER, num_viewport = 1,
43 x_size = X_SIZE, y_size = Y_SIZE)
44
45 def testRender(self):
46 file = "TestSceneOneViewport_testRender.jpg"
47 self.render(file)
48
49 def testSetBackground(self):
50 self.setBackground(Color.GREEN)
51 file = "TestSceneOneViewport_testSetBackground.jpg"
52 self.render(file)
53
54 class TestSceneFourViewports(unittest.TestCase, TestScene):
55 def setUp(self):
56 self.scene = \
57 Scene(renderer = JPG_RENDERER, num_viewport = 4, x_size = 800,
58 y_size = 800)
59
60 def testRender(self):
61 file = "TestSceneFourViewport_testRender.jpg"
62 self.render(file)
63
64
65 ###############################################################################
66
67
68 if __name__ == '__main__':
69 suite = unittest.TestSuite()
70 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestSceneOneViewport))
71 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestSceneFourViewports))
72 unittest.TextTestRunner(verbosity=2).run(suite)

  ViewVC Help
Powered by ViewVC 1.1.26