mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-05 03:20:08 +01:00
Lotsa new unittests
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@69143 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
BIN
unittests/pointy.png
Normal file
BIN
unittests/pointy.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 489 B |
24
unittests/test_checkbox.py
Normal file
24
unittests/test_checkbox.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import imp_unittest, unittest
|
||||
import wtc
|
||||
import wx
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class CheckBoxTests(wtc.WidgetTestCase):
|
||||
|
||||
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):
|
||||
c = wx.CheckBox()
|
||||
c.Create(self.frame, label="checkbox")
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
25
unittests/test_checklst.py
Normal file
25
unittests/test_checklst.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import imp_unittest, unittest
|
||||
import wtc
|
||||
import wx
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class CheckListBoxTests(wtc.WidgetTestCase):
|
||||
|
||||
def test_CheckBoxCtors(self):
|
||||
c = wx.CheckListBox(self.frame, choices="one two three four".split())
|
||||
c = wx.CheckListBox(self.frame, -1, wx.Point(10,10), wx.Size(80,-1),
|
||||
"one two three four".split(),)
|
||||
|
||||
|
||||
def test_CheckListBoxDefaultCtor(self):
|
||||
c = wx.CheckListBox()
|
||||
c.Create(self.frame, choices="one two three four".split())
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
28
unittests/test_combobox.py
Normal file
28
unittests/test_combobox.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import imp_unittest, unittest
|
||||
import wtc
|
||||
import wx
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class ComboBoxTests(wtc.WidgetTestCase):
|
||||
|
||||
def test_ComboBoxCtors(self):
|
||||
c = wx.ComboBox(self.frame, value='value', choices="one two three four".split())
|
||||
c = wx.ComboBox(self.frame, -1, 'value', wx.Point(10,10), wx.Size(80,-1),
|
||||
"one two three four".split(), 0)
|
||||
c = wx.ComboBox(self.frame, -1, "", (10,10), (80,-1), "one two three four".split(), 0)
|
||||
|
||||
self.assertTrue(c.GetCount() == 4)
|
||||
|
||||
|
||||
def test_ComboBoxDefaultCtor(self):
|
||||
c = wx.ComboBox()
|
||||
c.Create(self.frame, value="value", choices="one two three four".split())
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
23
unittests/test_control.py
Normal file
23
unittests/test_control.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import imp_unittest, unittest
|
||||
import wtc
|
||||
import wx
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class ControlTests(wtc.WidgetTestCase):
|
||||
|
||||
def test_ControlCtors(self):
|
||||
c = wx.Control(self.frame)
|
||||
c = wx.Control(self.frame, -1, wx.Point(10,10), wx.Size(80,-1))
|
||||
|
||||
|
||||
def test_ControlDefaultCtor(self):
|
||||
c = wx.Control()
|
||||
c.Create(self.frame)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
42
unittests/test_dataobj.py
Normal file
42
unittests/test_dataobj.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import imp_unittest, unittest
|
||||
import wtc
|
||||
import wx
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class DataObjTests(wtc.WidgetTestCase):
|
||||
|
||||
def test_DataFormat(self):
|
||||
fmt1 = wx.DataFormat('my custom format')
|
||||
fmt2 = wx.DataFormat(wx.DF_TEXT)
|
||||
self.assertTrue(fmt1 != fmt2)
|
||||
|
||||
|
||||
def test_DataFormatIDsExist(self):
|
||||
wx.DF_INVALID
|
||||
wx.DF_TEXT
|
||||
wx.DF_BITMAP
|
||||
wx.DF_METAFILE
|
||||
wx.DF_SYLK
|
||||
wx.DF_DIF
|
||||
wx.DF_TIFF
|
||||
wx.DF_OEMTEXT
|
||||
wx.DF_DIB
|
||||
wx.DF_PALETTE
|
||||
wx.DF_PENDATA
|
||||
wx.DF_RIFF
|
||||
wx.DF_WAVE
|
||||
wx.DF_UNICODETEXT
|
||||
wx.DF_ENHMETAFILE
|
||||
wx.DF_FILENAME
|
||||
wx.DF_LOCALE
|
||||
wx.DF_PRIVATE
|
||||
wx.DF_HTML
|
||||
wx.DF_MAX
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
61
unittests/test_dc.py
Normal file
61
unittests/test_dc.py
Normal file
@@ -0,0 +1,61 @@
|
||||
import imp_unittest
|
||||
import wtc
|
||||
import wx
|
||||
|
||||
# NOTE: The wx.DC tests are done in the test modules for the various DC types
|
||||
# that inherit from wx.DC. The stuff tested here are just the other items
|
||||
# generated from etg/dc.py
|
||||
|
||||
# TODO: It may make sense to make a mixin class here that does test various
|
||||
# aspects and drawing APIs of a DC, and then have the other DC test cases mix
|
||||
# with it and call its methods.
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class DCTests(wtc.WidgetTestCase):
|
||||
|
||||
def test_ConstantsExist(self):
|
||||
wx.CLEAR
|
||||
wx.XOR
|
||||
wx.INVERT
|
||||
wx.OR_REVERSE
|
||||
wx.AND_REVERSE
|
||||
wx.COPY
|
||||
wx.AND
|
||||
wx.AND_INVERT
|
||||
wx.NO_OP
|
||||
wx.NOR
|
||||
wx.EQUIV
|
||||
wx.SRC_INVERT
|
||||
wx.OR_INVERT
|
||||
wx.NAND
|
||||
wx.OR
|
||||
wx.SET
|
||||
|
||||
wx.FLOOD_SURFACE
|
||||
wx.FLOOD_BORDER
|
||||
|
||||
wx.MM_TEXT
|
||||
wx.MM_METRIC
|
||||
wx.MM_LOMETRIC
|
||||
wx.MM_TWIPS
|
||||
wx.MM_POINTS
|
||||
|
||||
|
||||
|
||||
def test_FontMetrics(self):
|
||||
fm = wx.FontMetrics()
|
||||
fm.height
|
||||
fm.ascent
|
||||
fm.descent
|
||||
fm.internalLeading
|
||||
fm.externalLeading
|
||||
fm.averageWidth
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
100
unittests/test_dcbuffer.py
Normal file
100
unittests/test_dcbuffer.py
Normal file
@@ -0,0 +1,100 @@
|
||||
import imp_unittest, unittest
|
||||
import wtc
|
||||
import wx
|
||||
import sys
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class BufferedDCTests(wtc.WidgetTestCase):
|
||||
|
||||
def test_0_CheckKeepReference(self):
|
||||
# We're using the KeepReference annotation for the dc and bitmap args
|
||||
# to ensure that they will live as long as the DC does. This test will
|
||||
# try to verify that it works the way I think it does, that the extra
|
||||
# reference is made, and also released when the DC goes away.
|
||||
cdc = wx.ClientDC(self.frame)
|
||||
bmp = wx.Bitmap(1,1)
|
||||
cdc_cnt1 = sys.getrefcount(cdc)
|
||||
bmp_cnt1 = sys.getrefcount(bmp)
|
||||
|
||||
dc = wx.BufferedDC(cdc, bmp)
|
||||
|
||||
cdc_cnt2 = sys.getrefcount(cdc)
|
||||
bmp_cnt2 = sys.getrefcount(bmp)
|
||||
|
||||
del dc
|
||||
|
||||
cdc_cnt3 = sys.getrefcount(cdc)
|
||||
bmp_cnt3 = sys.getrefcount(bmp)
|
||||
|
||||
self.assertTrue(cdc_cnt2 == cdc_cnt1 + 1)
|
||||
self.assertTrue(cdc_cnt3 == cdc_cnt1)
|
||||
self.assertTrue(bmp_cnt2 == bmp_cnt1 + 1)
|
||||
self.assertTrue(bmp_cnt3 == bmp_cnt1)
|
||||
|
||||
|
||||
|
||||
def test_BufferedDCDefaultCtor(self):
|
||||
dc = wx.BufferedDC()
|
||||
dc.Init(None, wx.Bitmap(25,25))
|
||||
|
||||
|
||||
def test_BufferedDCCtors(self):
|
||||
dc = wx.BufferedDC(wx.ClientDC(self.frame), wx.Size(100,100))
|
||||
dc = wx.BufferedDC(wx.ClientDC(self.frame))
|
||||
dc = wx.BufferedDC(None, wx.Bitmap(100,100))
|
||||
|
||||
|
||||
def test_BufferedPaintDC(self):
|
||||
class TestPanel(wx.Panel):
|
||||
def __init__(self, *args, **kw):
|
||||
wx.Panel.__init__(self, *args, **kw)
|
||||
self.SetBackgroundStyle(wx.BG_STYLE_PAINT)
|
||||
self.Bind(wx.EVT_PAINT, self.onPaint)
|
||||
self.bmp = wx.Bitmap(100,100)
|
||||
self.onPaintCalled = False
|
||||
|
||||
def onPaint(self, evt):
|
||||
dc = wx.BufferedPaintDC(self, self.bmp)
|
||||
dc.DrawLine(0,0, 50,50)
|
||||
self.onPaintCalled = True
|
||||
|
||||
panel = TestPanel(self.frame)
|
||||
self.frame.SendSizeEvent()
|
||||
panel.Refresh()
|
||||
panel.Update()
|
||||
wx.Yield()
|
||||
self.assertTrue(panel.onPaintCalled == True)
|
||||
|
||||
|
||||
def test_AutoBufferedPaintDC(self):
|
||||
class TestPanel(wx.Panel):
|
||||
def __init__(self, *args, **kw):
|
||||
wx.Panel.__init__(self, *args, **kw)
|
||||
self.SetBackgroundStyle(wx.BG_STYLE_PAINT)
|
||||
self.Bind(wx.EVT_PAINT, self.onPaint)
|
||||
self.onPaintCalled = False
|
||||
|
||||
def onPaint(self, evt):
|
||||
dc = wx.AutoBufferedPaintDC(self)
|
||||
dc.DrawLine(0,0, 50,50)
|
||||
self.onPaintCalled = True
|
||||
|
||||
panel = TestPanel(self.frame)
|
||||
self.frame.SendSizeEvent()
|
||||
panel.Refresh()
|
||||
panel.Update()
|
||||
wx.Yield()
|
||||
self.assertTrue(panel.onPaintCalled == True)
|
||||
|
||||
|
||||
def test_BufferedDCConstantsExist(self):
|
||||
wx.BUFFER_VIRTUAL_AREA
|
||||
wx.BUFFER_CLIENT_AREA
|
||||
wx.BUFFER_USES_SHARED_BUFFER
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -40,6 +40,11 @@ class WindowList(unittest.TestCase):
|
||||
children = self.frames[4].GetChildren()
|
||||
self.assertTrue(len(children) == 5)
|
||||
|
||||
def test_WindowList_repr(self):
|
||||
TLWs = wx.GetTopLevelWindows()
|
||||
self.assertTrue(repr(TLWs).startswith("WindowList:"))
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user