/[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 1381 - (show annotations)
Wed Jan 9 07:59:15 2008 UTC (11 years, 5 months ago) by gross
File MIME type: text/x-python
File size: 1817 byte(s)
import sys missing
1 from esys.pyvisi import Scene, ImageReader, Logo
2 from esys.pyvisi import LocalPosition
3 from esys.pyvisi.constant import *
4 import unittest, os, sys
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_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
18 "data_sample_images", "logo")
19
20 MIN_IMAGE_SIZE = 100
21 LOGO = "access_logo.jpg"
22 X_SIZE = 400
23 Y_SIZE = 400
24 JPG_RENDERER = Renderer.OFFLINE_JPG
25
26 class TestLogo:
27 def render(self, file):
28 self.scene.render(image_name = \
29 os.path.join(PYVISI_TEST_LOGO_IMAGES_PATH, file))
30
31 self.failUnless(os.stat(os.path.join(PYVISI_TEST_LOGO_IMAGES_PATH, \
32 file))[ST_SIZE] > MIN_IMAGE_SIZE)
33
34 class TestAccessLogo(unittest.TestCase, TestLogo):
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 self.image_reader = ImageReader(ImageFormat.JPG)
41 self.image_reader.setImageName(os.path.join(PYVISI_TEST_MESHES_PATH, \
42 LOGO))
43
44 self.logo = Logo(scene = self.scene, image_reader = self.image_reader)
45
46 def tearDown(self):
47 del self.scene
48 del self.image_reader
49 del self.logo
50
51 def testImage(self):
52 self.logo.setPosition(position = LocalPosition(20,50))
53 self.logo.setSize(size = 0.5)
54 self.render("TestLogo.jpg")
55
56
57 ###############################################################################
58
59
60 if __name__ == '__main__':
61 suite = unittest.TestSuite()
62 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestAccessLogo))
63 s=unittest.TextTestRunner(verbosity=2).run(suite)
64 if not s.wasSuccessful(): sys.exit(1)
65

  ViewVC Help
Powered by ViewVC 1.1.26