new unittests

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@69341 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2011-10-09 07:47:33 +00:00
parent e868502a7b
commit 25c3e80700
6 changed files with 369 additions and 0 deletions

25
unittests/test_display.py Normal file
View File

@@ -0,0 +1,25 @@
import imp_unittest, unittest
import wtc
import wx
#---------------------------------------------------------------------------
class display_Tests(wtc.WidgetTestCase):
def test_display(self):
d = wx.Display()
r = d.GetClientArea()
c = wx.Display.GetCount()
self.assertTrue(c >= 1)
m = d.GetModes()
self.assertTrue(isinstance(m, wx.ArrayVideoModes))
self.assertTrue(len(m))
vm = m[0]
self.assertTrue(isinstance(vm, wx.VideoMode))
self.assertTrue(vm.IsOk())
#---------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()

View File

@@ -140,6 +140,14 @@ class Events(unittest.TestCase):
self.assertTrue(frm.gotEvent)
def test_DropFilesEvent_tweaks(self):
evt = wx.DropFilesEvent(123, 'one two three four five'.split())
self.assertTrue(evt.NumberOfFiles == 5)
f = evt.Files
self.assertTrue(isinstance(f, list))
self.assertTrue(len(f) == 5)
#---------------------------------------------------------------------------

50
unittests/test_filedlg.py Normal file
View File

@@ -0,0 +1,50 @@
import imp_unittest, unittest
import wtc
import wx
import os
#---------------------------------------------------------------------------
class filedlg_Tests(wtc.WidgetTestCase):
def test_filedlgFlags(self):
wx.FD_OPEN
wx.FD_SAVE
wx.FD_OVERWRITE_PROMPT
wx.FD_FILE_MUST_EXIST
wx.FD_MULTIPLE
wx.FD_CHANGE_DIR
wx.FD_PREVIEW
def test_filedlg(self):
# a typical use case
dlg = wx.FileDialog(self.frame, 'message', os.getcwd(), "",
wildcard="Python source (*.py)|*.py|")
dlg.Destroy()
def test_filedlgProperties(self):
dlg = wx.FileDialog(None)
dlg.Directory
dlg.ExtraControl
dlg.Filename
dlg.FilterIndex
dlg.Message
dlg.Path
dlg.Wildcard
dlg.Filenames
dlg.Paths
dlg.Destroy()
def test_filedlgTweaks(self):
dlg = wx.FileDialog(None, style=wx.FD_MULTIPLE)
f = dlg.GetFilenames()
p = dlg.GetPaths()
self.assertTrue(isinstance(f, list))
self.assertTrue(isinstance(p, list))
dlg.Destroy()
#---------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()

225
unittests/test_font.py Normal file
View File

