|
1 #include "TestFailedCtor.h" |
|
2 |
|
3 #include "IPDLUnitTests.h" // fail etc. |
|
4 |
|
5 namespace mozilla { |
|
6 namespace _ipdltest { |
|
7 |
|
8 //----------------------------------------------------------------------------- |
|
9 // parent |
|
10 void |
|
11 TestFailedCtorParent::Main() |
|
12 { |
|
13 PTestFailedCtorSubParent* p = CallPTestFailedCtorSubConstructor(); |
|
14 if (p) |
|
15 fail("expected ctor to fail"); |
|
16 |
|
17 Close(); |
|
18 } |
|
19 |
|
20 PTestFailedCtorSubParent* |
|
21 TestFailedCtorParent::AllocPTestFailedCtorSubParent() |
|
22 { |
|
23 return new TestFailedCtorSubParent(); |
|
24 } |
|
25 bool |
|
26 TestFailedCtorParent::DeallocPTestFailedCtorSubParent(PTestFailedCtorSubParent* actor) |
|
27 { |
|
28 delete actor; |
|
29 return true; |
|
30 } |
|
31 |
|
32 PTestFailedCtorSubsubParent* |
|
33 TestFailedCtorSubParent::AllocPTestFailedCtorSubsubParent() |
|
34 { |
|
35 TestFailedCtorSubsub* a = new TestFailedCtorSubsub(); |
|
36 if (!mOne) { |
|
37 return mOne = a; |
|
38 } else if (!mTwo) { |
|
39 return mTwo = a; |
|
40 } else if (!mThree) { |
|
41 return mThree = a; |
|
42 } else { |
|
43 fail("unexpected Alloc()"); |
|
44 return nullptr; |
|
45 } |
|
46 } |
|
47 bool |
|
48 TestFailedCtorSubParent::DeallocPTestFailedCtorSubsubParent(PTestFailedCtorSubsubParent* actor) |
|
49 { |
|
50 static_cast<TestFailedCtorSubsub*>(actor)->mDealloced = true; |
|
51 return true; |
|
52 } |
|
53 |
|
54 void |
|
55 TestFailedCtorSubParent::ActorDestroy(ActorDestroyReason why) |
|
56 { |
|
57 |
|
58 if (mOne->mWhy != Deletion) |
|
59 fail("Subsub one got wrong ActorDestroyReason"); |
|
60 if (mTwo->mWhy != AncestorDeletion) |
|
61 fail("Subsub two got wrong ActorDestroyReason"); |
|
62 if (mThree->mWhy != AncestorDeletion) |
|
63 fail("Subsub three got wrong ActorDestroyReason"); |
|
64 |
|
65 if (FailedConstructor != why) |
|
66 fail("unexpected destruction!"); |
|
67 } |
|
68 |
|
69 TestFailedCtorSubParent::~TestFailedCtorSubParent() |
|
70 { |
|
71 if (!(mOne->mDealloced && mTwo->mDealloced && mThree->mDealloced)) |
|
72 fail("Not all subsubs were Dealloc'd"); |
|
73 delete mOne; |
|
74 delete mTwo; |
|
75 delete mThree; |
|
76 } |
|
77 |
|
78 |
|
79 //----------------------------------------------------------------------------- |
|
80 // child |
|
81 |
|
82 PTestFailedCtorSubChild* |
|
83 TestFailedCtorChild::AllocPTestFailedCtorSubChild() |
|
84 { |
|
85 return new TestFailedCtorSubChild(); |
|
86 } |
|
87 |
|
88 bool |
|
89 TestFailedCtorChild::AnswerPTestFailedCtorSubConstructor(PTestFailedCtorSubChild* actor) |
|
90 { |
|
91 PTestFailedCtorSubsubChild* c1 = actor->SendPTestFailedCtorSubsubConstructor(); |
|
92 PTestFailedCtorSubsubChild::Send__delete__(c1); |
|
93 |
|
94 if (!actor->SendPTestFailedCtorSubsubConstructor() || |
|
95 !actor->SendPTestFailedCtorSubsubConstructor() || |
|
96 !actor->SendSync()) |
|
97 fail("setting up test"); |
|
98 |
|
99 // This causes our process to die |
|
100 return false; |
|
101 } |
|
102 |
|
103 bool |
|
104 TestFailedCtorChild::DeallocPTestFailedCtorSubChild(PTestFailedCtorSubChild* actor) |
|
105 { |
|
106 delete actor; |
|
107 return true; |
|
108 } |
|
109 |
|
110 void |
|
111 TestFailedCtorChild::ProcessingError(Result what) |
|
112 { |
|
113 if (OtherProcess() != 0) // thread-mode |
|
114 _exit(0); |
|
115 } |
|
116 |
|
117 PTestFailedCtorSubsubChild* |
|
118 TestFailedCtorSubChild::AllocPTestFailedCtorSubsubChild() |
|
119 { |
|
120 return new TestFailedCtorSubsub(); |
|
121 } |
|
122 |
|
123 bool |
|
124 TestFailedCtorSubChild::DeallocPTestFailedCtorSubsubChild(PTestFailedCtorSubsubChild* actor) |
|
125 { |
|
126 delete actor; |
|
127 return true; |
|
128 } |
|
129 |
|
130 void |
|
131 TestFailedCtorSubChild::ActorDestroy(ActorDestroyReason why) |
|
132 { |
|
133 } |
|
134 |
|
135 |
|
136 } // namespace _ipdltest |
|
137 } // namespace mozilla |