Add some Html unittests, and fix some issues discovered by the tests.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@72857 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2012-11-01 22:51:42 +00:00
parent 79e9959281
commit d4ce9984ff
15 changed files with 116 additions and 53 deletions

View File

@@ -44,10 +44,12 @@ def run():
c = module.find('wxHtmlCell')
assert isinstance(c, etgtools.ClassDef)
c.addPrivateCopyCtor()
c.find('SetNext.cell').transfer = True
c.find('AdjustPagebreak.pagebreak').inOut = True
c = module.find('wxHtmlContainerCell')
c.find('InsertCell.cell').transfer = True
#-----------------------------------------------------------------
tools.doCommonTweaks(module)

View File

@@ -18,7 +18,6 @@ DOCSTRING = ""
# The classes and/or the basename of the Doxygen XML files to be processed by
# this script.
ITEMS = [ "htmldefs_8h.xml",
]
#---------------------------------------------------------------------------
@@ -35,6 +34,7 @@ def run():
#c = module.find('')
#assert isinstance(c, etgtools.ClassDef)
module.addItem(etgtools.DefineDef(name='INT_MAX', value='11111'))
#-----------------------------------------------------------------
tools.doCommonTweaks(module)

View File

@@ -25,7 +25,7 @@ ITEMS = [ "wxHtmlFilter",
def run():
# Parse the XML file(s) building a collection of Extractor objects
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING, check4unittest=False)
etgtools.parseDoxyXML(module, ITEMS)
#-----------------------------------------------------------------

View File

@@ -21,7 +21,7 @@ ITEMS = [ "wxHtmlDCRenderer",
"wxHtmlEasyPrinting",
"wxHtmlPrintout",
]
#---------------------------------------------------------------------------
def run():
@@ -38,6 +38,9 @@ def run():
c.addPrivateCopyCtor()
tools.fixHtmlSetFonts(c)
c.find('Render.from').name = 'from_'
c.find('Render.to').name = 'to_'
c = module.find('wxHtmlEasyPrinting')
c.addPrivateCopyCtor()

View File

@@ -25,7 +25,7 @@ ITEMS = [ "wxHtmlTag",
def run():
# Parse the XML file(s) building a collection of Extractor objects
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING, check4unittest=False)
etgtools.parseDoxyXML(module, ITEMS)
#-----------------------------------------------------------------

View File

@@ -50,6 +50,10 @@ def run():
c.find('AddModule').ignore()
c.addItem(etgtools.WigCode("""\
virtual wxObject* GetProduct();
"""))
module.addCppCode("""\
class wxPyHtmlTagsModule : public wxHtmlTagsModule {
@@ -58,7 +62,7 @@ def run():
m_tagHandlerClass = thc;
wxPyThreadBlocker blocker;
Py_INCREF(m_tagHandlerClass);
RegisterModule(this);
RegisterModule(this);
wxHtmlWinParser::AddModule(this);
}
@@ -70,11 +74,9 @@ def run():
PyObject* obj = (PyObject*)m_objArray.Item(x);
Py_DECREF(obj);
}
};
}
void FillHandlersTable(wxHtmlWinParser *parser) {
// Wave our magic wand... (if it works it's a miracle! ;-)
wxPyThreadBlocker blocker;
wxHtmlWinTagHandler* thPtr = 0;
// First, make a new instance of the tag handler
@@ -107,6 +109,7 @@ def run():
// Dynamically create a new wxModule. Refcounts tagHandlerClass
// and adds itself to the wxModules list and to the wxHtmlWinParser.
new wxPyHtmlTagsModule(tagHandlerClass);
wxModule::InitializeModules();
""")

View File

@@ -1,14 +1,36 @@
import imp_unittest, unittest
import wtc
import wx
import wx.html
#---------------------------------------------------------------------------
class htmlcell_Tests(wtc.WidgetTestCase):
# TODO: Remove this test and add real ones.
def test_htmlcell1(self):
self.fail("Unit tests for htmlcell not implemented yet.")
c = wx.html.HtmlCell()
def test_htmlcell2(self):
obj = wx.html.HtmlSelection()
def test_htmlcell3(self):
obj = wx.html.HtmlRenderingState()
def test_htmlcell4(self):
obj = wx.html.HtmlRenderingInfo()
def test_htmlcell5(self):
obj = wx.html.HtmlContainerCell(None)
def test_htmlcell6(self):
obj = wx.html.HtmlLinkInfo()
def test_htmlcell7(self):
obj = wx.html.HtmlColourCell(wx.BLACK)
def test_htmlcell8(self):
obj = wx.html.HtmlWidgetCell(self.frame)
#---------------------------------------------------------------------------

View File

