More unittests and fixes for issues found by the tests.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@74148 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2013-06-08 23:37:23 +00:00
parent 543dcf303a
commit b0842a986d
2 changed files with 173 additions and 9 deletions

View File

@@ -158,24 +158,93 @@ def run():
c.find('operator[]').ignore()
#-------------------------------------------------------
def _fixDrawObject(c, addMissingVirtuals=True):
assert isinstance(c, etgtools.ClassDef)
if c.findItem('HitTest'):
c.find('HitTest.textPosition').out = True
c.find('HitTest.obj').out = True
c.find('HitTest.contextObj').out = True
if c.findItem('FindPosition'):
c.find('FindPosition.pt').out = True
c.find('FindPosition.height').out = True
if c.findItem('GetBoxRects'):
c.find('GetBoxRects.marginRect').out = True
c.find('GetBoxRects.borderRect').out = True
c.find('GetBoxRects.contentRect').out = True
c.find('GetBoxRects.paddingRect').out = True
c.find('GetBoxRects.outlineRect').out = True
if c.findItem('GetTotalMargin'):
c.find('GetTotalMargin.leftMargin').out = True
c.find('GetTotalMargin.rightMargin').out = True
c.find('GetTotalMargin.topMargin').out = True
c.find('GetTotalMargin.bottomMargin').out = True
if c.findItem('CalculateRange'):
c.find('CalculateRange.end').out = True # TODO: should it be an inOut?
# This are the pure virtuals in the base class. SIP needs to see that
# all the drived classes have an implementation, otherwise it will
# consider them to be ABCs/
if not c.findItem('Draw') and addMissingVirtuals:
c.addItem(etgtools.WigCode("""\
virtual bool Draw(wxDC& dc, wxRichTextDrawingContext& context,
const wxRichTextRange& range,
const wxRichTextSelection& selection,
const wxRect& rect, int descent, int style);"""))
if not c.findItem('Layout') and addMissingVirtuals:
c.addItem(etgtools.WigCode("""\
virtual bool Layout(wxDC& dc, wxRichTextDrawingContext& context,
const wxRect& rect, const wxRect& parentRect,
int style);"""))
# TODO: Some of these args are output parameters. How should they be dealt with?
if not c.findItem('GetRangeSize') and addMissingVirtuals:
c.addItem(etgtools.WigCode("""\
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size,
int& descent,
wxDC& dc, wxRichTextDrawingContext& context, int flags,
const wxPoint& position = wxPoint(0,0),
const wxSize& parentSize = wxDefaultSize,
wxArrayInt* partialExtents = NULL) const;"""))
#-------------------------------------------------------
c = module.find('wxRichTextObject')
#c.find('ImportFromXML').ignore()
tools.ignoreConstOverloads(c)
_fixDrawObject(c)
#-------------------------------------------------------
c = module.find('wxRichTextCompositeObject')
tools.ignoreConstOverloads(c)
_fixDrawObject(c, addMissingVirtuals=False)
#-------------------------------------------------------
c = module.find('wxRichTextParagraphLayoutBox')
tools.ignoreConstOverloads(c)
_fixDrawObject(c)
c.find('MoveAnchoredObjectToParagraph.from').name = 'from_'
c.find('MoveAnchoredObjectToParagraph.to').name = 'to_'
c.find('DoNumberList.def').name = 'styleDef'
c.find('SetListStyle.def').name = 'styleDef'
#-------------------------------------------------------
c = module.find('wxRichTextBox')
_fixDrawObject(c)
#-------------------------------------------------------
c = module.find('wxRichTextField')
_fixDrawObject(c)
#-------------------------------------------------------
c = module.find('wxRichTextLine')
tools.ignoreConstOverloads(c)
@@ -185,6 +254,7 @@ def run():
#-------------------------------------------------------
c = module.find('wxRichTextParagraph')
_fixDrawObject(c)
# These methods use an untyped wxList, but since we know what is in it
# we'll make a fake typed list for wxPython so we can know what kinds of
@@ -196,9 +266,18 @@ def run():
c.find('MoveFromList.list').type = 'wxRichTextObjectList_&'
#-------------------------------------------------------
c = module.find('wxRichTextPlainText')
_fixDrawObject(c)
#-------------------------------------------------------
c = module.find('wxRichTextImage')
_fixDrawObject(c)
#-------------------------------------------------------
c = module.find('wxRichTextBuffer')
tools.ignoreConstOverloads(c)
_fixDrawObject(c)
# More untyped wxLists
module.addItem(
@@ -216,10 +295,22 @@ def run():
# TODO: Need a template to wrap STRING_HASH_MAP
c.find('GetFieldTypes').ignore()
c.find('AddHandler.handler').transfer = True
c.find('InsertHandler.handler').transfer = True
c.find('AddDrawingHandler.handler').transfer = True
c.find('InsertDrawingHandler.handler').transfer = True
c.find('AddFieldType.fieldType').transfer = True
# TODO: Transfer ownership with AddEventHandler? TransferBack with Remove?
#-------------------------------------------------------
c = module.find('wxRichTextTable')
tools.ignoreConstOverloads(c)
_fixDrawObject(c)
#-------------------------------------------------------
@@ -235,7 +326,9 @@ def run():
fakeListClassName='wxRichTextActionList'))
c.find('GetActions').type = 'wxRichTextActionList&'
c.find('GetActions').noCopy = True
c.find('AddAction.action').transfer = True
#-------------------------------------------------------
c = module.find('wxRichTextAction')

