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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1158 - (show annotations)
Tue May 22 04:24:01 2007 UTC (13 years, 11 months ago) by jongui
File MIME type: text/x-python
File size: 1685 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, Text2D, LocalPosition
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_TEXT_REFERENCE_IMAGES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT, \
16 "data_reference_images", "text")
17 PYVISI_TEST_TEXT_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
18 "data_sample_images", "text")
19
20 MIN_IMAGE_SIZE = 100
21 X_SIZE = 400
22 Y_SIZE = 400
23 JPG_RENDERER = Renderer.OFFLINE_JPG
24
25 class TestText2D(unittest.TestCase):
26 def setUp(self):
27 self.scene = \
28 Scene(renderer = JPG_RENDERER, num_viewport = 1,
29 x_size = X_SIZE, y_size = Y_SIZE)
30
31 self.text2D = Text2D(scene = self.scene, text = "Testing ...",
32 viewport = Viewport.SOUTH_WEST)
33
34 def tearDown(self):
35 del self.scene
36 del self.text2D
37
38 def render(self, file):
39 self.scene.render(image_name = \
40 os.path.join(PYVISI_TEST_TEXT_IMAGES_PATH, file))
41
42 self.failUnless(os.stat(os.path.join(PYVISI_TEST_TEXT_IMAGES_PATH, \
43 file))[ST_SIZE] > MIN_IMAGE_SIZE)
44
45 def testText(self):
46 self.text2D.setFontSize(35)
47 self.text2D.setFontToArial()
48 self.text2D.boldOn()
49 self.text2D.shadowOn()
50 self.text2D.setColor(Color.BLUE)
51 self.text2D.setPosition(LocalPosition(90, 90))
52 self.render("TestText2D.jpg")
53
54
55
56 ##############################################################################
57
58
59 if __name__ == '__main__':
60 suite = unittest.TestSuite()
61 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestText2D))
62 unittest.TextTestRunner(verbosity=2).run(suite)
63

  ViewVC Help
Powered by ViewVC 1.1.26