1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/ipc/ipdl/test/cxx/TestManyChildAllocs.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,104 @@ 1.4 +#include "TestManyChildAllocs.h" 1.5 + 1.6 +#include "IPDLUnitTests.h" // fail etc. 1.7 + 1.8 + 1.9 +#define NALLOCS 10 1.10 + 1.11 +namespace mozilla { 1.12 +namespace _ipdltest { 1.13 + 1.14 +// parent code 1.15 + 1.16 +TestManyChildAllocsParent::TestManyChildAllocsParent() 1.17 +{ 1.18 + MOZ_COUNT_CTOR(TestManyChildAllocsParent); 1.19 +} 1.20 + 1.21 +TestManyChildAllocsParent::~TestManyChildAllocsParent() 1.22 +{ 1.23 + MOZ_COUNT_DTOR(TestManyChildAllocsParent); 1.24 +} 1.25 + 1.26 +void 1.27 +TestManyChildAllocsParent::Main() 1.28 +{ 1.29 + if (!SendGo()) 1.30 + fail("can't send Go()"); 1.31 +} 1.32 + 1.33 +bool 1.34 +TestManyChildAllocsParent::RecvDone() 1.35 +{ 1.36 + // explicitly *not* cleaning up, so we can sanity-check IPDL's 1.37 + // auto-shutdown/cleanup handling 1.38 + Close(); 1.39 + 1.40 + return true; 1.41 +} 1.42 + 1.43 +bool 1.44 +TestManyChildAllocsParent::DeallocPTestManyChildAllocsSubParent( 1.45 + PTestManyChildAllocsSubParent* __a) 1.46 +{ 1.47 + delete __a; return true; 1.48 +} 1.49 + 1.50 +PTestManyChildAllocsSubParent* 1.51 +TestManyChildAllocsParent::AllocPTestManyChildAllocsSubParent() 1.52 +{ 1.53 + return new TestManyChildAllocsSubParent(); 1.54 +} 1.55 + 1.56 + 1.57 +// child code 1.58 + 1.59 +TestManyChildAllocsChild::TestManyChildAllocsChild() 1.60 +{ 1.61 + MOZ_COUNT_CTOR(TestManyChildAllocsChild); 1.62 +} 1.63 + 1.64 +TestManyChildAllocsChild::~TestManyChildAllocsChild() 1.65 +{ 1.66 + MOZ_COUNT_DTOR(TestManyChildAllocsChild); 1.67 +} 1.68 + 1.69 +bool TestManyChildAllocsChild::RecvGo() 1.70 +{ 1.71 + for (int i = 0; i < NALLOCS; ++i) { 1.72 + PTestManyChildAllocsSubChild* child = 1.73 + SendPTestManyChildAllocsSubConstructor(); 1.74 + 1.75 + if (!child) 1.76 + fail("can't send ctor()"); 1.77 + 1.78 + if (!child->SendHello()) 1.79 + fail("can't send Hello()"); 1.80 + } 1.81 + 1.82 + size_t len = ManagedPTestManyChildAllocsSubChild().Length(); 1.83 + if (NALLOCS != len) 1.84 + fail("expected %lu kids, got %lu", NALLOCS, len); 1.85 + 1.86 + if (!SendDone()) 1.87 + fail("can't send Done()"); 1.88 + 1.89 + return true; 1.90 +} 1.91 + 1.92 +bool 1.93 +TestManyChildAllocsChild::DeallocPTestManyChildAllocsSubChild( 1.94 + PTestManyChildAllocsSubChild* __a) 1.95 +{ 1.96 + delete __a; return true; 1.97 +} 1.98 + 1.99 +PTestManyChildAllocsSubChild* 1.100 +TestManyChildAllocsChild::AllocPTestManyChildAllocsSubChild() 1.101 +{ 1.102 + return new TestManyChildAllocsSubChild(); 1.103 +} 1.104 + 1.105 + 1.106 +} // namespace _ipdltest 1.107 +} // namespace mozilla