michael@0: #if defined(OS_POSIX) michael@0: #include // sleep() michael@0: #endif michael@0: michael@0: #include "TestSyncWakeup.h" michael@0: michael@0: #include "IPDLUnitTests.h" // fail etc. michael@0: michael@0: namespace mozilla { michael@0: namespace _ipdltest { michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: // parent michael@0: michael@0: TestSyncWakeupParent::TestSyncWakeupParent() michael@0: { michael@0: MOZ_COUNT_CTOR(TestSyncWakeupParent); michael@0: } michael@0: michael@0: TestSyncWakeupParent::~TestSyncWakeupParent() michael@0: { michael@0: MOZ_COUNT_DTOR(TestSyncWakeupParent); michael@0: } michael@0: michael@0: void michael@0: TestSyncWakeupParent::Main() michael@0: { michael@0: if (!SendStart()) michael@0: fail("sending Start()"); michael@0: } michael@0: michael@0: bool michael@0: TestSyncWakeupParent::AnswerStackFrame() michael@0: { michael@0: if (!CallStackFrame()) michael@0: fail("calling StackFrame()"); michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TestSyncWakeupParent::RecvSync1() michael@0: { michael@0: if (!SendNote1()) michael@0: fail("sending Note1()"); michael@0: michael@0: // XXX ugh ... need to ensure that the async message and sync michael@0: // reply come in "far enough" apart that this test doesn't pass on michael@0: // accident michael@0: #if defined(OS_POSIX) michael@0: // NB: can't use PR_Sleep (i.e. Sleep() on windows) because it's michael@0: // only spec'd to block the current thread, not the current michael@0: // process. We need the IO thread to sleep as well. michael@0: puts(" (sleeping for 5 seconds. sorry!)"); michael@0: sleep(5); michael@0: #endif michael@0: michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TestSyncWakeupParent::RecvSync2() michael@0: { michael@0: if (!SendNote2()) michael@0: fail("sending Note2()"); michael@0: michael@0: #if defined(OS_POSIX) michael@0: // see above michael@0: sleep(5); michael@0: puts(" (sleeping for 5 seconds. sorry!)"); michael@0: #endif michael@0: michael@0: return true; michael@0: } michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: // child michael@0: michael@0: TestSyncWakeupChild::TestSyncWakeupChild() : mDone(false) michael@0: { michael@0: MOZ_COUNT_CTOR(TestSyncWakeupChild); michael@0: } michael@0: michael@0: TestSyncWakeupChild::~TestSyncWakeupChild() michael@0: { michael@0: MOZ_COUNT_DTOR(TestSyncWakeupChild); michael@0: } michael@0: michael@0: bool michael@0: TestSyncWakeupChild::RecvStart() michael@0: { michael@0: // First test: the parent fires back an async message while michael@0: // replying to a sync one michael@0: if (!SendSync1()) michael@0: fail("sending Sync()"); michael@0: michael@0: // drop back into the event loop to get Note1(), then kick off the michael@0: // second test michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TestSyncWakeupChild::RecvNote1() michael@0: { michael@0: // Second test: the parent fires back an async message while michael@0: // replying to a sync one, with a frame on the RPC stack michael@0: if (!CallStackFrame()) michael@0: fail("calling StackFrame()"); michael@0: michael@0: if (!mDone) michael@0: fail("should have received Note2()!"); michael@0: michael@0: Close(); michael@0: michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TestSyncWakeupChild::AnswerStackFrame() michael@0: { michael@0: if (!SendSync2()) michael@0: fail("sending Sync()"); michael@0: michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TestSyncWakeupChild::RecvNote2() michael@0: { michael@0: mDone = true; michael@0: return true; michael@0: } michael@0: michael@0: } // namespace _ipdltest michael@0: } // namespace mozilla