1 2from PyObjCTools.TestSupport import * 3from AppKit import * 4 5class TestNSOutlineViewHelper (NSObject): 6 def outlineView_child_ofItem_(self, ov, nr, item): return 1 7 def outlineView_isItemExpandable_(self, ov, item): return 1 8 def outlineView_numberOfChildrenOfItem_(self, ov, item): return 1 9 def outlineView_objectValueForTableColumn_byItem_(self, ov, tc, item): return 1 10 def outlineView_setObjectValue_forTableColumn_byItem_(self, ov, value, tc, item): pass 11 def outlineView_itemForPersistentObject_(self, ov, po): return 1 12 def outlineView_persistentObjectForItem_(self, ov, item): return 1 13 def outlineView_sortDescriptorsDidChange_(self, ov, old): pass 14 def outlineView_writeItems_toPasteboard_(self, ov, items, pb): return 1 15 def outlineView_validateDrop_proposedItem_proposedChildIndex_(self, ov, dr, item, idx): return 1 16 def outlineView_acceptDrop_item_childIndex_(self, ov, dr, it, idx): return 1 17 def outlineView_namesOfPromisedFilesDroppedAtDestination_forDraggedItems_(self, ov, dr, it): return 1 18 19 def outlineView_willDisplayCell_forTableColumn_item_(self, ov, c, tc, i): pass 20 def outlineView_shouldEditTableColumn_item_(self, ov, tc, i): return 1 21 def selectionShouldChangeInOutlineView_(self, ov): return 1 22 def outlineView_selectionIndexesForProposedSelection_(self, ov, idx): return 1 23 def outlineView_shouldSelectItem_(self, ov, tc): return 1 24 def outlineView_shouldSelectTableColumn_(self, ov, tc): return 1 25 def outlineView_toolTipForCell_rect_tableColumn_item_mouseLocation_(self, ov, c, r, tc, it, ml): return 1 26 def outlineView_heightOfRowByItem_(self, ov, item): return 1 27 def outlineView_typeSelectStringForTableColumn_item_(self, ov, tc, item): return 1 28 def outlineView_nextTypeSelectMatchFromItem_toItem_forString_(self, ov, si, ei, ss): return 1 29 def outlineView_shouldTypeSelectForEvent_withCurrentSearchString_(self, ov, ev, ss): return 1 30 def outlineView_shouldShowCellExpansionForTableColumn_item_(self, ov, tc, it): return 1 31 def outlineView_shouldTrackCell_forTableColumn_item_(self, ov, c, tc, it): return 1 32 def outlineView_dataCellForTableColumn_item_(self, ov, tc, it): return 1 33 def outlineView_isGroupItem_(self, ov, item): return 1 34 def outlineView_shouldExpandItem_(self, ov, it): return 1 35 def outlineView_shouldCollapseItem_(self, ov, it): return 1 36 def outlineView_willDisplayOutlineCell_forTableColumn_item_(self, ov, c, tc, i): pass 37 38 39 40class TestNSOutlineView (TestCase): 41 def testConstants(self): 42 self.failUnlessEqual(NSOutlineViewDropOnItemIndex, -1) 43 44 self.failUnlessIsInstance(NSOutlineViewSelectionDidChangeNotification, unicode) 45 self.failUnlessIsInstance(NSOutlineViewColumnDidMoveNotification, unicode) 46 self.failUnlessIsInstance(NSOutlineViewColumnDidResizeNotification, unicode) 47 self.failUnlessIsInstance(NSOutlineViewSelectionIsChangingNotification, unicode) 48 self.failUnlessIsInstance(NSOutlineViewItemWillExpandNotification, unicode) 49 self.failUnlessIsInstance(NSOutlineViewItemDidExpandNotification, unicode) 50 self.failUnlessIsInstance(NSOutlineViewItemWillCollapseNotification, unicode) 51 self.failUnlessIsInstance(NSOutlineViewItemDidCollapseNotification, unicode) 52 53 54 def testMethods(self): 55 self.failUnlessResultIsBOOL(NSOutlineView.isExpandable_) 56 self.failUnlessArgIsBOOL(NSOutlineView.expandItem_expandChildren_, 1) 57 self.failUnlessArgIsBOOL(NSOutlineView.collapseItem_collapseChildren_, 1) 58 self.failUnlessArgIsBOOL(NSOutlineView.reloadItem_reloadChildren_, 1) 59 self.failUnlessResultIsBOOL(NSOutlineView.isItemExpanded_) 60 self.failUnlessResultIsBOOL(NSOutlineView.indentationMarkerFollowsCell) 61 self.failUnlessArgIsBOOL(NSOutlineView.setIndentationMarkerFollowsCell_, 0) 62 self.failUnlessResultIsBOOL(NSOutlineView.autoresizesOutlineColumn) 63 self.failUnlessArgIsBOOL(NSOutlineView.setAutoresizesOutlineColumn_, 0) 64 self.failUnlessResultIsBOOL(NSOutlineView.shouldCollapseAutoExpandedItemsForDeposited_) 65 self.failUnlessArgIsBOOL(NSOutlineView.shouldCollapseAutoExpandedItemsForDeposited_, 0) 66 self.failUnlessResultIsBOOL(NSOutlineView.autosaveExpandedItems) 67 self.failUnlessArgIsBOOL(NSOutlineView.setAutosaveExpandedItems_, 0) 68 69 def testProtocols(self): 70 self.failUnlessArgHasType(TestNSOutlineViewHelper.outlineView_child_ofItem_, 1, objc._C_NSInteger) 71 self.failUnlessResultIsBOOL(TestNSOutlineViewHelper.outlineView_isItemExpandable_) 72 self.failUnlessResultHasType(TestNSOutlineViewHelper.outlineView_numberOfChildrenOfItem_, objc._C_NSInteger) 73 self.failUnlessResultIsBOOL(TestNSOutlineViewHelper.outlineView_writeItems_toPasteboard_) 74 self.failUnlessResultHasType(TestNSOutlineViewHelper.outlineView_validateDrop_proposedItem_proposedChildIndex_, objc._C_NSUInteger) 75 self.failUnlessArgHasType(TestNSOutlineViewHelper.outlineView_validateDrop_proposedItem_proposedChildIndex_, 3, objc._C_NSInteger) 76 self.failUnlessResultIsBOOL(TestNSOutlineViewHelper.outlineView_shouldEditTableColumn_item_) 77 self.failUnlessResultIsBOOL(TestNSOutlineViewHelper.selectionShouldChangeInOutlineView_) 78 self.failUnlessResultIsBOOL(TestNSOutlineViewHelper.outlineView_shouldSelectItem_) 79 self.failUnlessResultIsBOOL(TestNSOutlineViewHelper.outlineView_shouldSelectTableColumn_) 80 self.failUnlessArgHasType(TestNSOutlineViewHelper.outlineView_toolTipForCell_rect_tableColumn_item_mouseLocation_, 2, 'N^' + NSRect.__typestr__) 81 self.failUnlessArgHasType(TestNSOutlineViewHelper.outlineView_toolTipForCell_rect_tableColumn_item_mouseLocation_, 5, NSPoint.__typestr__) 82 self.failUnlessResultHasType(TestNSOutlineViewHelper.outlineView_heightOfRowByItem_, objc._C_CGFloat) 83 self.failUnlessResultIsBOOL(TestNSOutlineViewHelper.outlineView_shouldExpandItem_) 84 self.failUnlessResultIsBOOL(TestNSOutlineViewHelper.outlineView_shouldCollapseItem_) 85 86 @min_os_level('10.5') 87 def testProtocols10_5(self): 88 self.failUnlessResultIsBOOL(TestNSOutlineViewHelper.outlineView_shouldTypeSelectForEvent_withCurrentSearchString_) 89 self.failUnlessResultIsBOOL(TestNSOutlineViewHelper.outlineView_shouldShowCellExpansionForTableColumn_item_) 90 self.failUnlessResultIsBOOL(TestNSOutlineViewHelper.outlineView_shouldTrackCell_forTableColumn_item_) 91 self.failUnlessResultIsBOOL(TestNSOutlineViewHelper.outlineView_isGroupItem_) 92 93 94if __name__ == "__main__": 95 main() 96