ipc/ipdl/test/cxx/TestManyChildAllocs.cpp

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

michael@0 1 #include "TestManyChildAllocs.h"
michael@0 2
michael@0 3 #include "IPDLUnitTests.h" // fail etc.
michael@0 4
michael@0 5
michael@0 6 #define NALLOCS 10
michael@0 7
michael@0 8 namespace mozilla {
michael@0 9 namespace _ipdltest {
michael@0 10
michael@0 11 // parent code
michael@0 12
michael@0 13 TestManyChildAllocsParent::TestManyChildAllocsParent()
michael@0 14 {
michael@0 15 MOZ_COUNT_CTOR(TestManyChildAllocsParent);
michael@0 16 }
michael@0 17
michael@0 18 TestManyChildAllocsParent::~TestManyChildAllocsParent()
michael@0 19 {
michael@0 20 MOZ_COUNT_DTOR(TestManyChildAllocsParent);
michael@0 21 }
michael@0 22
michael@0 23 void
michael@0 24 TestManyChildAllocsParent::Main()
michael@0 25 {
michael@0 26 if (!SendGo())
michael@0 27 fail("can't send Go()");
michael@0 28 }
michael@0 29
michael@0 30 bool
michael@0 31 TestManyChildAllocsParent::RecvDone()
michael@0 32 {
michael@0 33 // explicitly *not* cleaning up, so we can sanity-check IPDL's
michael@0 34 // auto-shutdown/cleanup handling
michael@0 35 Close();
michael@0 36
michael@0 37 return true;
michael@0 38 }
michael@0 39
michael@0 40 bool
michael@0 41 TestManyChildAllocsParent::DeallocPTestManyChildAllocsSubParent(
michael@0 42 PTestManyChildAllocsSubParent* __a)
michael@0 43 {
michael@0 44 delete __a; return true;
michael@0 45 }
michael@0 46
michael@0 47 PTestManyChildAllocsSubParent*
michael@0 48 TestManyChildAllocsParent::AllocPTestManyChildAllocsSubParent()
michael@0 49 {
michael@0 50 return new TestManyChildAllocsSubParent();
michael@0 51 }
michael@0 52
michael@0 53
michael@0 54 // child code
michael@0 55
michael@0 56 TestManyChildAllocsChild::TestManyChildAllocsChild()
michael@0 57 {
michael@0 58 MOZ_COUNT_CTOR(TestManyChildAllocsChild);
michael@0 59 }
michael@0 60
michael@0 61 TestManyChildAllocsChild::~TestManyChildAllocsChild()
michael@0 62 {
michael@0 63 MOZ_COUNT_DTOR(TestManyChildAllocsChild);
michael@0 64 }
michael@0 65
michael@0 66 bool TestManyChildAllocsChild::RecvGo()
michael@0 67 {
michael@0 68 for (int i = 0; i < NALLOCS; ++i) {
michael@0 69 PTestManyChildAllocsSubChild* child =
michael@0 70 SendPTestManyChildAllocsSubConstructor();
michael@0 71
michael@0 72 if (!child)
michael@0 73 fail("can't send ctor()");
michael@0 74
michael@0 75 if (!child->SendHello())
michael@0 76 fail("can't send Hello()");
michael@0 77 }
michael@0 78
michael@0 79 size_t len = ManagedPTestManyChildAllocsSubChild().Length();
michael@0 80 if (NALLOCS != len)
michael@0 81 fail("expected %lu kids, got %lu", NALLOCS, len);
michael@0 82
michael@0 83 if (!SendDone())
michael@0 84 fail("can't send Done()");
michael@0 85
michael@0 86 return true;
michael@0 87 }
michael@0 88
michael@0 89 bool
michael@0 90 TestManyChildAllocsChild::DeallocPTestManyChildAllocsSubChild(
michael@0 91 PTestManyChildAllocsSubChild* __a)
michael@0 92 {
michael@0 93 delete __a; return true;
michael@0 94 }
michael@0 95
michael@0 96 PTestManyChildAllocsSubChild*
michael@0 97 TestManyChildAllocsChild::AllocPTestManyChildAllocsSubChild()
michael@0 98 {
michael@0 99 return new TestManyChildAllocsSubChild();
michael@0 100 }
michael@0 101
michael@0 102
michael@0 103 } // namespace _ipdltest
michael@0 104 } // namespace mozilla

mercurial