diff --git a/unittests/test_gdicmn.py b/unittests/test_gdicmn.py index e43888fc..40be1e4b 100644 --- a/unittests/test_gdicmn.py +++ b/unittests/test_gdicmn.py @@ -224,7 +224,7 @@ class RealPoint(unittest2.TestCase): p.x += 2 p.y += 2 - + #--------------------------------------------------------------------------- @@ -236,22 +236,22 @@ class Rect(unittest2.TestCase): def test_xywh_ctor(self): r = wx.Rect(1, 2, 3, 4) - def test_tlbr_ctor(self): - r = wx.Rect(wx.Point(10,10), wx.Point(100,100)) - self.assertTrue(r.width == 91 and r.height == 91) - self.assertTrue(r.bottomRight == wx.Point(100,100)) - self.assertTrue(r.topLeft == wx.Point(10,10)) - def test_possize_ctor(self): - # TODO: we have to use keyword args here since wx.Size has sequence - # protocol methods then it can also match the typemap for wxPoint and - # the other ctor is found first. Check if there is a way to fix or - # work around this. - r = wx.Rect(wx.Point(10,10), size=wx.Size(100,100)) + r = wx.Rect(wx.Point(10,10), wx.Size(100,100)) self.assertTrue(r.width == 100 and r.height == 100) self.assertTrue(r.x == 10 and r.y == 10) self.assertTrue(r == wx.Rect(pos=(10,10), size=(100,100))) + def test_tlbr_ctor(self): + # TODO: we have to use keyword args here since wx.Point has sequence + # protocol methods then it can also match the typemap for wxSize and + # the other ctor is found first. Check if there is a way to fix or + # work around this. + r = wx.Rect(topLeft=wx.Point(10,10), bottomRight=wx.Point(100,100)) + self.assertTrue(r.width == 91 and r.height == 91) + self.assertTrue(r.bottomRight == wx.Point(100,100)) + self.assertTrue(r.topLeft == wx.Point(10,10)) + def test_size_ctor(self): r = wx.Rect(wx.Size(50,100)) self.assertTrue(r.width == 50 and r.height == 100) diff --git a/unittests/test_geometry.py b/unittests/test_geometry.py new file mode 100644 index 00000000..545a5ae2 --- /dev/null +++ b/unittests/test_geometry.py @@ -0,0 +1,46 @@ +import unittest2 +import wx + + +#--------------------------------------------------------------------------- + +class Point2D(unittest2.TestCase): + + def test_default_ctor(self): + p = wx.Point2D() + + def test_xy_ctor(self): + p = wx.Point2D(12.3, 45.6) + + def test_copy_ctor(self): + p1 = wx.Point2D(1.23, 4.56) + p2 = wx.Point2D(p1) + self.assertTrue(p1 == p2) + self.assertTrue(p1 is not p2) + self.assertTrue(p1 == (1.23, 4.56)) + + + +class Rect2D(unittest2.TestCase): + + def test_default_ctor(self): + r = wx.Rect2D() + + def test_xywh_ctor(self): + r = wx.Rect2D(.5, .5, 100.1, 99.2) + + def test_copy_ctor(self): + r1 = wx.Rect2D(.5, .5, 100.1, 99.2) + r2 = wx.Rect2D(r1) + self.assertTrue(r1 == r2) + self.assertTrue(r1 is not r2) + self.assertTrue(r1 == (.5, .5, 100.1, 99.2)) + + + +#--------------------------------------------------------------------------- + + +if __name__ == '__main__': + unittest2.main() + \ No newline at end of file diff --git a/unittests/test_kbdstate.py b/unittests/test_kbdstate.py new file mode 100644 index 00000000..9f8fd271 --- /dev/null +++ b/unittests/test_kbdstate.py @@ -0,0 +1,22 @@ +import unittest2 +import wx + + +#--------------------------------------------------------------------------- + +class KeyboardState(unittest2.TestCase): + + def test_KeyboardState(self): + ks = wx.KeyboardState(False, True, False, True) + ks.controlDown + ks.shiftDown + ks.altDown + ks.cmdDown + + + +#--------------------------------------------------------------------------- + + +if __name__ == '__main__': + unittest2.main() diff --git a/unittests/test_mousestate.py b/unittests/test_mousestate.py new file mode 100644 index 00000000..b08fe7a9 --- /dev/null +++ b/unittests/test_mousestate.py @@ -0,0 +1,31 @@ +import unittest2 +import wx + + +#--------------------------------------------------------------------------- + +class MouseState(unittest2.TestCase): + + def test_MouseState(self): + ms = wx.MouseState() + ms.controlDown + ms.shiftDown + ms.altDown + ms.cmdDown + + ms.x + ms.y + ms.leftIsDown + ms.middleIsDown + ms.rightIsDown + ms.aux1IsDown + ms.aux2IsDown + ms.Position + + + +#--------------------------------------------------------------------------- + + +if __name__ == '__main__': + unittest2.main()