mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-05 16:42:58 +00:00
Refs #1632. Unit test for CPUndoManagerDidCloseUndoGroupNotification.
This commit is contained in:
1 parent
bf3c22f42c
commit
3e218d6aec
1 file changed
+47
-1
@@ -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
|
||||
Reference in new issue
Block a user