some unittest fixes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@70552 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2012-02-09 06:24:28 +00:00
parent ff5abd2efe
commit 5e1e9ac301
7 changed files with 20 additions and 7 deletions

View File

@@ -66,7 +66,7 @@ class BufferedDCTests(wtc.WidgetTestCase):
panel = TestPanel(self.frame)
self.frame.SendSizeEvent()
panel.Refresh()
panel.Update()
self.myUpdate(panel)
self.myYield()
self.assertTrue(panel.onPaintCalled == True)
@@ -87,7 +87,7 @@ class BufferedDCTests(wtc.WidgetTestCase):
panel = TestPanel(self.frame)
self.frame.SendSizeEvent()
panel.Refresh()
panel.Update()
self.myUpdate(panel)
self.myYield()
self.assertTrue(panel.onPaintCalled == True)

View File

@@ -32,7 +32,7 @@ class ClientDCTests(wtc.WidgetTestCase):
panel = TestPanel(self.frame)
self.frame.SendSizeEvent()
panel.Refresh()
panel.Update()
self.myUpdate(panel)
self.myYield()
self.assertTrue(panel.onPaintCalled == True)

View File

@@ -1,6 +1,7 @@
import imp_unittest, unittest
import wtc
import wx
import os; print os.getpid()
#---------------------------------------------------------------------------
@@ -13,7 +14,7 @@ class display_Tests(wtc.WidgetTestCase):
self.assertTrue(c >= 1)
m = d.GetModes()
self.assertTrue(isinstance(m, wx.ArrayVideoModes))
self.assertTrue(len(m))
self.assertTrue(len(m) > 0)
vm = m[0]
self.assertTrue(isinstance(vm, wx.VideoMode))
self.assertTrue(vm.IsOk())

View File

@@ -167,6 +167,7 @@ class font_Tests(wtc.WidgetTestCase):
f4 = wx.Font(wx.Size(12,12), wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)
f5 = wx.FFont(18, wx.FONTFAMILY_ROMAN)
f6 = wx.Font.New(18, wx.FONTFAMILY_SWISS)
f7 = wx.Font(18, wx.FONTFAMILY_SWISS, wx.FONTFLAG_BOLD|wx.FONTFLAG_ITALIC)
def test_fontOk(self):
@@ -210,8 +211,8 @@ class font_Tests(wtc.WidgetTestCase):
def test_fontFixedWidth(self):
f = wx.FFont(10, wx.FONTFAMILY_TELETYPE)
self.assertTrue(f.IsFixedWidth())
f = wx.FFont(10, wx.FONTFAMILY_TELETYPE)
self.assertTrue(f.IsFixedWidth())
def test_fontTweaks(self):

View File

@@ -72,7 +72,6 @@ class platinfo_Tests(wtc.WidgetTestCase):
wx.PORT_MAC
wx.PORT_COCOA
wx.PORT_WINCE
wx.PORT_PALMOS
wx.PORT_DFB
wx.ARCH_INVALID

View File

@@ -57,6 +57,7 @@ class scrolwin_Tests(wtc.WidgetTestCase):
w = MyScrolledWin(self.frame)
self.commonBits(w)
w.Refresh()
self.myUpdate(w)
self.myYield()
self.assertTrue(w.flag) # True if OnDraw was called

View File

@@ -36,6 +36,17 @@ class WidgetTestCase(unittest.TestCase):
activator = wx.EventLoopActivator(evtLoop) # automatically restores the old one
evtLoop.YieldFor(eventsToProcess)
def myUpdate(self, window):
"""
Since Update() will not trigger paint events on Mac faster than
1/30 of second we need to wait a little to ensure that there will
actually be a paint event while we are yielding.
"""
if 'wxOSX' in wx.PlatformInfo():
wx.MilliSleep(40) # a little more than 1/30, just in case
window.Update()
#---------------------------------------------------------------------------