This commit is contained in:
Chris Jones 2011-03-25 12:56:17 -05:00
Родитель f2a6e24d66
Коммит c4a785c9a8
7 изменённых файлов: 337 добавлений и 0 удалений

Просмотреть файл

@ -62,6 +62,7 @@ IPDLTESTS = \
TestCrashCleanup \
TestDataStructures \
TestDesc \
TestFailedCtor \
TestHangs \
TestJSON \
TestLatency \

Просмотреть файл

@ -0,0 +1,19 @@
include protocol PTestFailedCtorSub;
namespace mozilla {
namespace _ipdltest {
rpc protocol PTestFailedCtor {
manages PTestFailedCtorSub;
child:
rpc PTestFailedCtorSub();
__delete__();
state CONSTRUCT:
call PTestFailedCtorSub goto DEAD;
state DEAD:
send __delete__;
};
}
}

Просмотреть файл

@ -0,0 +1,18 @@
include protocol PTestFailedCtor;
include protocol PTestFailedCtorSubsub;
namespace mozilla {
namespace _ipdltest {
rpc protocol PTestFailedCtorSub {
manager PTestFailedCtor;
manages PTestFailedCtorSubsub;
parent:
async PTestFailedCtorSubsub();
sync Sync();
__delete__();
};
}
}

Просмотреть файл

@ -0,0 +1,15 @@
include protocol PTestFailedCtorSub;
namespace mozilla {
namespace _ipdltest {
rpc protocol PTestFailedCtorSubsub {
manager PTestFailedCtorSub;
parent:
__delete__();
};
}
}

Просмотреть файл

@ -0,0 +1,136 @@
#include "TestFailedCtor.h"
#include "IPDLUnitTests.h" // fail etc.
namespace mozilla {
namespace _ipdltest {
//-----------------------------------------------------------------------------
// parent
void
TestFailedCtorParent::Main()
{
PTestFailedCtorSubParent* p = CallPTestFailedCtorSubConstructor();
if (p)
fail("expected ctor to fail");
Close();
}
PTestFailedCtorSubParent*
TestFailedCtorParent::AllocPTestFailedCtorSub()
{
return new TestFailedCtorSubParent();
}
bool
TestFailedCtorParent::DeallocPTestFailedCtorSub(PTestFailedCtorSubParent* actor)
{
delete actor;
return true;
}
PTestFailedCtorSubsubParent*
TestFailedCtorSubParent::AllocPTestFailedCtorSubsub()
{
TestFailedCtorSubsub* a = new TestFailedCtorSubsub();
if (!mOne) {
return mOne = a;
} else if (!mTwo) {
return mTwo = a;
} else if (!mThree) {
return mThree = a;
} else {
fail("unexpected Alloc()");
return nsnull;
}
}
bool
TestFailedCtorSubParent::DeallocPTestFailedCtorSubsub(PTestFailedCtorSubsubParent* actor)
{
static_cast<TestFailedCtorSubsub*>(actor)->mDealloced = true;
return true;
}
void
TestFailedCtorSubParent::ActorDestroy(ActorDestroyReason why)
{
if (mOne->mWhy != Deletion)
fail("Subsub one got wrong ActorDestroyReason");
if (mTwo->mWhy != AncestorDeletion)
fail("Subsub two got wrong ActorDestroyReason");
if (mThree->mWhy != AncestorDeletion)
fail("Subsub three got wrong ActorDestroyReason");
if (FailedConstructor != why)
fail("unexpected destruction!");
}
TestFailedCtorSubParent::~TestFailedCtorSubParent()
{
if (!(mOne->mDealloced && mTwo->mDealloced && mThree->mDealloced))
fail("Not all subsubs were Dealloc'd");
delete mOne;
delete mTwo;
delete mThree;
}
//-----------------------------------------------------------------------------
// child
PTestFailedCtorSubChild*
TestFailedCtorChild::AllocPTestFailedCtorSub()
{
return new TestFailedCtorSubChild();
}
bool
TestFailedCtorChild::AnswerPTestFailedCtorSubConstructor(PTestFailedCtorSubChild* actor)
{
PTestFailedCtorSubsubChild* c1 = actor->SendPTestFailedCtorSubsubConstructor();
PTestFailedCtorSubsubChild::Send__delete__(c1);
if (!actor->SendPTestFailedCtorSubsubConstructor() ||
!actor->SendPTestFailedCtorSubsubConstructor() ||
!actor->SendSync())
fail("setting up test");
// This causes our process to die
return false;
}
bool
TestFailedCtorChild::DeallocPTestFailedCtorSub(PTestFailedCtorSubChild* actor)
{
delete actor;
return true;
}
void
TestFailedCtorChild::ProcessingError(Result what)
{
_exit(0);
}
PTestFailedCtorSubsubChild*
TestFailedCtorSubChild::AllocPTestFailedCtorSubsub()
{
return new TestFailedCtorSubsub();
}
bool
TestFailedCtorSubChild::DeallocPTestFailedCtorSubsub(PTestFailedCtorSubsubChild* actor)
{
delete actor;
return true;
}
void
TestFailedCtorSubChild::ActorDestroy(ActorDestroyReason why)
{
}
} // namespace _ipdltest
} // namespace mozilla

