From 79e995928127803fd085c806c7b89f3fba7efc27 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 1 Nov 2012 22:51:31 +0000 Subject: [PATCH] Add some HtmlHelp unittests, and fix some issues discovered by the tests. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@72856 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- etg/_html.py | 2 +- etg/helpctrl.py | 12 +++++- etg/helpwnd.py | 5 +++ unittests/helpfiles/Index.hhk | 71 ++++++++++++++++++++++++++++++++ unittests/helpfiles/another.hhc | 18 ++++++++ unittests/helpfiles/another.hhp | 6 +++ unittests/helpfiles/another.htm | 24 +++++++++++ unittests/helpfiles/book1.htm | 4 ++ unittests/helpfiles/book2.htm | 5 +++ unittests/helpfiles/contents.hhc | 28 +++++++++++++ unittests/helpfiles/main.htm | 5 +++ unittests/helpfiles/page2-b.htm | 5 +++ unittests/helpfiles/testing.hhp | 16 +++++++ unittests/test_helpctrl.py | 13 +++++- unittests/test_helpdata.py | 55 ++++++++++++++++++++++++- unittests/test_helpdlg.py | 13 +++++- unittests/test_helpfrm.py | 18 +++++++- unittests/test_helpwnd.py | 17 +++++++- unittests/test_htmldefs.py | 68 ++++++++++++++++++++++++++++++ 19 files changed, 373 insertions(+), 12 deletions(-) create mode 100644 unittests/helpfiles/Index.hhk create mode 100644 unittests/helpfiles/another.hhc create mode 100644 unittests/helpfiles/another.hhp create mode 100644 unittests/helpfiles/another.htm create mode 100644 unittests/helpfiles/book1.htm create mode 100644 unittests/helpfiles/book2.htm create mode 100644 unittests/helpfiles/contents.hhc create mode 100644 unittests/helpfiles/main.htm create mode 100644 unittests/helpfiles/page2-b.htm create mode 100644 unittests/helpfiles/testing.hhp create mode 100644 unittests/test_htmldefs.py diff --git a/etg/_html.py b/etg/_html.py index 53cfd1ff..b7396959 100644 --- a/etg/_html.py +++ b/etg/_html.py @@ -35,8 +35,8 @@ INCLUDES = [ 'htmlwinpars', 'helpdata', - 'helpdlg', 'helpfrm', + 'helpdlg', 'helpwnd', 'helpctrl', ] diff --git a/etg/helpctrl.py b/etg/helpctrl.py index 7aa0e200..f2000d09 100644 --- a/etg/helpctrl.py +++ b/etg/helpctrl.py @@ -35,7 +35,17 @@ def run(): c = module.find('wxHtmlHelpController') assert isinstance(c, etgtools.ClassDef) c.addPrivateCopyCtor() - + + c.find('CreateHelpDialog').ignore(False) + c.find('CreateHelpFrame').ignore(False) + + c.addItem(etgtools.WigCode("""\ + // Add implementations for the pure virtuals in the base class + virtual bool DisplayBlock(long blockNo); + virtual bool DisplaySection(int sectionNo); + virtual bool LoadFile(const wxString& file = wxEmptyString); + virtual bool Quit(); + """)) #----------------------------------------------------------------- tools.doCommonTweaks(module) diff --git a/etg/helpwnd.py b/etg/helpwnd.py index ae6a22a9..3c1684cd 100644 --- a/etg/helpwnd.py +++ b/etg/helpwnd.py @@ -38,6 +38,11 @@ def run(): c.find('SetController.controller').transfer = True + c.find('CreateSearch').ignore(False) + c.find('AddToolbarButtons').ignore(False) + c.find('CreateContents').ignore(False) + c.find('CreateIndex').ignore(False) + #----------------------------------------------------------------- tools.doCommonTweaks(module) diff --git a/unittests/helpfiles/Index.hhk b/unittests/helpfiles/Index.hhk new file mode 100644 index 00000000..1835a2dd --- /dev/null +++ b/unittests/helpfiles/Index.hhk @@ -0,0 +1,71 @@ + + + + + + + + diff --git a/unittests/helpfiles/another.hhc b/unittests/helpfiles/another.hhc new file mode 100644 index 00000000..f9dd6045 --- /dev/null +++ b/unittests/helpfiles/another.hhc @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/unittests/helpfiles/another.hhp b/unittests/helpfiles/another.hhp new file mode 100644 index 00000000..017ed242 --- /dev/null +++ b/unittests/helpfiles/another.hhp @@ -0,0 +1,6 @@ +[OPTIONS] +Compatibility=1.1 +Contents file=another.hhc +Display compile progress=No +Title=Another book +Default topic=another.htm diff --git a/unittests/helpfiles/another.htm b/unittests/helpfiles/another.htm new file mode 100644 index 00000000..4532dc8c --- /dev/null +++ b/unittests/helpfiles/another.htm @@ -0,0 +1,24 @@ + + + + Another HTML Help book + + + +

