/[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 1199 - (show annotations)
Wed Jun 20 05:01:30 2007 UTC (12 years ago) by jongui
File MIME type: text/x-python
File size: 1931 byte(s)
- Updated the epydocs and guide.
Deleted redundant files and methods.
Tidied up the codes.
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_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
16 "data_sample_images", "scene")
17
18 MIN_IMAGE_SIZE = 100
19 X_SIZE = 400
20 Y_SIZE = 400
21 JPG_RENDERER = Renderer.OFFLINE_JPG
22
23 class TestScene:
24 def render(self, file):
25 self.scene.render(image_name = \
26 os.path.join(PYVISI_TEST_SCENE_IMAGES_PATH, file))
27
28 self.failUnless(os.stat(os.path.join(PYVISI_TEST_SCENE_IMAGES_PATH, \
29 file))[ST_SIZE] > MIN_IMAGE_SIZE)
30
31 def setBackground(self, c):
32 self.scene.setBackground(color = c)
33
34 class TestSceneOneViewport(unittest.TestCase, TestScene):
35 def setUp(self):
36 self.scene = \
37 Scene(renderer = JPG_RENDERER, num_viewport = 1,
38 x_size = X_SIZE, y_size = Y_SIZE)
39
40 def tearDown(self):
41 del self.scene
42
43 def testRender(self):
44 file = "TestSceneOneViewport_testRender.jpg"
45 self.render(file)
46
47 def testSetBackground(self):
48 self.setBackground(Color.GREEN)
49 file = "TestSceneOneViewport_testSetBackground.jpg"
50 self.render(file)
51
52 class TestSceneFourViewports(unittest.TestCase, TestScene):
53 def setUp(self):
54 self.scene = \
55 Scene(renderer = JPG_RENDERER, num_viewport = 4, x_size = 800,
56 y_size = 800)
57
58 def tearDown(self):
59 del self.scene
60
61 def testRender(self):
62 file = "TestSceneFourViewport_testRender.jpg"
63 self.render(file)
64
65
66 ###############################################################################
67
68
69 if __name__ == '__main__':
70 suite = unittest.TestSuite()
71 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestSceneOneViewport))
72 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestSceneFourViewports))
73 unittest.TextTestRunner(verbosity=2).run(suite)

  ViewVC Help
Powered by ViewVC 1.1.26