~ubuntu-branches/ubuntu/trusty/python-enable/trusty

« back to all changes in this revision

Viewing changes to enthought/enable2/tests/component_test_case.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2010-02-28 14:56:36 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20100228145636-9ghfhe3uy37tt3q6
Tags: 3.3.0-1
* New upstream release
* Bump Standards-Version to 3.8.4
* Switch to source format 3.0
* Update patches/freetype2.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import unittest
2
 
 
3
 
from enthought.enable2.api import Component
4
 
 
5
 
 
6
 
class ComponentTestCase(unittest.TestCase):
7
 
    def test_position(self):
8
 
        c = Component(bounds=[50.0, 50.0])
9
 
        self.assert_(c.position[0] == c.x)
10
 
        self.assert_(c.position[1] == c.y)
11
 
        self.assert_(c.x == 0.0)
12
 
        self.assert_(c.y == 0.0)
13
 
        return
14
 
    
15
 
    def test_bounds(self):
16
 
        c = Component(bounds=[50.0, 60.0])
17
 
        self.assert_(c.width == c.bounds[0])
18
 
        self.assert_(c.height == c.bounds[1])
19
 
        self.assert_(c.bounds[0] == 50.0)
20
 
        self.assert_(c.bounds[1] == 60.0)
21
 
        self.assert_(c.x2 == c.x + 50.0 - 1)
22
 
        self.assert_(c.y2 == c.y + 60.0 - 1)
23
 
        return
24
 
 
25
 
    def test_get_outer_position(self):
26
 
        c = Component(bounds=[50.0, 60.0], padding=10, border_visible=False)
27
 
        self.assert_(c.outer_x == -10)
28
 
        self.assert_(c.outer_y == -10)
29
 
        self.assert_(c.outer_position[0] == -10)
30
 
        self.assert_(c.outer_position[1] == -10)
31
 
        self.assert_(c.outer_x2 == 59)
32
 
        self.assert_(c.outer_y2 == 69)
33
 
        self.assert_(c.outer_width == 70)
34
 
        self.assert_(c.outer_height == 80)
35
 
        self.assert_(c.outer_bounds[0] == 70)
36
 
        self.assert_(c.outer_bounds[1] == 80)
37
 
        return
38
 
    
39
 
    def test_set_outer_position(self):
40
 
        c = Component(bounds=[50.0, 60.0], padding=10, border_visible=False)
41
 
        # Test setting various things
42
 
        c.outer_position = [0,0]
43
 
        self.assert_(c.outer_x == 0)
44
 
        self.assert_(c.outer_y == 0)
45
 
        self.assert_(c.x == 10)
46
 
        self.assert_(c.y == 10)
47
 
        self.assert_(c.outer_x2 == 69)
48
 
        self.assert_(c.outer_y2 == 79)
49
 
        c.outer_x = 10
50
 
        self.assert_(c.x == 20)
51
 
        self.assert_(c.outer_x2 == 79)
52
 
        return
53
 
 
54
 
    def test_border(self):
55
 
        c = Component(bounds=[50.0, 60.0], 
56
 
                      position=[20, 20],
57
 
                      padding=10, border_visible=True, border_width=1)
58
 
        self.assert_(c.outer_x == 10)
59
 
        self.assert_(c.outer_y == 10)
60
 
        self.assert_(c.outer_bounds[0] == 70)
61
 
        self.assert_(c.outer_bounds[1] == 80)
62
 
        return
63
 
 
64
 
    def check_container(self):
65
 
        c = Component()
66
 
        self.assert_(c.container is None)
67
 
        return
68
 
 
69
 
if __name__ == "__main__":
70
 
    import nose
71
 
    nose.main()
72
 
 
73
 
# EOF