diff --git a/unittests/test_dc.py b/unittests/test_dc.py index e5a28a67..641eea04 100644 --- a/unittests/test_dc.py +++ b/unittests/test_dc.py @@ -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) + #--------------------------------------------------------------------------- diff --git a/unittests/test_dcbuffer.py b/unittests/test_dcbuffer.py index 35f8c86d..0f03c326 100644 --- a/unittests/test_dcbuffer.py +++ b/unittests/test_dcbuffer.py @@ -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): diff --git a/unittests/test_dcclient.py b/unittests/test_dcclient.py index 7c786896..dcd2c7f3 100644 --- a/unittests/test_dcclient.py +++ b/unittests/test_dcclient.py @@ -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): diff --git a/unittests/test_dcmemory.py b/unittests/test_dcmemory.py index dc492755..06ba5a87 100644 --- a/unittests/test_dcmemory.py +++ b/unittests/test_dcmemory.py @@ -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) #--------------------------------------------------------------------------- diff --git a/unittests/test_dcmirror.py b/unittests/test_dcmirror.py index eb6d667e..bd5a0df6 100644 --- a/unittests/test_dcmirror.py +++ b/unittests/test_dcmirror.py @@ -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) #--------------------------------------------------------------------------- diff --git a/unittests/test_dcprint.py b/unittests/test_dcprint.py index 236c374c..c138600d 100644 --- a/unittests/test_dcprint.py +++ b/unittests/test_dcprint.py @@ -9,6 +9,7 @@ class dcprint_tests(wtc.WidgetTestCase): def test_PrinterDC1(self): dc = wx.PrinterDC(wx.PrintData()) + dc.DrawLine(0,0, 50,50) diff --git a/unittests/test_dcps.py b/unittests/test_dcps.py new file mode 100644 index 00000000..67b10372 --- /dev/null +++ b/unittests/test_dcps.py @@ -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() diff --git a/unittests/test_dcscreen.py b/unittests/test_dcscreen.py index 988c17a5..bc354825 100644 --- a/unittests/test_dcscreen.py +++ b/unittests/test_dcscreen.py @@ -10,6 +10,7 @@ class ScreenDCTests(wtc.WidgetTestCase): def test_ScreenDC1(self): dc = wx.ScreenDC() + dc.DrawLine(0,0, 50,50) #---------------------------------------------------------------------------