From bb2242b4225f5ed14b2ad25748762092a8d0d827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Tue, 13 Jun 2006 11:28:36 +0000 Subject: [PATCH] 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 --- .../app/bmessenger/ForwardMessageTest.cpp | 55 +++++++++++++++++++ src/tests/kits/app/bmessenger/Jamfile | 5 ++ 2 files changed, 60 insertions(+) create mode 100644 src/tests/kits/app/bmessenger/ForwardMessageTest.cpp diff --git a/src/tests/kits/app/bmessenger/ForwardMessageTest.cpp b/src/tests/kits/app/bmessenger/ForwardMessageTest.cpp new file mode 100644 index 0000000000..0240e0a1d0 --- /dev/null +++ b/src/tests/kits/app/bmessenger/ForwardMessageTest.cpp @@ -0,0 +1,55 @@ +#include +#include +#include + +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(); +} diff --git a/src/tests/kits/app/bmessenger/Jamfile b/src/tests/kits/app/bmessenger/Jamfile index 0701738df2..9815e4411d 100644 --- a/src/tests/kits/app/bmessenger/Jamfile +++ b/src/tests/kits/app/bmessenger/Jamfile @@ -9,4 +9,9 @@ UnitTest SMRemoteTargetApp : be $(TARGET_LIBSTDC++) ; +SimpleTest ForwardMessageTest : + ForwardMessageTest.cpp + : be + ; + SubInclude HAIKU_TOP src tests kits app bmessenger testapps ;