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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1067 - (hide annotations)
Wed Mar 28 04:14:13 2007 UTC (14 years, 6 months ago) by jongui
File MIME type: text/x-python
File size: 1772 byte(s)
Added some test for the datacollector, map and scene modules.
1 jongui 1067 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     def testRender(self):
48     file = "TestSceneFourViewport_testRender.jpg"
49     self.render(file)
50    
51     def testSetBackground(self):
52     self.setBackground(Color.BLUE)
53     file = "TestSceneFourViewport_testSetBackground.jpg"
54     self.render(file)
55    
56    
57     ###############################################################################
58    
59    
60     if __name__ == '__main__':
61     suite = unittest.TestSuite()
62     suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestSceneOneViewport))
63     suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestSceneFourViewports))
64     unittest.TextTestRunner(verbosity=2).run(suite)

  ViewVC Help
Powered by ViewVC 1.1.26