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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1158 - (show annotations)
Tue May 22 04:24:01 2007 UTC (12 years, 6 months ago) by jongui
File MIME type: text/x-python
File size: 1878 byte(s)
Made some changes to fix the memory leak problem. However, the problem still persists for run_escript_with_lazy_evaluation.py, run_streamline.py and run_streamline_with_lazy_evaluation.py.

1 from esys.pyvisi import Scene, ImageReader, Logo
2 from esys.pyvisi import LocalPosition
3 from esys.pyvisi.constant import *
4 import unittest, os
5 from stat import ST_SIZE
6
7 try:
8 PYVISI_WORKDIR=os.environ['PYVISI_WORKDIR']
9 except KeyError:
10 PYVISI_WORKDIR='.'
11 try:
12 PYVISI_TEST_DATA_ROOT=os.environ['PYVISI_TEST_DATA_ROOT']
13 except KeyError:
14 PYVISI_TEST_DATA_ROOT='.'
15
16 PYVISI_TEST_MESHES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT, "data_meshes")
17 PYVISI_TEST_LOGO_REFERENCE_IMAGES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT, \
18 "data_reference_images", "logo")
19 PYVISI_TEST_LOGO_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
20 "data_sample_images", "logo")
21
22 MIN_IMAGE_SIZE = 100
23 LOGO = "access_logo.jpg"
24 X_SIZE = 400
25 Y_SIZE = 400
26 JPG_RENDERER = Renderer.OFFLINE_JPG
27
28 class TestLogo:
29 def render(self, file):
30 self.scene.render(image_name = \
31 os.path.join(PYVISI_TEST_LOGO_IMAGES_PATH, file))
32
33 self.failUnless(os.stat(os.path.join(PYVISI_TEST_LOGO_IMAGES_PATH, \
34 file))[ST_SIZE] > MIN_IMAGE_SIZE)
35
36 class TestAccessLogo(unittest.TestCase, TestLogo):
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 self.image_reader = ImageReader(ImageFormat.JPG)
43 self.image_reader.setImageName(os.path.join(PYVISI_TEST_MESHES_PATH, \
44 LOGO))
45
46 self.logo = Logo(scene = self.scene, image_reader = self.image_reader)
47
48 def tearDown(self):
49 del self.scene
50 del self.image_reader
51 del self.logo
52
53 def testImage(self):
54 self.logo.setPosition(position = LocalPosition(20,50))
55 self.logo.setSize(size = 0.5)
56 self.render("TestLogo.jpg")
57
58
59 ###############################################################################
60
61
62 if __name__ == '__main__':
63 suite = unittest.TestSuite()
64 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestAccessLogo))
65 unittest.TextTestRunner(verbosity=2).run(suite)
66

  ViewVC Help
Powered by ViewVC 1.1.26