added a test for message forward
on R5 it seems a reply to a asynchronously-forwarded synchronous BMessage is the same as when no forward happens I didn't test on Haiku, but I suspect the behavior is different, especially a _previous_ is added as for asynchronous BMessages git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17814 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
32553c9788
commit
bb2242b422
55
src/tests/kits/app/bmessenger/ForwardMessageTest.cpp
Normal file
55
src/tests/kits/app/bmessenger/ForwardMessageTest.cpp
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <Application.h>
|
||||||
|
#include <Looper.h>
|
||||||
|
|
||||||
|
class MyLooper : public BLooper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MyLooper(BLooper *looper) : BLooper("test") {
|
||||||
|
printf("Looper created\n");
|
||||||
|
fLooper = looper;
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual void MessageReceived(BMessage *msg) {
|
||||||
|
printf("MessageReceived : %.4s\n", (char*)&msg->what);
|
||||||
|
switch (msg->what) {
|
||||||
|
case 'toto':
|
||||||
|
if (fLooper) {
|
||||||
|
BMessenger(fLooper).SendMessage(msg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
msg->SendReply('couc');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
BLooper::MessageReceived(msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BLooper *fLooper;
|
||||||
|
};
|
||||||
|
|
||||||
|
class App : public BApplication
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
App() : BApplication("application/test") {
|
||||||
|
|
||||||
|
};
|
||||||
|
virtual void ReadyToRun() {
|
||||||
|
MyLooper looper2(NULL);
|
||||||
|
looper2.Run();
|
||||||
|
MyLooper looper1(&looper2);
|
||||||
|
looper1.Run();
|
||||||
|
printf("loopers run\n");
|
||||||
|
BMessage reply;
|
||||||
|
BMessenger(&looper1).SendMessage('toto', &reply);
|
||||||
|
printf("message sent and replied\ncheck there is only a 'couc' what in the reply\n");
|
||||||
|
reply.PrintToStream();
|
||||||
|
exit(0);
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
App().Run();
|
||||||
|
}
|
@ -9,4 +9,9 @@ UnitTest SMRemoteTargetApp
|
|||||||
: be $(TARGET_LIBSTDC++)
|
: be $(TARGET_LIBSTDC++)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
SimpleTest ForwardMessageTest :
|
||||||
|
ForwardMessageTest.cpp
|
||||||
|
: be
|
||||||
|
;
|
||||||
|
|
||||||
SubInclude HAIKU_TOP src tests kits app bmessenger testapps ;
|
SubInclude HAIKU_TOP src tests kits app bmessenger testapps ;
|
||||||
|
Loading…
Reference in New Issue
Block a user