Running Apple Event loop in unit tests
Running Apple Event loop in unit tests
- Subject: Running Apple Event loop in unit tests
- From: Nikita Zhuk <email@hidden>
- Date: Tue, 6 Feb 2007 09:35:19 +0200
Hi all. I'm writing an application which communicates with another
app via asyncronous Apple Events (AESendMessage with kAEQueueReply
send mode). When I compile & launch my app, the AE communication
works fine and I get reply events into my custom event handler which
I had installed with the following code:
[[NSAppleEventManager sharedAppleEventManager] setEventHandler:self
andSelector:@selector(dispatchAppleEvent:withReplyEvent:)
forEventClass:kCoreEventClass andEventID:kAEAnswer] // the
dispatchAppleEvent:withReplyEvent: just forwards the event to
appropriate object.
Now I would like to write a test case using OCUnit testing framework
which would execute a method which sends the AE to another app and
then block until the AE reply would be received & handled, so I could
use the return values in my assert checks.
Any ideas how to implement this kind of blocking? I have tried
something like:
NSEvent *event = nil; while(event = [[NSApplication
sharedApplication] nextEventMatchingMask:NSAppKitDefinedMask
untilDate:nil inMode:NSDefaultRunLoopMode dequeue:TRUE]);
but that kind of approach doesn't seem to work. I'm writing my app in
Objective-C and Cocoa (although AE stuff is Carbon).
Best regards,
Nikita Zhuk
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden