Verify correctness of observation notifications on arrangedObjects when the addObjects: message is sent.

This commit is contained in:
Alexander Ljungberg committed 2011-05-28 02:06:27 -04:00
1 parent 2e5081b137
commit cf04fcc9d0
1 file changed
+26
+26
View File
@@ -412,6 +412,32 @@
[self assert:newSelection equals:[arrayController selectionIndexes] message:@"selection was not set properly"];
}
- (void)testObservationDuringAddObject_
{
var arrayController = [self arrayController];
[arrayController addObserver:self forKeyPath:@"arrangedObjects" options:CPKeyValueObservingOptionOld | CPKeyValueObservingOptionNew context:nil];
// Add something to clear.
[arrayController setFilterPredicate:[CPPredicate predicateWithFormat:@"(name != %@)", "Francisco"]];
observations = [];
var aPerson = [Employee employeeWithName:@"Alexander" department:[Department departmentWithName:@"Cosmic Path Finding"]];
[arrayController setClearsFilterPredicateOnInsertion:NO];
[self assert:0 equals:[observations count] message:@"no observations before addObject test"];
[arrayController addObject:aPerson];
[self assert:1 equals:[observations count] message:@"exactly 1 notification for addObject (clearsFilterPredicate NO)"];
observations = [];
// Even that this is on, adding an object should only result in one notification.
[arrayController setClearsFilterPredicateOnInsertion:YES];
[self assert:0 equals:[observations count] message:@"no observations before addObject test"];
[arrayController addObject:aPerson];
[self assert:1 equals:[observations count] message:@"exactly 1 notification for addObject (clearsFilterPredicate YES)"];
}
- (void)testCompoundKeyPaths
{
var departmentNameField = [[CPTextField alloc] init];