mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-13 20:17:07 +00:00
Add -descendantNodeAtIndexPath: and tests to CPTreeNode
This commit is contained in:
1 parent
ab4dd1ac6d
commit
3a8773baec
2 files changed
+40
No files matched your search
@@ -87,6 +87,18 @@
|
||||
[_childNodes[count] sortWithSortDescriptors:sortDescriptors recursively:YES];
|
||||
}
|
||||
|
||||
- (CPTreeNode)descendantNodeAtIndexPath:(CPIndexPath)indexPath
|
||||
{
|
||||
var count = [indexPath length],
|
||||
node = self;
|
||||
|
||||
for(var i = 0; i < count; i++) {
|
||||
node = [node objectInChildNodesAtIndex:[indexPath indexAtPosition:i]];
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPTreeNodeRepresentedObjectKey = @"CPTreeNodeRepresentedObjectKey",
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
@import <AppKit/CPTreeNode.j>
|
||||
|
||||
|
||||
@implementation CPTreeNodeTest : OJTestCase
|
||||
{
|
||||
CPTreeNode treeNode;
|
||||
CPTreeNode childNode;
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
treeNode = [CPTreeNode treeNodeWithRepresentedObject:nil];
|
||||
|
||||
childNode = [CPTreeNode treeNodeWithRepresentedObject:nil];
|
||||
[treeNode insertObject:childNode inChildNodesAtIndex:0];
|
||||
}
|
||||
|
||||
- (void)testDescendantNodeAtIndexPath
|
||||
{
|
||||
var indexPath = [CPIndexPath indexPathWithIndex:0];
|
||||
[self assert:childNode equals:[treeNode descendantNodeAtIndexPath:indexPath]];
|
||||
|
||||
indexPath = [CPIndexPath indexPathWithIndex:1];
|
||||
[self assert:nil equals:[treeNode descendantNodeAtIndexPath:indexPath]];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user