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.

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

mercurial