Another book...

+ Here's another book to demonstrate that + + You can also view the project file for this book. + + diff --git a/unittests/helpfiles/book1.htm b/unittests/helpfiles/book1.htm new file mode 100644 index 00000000..fa470e3e --- /dev/null +++ b/unittests/helpfiles/book1.htm @@ -0,0 +1,4 @@ +Book 1 +

Book 1.

+How do you enjoy book one?? + diff --git a/unittests/helpfiles/book2.htm b/unittests/helpfiles/book2.htm new file mode 100644 index 00000000..828723fc --- /dev/null +++ b/unittests/helpfiles/book2.htm @@ -0,0 +1,5 @@ +Book 1 +

Book 2.

+How do you enjoy book two?? +

Please click HERE + diff --git a/unittests/helpfiles/contents.hhc b/unittests/helpfiles/contents.hhc new file mode 100644 index 00000000..9ecf3537 --- /dev/null +++ b/unittests/helpfiles/contents.hhc @@ -0,0 +1,28 @@ + + + + + + + + + +

+ + diff --git a/unittests/helpfiles/main.htm b/unittests/helpfiles/main.htm new file mode 100644 index 00000000..ca5275bf --- /dev/null +++ b/unittests/helpfiles/main.htm @@ -0,0 +1,5 @@ + +

This is main page.

