mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-06 20:10:08 +01:00
new unittests
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@69670 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -67,7 +67,7 @@ class timer_Tests(wtc.WidgetTestCase):
|
|||||||
|
|
||||||
def test_timerCallLater1(self):
|
def test_timerCallLater1(self):
|
||||||
# simple CallLater usage
|
# simple CallLater usage
|
||||||
wx.CallLater(250, self.onCallLater)
|
wx.CallLater(150, self.onCallLater)
|
||||||
self.waitFor(500)
|
self.waitFor(500)
|
||||||
self.assertTrue(self.flag)
|
self.assertTrue(self.flag)
|
||||||
|
|
||||||
|
|||||||
29
unittests/test_tooltip.py
Normal file
29
unittests/test_tooltip.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import imp_unittest, unittest
|
||||||
|
import wtc
|
||||||
|
import wx
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class tooltip_Tests(wtc.WidgetTestCase):
|
||||||
|
|
||||||
|
def test_tooltip(self):
|
||||||
|
tip = wx.ToolTip('help message')
|
||||||
|
self.frame.SetToolTip(tip)
|
||||||
|
tip.Tip
|
||||||
|
tip.Window
|
||||||
|
tip.Tip = 'new help message'
|
||||||
|
|
||||||
|
def test_tooltipStatics(self):
|
||||||
|
wx.ToolTip.Enable(True)
|
||||||
|
wx.ToolTip.SetAutoPop(2000)
|
||||||
|
wx.ToolTip.SetDelay(2000)
|
||||||
|
wx.ToolTip.SetMaxWidth(500)
|
||||||
|
wx.ToolTip.SetReshow(2000)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
67
unittests/test_utils.py
Normal file
67
unittests/test_utils.py
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
import imp_unittest, unittest
|
||||||
|
import wtc
|
||||||
|
import wx
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class utils_Tests(wtc.WidgetTestCase):
|
||||||
|
|
||||||
|
def test_utilsWindowDisabler(self):
|
||||||
|
wd = wx.WindowDisabler()
|
||||||
|
self.assertTrue(not self.frame.IsEnabled())
|
||||||
|
del wd
|
||||||
|
|
||||||
|
wd = wx.WindowDisabler(self.frame)
|
||||||
|
self.assertTrue( self.frame.IsEnabled())
|
||||||
|
|
||||||
|
def test_utilsBusyCursor(self):
|
||||||
|
self.assertTrue(not wx.IsBusy())
|
||||||
|
bc = wx.BusyCursor()
|
||||||
|
self.assertTrue( wx.IsBusy())
|
||||||
|
del bc
|
||||||
|
self.assertTrue(not wx.IsBusy())
|
||||||
|
|
||||||
|
def test_utilsBusyCursor2(self):
|
||||||
|
self.assertTrue(not wx.IsBusy())
|
||||||
|
wx.BeginBusyCursor()
|
||||||
|
self.assertTrue( wx.IsBusy())
|
||||||
|
wx.EndBusyCursor()
|
||||||
|
self.assertTrue(not wx.IsBusy())
|
||||||
|
|
||||||
|
|
||||||
|
def test_utilsSomeOtherStuff(self):
|
||||||
|
wx.GetBatteryState()
|
||||||
|
wx.GetPowerType()
|
||||||
|
wx.GetKeyState(wx.WXK_F1)
|
||||||
|
wx.GetMousePosition()
|
||||||
|
wx.GetMouseState()
|
||||||
|
wx.EnableTopLevelWindows(True)
|
||||||
|
wx.FindWindowAtPoint((1,1))
|
||||||
|
wx.NewId()
|
||||||
|
wx.RegisterId(12345)
|
||||||
|
wx.GetUserName()
|
||||||
|
wx.GetUserId()
|
||||||
|
wx.GetOsDescription()
|
||||||
|
|
||||||
|
|
||||||
|
def test_utilsVersionInfo(self):
|
||||||
|
vi = wx.GetLibraryVersionInfo()
|
||||||
|
assert isinstance(vi, wx.VersionInfo)
|
||||||
|
vi.ToString()
|
||||||
|
vi.Major
|
||||||
|
vi.Minor
|
||||||
|
vi.Micro
|
||||||
|
vi.Copyright
|
||||||
|
vi.Description
|
||||||
|
vi.Name
|
||||||
|
vi.VersionString
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
59
unittests/test_validate.py
Normal file
59
unittests/test_validate.py
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import imp_unittest, unittest
|
||||||
|
import wtc
|
||||||
|
import wx
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class MyValidator(wx.Validator):
|
||||||
|
def __init__(self, startingValue=""):
|
||||||
|
wx.Validator.__init__(self)
|
||||||
|
self.value = startingValue
|
||||||
|
|
||||||
|
def Clone(self):
|
||||||
|
return MyValidator(self.value)
|
||||||
|
|
||||||
|
def TransferToWindow(self):
|
||||||
|
self.GetWindow().SetValue(self.value)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def TransferFromWindow(self):
|
||||||
|
self.value = self.Window.Value # test using the properties
|
||||||
|
return True
|
||||||
|
|
||||||
|
def Validate(self, parent):
|
||||||
|
value = self.GetWindow().GetValue()
|
||||||
|
return value in ["", "hello", "world"]
|
||||||
|
|
||||||
|
|
||||||
|
class validate_Tests(wtc.WidgetTestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(validate_Tests, self).setUp()
|
||||||
|
self.pnl = wx.Panel(self.frame)
|
||||||
|
self.tc = wx.TextCtrl(self.pnl, pos=(10,10))
|
||||||
|
self.frame.SendSizeEvent()
|
||||||
|
validator = MyValidator("hello")
|
||||||
|
self.tc.SetValidator(validator)
|
||||||
|
|
||||||
|
|
||||||
|
def test_validateTransfer(self):
|
||||||
|
self.assertTrue(self.tc.Value == "")
|
||||||
|
self.pnl.TransferDataToWindow()
|
||||||
|
self.assertTrue(self.tc.Value == "hello")
|
||||||
|
self.tc.Value = "world"
|
||||||
|
self.pnl.TransferDataFromWindow()
|
||||||
|
v = self.tc.GetValidator()
|
||||||
|
self.assertTrue(v.value == "world")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def test_validateDefault(self):
|
||||||
|
wx.DefaultValidator
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
Reference in New Issue
Block a user