mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-07 04:20:07 +01:00
add more unit tests
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@69542 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
3
unittests/process_test.py
Normal file
3
unittests/process_test.py
Normal file
@@ -0,0 +1,3 @@
|
||||
import sys
|
||||
print 'process_test'
|
||||
sys.exit(0)
|
||||
@@ -4,14 +4,14 @@ import wx
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class CheckBoxTests(wtc.WidgetTestCase):
|
||||
class checkbox_Tests(wtc.WidgetTestCase):
|
||||
|
||||
def test_CheckBoxCtors(self):
|
||||
def test_checkboxCtors(self):
|
||||
c = wx.CheckBox(self.frame, label="checkbox")
|
||||
c = wx.CheckBox(self.frame, -1, "checkbox", wx.Point(10,10), wx.Size(80,-1))
|
||||
|
||||
|
||||
def test_CheckBoxDefaultCtor(self):
|
||||
def test_checkboxDefaultCtor(self):
|
||||
c = wx.CheckBox()
|
||||
c.Create(self.frame, label="checkbox")
|
||||
|
||||
|
||||
34
unittests/test_process.py
Normal file
34
unittests/test_process.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import imp_unittest, unittest
|
||||
import wtc
|
||||
import wx
|
||||
import sys, os
|
||||
|
||||
testscript = os.path.join(os.path.dirname(__file__), 'process_test.py')
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class process_Tests(wtc.WidgetTestCase):
|
||||
|
||||
def test_process1(self):
|
||||
# wx.Execute and wx.Process can only launch app bundles on OSX!! It's
|
||||
# a good thing we have the subprocess module that can be used instead.
|
||||
if 'wxMac' not in wx.PortInfo:
|
||||
p = wx.Process.Open('%s %s' % (sys.executable, testscript))
|
||||
pid = p.GetPid()
|
||||
|
||||
|
||||
def test_process2(self):
|
||||
flag = False
|
||||
def onEndProcess(evt):
|
||||
flag = True
|
||||
|
||||
if 'wxMac' not in wx.PortInfo:
|
||||
p = wx.Process(self.frame)
|
||||
self.frame.Bind(wx.EVT_END_PROCESS, onEndProcess)
|
||||
wx.Execute('%s %s' % (sys.executable, testscript), p)
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
33
unittests/test_progdlg.py
Normal file
33
unittests/test_progdlg.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import imp_unittest, unittest
|
||||
import wtc
|
||||
import wx
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class progdlg_Tests(wtc.WidgetTestCase):
|
||||
|
||||
def test_progdlg1(self):
|
||||
max = 50
|
||||
dlg = wx.ProgressDialog("Progress dialog example",
|
||||
"An informative message",
|
||||
parent=self.frame,
|
||||
maximum=max)
|
||||
|
||||
keepGoing = True
|
||||
count = 0
|
||||
|
||||
while keepGoing and count < max:
|
||||
count += 1
|
||||
#wx.MilliSleep(250)
|
||||
self.myYield()
|
||||
(keepGoing, skip) = dlg.Update(count)
|
||||
|
||||
dlg.Destroy()
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
34
unittests/test_radiobox.py
Normal file
34
unittests/test_radiobox.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import imp_unittest, unittest
|
||||
import wtc
|
||||
import wx
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class radiobox_Tests(wtc.WidgetTestCase):
|
||||
|
||||
def test_radioboxCtor(self):
|
||||
r = wx.RadioBox(self.frame, label='Label', choices='one two three four'.split(),
|
||||
majorDimension=2)
|
||||
|
||||
def test_radioboxDefaultCtor(self):
|
||||
r = wx.RadioBox()
|
||||
r.Create(self.frame, label='Label', choices='one two three four'.split(),
|
||||
majorDimension=2, style=wx.RA_SPECIFY_ROWS)
|
||||
|
||||
def test_radioboxTweaks(self):
|
||||
r = wx.RadioBox(self.frame, label='Label', choices='one two three four'.split(),
|
||||
majorDimension=2)
|
||||
r.SetItemLabel(0, 'ZERO')
|
||||
self.assertTrue(r.GetItemLabel(0) == 'ZERO')
|
||||
|
||||
r.Enable(False)
|
||||
r.Enable(True)
|
||||
r.EnableItem(1, False)
|
||||
r.ShowItem(2, False)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
29
unittests/test_radiobut.py
Normal file
29
unittests/test_radiobut.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import imp_unittest, unittest
|
||||
import wtc
|
||||
import wx
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class radiobut_Tests(wtc.WidgetTestCase):
|
||||
|
||||
def test_radiobutCtors(self):
|
||||
b = wx.RadioButton(self.frame, -1, 'radiobutton', wx.Point(10,10), wx.Size(80,-1))
|
||||
b = wx.RadioButton(self.frame, label='radiobutton', style=wx.RB_GROUP)
|
||||
|
||||
def test_radiobutDefaultCtor(self):
|
||||
b = wx.RadioButton()
|
||||
b.Create(self.frame, label="radiobutton")
|
||||
|
||||
def test_radiobutValue(self):
|
||||
b = wx.RadioButton(self.frame, label='radiobutton')
|
||||
b.Value = True
|
||||
self.assertTrue(b.GetValue() == True)
|
||||
b.Value = False
|
||||
self.assertTrue(b.GetValue() == False)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
58
unittests/test_region.py
Normal file
58
unittests/test_region.py
Normal file
@@ -0,0 +1,58 @@
|
||||
import imp_unittest, unittest
|
||||
import wtc
|
||||
import wx
|
||||
import sys, os
|
||||
|
||||
pngFile = os.path.join(os.path.dirname(__file__), 'toucan.png')
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class region_Tests(wtc.WidgetTestCase):
|
||||
|
||||
def test_regionCtors(self):
|
||||
r = wx.Region()
|
||||
r = wx.Region(10, 10, 100, 100)
|
||||
r = wx.Region(wx.Point(10,10), wx.Point(100,100))
|
||||
r = wx.Region(wx.Rect(10,10, 100, 100))
|
||||
r2 = wx.Region(r)
|
||||
r = wx.Region([(10,10), (100, 10), (100, 100), (10, 100)])
|
||||
bmp = wx.Bitmap(pngFile)
|
||||
r = wx.Region(bmp)
|
||||
r = wx.Region(bmp, 'black')
|
||||
|
||||
|
||||
def test_regionIterator1(self):
|
||||
region = wx.Region([(10,10), (100, 100), (10, 100)])
|
||||
iterator = wx.RegionIterator(region)
|
||||
count = 0
|
||||
while iterator:
|
||||
rect = iterator.GetRect()
|
||||
self.assertTrue(isinstance(rect, wx.Rect))
|
||||
iterator.Next()
|
||||
count += 1
|
||||
self.assertTrue(count > 0)
|
||||
|
||||
|
||||
def test_regionIterator2(self):
|
||||
region = wx.Region([(10,10), (100, 100), (10, 100)])
|
||||
count = 0
|
||||
for rect in region:
|
||||
self.assertTrue(isinstance(rect, wx.Rect))
|
||||
count += 1
|
||||
self.assertTrue(count > 0)
|
||||
|
||||
|
||||
def test_regionOtherRandomStuff(self):
|
||||
region = wx.Region([(10,10), (100, 100), (10, 100)])
|
||||
bmp = wx.Bitmap(pngFile)
|
||||
region.Union(bmp)
|
||||
region.Contains(10, 20)
|
||||
region.Contains(wx.Point(10,20))
|
||||
region.Contains(wx.Rect(10,20,4,4))
|
||||
region.Subtract(wx.Rect(10,20,4,4))
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user