Fixed: check box binding value transformers were ignored.

This commit is contained in:
Alexander Ljungberg committed 2012-03-27 13:53:32 +01:00
1 parent ff68ccdeab
commit 56c7e1991e
2 files changed
+26

No files matched your search

+2
View File
@@ -140,6 +140,8 @@ CPCheckBoxImageOffset = 4.0;
[_source setAllowsMixedState:NO];
}
}
else
newValue = [self transformValue:newValue withOptions:options];
[_source setState:newValue];
}
+24
View File
@@ -74,4 +74,28 @@
[self assert:CPOnState equals:[control objectValue] message:"content 1 is on"];
}
- (void)testTransformValueBinding
{
var control = [[CPCheckBox alloc] initWithFrame:CGRectMakeZero()];
content = [
[CPDictionary dictionaryWithObject:YES forKey:@"state"],
[CPDictionary dictionaryWithObject:NO forKey:@"state"]
];
arrayController = [[CPArrayController alloc] initWithContent:content];
// First test defaults.
[control bind:CPValueBinding toObject:arrayController withKeyPath:@"selection.state" options:[CPDictionary dictionaryWithObject:@"CPNegateBoolean" forKey:CPValueTransformerNameBindingOption]];
[arrayController setSelectionIndexes:[CPIndexSet indexSetWithIndex:0]];
[self assert:CPOffState equals:[control objectValue] message:"content[0] is negated"]
[arrayController setSelectionIndexes:[CPIndexSet indexSetWithIndex:1]];
[self assert:CPOnState equals:[control objectValue] message:"content[1] is negated"]
[control performClick:nil];
[self assert:CPOffState equals:[control objectValue] message:"value was changed"]
[self assert:YES equals:[content[1] valueForKey:@"state"] message:"content[1] was negated after change"]
}
@end