From c7a8124be8b6b045983422632f8959d4fe2d254f Mon Sep 17 00:00:00 2001 From: cacaodev Date: Wed, 4 Jul 2012 09:51:56 +0200 Subject: [PATCH] CPPopUpButtonTest test CPContentValuesBinding with value transformer. Currently failing. --- Tests/AppKit/CPPopUpButtonTest.j | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Tests/AppKit/CPPopUpButtonTest.j b/Tests/AppKit/CPPopUpButtonTest.j index a9c35e9e9..40f20e0b9 100644 --- a/Tests/AppKit/CPPopUpButtonTest.j +++ b/Tests/AppKit/CPPopUpButtonTest.j @@ -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 \ No newline at end of file