Merge branch 'refs/heads/master' into slevenbits

This commit is contained in:
Alexander Ljungberg
2012-07-26 13:34:45 +01:00
4 changed files with 56 additions and 2 deletions
+1 -1
View File
@@ -162,7 +162,7 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
- (BOOL)instantiateCibWithOwner:(id)anOwner topLevelObjects:(CPArray)topLevelObjects
{
return [self instantiateCibWithExternalNameTable:[CPDictionary dictionaryWithObjectsAndKeys:anOwner, CPCibOwner, topLevelObjects, CPCibTopLevelObjects]];
return [self instantiateCibWithExternalNameTable:[CPDictionary dictionaryWithObjects:[anOwner, topLevelObjects] forKeys:[CPCibOwner, CPCibTopLevelObjects]]];
}
@end
+5
View File
@@ -35,6 +35,7 @@ var CPUndoManagerNormal = 0,
CPUndoManagerCheckpointNotification = @"CPUndoManagerCheckpointNotification";
CPUndoManagerDidOpenUndoGroupNotification = @"CPUndoManagerDidOpenUndoGroupNotification";
CPUndoManagerDidCloseUndoGroupNotification = @"CPUndoManagerDidCloseUndoGroupNotification";
CPUndoManagerDidRedoChangeNotification = @"CPUndoManagerDidRedoChangeNotification";
CPUndoManagerDidUndoChangeNotification = @"CPUndoManagerDidUndoChangeNotification";
CPUndoManagerWillCloseUndoGroupNotification = @"CPUndoManagerWillCloseUndoGroupNotification";
@@ -490,6 +491,10 @@ if (_currentGroup == nil)
if (_levelsOfUndo > 0 && stack.length > _levelsOfUndo)
stack.splice(0, 1);
[defaultCenter
postNotificationName:CPUndoManagerDidCloseUndoGroupNotification
object:self];
}
// Nested Undo Grouping
+3
View File
@@ -288,6 +288,9 @@ function descriptionWithoutEntity(aString)
{
[self assert:[_set lastIndex] equals:19];
[self assert:[[CPIndexSet indexSet] lastIndex] equals:CPNotFound];
var singleIndexSet = [CPIndexSet indexSetWithIndex:3];
[self assert:3 equals:[singleIndexSet lastIndex]];
}
/*
- (void)testAddSpeed
+47 -1
View File
@@ -3,12 +3,16 @@
@implementation CPUndoManagerTest : OJTestCase
{
CPUndoManager undoManager;
CPArray receivedNotifications;
CPUndoManager undoManager;
BOOL itIsDone;
}
- (void)setUp
{
undoManager = [[CPUndoManager alloc] init];
itIsDone = NO;
receivedNotifications = [CPMutableArray array];
}
- (void)testUndoMenuTitleForUndoActionName
@@ -35,4 +39,46 @@
[self assert:[undoManager redoMenuTitleForUndoActionName:"STRING"] equals:@"Redo STRING"];
}
- (void)testNotifications
{
[[CPNotificationCenter defaultCenter] addObserver:self
selector:@selector(receiveNotification:)
name:CPUndoManagerDidCloseUndoGroupNotification
object:undoManager];
[self doIt];
// The default run loop undo grouping won't be closed until the next run loop cycle.
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
CPLog.error("receivedNotifications: %@", receivedNotifications);
[self assert:CPUndoManagerDidCloseUndoGroupNotification equals:[receivedNotifications[0] name]];
[[CPNotificationCenter defaultCenter] removeObserver:self];
}
- (void)receiveNotification:(CPNotification)aNotification
{
[receivedNotifications addObject:aNotification];
}
- (void)doIt
{
[undoManager registerUndoWithTarget:self
selector:@selector(undoIt)
object:nil];
itIsDone = YES;
}
- (void)undoIt
{
[undoManager registerUndoWithTarget:self
selector:@selector(doit)
object:nil];
itIsDone = NO;
}
@end