Process and wxScrolledWindow/Canvas unittests

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@69578 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2011-10-29 06:11:08 +00:00
parent a0d8470ec4
commit c39d88aeaa
3 changed files with 78 additions and 2 deletions

View File

@@ -1,3 +1,9 @@
import sys
if '--stdout' in sys.argv:
print 'process_test'
if '--echo' in sys.argv:
text = raw_input()
print "I read '%s'" % text
sys.exit(0)

View File

@@ -25,7 +25,10 @@ class process_Tests(wtc.WidgetTestCase):
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)
wx.Execute('%s %s' % (sys.executable, testscript), callback=p)
# TODO: When the stream classes are wrapped add tests for writing to and
# reading from the process
#---------------------------------------------------------------------------

View File

@@ -0,0 +1,67 @@
import imp_unittest, unittest
import wtc
import wx
#---------------------------------------------------------------------------
class scrolwin_Tests(wtc.WidgetTestCase):
def commonBits(self, w):
vsize = 750
rate = 20
w.SetSize(self.frame.GetClientSize())
w.EnableScrolling(True, True)
w.ShowScrollbars(wx.SHOW_SB_ALWAYS, wx.SHOW_SB_ALWAYS)
w.SetVirtualSize((vsize, vsize))
w.SetScrollRate(rate, rate)
w.Scroll(3,3) # in scroll units
self.myYield()
self.assertEqual(w.GetVirtualSize(), (vsize,vsize))
self.assertEqual(w.GetScrollPixelsPerUnit(), (rate,rate))
self.assertEqual(w.GetViewStart(), (3,3)) # scroll units
self.assertEqual(w.CalcScrolledPosition(0,0), (-3*rate,-3*rate)) # pixels
self.assertEqual(w.CalcUnscrolledPosition(0,0),(3*rate,3*rate)) # pixels
def test_scrolwinCtor(self):
w = wx.ScrolledWindow(self.frame)
self.commonBits(w)
def test_scrolwinDefaultCtor(self):
w = wx.ScrolledWindow()
w.Create(self.frame)
self.commonBits(w)
def test_scrolcvsCtor(self):
w = wx.ScrolledCanvas(self.frame)
self.commonBits(w)
def test_scrolcvsDefaultCtor(self):
w = wx.ScrolledCanvas()
w.Create(self.frame)
self.commonBits(w)
def test_scrolwinOnDraw(self):
class MyScrolledWin(wx.ScrolledWindow):
def __init__(self, *args, **kw):
wx.ScrolledWindow.__init__(self, *args, **kw)
self.flag = False
def OnDraw(self, dc):
self.flag = True
sz = dc.GetSize()
dc.SetPen(wx.Pen('blue', 3))
dc.DrawLine(0, 0, sz.width, sz.height)
w = MyScrolledWin(self.frame)
self.commonBits(w)
w.Refresh()
self.myYield()
self.assertTrue(w.flag) # True if OnDraw was called
#---------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()