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

  ViewVC Help
Powered by ViewVC 1.1.26