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