From c39d88aeaa33a5922b33ccdd6bad543ac0e3629b Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Sat, 29 Oct 2011 06:11:08 +0000 Subject: [PATCH] Process and wxScrolledWindow/Canvas unittests git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@69578 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- unittests/process_test.py | 8 ++++- unittests/test_process.py | 5 ++- unittests/test_scrolwin.py | 67 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 unittests/test_scrolwin.py diff --git a/unittests/process_test.py b/unittests/process_test.py index de98bf85..123a76ac 100644 --- a/unittests/process_test.py +++ b/unittests/process_test.py @@ -1,3 +1,9 @@ import sys -print 'process_test' + +if '--stdout' in sys.argv: + print 'process_test' +if '--echo' in sys.argv: + text = raw_input() + print "I read '%s'" % text + sys.exit(0) diff --git a/unittests/test_process.py b/unittests/test_process.py index 16d50ae3..249f44fc 100644 --- a/unittests/test_process.py +++ b/unittests/test_process.py @@ -25,8 +25,11 @@ 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 + #--------------------------------------------------------------------------- diff --git a/unittests/test_scrolwin.py b/unittests/test_scrolwin.py new file mode 100644 index 00000000..23702765 --- /dev/null +++ b/unittests/test_scrolwin.py @@ -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()