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