/[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 1074 - (show annotations)
Fri Mar 30 02:44:42 2007 UTC (14 years, 6 months ago) by jongui
File MIME type: text/x-python
File size: 1307 byte(s)
Added tests for the text and image modules, including their corresponding sample output.
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 PYVISI_TEST_TEXT_IMAGES_PATH = "data_sample_images/text/"
7 MIN_IMAGE_SIZE = 100
8
9 X_SIZE = 400
10 Y_SIZE = 400
11
12 JPG_RENDERER = Renderer.OFFLINE_JPG
13
14 class TestText2D(unittest.TestCase):
15 def setUp(self):
16 self.scene = \
17 Scene(renderer = JPG_RENDERER, num_viewport = 1,
18 x_size = X_SIZE, y_size = Y_SIZE)
19
20 self.text2D = Text2D(scene = self.scene, text = "Testing ...",
21 viewport = Viewport.SOUTH_WEST)
22
23 def tearDown(self):
24 self.scene
25 self.text2D
26
27 def render(self, file):
28 self.scene.render(image_name = \
29 PYVISI_TEST_TEXT_IMAGES_PATH + file)
30
31 self.failUnless(os.stat(PYVISI_TEST_TEXT_IMAGES_PATH + \
32 file)[ST_SIZE] > MIN_IMAGE_SIZE)
33
34
35 def testText(self):
36 self.text2D.setFontSize(35)
37 self.text2D.setFontToArial()
38 self.text2D.boldOn()
39 self.text2D.shadowOn()
40 self.text2D.setColor(Color.BLUE)
41 self.text2D.setPosition(LocalPosition(90, 90))
42 self.render("TestText2D.jpg")
43
44
45
46 ##############################################################################
47
48
49 if __name__ == '__main__':
50 suite = unittest.TestSuite()
51 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestText2D))
52 unittest.TextTestRunner(verbosity=2).run(suite)
53

  ViewVC Help
Powered by ViewVC 1.1.26