mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-23 19:09:49 +00:00
Test for bug 538239.
--HG-- extra : transplant_source : 8e%9E%87%3F%D1%EE%A7%3A%AB%19%84%AD%C1%DD%13%CE%82%E3w
This commit is contained in:
parent
73be3a1611
commit
25bab4e0a8
@ -62,6 +62,7 @@ IPDLTESTS = \
|
||||
TestSanity \
|
||||
TestRPCErrorCleanup \
|
||||
TestCrashCleanup \
|
||||
TestSyncWakeup \
|
||||
TestLatency \
|
||||
TestRPCRaces \
|
||||
TestManyChildAllocs \
|
||||
|
41
ipc/ipdl/test/cxx/PTestSyncWakeup.ipdl
Normal file
41
ipc/ipdl/test/cxx/PTestSyncWakeup.ipdl
Normal file
@ -0,0 +1,41 @@
|
||||
namespace mozilla {
|
||||
namespace _ipdltest {
|
||||
|
||||
rpc protocol PTestSyncWakeup {
|
||||
both:
|
||||
rpc StackFrame();
|
||||
|
||||
child:
|
||||
async Start();
|
||||
async Note1();
|
||||
async Note2();
|
||||
|
||||
parent:
|
||||
sync Sync1();
|
||||
sync Sync2();
|
||||
async __delete__();
|
||||
|
||||
|
||||
state START:
|
||||
send Start goto TEST1;
|
||||
|
||||
state TEST1:
|
||||
recv Sync1 goto TEST1_P2;
|
||||
state TEST1_P2:
|
||||
send Note1 goto TEST2;
|
||||
|
||||
state TEST2:
|
||||
answer StackFrame goto TEST2_P2;
|
||||
state TEST2_P2:
|
||||
call StackFrame goto TEST2_P3;
|
||||
state TEST2_P3:
|
||||
recv Sync2 goto TEST2_P4;
|
||||
state TEST2_P4:
|
||||
send Note2 goto DONE;
|
||||
|
||||
state DONE:
|
||||
recv __delete__;
|
||||
};
|
||||
|
||||
} // namespace _ipdltest
|
||||
} // namespace mozilla
|
121
ipc/ipdl/test/cxx/TestSyncWakeup.cpp
Normal file
121
ipc/ipdl/test/cxx/TestSyncWakeup.cpp
Normal file
@ -0,0 +1,121 @@
|
||||
#include "TestSyncWakeup.h"
|
||||
|
||||
#include "IPDLUnitTests.h" // fail etc.
|
||||
|
||||
namespace mozilla {
|
||||
namespace _ipdltest {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// parent
|
||||
|
||||
TestSyncWakeupParent::TestSyncWakeupParent()
|
||||
{
|
||||
MOZ_COUNT_CTOR(TestSyncWakeupParent);
|
||||
}
|
||||
|
||||
TestSyncWakeupParent::~TestSyncWakeupParent()
|
||||
{
|
||||
MOZ_COUNT_DTOR(TestSyncWakeupParent);
|
||||
}
|
||||
|
||||
void
|
||||
TestSyncWakeupParent::Main()
|
||||
{
|
||||
if (!SendStart())
|
||||
fail("sending Start()");
|
||||
}
|
||||
|
||||
bool
|
||||
TestSyncWakeupParent::AnswerStackFrame()
|
||||
{
|
||||
if (!CallStackFrame())
|
||||
fail("calling StackFrame()");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TestSyncWakeupParent::RecvSync1()
|
||||
{
|
||||
if (!SendNote1())
|
||||
fail("sending Note1()");
|
||||
|
||||
// XXX ugh ... need to ensure that the async message and sync
|
||||
// reply come in "far enough" apart that this test doesn't pass on
|
||||
// accident
|
||||
sleep(5);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TestSyncWakeupParent::RecvSync2()
|
||||
{
|
||||
if (!SendNote2())
|
||||
fail("sending Note2()");
|
||||
|
||||
// see above
|
||||
sleep(5);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// child
|
||||
|
||||
TestSyncWakeupChild::TestSyncWakeupChild() : mDone(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(TestSyncWakeupChild);
|
||||
}
|
||||
|
||||
TestSyncWakeupChild::~TestSyncWakeupChild()
|
||||
{
|
||||
MOZ_COUNT_DTOR(TestSyncWakeupChild);
|
||||
}
|
||||
|
||||
bool
|
||||
TestSyncWakeupChild::RecvStart()
|
||||
{
|
||||
// First test: the parent fires back an async message while
|
||||
// replying to a sync one
|
||||
if (!SendSync1())
|
||||
fail("sending Sync()");
|
||||
|
||||
// drop back into the event loop to get Note1(), then kick off the
|
||||
// second test
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TestSyncWakeupChild::RecvNote1()
|
||||
{
|
||||
// Second test: the parent fires back an async message while
|
||||
// replying to a sync one, with a frame on the RPC stack
|
||||
if (!CallStackFrame())
|
||||
fail("calling StackFrame()");
|
||||
|
||||
if (!mDone)
|
||||
fail("should have received Note2()!");
|
||||
|
||||
Close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TestSyncWakeupChild::AnswerStackFrame()
|
||||
{
|
||||
if (!SendSync2())
|
||||
fail("sending Sync()");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TestSyncWakeupChild::RecvNote2()
|
||||
{
|
||||
mDone = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace _ipdltest
|
||||
} // namespace mozilla
|
80
ipc/ipdl/test/cxx/TestSyncWakeup.h
Normal file
80
ipc/ipdl/test/cxx/TestSyncWakeup.h
Normal file
@ -0,0 +1,80 @@
|
||||
#ifndef mozilla__ipdltest_TestSyncWakeup_h
|
||||
#define mozilla__ipdltest_TestSyncWakeup_h 1
|
||||
|
||||
#include "mozilla/_ipdltest/IPDLUnitTests.h"
|
||||
|
||||
#include "mozilla/_ipdltest/PTestSyncWakeupParent.h"
|
||||
#include "mozilla/_ipdltest/PTestSyncWakeupChild.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace _ipdltest {
|
||||
|
||||
|
||||
class TestSyncWakeupParent :
|
||||
public PTestSyncWakeupParent
|
||||
{
|
||||
public:
|
||||
TestSyncWakeupParent();
|
||||
virtual ~TestSyncWakeupParent();
|
||||
|
||||
void Main();
|
||||
|
||||
protected:
|
||||
NS_OVERRIDE
|
||||
virtual bool AnswerStackFrame();
|
||||
|
||||
NS_OVERRIDE
|
||||
virtual bool RecvSync1();
|
||||
|
||||
NS_OVERRIDE
|
||||
virtual bool RecvSync2();
|
||||
|
||||
NS_OVERRIDE
|
||||
virtual void ActorDestroy(ActorDestroyReason why)
|
||||
{
|
||||
if (NormalShutdown != why)
|
||||
fail("unexpected destruction!");
|
||||
passed("ok");
|
||||
QuitParent();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class TestSyncWakeupChild :
|
||||
public PTestSyncWakeupChild
|
||||
{
|
||||
public:
|
||||
TestSyncWakeupChild();
|
||||
virtual ~TestSyncWakeupChild();
|
||||
|
||||
protected:
|
||||
NS_OVERRIDE
|
||||
virtual bool RecvStart();
|
||||
|
||||
NS_OVERRIDE
|
||||
virtual bool RecvNote1();
|
||||
|
||||
NS_OVERRIDE
|
||||
virtual bool AnswerStackFrame();
|
||||
|
||||
NS_OVERRIDE
|
||||
virtual bool RecvNote2();
|
||||
|
||||
NS_OVERRIDE
|
||||
virtual void ActorDestroy(ActorDestroyReason why)
|
||||
{
|
||||
if (NormalShutdown != why)
|
||||
fail("unexpected destruction!");
|
||||
QuitChild();
|
||||
}
|
||||
|
||||
private:
|
||||
bool mDone;
|
||||
};
|
||||
|
||||
|
||||
} // namespace _ipdltest
|
||||
} // namespace mozilla
|
||||
|
||||
|
||||
#endif // ifndef mozilla__ipdltest_TestSyncWakeup_h
|
@ -15,4 +15,5 @@ IPDLSRCS = \
|
||||
PTestShutdown.ipdl \
|
||||
PTestShutdownSub.ipdl \
|
||||
PTestShutdownSubsub.ipdl \
|
||||
PTestSyncWakeup.ipdl \
|
||||
$(NULL)
|
||||
|
Loading…
x
Reference in New Issue
Block a user