+Book 1
+Book 2
+ diff --git a/unittests/helpfiles/page2-b.htm b/unittests/helpfiles/page2-b.htm new file mode 100644 index 00000000..f51dd6d6 --- /dev/null +++ b/unittests/helpfiles/page2-b.htm @@ -0,0 +1,5 @@ + + +Hello, you're on sub page of page 2 !!! + + diff --git a/unittests/helpfiles/testing.hhp b/unittests/helpfiles/testing.hhp new file mode 100644 index 00000000..5f8eb344 --- /dev/null +++ b/unittests/helpfiles/testing.hhp @@ -0,0 +1,16 @@ +[OPTIONS] +Compatibility=1.1 +Compiled file=testing.chm +Contents file=contents.hhc +Display compile progress=No +Index file=Index.hhk +Language=0x405 Èesky +Title=Test HELPFILE +Default topic=main.htm + +[FILES] +main.htm +book1.htm +book2.htm +page2-b.htm + diff --git a/unittests/test_helpctrl.py b/unittests/test_helpctrl.py index 570430a1..9b31eb09 100644 --- a/unittests/test_helpctrl.py +++ b/unittests/test_helpctrl.py @@ -1,14 +1,23 @@ import imp_unittest, unittest import wtc import wx +import wx.html + +import os +helpPath = os.path.join(os.path.dirname(__file__), 'helpfiles') #--------------------------------------------------------------------------- class helpctrl_Tests(wtc.WidgetTestCase): - # TODO: Remove this test and add real ones. def test_helpctrl1(self): - self.fail("Unit tests for helpctrl not implemented yet.") + hc = wx.html.HtmlHelpController(parentWindow=self.frame) + hc.AddBook(os.path.join(helpPath, 'testing.hhp')) + hc.AddBook(os.path.join(helpPath, 'another.hhp')) + hc.SetShouldPreventAppExit(False) + + hc.DisplayContents() + self.myYield() #--------------------------------------------------------------------------- diff --git a/unittests/test_helpdata.py b/unittests/test_helpdata.py index 85360f62..b882f2c8 100644 --- a/unittests/test_helpdata.py +++ b/unittests/test_helpdata.py @@ -1,15 +1,66 @@ import imp_unittest, unittest import wtc import wx +import wx.html #--------------------------------------------------------------------------- class helpdata_Tests(wtc.WidgetTestCase): - # TODO: Remove this test and add real ones. def test_helpdata1(self): - self.fail("Unit tests for helpdata not implemented yet.") + obj = wx.html.HtmlBookRecord("file", "path", "title", "start") + def test_helpdata2(self): + obj = wx.html.HtmlHelpDataItem() + + def test_helpdata3(self): + obj = wx.html.HtmlHelpData() + + + def test_helpdata4(self): + wx.html.HF_TOOLBAR, + wx.html.HF_CONTENTS, + wx.html.HF_INDEX, + wx.html.HF_SEARCH, + wx.html.HF_BOOKMARKS, + wx.html.HF_OPEN_FILES, + wx.html.HF_PRINT, + wx.html.HF_FLAT_TOOLBAR, + wx.html.HF_MERGE_BOOKS, + wx.html.HF_ICONS_BOOK, + wx.html.HF_ICONS_BOOK_CHAPTER, + wx.html.HF_ICONS_FOLDER, + wx.html.HF_DEFAULT_STYLE, + wx.html.HF_EMBEDDED, + wx.html.HF_DIALOG, + wx.html.HF_FRAME, + wx.html.HF_MODAL, + wx.html.ID_HTML_PANEL, + wx.html.ID_HTML_BACK, + wx.html.ID_HTML_FORWARD, + wx.html.ID_HTML_UPNODE, + wx.html.ID_HTML_UP, + wx.html.ID_HTML_DOWN, + wx.html.ID_HTML_PRINT, + wx.html.ID_HTML_OPENFILE, + wx.html.ID_HTML_OPTIONS, + wx.html.ID_HTML_BOOKMARKSLIST, + wx.html.ID_HTML_BOOKMARKSADD, + wx.html.ID_HTML_BOOKMARKSREMOVE, + wx.html.ID_HTML_TREECTRL, + wx.html.ID_HTML_INDEXPAGE, + wx.html.ID_HTML_INDEXLIST, + wx.html.ID_HTML_INDEXTEXT, + wx.html.ID_HTML_INDEXBUTTON, + wx.html.ID_HTML_INDEXBUTTONALL, + wx.html.ID_HTML_NOTEBOOK, + wx.html.ID_HTML_SEARCHPAGE, + wx.html.ID_HTML_SEARCHTEXT, + wx.html.ID_HTML_SEARCHLIST, + wx.html.ID_HTML_SEARCHBUTTON, + wx.html.ID_HTML_SEARCHCHOICE, + wx.html.ID_HTML_COUNTINFO + #--------------------------------------------------------------------------- if __name__ == '__main__': diff --git a/unittests/test_helpdlg.py b/unittests/test_helpdlg.py index c9d7bb26..59c6571d 100644 --- a/unittests/test_helpdlg.py +++ b/unittests/test_helpdlg.py @@ -1,14 +1,23 @@ import imp_unittest, unittest import wtc import wx +import wx.html + +import os +helpPath = os.path.join(os.path.dirname(__file__), 'helpfiles') #--------------------------------------------------------------------------- class helpdlg_Tests(wtc.WidgetTestCase): - # TODO: Remove this test and add real ones. def test_helpdlg1(self): - self.fail("Unit tests for helpdlg not implemented yet.") + data = wx.html.HtmlHelpData() + data.AddBook(os.path.join(helpPath, 'testing.hhp')) + data.AddBook(os.path.join(helpPath, 'another.hhp')) + dlg = wx.html.HtmlHelpDialog(data) + + self.myYield() + dlg.Destroy() #--------------------------------------------------------------------------- diff --git a/unittests/test_helpfrm.py b/unittests/test_helpfrm.py index 80ad1c58..1f1529ca 100644 --- a/unittests/test_helpfrm.py +++ b/unittests/test_helpfrm.py @@ -1,14 +1,28 @@ import imp_unittest, unittest import wtc import wx +import wx.html + +import os +helpPath = os.path.join(os.path.dirname(__file__), 'helpfiles') #--------------------------------------------------------------------------- class helpfrm_Tests(wtc.WidgetTestCase): - # TODO: Remove this test and add real ones. def test_helpfrm1(self): - self.fail("Unit tests for helpfrm not implemented yet.") + data = wx.html.HtmlHelpData() + data.AddBook(os.path.join(helpPath, 'testing.hhp')) + data.AddBook(os.path.join(helpPath, 'another.hhp')) + + hc = wx.html.HtmlHelpController() + frm = wx.html.HtmlHelpFrame(data) + frm.SetController(hc) + frm.Create(self.frame, -1) + frm.Show() + + self.myYield() + frm.Close() #--------------------------------------------------------------------------- diff --git a/unittests/test_helpwnd.py b/unittests/test_helpwnd.py index 729d5040..a733dcee 100644 --- a/unittests/test_helpwnd.py +++ b/unittests/test_helpwnd.py @@ -1,14 +1,27 @@ import imp_unittest, unittest import wtc import wx +import wx.html + +import os +helpPath = os.path.join(os.path.dirname(__file__), 'helpfiles') + #--------------------------------------------------------------------------- class helpwnd_Tests(wtc.WidgetTestCase): - # TODO: Remove this test and add real ones. def test_helpwnd1(self): - self.fail("Unit tests for helpwnd not implemented yet.") + hc = wx.html.HtmlHelpController(wx.html.HF_EMBEDDED) + hw = wx.html.HtmlHelpWindow() + hc.SetHelpWindow(hw) + hw.Create(self.frame) + hc.AddBook(os.path.join(helpPath, 'testing.hhp')) + hc.AddBook(os.path.join(helpPath, 'another.hhp')) + + self.frame.SendSizeEvent() + self.myYield() + #--------------------------------------------------------------------------- diff --git a/unittests/test_htmldefs.py b/unittests/test_htmldefs.py new file mode 100644 index 00000000..8e2f72de --- /dev/null +++ b/unittests/test_htmldefs.py @@ -0,0 +1,68 @@ +import imp_unittest, unittest +import wtc +import wx +import wx.html + +#--------------------------------------------------------------------------- + +class htmldefs_Tests(wtc.WidgetTestCase): + + def test_htmldefs1(self): + wx.html.HTML_ALIGN_LEFT + wx.html.HTML_ALIGN_CENTER + wx.html.HTML_ALIGN_RIGHT + wx.html.HTML_ALIGN_BOTTOM + wx.html.HTML_ALIGN_TOP + wx.html.HTML_CLR_FOREGROUND + wx.html.HTML_CLR_BACKGROUND + wx.html.HTML_UNITS_PIXELS + wx.html.HTML_UNITS_PERCENT + wx.html.HTML_INDENT_LEFT + wx.html.HTML_INDENT_RIGHT + wx.html.HTML_INDENT_TOP + wx.html.HTML_INDENT_BOTTOM + wx.html.HTML_INDENT_HORIZONTAL + wx.html.HTML_INDENT_VERTICAL + wx.html.HTML_INDENT_ALL + wx.html.HTML_COND_ISANCHOR + wx.html.HTML_COND_ISIMAGEMAP + wx.html.HTML_COND_USER + wx.html.HW_SCROLLBAR_NEVER + wx.html.HW_SCROLLBAR_AUTO + wx.html.HW_NO_SELECTION + wx.html.HW_DEFAULT_STYLE + wx.html.HTML_OPEN + wx.html.HTML_BLOCK + wx.html.HTML_REDIRECT + wx.html.HTML_URL_PAGE + wx.html.HTML_URL_IMAGE + wx.html.HTML_URL_OTHER + + wx.html.HTML_ALIGN_LEFT + wx.html.HTML_ALIGN_RIGHT + wx.html.HTML_ALIGN_JUSTIFY + wx.html.HTML_ALIGN_TOP + wx.html.HTML_ALIGN_BOTTOM + wx.html.HTML_ALIGN_CENTER + wx.html.HTML_CLR_FOREGROUND + wx.html.HTML_CLR_BACKGROUND + wx.html.HTML_CLR_TRANSPARENT_BACKGROUND + wx.html.HTML_UNITS_PIXELS + wx.html.HTML_UNITS_PERCENT + wx.html.HTML_INDENT_LEFT + wx.html.HTML_INDENT_RIGHT + wx.html.HTML_INDENT_TOP + wx.html.HTML_INDENT_BOTTOM + wx.html.HTML_INDENT_HORIZONTAL + wx.html.HTML_INDENT_VERTICAL + wx.html.HTML_INDENT_ALL + wx.html.HTML_COND_ISANCHOR + wx.html.HTML_COND_ISIMAGEMAP + wx.html.HTML_COND_USER + + + +#--------------------------------------------------------------------------- + +if __name__ == '__main__': + unittest.main()