CPPopUpButtonTest test CPContentValuesBinding with value transformer. Currently failing.

This commit is contained in:
cacaodev committed 2012-07-04 17:55:39 +02:00
1 parent e5f4a7c39a
commit c7a8124be8
1 file changed
+30
+30
View File
@@ -398,8 +398,38 @@
[self assert:0 equals:[[self button] indexOfSelectedItem]];
}
- (void)testContentValuesWithValueTransformer
{
var arrayController = [[CPArrayController alloc] init],
martin = [CPDictionary dictionaryWithJSObject:{@"name": @"Martin"}],
malte = [CPDictionary dictionaryWithJSObject:{@"name": @"Malte"}],
johan = [CPDictionary dictionaryWithJSObject:{@"name": @"Johan"}],
menuObjects = [martin, malte, johan];
[arrayController setContent:menuObjects];
[button bind:CPContentBinding toObject:arrayController withKeyPath:@"arrangedObjects" options:nil];
var options = [CPDictionary dictionary];
[options setObject:[ContentValuesTransformer new] forKey:CPValueTransformerBindingOption];
[button bind:CPContentValuesBinding toObject:arrayController withKeyPath:@"arrangedObjects.name" options:options];
[self assert:@"Transformed-Malte" equals:[[[self button] itemAtIndex:1] title]];
}
- (void)actionTest:(id)sender
{
}
@end
@implementation ContentValuesTransformer : CPValueTransformer
{
}
- (id)transformedValue:(id)aValue
{
return "Transformed-" + aValue;
}
@end