|
1 #ifndef mozilla__ipdltest_TestShutdown_h |
|
2 #define mozilla__ipdltest_TestShutdown_h 1 |
|
3 |
|
4 #include "mozilla/_ipdltest/IPDLUnitTests.h" |
|
5 |
|
6 #include "mozilla/_ipdltest/PTestShutdownParent.h" |
|
7 #include "mozilla/_ipdltest/PTestShutdownChild.h" |
|
8 |
|
9 #include "mozilla/_ipdltest/PTestShutdownSubParent.h" |
|
10 #include "mozilla/_ipdltest/PTestShutdownSubChild.h" |
|
11 |
|
12 #include "mozilla/_ipdltest/PTestShutdownSubsubParent.h" |
|
13 #include "mozilla/_ipdltest/PTestShutdownSubsubChild.h" |
|
14 |
|
15 namespace mozilla { |
|
16 namespace _ipdltest { |
|
17 |
|
18 //----------------------------------------------------------------------------- |
|
19 // Parent side |
|
20 |
|
21 class TestShutdownSubsubParent : |
|
22 public PTestShutdownSubsubParent |
|
23 { |
|
24 public: |
|
25 TestShutdownSubsubParent(bool expectParentDeleted) : |
|
26 mExpectParentDeleted(expectParentDeleted) |
|
27 { |
|
28 } |
|
29 |
|
30 virtual ~TestShutdownSubsubParent() |
|
31 { |
|
32 } |
|
33 |
|
34 protected: |
|
35 virtual void |
|
36 ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; |
|
37 |
|
38 private: |
|
39 bool mExpectParentDeleted; |
|
40 }; |
|
41 |
|
42 |
|
43 class TestShutdownSubParent : |
|
44 public PTestShutdownSubParent |
|
45 { |
|
46 public: |
|
47 TestShutdownSubParent(bool expectCrash) : |
|
48 mExpectCrash(expectCrash), |
|
49 mDeletedCount(0) |
|
50 { |
|
51 } |
|
52 |
|
53 virtual ~TestShutdownSubParent() |
|
54 { |
|
55 if (2 != mDeletedCount) |
|
56 fail("managees outliving manager!"); |
|
57 } |
|
58 |
|
59 protected: |
|
60 virtual bool |
|
61 AnswerStackFrame() MOZ_OVERRIDE |
|
62 { |
|
63 return CallStackFrame(); |
|
64 } |
|
65 |
|
66 virtual PTestShutdownSubsubParent* |
|
67 AllocPTestShutdownSubsubParent(const bool& expectParentDelete) MOZ_OVERRIDE |
|
68 { |
|
69 return new TestShutdownSubsubParent(expectParentDelete); |
|
70 } |
|
71 |
|
72 virtual bool |
|
73 DeallocPTestShutdownSubsubParent(PTestShutdownSubsubParent* actor) MOZ_OVERRIDE |
|
74 { |
|
75 delete actor; |
|
76 ++mDeletedCount; |
|
77 return true; |
|
78 } |
|
79 |
|
80 virtual void |
|
81 ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; |
|
82 |
|
83 private: |
|
84 bool mExpectCrash; |
|
85 int mDeletedCount; |
|
86 }; |
|
87 |
|
88 |
|
89 class TestShutdownParent : |
|
90 public PTestShutdownParent |
|
91 { |
|
92 public: |
|
93 TestShutdownParent() |
|
94 { |
|
95 } |
|
96 virtual ~TestShutdownParent() |
|
97 { |
|
98 } |
|
99 |
|
100 static bool RunTestInProcesses() { return true; } |
|
101 // FIXME/bug 703323 Could work if modified |
|
102 static bool RunTestInThreads() { return false; } |
|
103 |
|
104 void Main(); |
|
105 |
|
106 protected: |
|
107 virtual bool RecvSync() MOZ_OVERRIDE { return true; } |
|
108 |
|
109 virtual PTestShutdownSubParent* |
|
110 AllocPTestShutdownSubParent(const bool& expectCrash) MOZ_OVERRIDE |
|
111 { |
|
112 return new TestShutdownSubParent(expectCrash); |
|
113 } |
|
114 |
|
115 virtual bool |
|
116 DeallocPTestShutdownSubParent(PTestShutdownSubParent* actor) MOZ_OVERRIDE |
|
117 { |
|
118 delete actor; |
|
119 return true; |
|
120 } |
|
121 |
|
122 virtual void |
|
123 ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; |
|
124 }; |
|
125 |
|
126 |
|
127 //----------------------------------------------------------------------------- |
|
128 // Child side |
|
129 |
|
130 class TestShutdownSubsubChild : |
|
131 public PTestShutdownSubsubChild |
|
132 { |
|
133 public: |
|
134 TestShutdownSubsubChild(bool expectParentDeleted) : |
|
135 mExpectParentDeleted(expectParentDeleted) |
|
136 { |
|
137 } |
|
138 virtual ~TestShutdownSubsubChild() |
|
139 { |
|
140 } |
|
141 |
|
142 protected: |
|
143 virtual void |
|
144 ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; |
|
145 |
|
146 private: |
|
147 bool mExpectParentDeleted; |
|
148 }; |
|
149 |
|
150 |
|
151 class TestShutdownSubChild : |
|
152 public PTestShutdownSubChild |
|
153 { |
|
154 public: |
|
155 TestShutdownSubChild(bool expectCrash) : mExpectCrash(expectCrash) |
|
156 { |
|
157 } |
|
158 |
|
159 virtual ~TestShutdownSubChild() |
|
160 { |
|
161 } |
|
162 |
|
163 protected: |
|
164 virtual bool AnswerStackFrame() MOZ_OVERRIDE; |
|
165 |
|
166 virtual PTestShutdownSubsubChild* |
|
167 AllocPTestShutdownSubsubChild(const bool& expectParentDelete) MOZ_OVERRIDE |
|
168 { |
|
169 return new TestShutdownSubsubChild(expectParentDelete); |
|
170 } |
|
171 |
|
172 virtual bool |
|
173 DeallocPTestShutdownSubsubChild(PTestShutdownSubsubChild* actor) MOZ_OVERRIDE |
|
174 { |
|
175 delete actor; |
|
176 return true; |
|
177 } |
|
178 |
|
179 virtual void |
|
180 ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; |
|
181 |
|
182 private: |
|
183 bool mExpectCrash; |
|
184 }; |
|
185 |
|
186 |
|
187 class TestShutdownChild : |
|
188 public PTestShutdownChild |
|
189 { |
|
190 public: |
|
191 TestShutdownChild() |
|
192 { |
|
193 } |
|
194 virtual ~TestShutdownChild() |
|
195 { |
|
196 } |
|
197 |
|
198 protected: |
|
199 virtual bool |
|
200 RecvStart(); |
|
201 |
|
202 virtual PTestShutdownSubChild* |
|
203 AllocPTestShutdownSubChild( |
|
204 const bool& expectCrash) MOZ_OVERRIDE |
|
205 { |
|
206 return new TestShutdownSubChild(expectCrash); |
|
207 } |
|
208 |
|
209 virtual bool |
|
210 DeallocPTestShutdownSubChild(PTestShutdownSubChild* actor) MOZ_OVERRIDE |
|
211 { |
|
212 delete actor; |
|
213 return true; |
|
214 } |
|
215 |
|
216 virtual void |
|
217 ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; |
|
218 }; |
|
219 |
|
220 |
|
221 } // namespace _ipdltest |
|
222 } // namespace mozilla |
|
223 |
|
224 |
|
225 #endif // ifndef mozilla__ipdltest_TestShutdown_h |