/[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 1167 - (show annotations)
Thu May 24 01:04:17 2007 UTC (13 years, 11 months ago) by jongui
File MIME type: text/x-python
File size: 2047 byte(s)
Deleted remaining scenes from the test cases and updated the guide.
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 render(self, file):
27 self.scene.render(image_name = \
28 os.path.join(PYVISI_TEST_SCENE_IMAGES_PATH, file))
29
30 self.failUnless(os.stat(os.path.join(PYVISI_TEST_SCENE_IMAGES_PATH, \
31 file))[ST_SIZE] > MIN_IMAGE_SIZE)
32
33 def setBackground(self, c):
34 self.scene.setBackground(color = c)
35
36 class TestSceneOneViewport(unittest.TestCase, TestScene):
37 def setUp(self):
38 self.scene = \
39 Scene(renderer = JPG_RENDERER, num_viewport = 1,
40 x_size = X_SIZE, y_size = Y_SIZE)
41
42 def tearDown(self):
43 del self.scene
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 tearDown(self):
61 del self.scene
62
63 def testRender(self):
64 file = "TestSceneFourViewport_testRender.jpg"
65 self.render(file)
66
67
68 ###############################################################################
69
70
71 if __name__ == '__main__':
72 suite = unittest.TestSuite()
73 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestSceneOneViewport))
74 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestSceneFourViewports))
75 unittest.TextTestRunner(verbosity=2).run(suite)

  ViewVC Help
Powered by ViewVC 1.1.26