mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-09 10:20:59 +00:00
Fix for #1723: CPArrayController insert
This fix addresses the following problems: - fixes a bug with add: where it would try to add the sender object, not the represented object - changes insert: to insert a new represented object after the currently selected object. If no object is currently selected it behaves like add: and adds a new object to the end. This patch includes tests.
This commit is contained in:
1 parent
5f99ebefb1
commit
ab49c63840
2 files changed
+49
-3
No files matched your search
@@ -184,7 +184,46 @@
|
||||
[self assert:[CPNumber numberWithInt:2] equals:[_arrayController arrangedObjects][1]];
|
||||
}
|
||||
|
||||
- (void)testAdd
|
||||
{
|
||||
_contentArray = [];
|
||||
_arrayController = [[CPArrayController alloc] initWithContent:_contentArray];
|
||||
[self _testAdd];
|
||||
}
|
||||
|
||||
- (void)_testAdd
|
||||
{
|
||||
[_arrayController setObjectClass:[Employee class]];
|
||||
[self assert:[[_arrayController contentArray] count] equals:0];
|
||||
[_arrayController add:nil];
|
||||
[self assert:[[_arrayController contentArray] count] equals:1];
|
||||
[self assert:[[_arrayController arrangedObjects][0] class] equals:[Employee class]];
|
||||
|
||||
// switch it up so that we can tell where this one is.
|
||||
[_arrayController setObjectClass:[Department class]];
|
||||
[_arrayController add:nil];
|
||||
[self assert:[[[_arrayController arrangedObjects] lastObject] class] equals:[Department class]];
|
||||
}
|
||||
|
||||
- (void)testInsert
|
||||
{
|
||||
_contentArray = [];
|
||||
_arrayController = [[CPArrayController alloc] initWithContent:_contentArray];
|
||||
[self _testInsert];
|
||||
}
|
||||
|
||||
- (void)_testInsert
|
||||
{
|
||||
[_arrayController setObjectClass:[Employee class]];
|
||||
[_arrayController add:nil];
|
||||
[_arrayController add:nil];
|
||||
[_arrayController add:nil];
|
||||
|
||||
[_arrayController setObjectClass:[Department class]];
|
||||
[_arrayController setSelectionIndex:1];
|
||||
[_arrayController insert:nil];
|
||||
[self assert:[[[_arrayController arrangedObjects] objectAtIndex:2] class] equals:[Department class]];
|
||||
}
|
||||
|
||||
- (void)_initTestRemoveObjects_SimpleArray
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user