2010-02-16 10:44:23 -08:00
|
|
|
#include "TestStackHooks.h"
|
|
|
|
|
|
|
|
#include "IPDLUnitTests.h" // fail etc.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace _ipdltest {
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// parent
|
|
|
|
|
2010-04-29 09:49:00 -07:00
|
|
|
TestStackHooksParent::TestStackHooksParent() :
|
|
|
|
mOnStack(false), mIncallDepth(0)
|
2010-02-16 10:44:23 -08:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(TestStackHooksParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
TestStackHooksParent::~TestStackHooksParent()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(TestStackHooksParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TestStackHooksParent::Main()
|
|
|
|
{
|
|
|
|
if (!SendStart())
|
|
|
|
fail("sending Start()");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
TestStackHooksParent::AnswerStackFrame()
|
|
|
|
{
|
|
|
|
if (!mOnStack)
|
|
|
|
fail("not on C++ stack?!");
|
|
|
|
|
|
|
|
if (!CallStackFrame())
|
|
|
|
fail("calling StackFrame()");
|
|
|
|
|
|
|
|
if (!mOnStack)
|
|
|
|
fail("not on C++ stack?!");
|
|
|
|
|
2010-04-29 09:49:00 -07:00
|
|
|
if (1 != mIncallDepth)
|
|
|
|
fail("missed EnteredCall or ExitedCall hook");
|
|
|
|
|
2010-02-16 10:44:23 -08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// child
|
|
|
|
|
|
|
|
TestStackHooksChild::TestStackHooksChild() :
|
|
|
|
mOnStack(false),
|
|
|
|
mEntered(0),
|
2010-04-29 09:49:00 -07:00
|
|
|
mExited(0),
|
|
|
|
mIncallDepth(0)
|
2010-02-16 10:44:23 -08:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(TestStackHooksChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
TestStackHooksChild::~TestStackHooksChild()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(TestStackHooksChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
void RunTestsFn() {
|
|
|
|
static_cast<TestStackHooksChild*>(gChildActor)->RunTests();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TestStackHooksChild::RecvStart()
|
|
|
|
{
|
|
|
|
if (!mOnStack)
|
|
|
|
fail("missed stack notification");
|
|
|
|
|
2010-04-29 09:49:00 -07:00
|
|
|
if (0 != mIncallDepth)
|
|
|
|
fail("EnteredCall/ExitedCall malfunction");
|
|
|
|
|
2010-02-16 10:44:23 -08:00
|
|
|
// kick off tests from a runnable so that we can start with
|
|
|
|
// RPCChannel code on the C++ stack
|
|
|
|
MessageLoop::current()->PostTask(FROM_HERE,
|
|
|
|
NewRunnableFunction(RunTestsFn));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TestStackHooksChild::AnswerStackFrame()
|
|
|
|
{
|
|
|
|
if (!mOnStack)
|
|
|
|
fail("missed stack notification");
|
|
|
|
|
2010-04-29 09:49:00 -07:00
|
|
|
if (1 != mIncallDepth)
|
|
|
|
fail("missed EnteredCall or ExitedCall hook");
|
|
|
|
|
2010-07-15 12:27:43 -07:00
|
|
|
if (PTestStackHooks::TEST4_3 == state()) {
|
2010-02-16 10:44:23 -08:00
|
|
|
if (!SendAsync())
|
|
|
|
fail("sending Async()");
|
|
|
|
}
|
2010-07-15 12:27:43 -07:00
|
|
|
else if (PTestStackHooks::TEST5_3 == state()) {
|
2010-02-16 10:44:23 -08:00
|
|
|
if (!SendSync())
|
|
|
|
fail("sending Sync()");
|
|
|
|
}
|
|
|
|
else {
|
2010-07-15 12:27:43 -07:00
|
|
|
fail("unexpected state");
|
2010-02-16 10:44:23 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!mOnStack)
|
|
|
|
fail("bad stack exit notification");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TestStackHooksChild::RunTests()
|
|
|
|
{
|
|
|
|
// 1 because of RecvStart()
|
|
|
|
if (1 != mEntered)
|
|
|
|
fail("missed stack notification");
|
|
|
|
if (mOnStack)
|
|
|
|
fail("spurious stack notification");
|
2010-04-29 09:49:00 -07:00
|
|
|
if (0 != mIncallDepth)
|
|
|
|
fail("EnteredCall/ExitedCall malfunction");
|
2010-02-16 10:44:23 -08:00
|
|
|
|
|
|
|
if (!SendAsync())
|
|
|
|
fail("sending Async()");
|
|
|
|
if (mOnStack)
|
|
|
|
fail("spurious stack notification");
|
2010-04-29 09:49:00 -07:00
|
|
|
if (0 != mIncallDepth)
|
|
|
|
fail("EnteredCall/ExitedCall malfunction");
|
2010-02-16 10:44:23 -08:00
|
|
|
if (2 != mEntered)
|
|
|
|
fail("missed stack notification");
|
|
|
|
|
|
|
|
if (!SendSync())
|
|
|
|
fail("sending Sync()");
|
|
|
|
if (mOnStack)
|
|
|
|
fail("spurious stack notification");
|
2010-04-29 09:49:00 -07:00
|
|
|
if (0 != mIncallDepth)
|
|
|
|
fail("EnteredCall/ExitedCall malfunction");
|
2010-02-16 10:44:23 -08:00
|
|
|
if (3 != mEntered)
|
|
|
|
fail("missed stack notification");
|
|
|
|
|
|
|
|
if (!CallRpc())
|
|
|
|
fail("calling RPC()");
|
|
|
|
if (mOnStack)
|
|
|
|
fail("spurious stack notification");
|
2010-04-29 09:49:00 -07:00
|
|
|
if (0 != mIncallDepth)
|
|
|
|
fail("EnteredCall/ExitedCall malfunction");
|
2010-02-16 10:44:23 -08:00
|
|
|
if (4 != mEntered)
|
|
|
|
fail("missed stack notification");
|
|
|
|
|
|
|
|
if (!CallStackFrame())
|
|
|
|
fail("calling StackFrame()");
|
|
|
|
if (mOnStack)
|
|
|
|
fail("spurious stack notification");
|
2010-04-29 09:49:00 -07:00
|
|
|
if (0 != mIncallDepth)
|
|
|
|
fail("EnteredCall/ExitedCall malfunction");
|
2010-02-16 10:44:23 -08:00
|
|
|
if (5 != mEntered)
|
|
|
|
fail("missed stack notification");
|
|
|
|
|
|
|
|
Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace _ipdltest
|
|
|
|
} // namespace mozilla
|