mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-04 03:44:58 +00:00
Verify correctness of observation notifications on arrangedObjects when the addObjects: message is sent.
This commit is contained in:
1 parent
2e5081b137
commit
cf04fcc9d0
1 file changed
+26
@@ -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];
|
||||
|
||||
Reference in new issue
Block a user