2010-04-27 05:11:48 +04:00
|
|
|
#ifndef mozilla__ipdltest_TestSelfManageRoot_h
|
|
|
|
#define mozilla__ipdltest_TestSelfManageRoot_h 1
|
|
|
|
|
|
|
|
#include "mozilla/_ipdltest/IPDLUnitTests.h"
|
|
|
|
|
|
|
|
#include "mozilla/_ipdltest/PTestSelfManageRootParent.h"
|
|
|
|
#include "mozilla/_ipdltest/PTestSelfManageRootChild.h"
|
|
|
|
#include "mozilla/_ipdltest/PTestSelfManageParent.h"
|
|
|
|
#include "mozilla/_ipdltest/PTestSelfManageChild.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace _ipdltest {
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Parent side
|
|
|
|
|
|
|
|
class TestSelfManageParent : public PTestSelfManageParent {
|
2019-02-26 18:37:22 +03:00
|
|
|
friend class PTestSelfManageParent;
|
|
|
|
|
2010-04-27 05:11:48 +04:00
|
|
|
public:
|
2020-02-20 14:40:14 +03:00
|
|
|
MOZ_COUNTED_DEFAULT_CTOR(TestSelfManageParent)
|
|
|
|
MOZ_COUNTED_DTOR_OVERRIDE(TestSelfManageParent)
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2010-04-27 05:11:48 +04:00
|
|
|
ActorDestroyReason mWhy;
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2010-04-27 05:11:48 +04:00
|
|
|
protected:
|
2019-02-26 18:37:22 +03:00
|
|
|
PTestSelfManageParent* AllocPTestSelfManageParent() {
|
2010-04-27 05:11:48 +04:00
|
|
|
return new TestSelfManageParent();
|
|
|
|
}
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2019-02-26 18:37:22 +03:00
|
|
|
bool DeallocPTestSelfManageParent(PTestSelfManageParent* a) { return true; }
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason why) override { mWhy = why; }
|
2010-04-27 05:11:48 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
class TestSelfManageRootParent : public PTestSelfManageRootParent {
|
2019-02-26 18:37:22 +03:00
|
|
|
friend class PTestSelfManageRootParent;
|
|
|
|
|
2010-04-27 05:11:48 +04:00
|
|
|
public:
|
2020-02-20 14:40:14 +03:00
|
|
|
MOZ_COUNTED_DEFAULT_CTOR(TestSelfManageRootParent)
|
2010-04-27 05:11:48 +04:00
|
|
|
virtual ~TestSelfManageRootParent() {
|
|
|
|
MOZ_COUNT_DTOR(TestSelfManageRootParent);
|
|
|
|
}
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2011-11-30 20:27:22 +04:00
|
|
|
static bool RunTestInProcesses() { return true; }
|
|
|
|
static bool RunTestInThreads() { return true; }
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2010-04-27 05:11:48 +04:00
|
|
|
void Main();
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2010-04-27 05:11:48 +04:00
|
|
|
protected:
|
2019-02-26 18:37:22 +03:00
|
|
|
PTestSelfManageParent* AllocPTestSelfManageParent() {
|
2010-04-27 05:11:48 +04:00
|
|
|
return new TestSelfManageParent();
|
|
|
|
}
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2019-02-26 18:37:22 +03:00
|
|
|
bool DeallocPTestSelfManageParent(PTestSelfManageParent* a) { return true; }
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason why) override {
|
2010-04-27 05:11:48 +04:00
|
|
|
if (NormalShutdown != why) fail("unexpected destruction!");
|
|
|
|
passed("ok");
|
|
|
|
QuitParent();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Child side
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class TestSelfManageChild : public PTestSelfManageChild {
|
2019-02-26 18:37:22 +03:00
|
|
|
friend class PTestSelfManageChild;
|
|
|
|
|
2018-12-14 21:10:35 +03:00
|
|
|
public:
|
2020-02-20 14:40:14 +03:00
|
|
|
MOZ_COUNTED_DEFAULT_CTOR(TestSelfManageChild)
|
|
|
|
MOZ_COUNTED_DTOR_OVERRIDE(TestSelfManageChild)
|
2010-04-27 05:11:48 +04:00
|
|
|
|
|
|
|
protected:
|
2019-02-26 18:37:22 +03:00
|
|
|
PTestSelfManageChild* AllocPTestSelfManageChild() {
|
2010-04-27 05:11:48 +04:00
|
|
|
return new TestSelfManageChild();
|
|
|
|
}
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2019-02-26 18:37:22 +03:00
|
|
|
bool DeallocPTestSelfManageChild(PTestSelfManageChild* a) {
|
2010-04-27 05:11:48 +04:00
|
|
|
delete a;
|
|
|
|
return true;
|
|
|
|
}
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason why) override {}
|
2010-04-27 05:11:48 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
class TestSelfManageRootChild : public PTestSelfManageRootChild {
|
2019-02-26 18:37:22 +03:00
|
|
|
friend class PTestSelfManageRootChild;
|
|
|
|
|
2018-12-14 21:10:35 +03:00
|
|
|
public:
|
2020-02-20 14:40:14 +03:00
|
|
|
MOZ_COUNTED_DEFAULT_CTOR(TestSelfManageRootChild)
|
2010-04-27 05:11:48 +04:00
|
|
|
virtual ~TestSelfManageRootChild() {
|
|
|
|
MOZ_COUNT_DTOR(TestSelfManageRootChild);
|
2018-12-14 21:10:35 +03:00
|
|
|
}
|
|
|
|
|
2010-04-27 05:11:48 +04:00
|
|
|
void Main();
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2010-04-27 05:11:48 +04:00
|
|
|
protected:
|
2019-02-26 18:37:22 +03:00
|
|
|
PTestSelfManageChild* AllocPTestSelfManageChild() {
|
2010-04-27 05:11:48 +04:00
|
|
|
return new TestSelfManageChild();
|
2018-12-14 21:10:35 +03:00
|
|
|
}
|
|
|
|
|
2019-02-26 18:37:22 +03:00
|
|
|
bool DeallocPTestSelfManageChild(PTestSelfManageChild* a) {
|
2010-04-27 05:11:48 +04:00
|
|
|
delete a;
|
|
|
|
return true;
|
2018-12-14 21:10:35 +03:00
|
|
|
}
|
|
|
|
|
2010-04-27 05:11:48 +04:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason why) override {
|
|
|
|
if (NormalShutdown != why) fail("unexpected destruction!");
|
|
|
|
QuitChild();
|
2018-12-14 21:10:35 +03:00
|
|
|
}
|
|
|
|
};
|
2010-04-27 05:11:48 +04:00
|
|
|
|
|
|
|
} // namespace _ipdltest
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // ifndef mozilla__ipdltest_TestSelfManageRoot_h
|