@@ -60,7 +60,12 @@ class htmldefs_Tests(wtc.WidgetTestCase):
wx.html.HTML_COND_ISIMAGEMAP
wx.html.HTML_COND_USER
wx.html.HTML_FIND_EXACT
wx.html.HTML_FIND_NEAREST_BEFORE
wx.html.HTML_FIND_NEAREST_AFTER
wx.html.HTML_SCRIPT_NORMAL
wx.html.HTML_SCRIPT_SUB
wx.html.HTML_SCRIPT_SUP
#---------------------------------------------------------------------------

View File

@@ -1,16 +0,0 @@
import imp_unittest, unittest
import wtc
import wx
#---------------------------------------------------------------------------
class htmlfilt_Tests(wtc.WidgetTestCase):
# TODO: Remove this test and add real ones.
def test_htmlfilt1(self):
self.fail("Unit tests for htmlfilt not implemented yet.")
#---------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()

View File

@@ -1,15 +1,28 @@
import imp_unittest, unittest
import wtc
import wx
import wx.html
#---------------------------------------------------------------------------
class htmlpars_Tests(wtc.WidgetTestCase):
# TODO: Remove this test and add real ones.
def test_htmlpars1(self):
self.fail("Unit tests for htmlpars not implemented yet.")
class myTagHandler(wx.html.HtmlTagHandler):
def __init__(self):
wx.html.HtmlTagHandler.__init__(self)
self.test = None
def GetSupportedTags(self):
return 'FOO,BAR'
def HandleTag(self, tag):
self.test = tag.GetTagName()
wx.html.HtmlWinParser_AddTagHandler(myTagHandler)
self.myYield()
#---------------------------------------------------------------------------
if __name__ == '__main__':

View File

@@ -1,14 +1,24 @@
import imp_unittest, unittest
import wtc
import wx
import wx.html
#---------------------------------------------------------------------------
class htmlprint_Tests(wtc.WidgetTestCase):
# TODO: Remove this test and add real ones.
def test_htmlprint1(self):
self.fail("Unit tests for htmlprint not implemented yet.")
def test_htmlprint1(self):
size = (100,100)
bmp = wx.Bitmap(*size)
dc = wx.MemoryDC(bmp)
obj = wx.html.HtmlDCRenderer()
obj.SetDC(dc)
obj.SetSize(*size)
obj.SetHtmlText('<body><h1>Hello World</h1></body>')
obj.Render(0,0, [])
#---------------------------------------------------------------------------

View File

@@ -1,16 +0,0 @@
import imp_unittest, unittest
import wtc
import wx
#---------------------------------------------------------------------------
class htmltag_Tests(wtc.WidgetTestCase):
# TODO: Remove this test and add real ones.
def test_htmltag1(self):
self.fail("Unit tests for htmltag not implemented yet.")
#---------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()

View File

@@ -1,14 +1,48 @@
import imp_unittest, unittest
import wtc
import wx
import wx.html
import os
helpPath = os.path.join(os.path.dirname(__file__), 'helpfiles')
#---------------------------------------------------------------------------
class htmlwin_Tests(wtc.WidgetTestCase):
# TODO: Remove this test and add real ones.
def test_htmlwin1(self):
self.fail("Unit tests for htmlwin not implemented yet.")
obj = wx.html.HtmlWindow(self.frame)
def test_htmlwin2(self):
obj = wx.html.HtmlWindow()
obj.Create(self.frame)
def test_htmlwin3(self):
obj = wx.html.HtmlWindow(self.frame)
obj.LoadFile(os.path.join(helpPath, 'main.htm'))
self.frame.SendSizeEvent()
self.myYield()
def test_htmlwin4(self):
noLog = wx.LogNull()
obj = wx.html.HtmlWindow(self.frame)
obj.LoadPage('http://www.google.com/')
self.frame.SendSizeEvent()
self.myYield()
def test_htmlwin5(self):
obj = wx.html.HtmlWindow(self.frame)
obj.SetPage("<html><body>Hello, world!</body></html>")
self.frame.SendSizeEvent()
self.myYield()
def test_htmlwin6(self):
obj = wx.html.HtmlWindow(self.frame)
self.frame.SendSizeEvent()
self.myYield()
#---------------------------------------------------------------------------

View File

@@ -1,14 +1,14 @@
import imp_unittest, unittest
import wtc
import wx
import wx.html
#---------------------------------------------------------------------------
class htmlwinpars_Tests(wtc.WidgetTestCase):
# TODO: Remove this test and add real ones.
def test_htmlwinpars1(self):
self.fail("Unit tests for htmlwinpars not implemented yet.")
obj = wx.html.HtmlWinParser()
#---------------------------------------------------------------------------

View File

@@ -39,6 +39,9 @@ class PIImportTest(unittest.TestCase):
def test_stc_pi(self):
self.runPI('stc.pi')
def test_html_pi(self):
self.runPI('html.pi')
#---------------------------------------------------------------------------