From 770b0c70227a779f67c5b9e5548811023b8c8bbb Mon Sep 17 00:00:00 2001 From: cacaodev Date: Sat, 7 Jun 2014 18:34:59 +0200 Subject: [PATCH] Here is an ojtest for this issue. --- Tests/AppKit/CPKeyValueBindingTest.j | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Tests/AppKit/CPKeyValueBindingTest.j b/Tests/AppKit/CPKeyValueBindingTest.j index 2b03ff655..3b9e75ab7 100644 --- a/Tests/AppKit/CPKeyValueBindingTest.j +++ b/Tests/AppKit/CPKeyValueBindingTest.j @@ -315,6 +315,33 @@ [self assert:0 equals:[control objectValueSetterCount] message:@"-setObjectValue should not be called"]; } +- (void)testMultipleBindingsToArrayControllerSelection +{ + var control1 = [[TextField alloc] init]; + var control2 = [[TextField alloc] init]; + + var cheese1 = [BindingTester testerWithCheese:@"roblochon"], + cheese2 = [BindingTester testerWithCheese:@"brie"]; + + var ac = [[CPArrayController alloc] initWithContent:@[cheese1, cheese2]]; + var oc = [[CPObjectController alloc] init]; + +// This tests fails only if multiple controls are binded BEFORE the object controller + [control1 bind:CPValueBinding toObject:oc withKeyPath:@"selection.cheese" options:nil]; + [control2 bind:CPValueBinding toObject:oc withKeyPath:@"selection.cheese" options:nil]; + [oc bind:CPContentBinding toObject:ac withKeyPath:@"selection" options:nil]; + + [ac setSelectionIndex:0]; + + [self assert:@"roblochon" equals:[control1 objectValue] message:@"control1 objectValue is wrong"]; + [self assert:@"roblochon" equals:[control2 objectValue] message:@"control2 objectValue is wrong"]; + + [ac setSelectionIndex:1]; + + [self assert:@"brie" equals:[control1 objectValue] message:@"control1 objectValue is wrong"]; + [self assert:@"brie" equals:[control2 objectValue] message:@"control2 objectValue is wrong"]; +} + @end @implementation TextField : CPTextField