View File

@@ -182,21 +182,92 @@ class richtextbuffer_Tests(wtc.WidgetTestCase):
s2 = wx.richtext.RichTextSelection(s1)
@unittest.expectedFailure
def test_richtextbuffer16(self):
c = wx.richtext.RichTextDrawingContext()
# TODO
c = wx.richtext.RichTextDrawingContext(None)
@unittest.expectedFailure
def test_richtextbuffer17(self):
o1 = wx.richtext.RichTextObject() # It's an ABC
@unittest.expectedFailure
def test_richtextbuffer18(self):
o1 = wx.richtext.RichTextCompositeObject()
o1 = wx.richtext.RichTextCompositeObject() # It's an ABC
def test_richtextbuffer19(self):
o1 = wx.richtext.RichTextParagraphLayoutBox()
def test_richtextbuffer20(self):
o1 = wx.richtext.RichTextBox()
def test_richtextbuffer21(self):
o1 = wx.richtext.RichTextField()
@unittest.expectedFailure
def test_richtextbuffer22(self):
o1 = wx.richtext.RichTextFieldType('foo') # It's an ABC
def test_richtextbuffer23(self):
o1 = wx.richtext.RichTextFieldTypeStandard()
def test_richtextbuffer24(self):
o1 = wx.richtext.RichTextFieldTypeStandard('foo', 'bar')
def test_richtextbuffer25(self):
o1 = wx.richtext.RichTextLine(None)
def test_richtextbuffer26(self):
o1 = wx.richtext.RichTextLineList()
def test_richtextbuffer27(self):
o1 = wx.richtext.RichTextParagraph()
def test_richtextbuffer28(self):
o1 = wx.richtext.RichTextPlainText()
def test_richtextbuffer29(self):
o1 = wx.richtext.RichTextPlainText('some text')
def test_richtextbuffer30(self):
o1 = wx.richtext.RichTextImageBlock()
def test_richtextbuffer31(self):
o1 = wx.richtext.RichTextImage()
def test_richtextbuffer32(self):
o1 = wx.richtext.RichTextImage(wx.Image(100,75))
def test_richtextbuffer33(self):
o1 = wx.richtext.RichTextImage()
o2 = wx.richtext.RichTextImage(o1)
def test_richtextbuffer34(self):
o1 = wx.richtext.RichTextBuffer()
def test_richtextbuffer35(self):
o1 = wx.richtext.RichTextObjectAddress()
def test_richtextbuffer36(self):
o1 = wx.richtext.RichTextCommand('name')
def test_richtextbuffer37(self):
c = wx.richtext.RichTextCommand('name')
b = wx.richtext.RichTextBuffer()
# TODO: finish this a = wx.richtext.RichTextAction(c, 'name', 1234, b, )
def test_richtextbuffer38(self):
o1 = wx.richtext.RichTextBufferDataObject()
def test_richtextbuffer39(self):
o1 = wx.richtext.RichTextRenderer()
def test_richtextbuffer39(self):
o1 = wx.richtext.RichTextStdRenderer()
#---------------------------------------------------------------------------