@@ -0,0 +1,225 @@
import imp_unittest, unittest
import wtc
import wx
import os
#---------------------------------------------------------------------------
class font_Tests(wtc.WidgetTestCase):
def test_fontFlags(self):
wx.FONTFAMILY_DEFAULT
wx.FONTFAMILY_DECORATIVE
wx.FONTFAMILY_ROMAN
wx.FONTFAMILY_SCRIPT
wx.FONTFAMILY_SWISS
wx.FONTFAMILY_MODERN
wx.FONTFAMILY_TELETYPE
wx.FONTFAMILY_UNKNOWN
wx.FONTSTYLE_NORMAL
wx.FONTSTYLE_ITALIC
wx.FONTSTYLE_SLANT
wx.FONTWEIGHT_NORMAL
wx.FONTWEIGHT_LIGHT
wx.FONTWEIGHT_BOLD
wx.FONTSIZE_XX_SMALL
wx.FONTSIZE_X_SMALL
wx.FONTSIZE_SMALL
wx.FONTSIZE_MEDIUM
wx.FONTSIZE_LARGE
wx.FONTSIZE_X_LARGE
wx.FONTSIZE_XX_LARGE
wx.FONTFLAG_DEFAULT
wx.FONTFLAG_ITALIC
wx.FONTFLAG_SLANT
wx.FONTFLAG_LIGHT
wx.FONTFLAG_BOLD
wx.FONTFLAG_ANTIALIASED
wx.FONTFLAG_NOT_ANTIALIASED
wx.FONTFLAG_UNDERLINED
wx.FONTFLAG_STRIKETHROUGH
wx.FONTENCODING_SYSTEM
wx.FONTENCODING_DEFAULT
wx.FONTENCODING_ISO8859_1
wx.FONTENCODING_ISO8859_2
wx.FONTENCODING_ISO8859_3
wx.FONTENCODING_ISO8859_4
wx.FONTENCODING_ISO8859_5
wx.FONTENCODING_ISO8859_6
wx.FONTENCODING_ISO8859_7
wx.FONTENCODING_ISO8859_8
wx.FONTENCODING_ISO8859_9
wx.FONTENCODING_ISO8859_10
wx.FONTENCODING_ISO8859_11
wx.FONTENCODING_ISO8859_12
wx.FONTENCODING_ISO8859_13
wx.FONTENCODING_ISO8859_14
wx.FONTENCODING_ISO8859_15
wx.FONTENCODING_ISO8859_MAX
wx.FONTENCODING_KOI8
wx.FONTENCODING_KOI8_U
wx.FONTENCODING_ALTERNATIVE
wx.FONTENCODING_BULGARIAN
wx.FONTENCODING_CP437
wx.FONTENCODING_CP850
wx.FONTENCODING_CP852
wx.FONTENCODING_CP855
wx.FONTENCODING_CP866
wx.FONTENCODING_CP874
wx.FONTENCODING_CP932
wx.FONTENCODING_CP936
wx.FONTENCODING_CP949
wx.FONTENCODING_CP950
wx.FONTENCODING_CP1250
wx.FONTENCODING_CP1251
wx.FONTENCODING_CP1252
wx.FONTENCODING_CP1253
wx.FONTENCODING_CP1254
wx.FONTENCODING_CP1255
wx.FONTENCODING_CP1256
wx.FONTENCODING_CP1257
wx.FONTENCODING_CP12_MAX
wx.FONTENCODING_UTF7
wx.FONTENCODING_UTF8
wx.FONTENCODING_EUC_JP
wx.FONTENCODING_UTF16BE
wx.FONTENCODING_UTF16LE
wx.FONTENCODING_UTF32BE
wx.FONTENCODING_UTF32LE
wx.FONTENCODING_MACROMAN
wx.FONTENCODING_MACJAPANESE
wx.FONTENCODING_MACCHINESETRAD
wx.FONTENCODING_MACKOREAN
wx.FONTENCODING_MACARABIC
wx.FONTENCODING_MACHEBREW
wx.FONTENCODING_MACGREEK
wx.FONTENCODING_MACCYRILLIC
wx.FONTENCODING_MACDEVANAGARI
wx.FONTENCODING_MACGURMUKHI
wx.FONTENCODING_MACGUJARATI
wx.FONTENCODING_MACORIYA
wx.FONTENCODING_MACBENGALI
wx.FONTENCODING_MACTAMIL
wx.FONTENCODING_MACTELUGU
wx.FONTENCODING_MACKANNADA
wx.FONTENCODING_MACMALAJALAM
wx.FONTENCODING_MACSINHALESE
wx.FONTENCODING_MACBURMESE
wx.FONTENCODING_MACKHMER
wx.FONTENCODING_MACTHAI
wx.FONTENCODING_MACLAOTIAN
wx.FONTENCODING_MACGEORGIAN
wx.FONTENCODING_MACARMENIAN
wx.FONTENCODING_MACCHINESESIMP
wx.FONTENCODING_MACTIBETAN
wx.FONTENCODING_MACMONGOLIAN
wx.FONTENCODING_MACETHIOPIC
wx.FONTENCODING_MACCENTRALEUR
wx.FONTENCODING_MACVIATNAMESE
wx.FONTENCODING_MACARABICEXT
wx.FONTENCODING_MACSYMBOL
wx.FONTENCODING_MACDINGBATS
wx.FONTENCODING_MACTURKISH
wx.FONTENCODING_MACCROATIAN
wx.FONTENCODING_MACICELANDIC
wx.FONTENCODING_MACROMANIAN
wx.FONTENCODING_MACCELTIC
wx.FONTENCODING_MACGAELIC
wx.FONTENCODING_MACKEYBOARD
wx.FONTENCODING_ISO2022_JP
wx.FONTENCODING_MAX
wx.FONTENCODING_MACMIN
wx.FONTENCODING_MACMAX
wx.FONTENCODING_UTF16
wx.FONTENCODING_UTF32
wx.FONTENCODING_UNICODE
wx.FONTENCODING_GB2312
wx.FONTENCODING_BIG5
wx.FONTENCODING_SHIFT_JIS
wx.FONTENCODING_EUC_KR
def test_fontFlagsOld(self):
wx.DEFAULT
wx.DECORATIVE
wx.ROMAN
wx.SCRIPT
wx.SWISS
wx.MODERN
wx.TELETYPE
wx.NORMAL
wx.LIGHT
wx.BOLD
wx.NORMAL
wx.ITALIC
wx.SLANT
def test_font(self):
f1 = wx.Font()
f2 = wx.Font(f1)
f3 = wx.Font(18, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)
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)
def test_fontOk(self):
f1 = wx.Font()
f2 = wx.FFont(18, wx.FONTFAMILY_ROMAN)
self.assertTrue(not f1.IsOk())
self.assertTrue( f2.IsOk())
if f1:
self.fail('f1 should not be True')
if not f2:
self.fail('f2 should not be False')
def test_fontEquality(self):
f1 = wx.Font(18, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)
f2 = wx.FFont(18, wx.FONTFAMILY_ROMAN)
f3 = wx.Font(wx.Size(12,12), wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)
self.assertTrue(f1 == f2)
self.assertTrue(f1 != f3)
def test_fontProperties(self):
f = wx.FFont(18, wx.FONTFAMILY_SWISS)
f.Encoding
f.FaceName
f.Family
f.NativeFontInfoDesc
f.NativeFontInfoUserDesc
f.PointSize
f.PixelSize
f.Style
f.Weight
def test_stockFonts(self):
self.assertTrue(not wx.NullFont.IsOk())
self.assertTrue(wx.NORMAL_FONT.IsOk())
self.assertTrue(wx.SMALL_FONT.IsOk())
self.assertTrue(wx.ITALIC_FONT.IsOk())
self.assertTrue(wx.SWISS_FONT.IsOk())
def test_fontFixedWidth(self):
f = wx.FFont(10, wx.FONTFAMILY_TELETYPE)
self.assertTrue(f.IsFixedWidth())
def test_fontTweaks(self):
pass
#---------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,38 @@
import imp_unittest, unittest
import wtc
import wx
import os
#---------------------------------------------------------------------------
class fontutil_Tests(wtc.WidgetTestCase):
def test_fontutil(self):
f1 = wx.FFont(12, wx.FONTFAMILY_SWISS)
i1 = f1.GetNativeFontInfo()
st = i1.ToString()
i2 = wx.NativeFontInfo()
i2.FromString(st)
f2 = wx.Font(i2)
self.assertTrue(f1 == f2)
def test_fontutilProperties(self):
nfi = wx.NativeFontInfo()
nfi.InitFromFont(wx.NORMAL_FONT)
nfi.Encoding
nfi.FaceName
nfi.Family
nfi.PointSize
#nfi.PixelSize
nfi.Style
nfi.Underlined
nfi.Weight
#---------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()

23
unittests/test_vidmode.py Normal file
View File

@@ -0,0 +1,23 @@
import imp_unittest, unittest
import wtc
import wx
#---------------------------------------------------------------------------
class vidmode_Tests(wtc.WidgetTestCase):
def test_vidmode(self):
vm = wx.VideoMode()
vm = wx.VideoMode(1024, 768, 32)
self.assertTrue(vm.w == 1024)
self.assertTrue(vm.h == 768)
self.assertTrue(vm.bpp == 32)
def test_defaultVidmode(self):
wx.DefaultVideoMode # just testing that it exists
#---------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()