Просмотреть файл

@ -0,0 +1,145 @@
#ifndef mozilla_ipdltest_TestFailedCtor_h
#define mozilla_ipdltest_TestFailedCtor_h
#include "mozilla/_ipdltest/IPDLUnitTests.h"
#include "mozilla/_ipdltest/PTestFailedCtorParent.h"
#include "mozilla/_ipdltest/PTestFailedCtorChild.h"
#include "mozilla/_ipdltest/PTestFailedCtorSubParent.h"
#include "mozilla/_ipdltest/PTestFailedCtorSubChild.h"
#include "mozilla/_ipdltest/PTestFailedCtorSubsubParent.h"
#include "mozilla/_ipdltest/PTestFailedCtorSubsubChild.h"
namespace mozilla {
namespace _ipdltest {
//-----------------------------------------------------------------------------
// Top-level
//
class TestFailedCtorParent :
public PTestFailedCtorParent
{
public:
TestFailedCtorParent() { }
virtual ~TestFailedCtorParent() { }
void Main();
protected:
NS_OVERRIDE
virtual PTestFailedCtorSubParent* AllocPTestFailedCtorSub();
NS_OVERRIDE
virtual bool DeallocPTestFailedCtorSub(PTestFailedCtorSubParent* actor);
NS_OVERRIDE
virtual void ActorDestroy(ActorDestroyReason why)
{
if (AbnormalShutdown != why)
fail("unexpected destruction!");
passed("ok");
QuitParent();
}
};
class TestFailedCtorChild :
public PTestFailedCtorChild
{
public:
TestFailedCtorChild() { }
virtual ~TestFailedCtorChild() { }
protected:
NS_OVERRIDE
virtual PTestFailedCtorSubChild* AllocPTestFailedCtorSub();
NS_OVERRIDE
virtual bool AnswerPTestFailedCtorSubConstructor(PTestFailedCtorSubChild* actor);
NS_OVERRIDE
virtual bool DeallocPTestFailedCtorSub(PTestFailedCtorSubChild* actor);
NS_OVERRIDE
virtual void ProcessingError(Result what);
NS_OVERRIDE
virtual void ActorDestroy(ActorDestroyReason why)
{
fail("should have _exit()ed");
}
};
//-----------------------------------------------------------------------------
// First descendent
//
class TestFailedCtorSubsub;
class TestFailedCtorSubParent :
public PTestFailedCtorSubParent
{
public:
TestFailedCtorSubParent() : mOne(NULL), mTwo(NULL), mThree(NULL) { }
virtual ~TestFailedCtorSubParent();
protected:
NS_OVERRIDE
virtual PTestFailedCtorSubsubParent* AllocPTestFailedCtorSubsub();
NS_OVERRIDE
virtual bool DeallocPTestFailedCtorSubsub(PTestFailedCtorSubsubParent* actor);
NS_OVERRIDE
virtual bool RecvSync() { return true; }
NS_OVERRIDE
virtual void ActorDestroy(ActorDestroyReason why);
TestFailedCtorSubsub* mOne;
TestFailedCtorSubsub* mTwo;
TestFailedCtorSubsub* mThree;
};
class TestFailedCtorSubChild :
public PTestFailedCtorSubChild
{
public:
TestFailedCtorSubChild() { }
virtual ~TestFailedCtorSubChild() { }
protected:
NS_OVERRIDE
virtual PTestFailedCtorSubsubChild* AllocPTestFailedCtorSubsub();
NS_OVERRIDE
virtual bool DeallocPTestFailedCtorSubsub(PTestFailedCtorSubsubChild* actor);
NS_OVERRIDE
virtual void ActorDestroy(ActorDestroyReason why);
};
//-----------------------------------------------------------------------------
// Grand-descendent
//
class TestFailedCtorSubsub :
public PTestFailedCtorSubsubParent,
public PTestFailedCtorSubsubChild
{
public:
TestFailedCtorSubsub() : mWhy(ActorDestroyReason(-1)), mDealloced(false) {}
virtual ~TestFailedCtorSubsub() {}
NS_OVERRIDE
virtual void ActorDestroy(ActorDestroyReason why) { mWhy = why; }
ActorDestroyReason mWhy;
bool mDealloced;
};
}
}
#endif // ifndef mozilla_ipdltest_TestFailedCtor_h

Просмотреть файл

@ -6,6 +6,9 @@ IPDLSRCS = \
PTestDesc.ipdl \
PTestDescSub.ipdl \
PTestDescSubsub.ipdl \
PTestFailedCtor.ipdl \
PTestFailedCtorSub.ipdl \
PTestFailedCtorSubsub.ipdl \
PTestHandle.ipdl \
PTestHangs.ipdl \
PTestJSON.ipdl \