mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-21 14:09:22 +00:00
Merge branch 'CPArrayController-removeObject-fix' of https://github.com/eventualbuddha/cappuccino into eventualbuddha-CPArrayController-removeObject-fix
This commit is contained in:
commit
0d2b13dd75
2 files changed
+29
-6
No files matched your search
@@ -534,9 +534,6 @@
|
||||
|
||||
- (void)removeObject:(id)object
|
||||
{
|
||||
if (![self canRemove])
|
||||
return;
|
||||
|
||||
[self willChangeValueForKey:@"content"];
|
||||
[_contentObject removeObject:object];
|
||||
|
||||
@@ -598,9 +595,6 @@
|
||||
|
||||
- (void)removeObjects:(CPArray)objects
|
||||
{
|
||||
if (![self canRemove])
|
||||
return;
|
||||
|
||||
[self _removeObjects:objects];
|
||||
}
|
||||
|
||||
|
||||
@@ -122,6 +122,35 @@
|
||||
[self assert:[CPIndexSet indexSet] equals:[arrayController selectionIndexes] message:@"no objects left, selection should disappear"];
|
||||
}
|
||||
|
||||
- (void)testRemoveObjectsWithoutSelection
|
||||
{
|
||||
var arrayController = [self arrayController],
|
||||
objectsToRemove = [[[self arrayController] arrangedObjects] objectsAtIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(1, 2)]];
|
||||
|
||||
// without any selection
|
||||
[arrayController setSelectedObjects:[]];
|
||||
|
||||
// we should be able to remove arbitrary sets of objects
|
||||
[arrayController removeObjects:objectsToRemove];
|
||||
|
||||
for (var i = 0; i < [objectsToRemove count]; i++)
|
||||
[self assertFalse:[[arrayController arrangedObjects] containsObject:[objectsToRemove objectAtIndex:i]] message:@"remove objects should no longer appear in arrangedObjects"];
|
||||
}
|
||||
|
||||
- (void)testRemoveObject
|
||||
{
|
||||
var arrayController = [self arrayController],
|
||||
objectToRemove = [[arrayController arrangedObjects] objectAtIndex:0];
|
||||
|
||||
// without any selection
|
||||
[arrayController setSelectedObjects:[]];
|
||||
|
||||
// we should be able to remove arbitrary objects
|
||||
[arrayController removeObject:objectToRemove];
|
||||
|
||||
[self assertFalse:[[arrayController arrangedObjects] containsObject:objectToRemove] message:@"removed objects should no longer appear in arrangedObjects"];
|
||||
}
|
||||
|
||||
- (void)testSelectionWhenObjectsDisappear
|
||||
{
|
||||
// If the selected object disappeares during a rearrange, the selection
|
||||
|
||||
Reference in new issue
Block a user