mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-12-16 09:40:07 +01:00
new unit tests
git-svn-id: https://svn.wxwidgets.org/svn/wx/sandbox/trunk/Phoenix@66193 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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)
|
||||
|
||||
46
unittests/test_geometry.py
Normal file
46
unittests/test_geometry.py
Normal file
@@ -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()
|
||||
|
||||
22
unittests/test_kbdstate.py
Normal file
22
unittests/test_kbdstate.py
Normal file
@@ -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()
|
||||
31
unittests/test_mousestate.py
Normal file
31
unittests/test_mousestate.py
Normal file
@@ -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()
|
||||
Reference in New Issue
Block a user