From 4195f3b8c636cac05410e2cffbc2aba6e21098d6 Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Wed, 7 Sep 2011 17:58:21 +0100 Subject: [PATCH] Test that CPArrayController setSelectionIndexes: does not modify its input. --- Tests/AppKit/CPArrayControllerTest.j | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Tests/AppKit/CPArrayControllerTest.j b/Tests/AppKit/CPArrayControllerTest.j index afb2a9e3f..0ecbfac0b 100644 --- a/Tests/AppKit/CPArrayControllerTest.j +++ b/Tests/AppKit/CPArrayControllerTest.j @@ -488,6 +488,9 @@ [companiesController setSelectionIndexes:[CPIndexSet indexSetWithIndex:1]]; + //for (var i = 0; i < [observations count]; i++) + // CPLog.error(observations[i].context); + // There should be exactly one observation of each kind, and they should be in the right // order. [self assert:5 equals:[observations count]]; @@ -560,6 +563,18 @@ [self assert:[1, 2, 1] equals:[ac arrangedObjects] message:"only one copy of 1 removed + the right copy should be removed"]; } +- (void)testSetOutOfBoundsSelectedIndexes +{ + var ac = [CPArrayController new], + contentArray = [1, 2, 3], + indexes = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, 4)]; + + [ac setContent:contentArray]; + [ac setSelectionIndexes:indexes]; + [self assert:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, 3)] equals:[ac selectionIndexes]]; + [self assert:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, 4)] equals:indexes]; +} + - (void)observeValueForKeyPath:keyPath ofObject:anActivity change:change