Merge branch '0.9.1'

This commit is contained in:
Alexander Ljungberg committed 2011-04-27 13:20:39 -04:00
commit 5a580f4983
6 files changed
+118 -117

No files matched your search

+13 -9
View File
@@ -270,10 +270,10 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
{
if ([scrollView hasVerticalScroller])
{
if (eventLocation.y < CGRectGetMinY(insetBounds))
deltaY = CGRectGetMinY(insetBounds) - eventLocation.y;
else if (eventLocation.y > CGRectGetMaxY(insetBounds))
deltaY = CGRectGetMaxY(insetBounds) - eventLocation.y;
if (eventLocation.y < _CGRectGetMinY(insetBounds))
deltaY = _CGRectGetMinY(insetBounds) - eventLocation.y;
else if (eventLocation.y > _CGRectGetMaxY(insetBounds))
deltaY = _CGRectGetMaxY(insetBounds) - eventLocation.y;
if (deltaY < -insetBounds.size.height)
deltaY = -insetBounds.size.height;
if (deltaY > insetBounds.size.height)
@@ -282,17 +282,21 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
if ([scrollView hasHorizontalScroller])
{
if (eventLocation.x < CGRectGetMinX(insetBounds))
deltaX = CGRectGetMinX(insetBounds) - eventLocation.x;
else if (eventLocation.x > CGRectGetMaxX(insetBounds))
deltaX = CGRectGetMaxX(insetBounds) - eventLocation.x;
if (eventLocation.x < _CGRectGetMinX(insetBounds))
deltaX = _CGRectGetMinX(insetBounds) - eventLocation.x;
else if (eventLocation.x > _CGRectGetMaxX(insetBounds))
deltaX = _CGRectGetMaxX(insetBounds) - eventLocation.x;
if (deltaX < -insetBounds.size.width)
deltaX = -insetBounds.size.width;
if (deltaX > insetBounds.size.width)
deltaX = insetBounds.size.width;
}
[contentView scrollToPoint:CGPointMake(bounds.origin.x - deltaX, bounds.origin.y - deltaY)];
var scrollPoint = _CGPointMake(bounds.origin.x - deltaX, bounds.origin.y - deltaY);
[contentView scrollToPoint:scrollPoint];
[[scrollView _headerView] scrollPoint:scrollPoint];
}
}
}
+1 -1
View File
@@ -332,7 +332,7 @@
[self replaceObjectAtIndex:otherIndex withObject:temporary];
}
- (CPArray)sortUsingDescriptors:(CPArray)descriptors
- (void)sortUsingDescriptors:(CPArray)descriptors
{
[self sortUsingFunction:compareObjectsUsingDescriptors context:descriptors];
}
+8
View File
@@ -678,6 +678,14 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOpti
{
var observers = _observersForKey[aPath];
if (!observers)
{
CPLog.warn(@"Cannot remove an observer %@ for the key path \"%@\" from %@ because it is not registered as an observer.",
_targetObject, aPath, anObserver);
return;
}
if (aPath.indexOf('.') != CPNotFound)
{
var forwarder = [observers objectForKey:[anObserver UID]].forwarder;
+1 -1
View File
@@ -227,7 +227,7 @@ CPURLCustomIconKey = @"CPURLCustomIconKey";
return self.setResourcePropertyForKey(aKey, anObject);
}
- (CPString)staticResourceData
- (CPData)staticResourceData
{
return self.staticResourceData();
}
-106
View File
@@ -1,106 +0,0 @@
@import <Foundation/CPKeyValueObserving.j>
@implementation CPKeyValueObservingTest : OJTestCase
{
CPString _lastKeyPath;
id _lastObject;
CPDictionary _lastChange;
id _lastContext;
}
- (void)setup
{
_lastKeyPath = _lastObject = _lastChange = _lastContext = nil;
}
- (void)testInitialObserving
{
var tester = [ObservingTester testerWithCheese:@"CHEESE!"];
[tester addObserver:self forKeyPath:@"cheese" options:CPKeyValueObservingOptionNew | CPKeyValueObservingOptionInitial context:nil];
[self assert:@"cheese" equals:_lastKeyPath];
[self assert:tester equals:_lastObject];
[self assert:[CPDictionary dictionaryWithObject:@"CHEESE!" forKey:CPKeyValueChangeNewKey] equals:_lastChange];
[self assert:nil equals:_lastContext];
}
- (void)observeValueForKeyPath:(CPString)aKeyPath
ofObject:(id)anObject
change:(CPDictionary)aChange
context:(id)aContext
{
_lastKeyPath = aKeyPath;
_lastObject = anObject;
_lastChange = aChange;
_lastContext = aContext;
}
- (void)testSendNotificationsForDependantKeyPaths
{
var observingTester = [ObservingTester testerWithCheese:@"cheese"],
dependantKeyPathTester = [DependantKeyPathsTester testerWithObservingTester:observingTester];
[dependantKeyPathTester addObserver:self forKeyPath:@"observedCheese" options:CPKeyValueObservingOptionNew context:nil];
[observingTester setCheese:@"changed cheese"];
[self assert:@"observedCheese" equals:_lastKeyPath]
[self assert:dependantKeyPathTester equals:_lastObject];
}
@end
@implementation ObservingTester : CPObject
{
id cheese;
}
+ (id)testerWithCheese:(id)aCheese
{
var tester = [[self alloc] init];
[tester setCheese:aCheese];
return tester;
}
- (void)setCheese:(id)aCheese
{
cheese = aCheese;
}
- (id)cheese
{
return cheese;
}
@end
@implementation DependantKeyPathsTester: CPObject
{
ObservingTester _observingTester @accessors(property=observingTester);
}
+ (CPSet)keyPathsForValuesAffectingObservedCheese
{
return [CPSet setWithObjects:@"observingTester.cheese"];
}
+ (id)testerWithObservingTester:(ObservingTester)theObservingTester
{
return [[self alloc] initWithObservingTester:theObservingTester];
}
- (id)initWithObservingTester:(ObservingTester)theObservingTester
{
if (self = [super init])
{
_observingTester = theObservingTester;
}
return self;
}
- (CPString)observedCheese
{
return [[self observingTester] cheese];
}
@end
@@ -22,6 +22,45 @@
return [theClass new];
}
- (void)setup
{
_lastKeyPath = _lastObject = _lastChange = _lastContext = nil;
}
- (void)testInitialObserving
{
var tester = [ObservingTester testerWithCheese:@"CHEESE!"];
[tester addObserver:self forKeyPath:@"cheese" options:CPKeyValueObservingOptionNew | CPKeyValueObservingOptionInitial context:nil];
[self assert:@"cheese" equals:_lastKeyPath];
[self assert:tester equals:_lastObject];
[self assert:[CPDictionary dictionaryWithObject:@"CHEESE!" forKey:CPKeyValueChangeNewKey] equals:_lastChange];
[self assert:nil equals:_lastContext];
}
- (void)observeValueForKeyPath:(CPString)aKeyPath
ofObject:(id)anObject
change:(CPDictionary)aChange
context:(id)aContext
{
_lastKeyPath = aKeyPath;
_lastObject = anObject;
_lastChange = aChange;
_lastContext = aContext;
}
- (void)testSendNotificationsForDependantKeyPaths
{
var observingTester = [ObservingTester testerWithCheese:@"cheese"],
dependantKeyPathTester = [DependantKeyPathsTester testerWithObservingTester:observingTester];
[dependantKeyPathTester addObserver:self forKeyPath:@"observedCheese" options:CPKeyValueObservingOptionNew context:nil];
[observingTester setCheese:@"changed cheese"];
[self assert:@"observedCheese" equals:_lastKeyPath]
[self assert:dependantKeyPathTester equals:_lastObject];
}
- (void)testOnlyInsertObject_AtKeyIndex_Implemented
{
var insertSelector = @selector(insertObject:inObjectsAtIndex:),
@@ -155,3 +194,59 @@
}
@end
@implementation ObservingTester : CPObject
{
id cheese;
}
+ (id)testerWithCheese:(id)aCheese
{
var tester = [[self alloc] init];
[tester setCheese:aCheese];
return tester;
}
- (void)setCheese:(id)aCheese
{
cheese = aCheese;
}
- (id)cheese
{
return cheese;
}
@end
@implementation DependantKeyPathsTester: CPObject
{
ObservingTester _observingTester @accessors(property=observingTester);
}
+ (CPSet)keyPathsForValuesAffectingObservedCheese
{
return [CPSet setWithObjects:@"observingTester.cheese"];
}
+ (id)testerWithObservingTester:(ObservingTester)theObservingTester
{
return [[self alloc] initWithObservingTester:theObservingTester];
}
- (id)initWithObservingTester:(ObservingTester)theObservingTester
{
if (self = [super init])
{
_observingTester = theObservingTester;
}
return self;
}
- (CPString)observedCheese
{
return [[self observingTester] cheese];
}
@end