michael@0: #include "TestManyChildAllocs.h" michael@0: michael@0: #include "IPDLUnitTests.h" // fail etc. michael@0: michael@0: michael@0: #define NALLOCS 10 michael@0: michael@0: namespace mozilla { michael@0: namespace _ipdltest { michael@0: michael@0: // parent code michael@0: michael@0: TestManyChildAllocsParent::TestManyChildAllocsParent() michael@0: { michael@0: MOZ_COUNT_CTOR(TestManyChildAllocsParent); michael@0: } michael@0: michael@0: TestManyChildAllocsParent::~TestManyChildAllocsParent() michael@0: { michael@0: MOZ_COUNT_DTOR(TestManyChildAllocsParent); michael@0: } michael@0: michael@0: void michael@0: TestManyChildAllocsParent::Main() michael@0: { michael@0: if (!SendGo()) michael@0: fail("can't send Go()"); michael@0: } michael@0: michael@0: bool michael@0: TestManyChildAllocsParent::RecvDone() michael@0: { michael@0: // explicitly *not* cleaning up, so we can sanity-check IPDL's michael@0: // auto-shutdown/cleanup handling michael@0: Close(); michael@0: michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TestManyChildAllocsParent::DeallocPTestManyChildAllocsSubParent( michael@0: PTestManyChildAllocsSubParent* __a) michael@0: { michael@0: delete __a; return true; michael@0: } michael@0: michael@0: PTestManyChildAllocsSubParent* michael@0: TestManyChildAllocsParent::AllocPTestManyChildAllocsSubParent() michael@0: { michael@0: return new TestManyChildAllocsSubParent(); michael@0: } michael@0: michael@0: michael@0: // child code michael@0: michael@0: TestManyChildAllocsChild::TestManyChildAllocsChild() michael@0: { michael@0: MOZ_COUNT_CTOR(TestManyChildAllocsChild); michael@0: } michael@0: michael@0: TestManyChildAllocsChild::~TestManyChildAllocsChild() michael@0: { michael@0: MOZ_COUNT_DTOR(TestManyChildAllocsChild); michael@0: } michael@0: michael@0: bool TestManyChildAllocsChild::RecvGo() michael@0: { michael@0: for (int i = 0; i < NALLOCS; ++i) { michael@0: PTestManyChildAllocsSubChild* child = michael@0: SendPTestManyChildAllocsSubConstructor(); michael@0: michael@0: if (!child) michael@0: fail("can't send ctor()"); michael@0: michael@0: if (!child->SendHello()) michael@0: fail("can't send Hello()"); michael@0: } michael@0: michael@0: size_t len = ManagedPTestManyChildAllocsSubChild().Length(); michael@0: if (NALLOCS != len) michael@0: fail("expected %lu kids, got %lu", NALLOCS, len); michael@0: michael@0: if (!SendDone()) michael@0: fail("can't send Done()"); michael@0: michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TestManyChildAllocsChild::DeallocPTestManyChildAllocsSubChild( michael@0: PTestManyChildAllocsSubChild* __a) michael@0: { michael@0: delete __a; return true; michael@0: } michael@0: michael@0: PTestManyChildAllocsSubChild* michael@0: TestManyChildAllocsChild::AllocPTestManyChildAllocsSubChild() michael@0: { michael@0: return new TestManyChildAllocsSubChild(); michael@0: } michael@0: michael@0: michael@0: } // namespace _ipdltest michael@0: } // namespace mozilla