mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-05 11:30:06 +01:00
Add and update DC unittests
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@69306 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,15 +1,10 @@
|
||||
import imp_unittest
|
||||
import imp_unittest, unittest
|
||||
import wtc
|
||||
import wx
|
||||
import os
|
||||
|
||||
# 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.
|
||||
|
||||
pngFile = os.path.join(os.path.dirname(__file__), 'toucan.png')
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
@@ -54,6 +49,87 @@ class DCTests(wtc.WidgetTestCase):
|
||||
fm.averageWidth
|
||||
|
||||
|
||||
def test_DCClipper(self):
|
||||
dc = wx.ClientDC(self.frame)
|
||||
c = wx.DCClipper(dc, wx.Rect(10,10,25,25))
|
||||
del c
|
||||
c = wx.DCClipper(dc, (10,10,25,25))
|
||||
del c
|
||||
c = wx.DCClipper(dc, 10,10,25,25)
|
||||
del c
|
||||
r = wx.Region(10,10,25,25)
|
||||
c = wx.DCClipper(dc, r)
|
||||
del c
|
||||
|
||||
|
||||
def test_DCBrushChanger(self):
|
||||
dc = wx.ClientDC(self.frame)
|
||||
c = wx.DCBrushChanger(dc, wx.Brush('blue'))
|
||||
del c
|
||||
|
||||
|
||||
def test_DCPenChanger(self):
|
||||
dc = wx.ClientDC(self.frame)
|
||||
c = wx.DCPenChanger(dc, wx.Pen('blue'))
|
||||
del c
|
||||
|
||||
|
||||
def test_DCTextColourChanger(self):
|
||||
dc = wx.ClientDC(self.frame)
|
||||
c = wx.DCTextColourChanger(dc)
|
||||
c.Set('blue')
|
||||
del c
|
||||
c = wx.DCTextColourChanger(dc, 'blue')
|
||||
del c
|
||||
|
||||
|
||||
def test_DCFontChanger(self):
|
||||
dc = wx.ClientDC(self.frame)
|
||||
font = wx.FFont(12, wx.FONTFAMILY_SWISS)
|
||||
c = wx.DCFontChanger(dc)
|
||||
c.Set(font)
|
||||
del c
|
||||
c = wx.DCFontChanger(dc, font)
|
||||
del c
|
||||
|
||||
|
||||
def test_NativeWinHandle(self):
|
||||
dc = wx.ClientDC(self.frame)
|
||||
if 'wxMSW' in wx.PortInfo:
|
||||
h = dc.GetHDC()
|
||||
self.assertNotEqual(h, 0)
|
||||
else:
|
||||
with self.assertRaises(NotImplementedError):
|
||||
h = dc.GetHDC()
|
||||
|
||||
def test_NativeGTKHandle(self):
|
||||
dc = wx.ClientDC(self.frame)
|
||||
if 'wxGTK' in wx.PortInfo:
|
||||
h = dc.GetGdkDrawable()
|
||||
self.assertNotEqual(h, 0)
|
||||
else:
|
||||
with self.assertRaises(NotImplementedError):
|
||||
h = dc.GetGdkDrawable()
|
||||
|
||||
def test_NativeMacHandle(self):
|
||||
dc = wx.ClientDC(self.frame)
|
||||
if 'wxMac' in wx.PortInfo:
|
||||
h = dc.GetCGContext()
|
||||
self.assertNotEqual(h, 0)
|
||||
else:
|
||||
with self.assertRaises(NotImplemented):
|
||||
h = dc.GetGCContext()
|
||||
|
||||
def test_trickyStuff(self):
|
||||
# execute some tricky tweaks to make sure they work are as they are supposed to.
|
||||
dc = wx.ClientDC(self.frame)
|
||||
bmp = wx.Bitmap(pngFile)
|
||||
dc.DrawLabel("toucan", bmp, (10,10, 200, 100))
|
||||
|
||||
values = dc.GetPartialTextExtents("Hello")
|
||||
self.assertTrue(type(values) == list)
|
||||
self.assertTrue(len(values) == 5)
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@@ -37,12 +37,16 @@ class BufferedDCTests(wtc.WidgetTestCase):
|
||||
def test_BufferedDCDefaultCtor(self):
|
||||
dc = wx.BufferedDC()
|
||||
dc.Init(None, wx.Bitmap(25,25))
|
||||
dc.DrawLine(0,0, 50,50)
|
||||
|
||||
|
||||
def test_BufferedDCCtors(self):
|
||||
dc = wx.BufferedDC(wx.ClientDC(self.frame), wx.Size(100,100))
|
||||
dc.DrawLine(0,0, 50,50)
|
||||
dc = wx.BufferedDC(wx.ClientDC(self.frame))
|
||||
dc.DrawLine(0,0, 50,50)
|
||||
dc = wx.BufferedDC(None, wx.Bitmap(100,100))
|
||||
dc.DrawLine(0,0, 50,50)
|
||||
|
||||
|
||||
def test_BufferedPaintDC(self):
|
||||
|
||||
@@ -9,9 +9,11 @@ class ClientDCTests(wtc.WidgetTestCase):
|
||||
|
||||
def test_ClientDC(self):
|
||||
dc = wx.ClientDC(self.frame)
|
||||
dc.DrawLine(0,0, 50,50)
|
||||
|
||||
def test_WindowDC(self):
|
||||
dc = wx.ClientDC(self.frame)
|
||||
dc = wx.WindowDC(self.frame)
|
||||
dc.DrawLine(0,0, 50,50)
|
||||
|
||||
|
||||
def test_PaintDC(self):
|
||||
|
||||
@@ -8,20 +8,23 @@ import sys
|
||||
class MemoryDCTests(wtc.WidgetTestCase):
|
||||
|
||||
def test_MemoryDC1(self):
|
||||
bmp = wx.Bitmap(25,25)
|
||||
bmp = wx.Bitmap(250,250)
|
||||
dc = wx.MemoryDC()
|
||||
dc.SelectObject(bmp)
|
||||
dc.DrawLine(0,0, 50,50)
|
||||
|
||||
|
||||
def test_MemoryDC2(self):
|
||||
bmp = wx.Bitmap(25,25)
|
||||
bmp = wx.Bitmap(250,250)
|
||||
dc = wx.MemoryDC(bmp)
|
||||
dc.DrawLine(0,0, 50,50)
|
||||
|
||||
def test_MemoryDC3(self):
|
||||
cdc = wx.ClientDC(self.frame)
|
||||
dc = wx.MemoryDC(cdc)
|
||||
bmp = wx.Bitmap(25,25)
|
||||
bmp = wx.Bitmap(250,250)
|
||||
dc.SelectObject(bmp)
|
||||
dc.DrawLine(0,0, 50,50)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
@@ -10,6 +10,7 @@ class MirrorDCTests(wtc.WidgetTestCase):
|
||||
def test_MirrorDC1(self):
|
||||
cdc = wx.ClientDC(self.frame)
|
||||
dc = wx.MirrorDC(cdc, True)
|
||||
dc.DrawLine(0,0, 50,50)
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ class dcprint_tests(wtc.WidgetTestCase):
|
||||
|
||||
def test_PrinterDC1(self):
|
||||
dc = wx.PrinterDC(wx.PrintData())
|
||||
dc.DrawLine(0,0, 50,50)
|
||||
|
||||
|
||||
|
||||
|
||||
28
unittests/test_dcps.py
Normal file
28
unittests/test_dcps.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import imp_unittest, unittest
|
||||
import wtc
|
||||
import wx
|
||||
import sys
|
||||
import os
|
||||
|
||||
fileName = 'svgtest.svg'
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class dcps_tests(wtc.WidgetTestCase):
|
||||
|
||||
def test_PostscriptDC1(self):
|
||||
return
|
||||
pd = wx.PrintData()
|
||||
pd.SetFilename(fileName)
|
||||
dc = wx.PostScriptDC(pd)
|
||||
dc.StartDoc("message")
|
||||
dc.DrawLine(0,0, 50,50)
|
||||
del dc
|
||||
os.remove(fileName)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -10,6 +10,7 @@ class ScreenDCTests(wtc.WidgetTestCase):
|
||||
|
||||
def test_ScreenDC1(self):
|
||||
dc = wx.ScreenDC()
|
||||
dc.DrawLine(0,0, 50,50)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user