1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/ipc/ipdl/test/cxx/TestShutdown.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,225 @@ 1.4 +#ifndef mozilla__ipdltest_TestShutdown_h 1.5 +#define mozilla__ipdltest_TestShutdown_h 1 1.6 + 1.7 +#include "mozilla/_ipdltest/IPDLUnitTests.h" 1.8 + 1.9 +#include "mozilla/_ipdltest/PTestShutdownParent.h" 1.10 +#include "mozilla/_ipdltest/PTestShutdownChild.h" 1.11 + 1.12 +#include "mozilla/_ipdltest/PTestShutdownSubParent.h" 1.13 +#include "mozilla/_ipdltest/PTestShutdownSubChild.h" 1.14 + 1.15 +#include "mozilla/_ipdltest/PTestShutdownSubsubParent.h" 1.16 +#include "mozilla/_ipdltest/PTestShutdownSubsubChild.h" 1.17 + 1.18 +namespace mozilla { 1.19 +namespace _ipdltest { 1.20 + 1.21 +//----------------------------------------------------------------------------- 1.22 +// Parent side 1.23 + 1.24 +class TestShutdownSubsubParent : 1.25 + public PTestShutdownSubsubParent 1.26 +{ 1.27 +public: 1.28 + TestShutdownSubsubParent(bool expectParentDeleted) : 1.29 + mExpectParentDeleted(expectParentDeleted) 1.30 + { 1.31 + } 1.32 + 1.33 + virtual ~TestShutdownSubsubParent() 1.34 + { 1.35 + } 1.36 + 1.37 +protected: 1.38 + virtual void 1.39 + ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; 1.40 + 1.41 +private: 1.42 + bool mExpectParentDeleted; 1.43 +}; 1.44 + 1.45 + 1.46 +class TestShutdownSubParent : 1.47 + public PTestShutdownSubParent 1.48 +{ 1.49 +public: 1.50 + TestShutdownSubParent(bool expectCrash) : 1.51 + mExpectCrash(expectCrash), 1.52 + mDeletedCount(0) 1.53 + { 1.54 + } 1.55 + 1.56 + virtual ~TestShutdownSubParent() 1.57 + { 1.58 + if (2 != mDeletedCount) 1.59 + fail("managees outliving manager!"); 1.60 + } 1.61 + 1.62 +protected: 1.63 + virtual bool 1.64 + AnswerStackFrame() MOZ_OVERRIDE 1.65 + { 1.66 + return CallStackFrame(); 1.67 + } 1.68 + 1.69 + virtual PTestShutdownSubsubParent* 1.70 + AllocPTestShutdownSubsubParent(const bool& expectParentDelete) MOZ_OVERRIDE 1.71 + { 1.72 + return new TestShutdownSubsubParent(expectParentDelete); 1.73 + } 1.74 + 1.75 + virtual bool 1.76 + DeallocPTestShutdownSubsubParent(PTestShutdownSubsubParent* actor) MOZ_OVERRIDE 1.77 + { 1.78 + delete actor; 1.79 + ++mDeletedCount; 1.80 + return true; 1.81 + } 1.82 + 1.83 + virtual void 1.84 + ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; 1.85 + 1.86 +private: 1.87 + bool mExpectCrash; 1.88 + int mDeletedCount; 1.89 +}; 1.90 + 1.91 + 1.92 +class TestShutdownParent : 1.93 + public PTestShutdownParent 1.94 +{ 1.95 +public: 1.96 + TestShutdownParent() 1.97 + { 1.98 + } 1.99 + virtual ~TestShutdownParent() 1.100 + { 1.101 + } 1.102 + 1.103 + static bool RunTestInProcesses() { return true; } 1.104 + // FIXME/bug 703323 Could work if modified 1.105 + static bool RunTestInThreads() { return false; } 1.106 + 1.107 + void Main(); 1.108 + 1.109 +protected: 1.110 + virtual bool RecvSync() MOZ_OVERRIDE { return true; } 1.111 + 1.112 + virtual PTestShutdownSubParent* 1.113 + AllocPTestShutdownSubParent(const bool& expectCrash) MOZ_OVERRIDE 1.114 + { 1.115 + return new TestShutdownSubParent(expectCrash); 1.116 + } 1.117 + 1.118 + virtual bool 1.119 + DeallocPTestShutdownSubParent(PTestShutdownSubParent* actor) MOZ_OVERRIDE 1.120 + { 1.121 + delete actor; 1.122 + return true; 1.123 + } 1.124 + 1.125 + virtual void 1.126 + ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; 1.127 +}; 1.128 + 1.129 + 1.130 +//----------------------------------------------------------------------------- 1.131 +// Child side 1.132 + 1.133 +class TestShutdownSubsubChild : 1.134 + public PTestShutdownSubsubChild 1.135 +{ 1.136 +public: 1.137 + TestShutdownSubsubChild(bool expectParentDeleted) : 1.138 + mExpectParentDeleted(expectParentDeleted) 1.139 + { 1.140 + } 1.141 + virtual ~TestShutdownSubsubChild() 1.142 + { 1.143 + } 1.144 + 1.145 +protected: 1.146 + virtual void 1.147 + ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; 1.148 + 1.149 +private: 1.150 + bool mExpectParentDeleted; 1.151 +}; 1.152 + 1.153 + 1.154 +class TestShutdownSubChild : 1.155 + public PTestShutdownSubChild 1.156 +{ 1.157 +public: 1.158 + TestShutdownSubChild(bool expectCrash) : mExpectCrash(expectCrash) 1.159 + { 1.160 + } 1.161 + 1.162 + virtual ~TestShutdownSubChild() 1.163 + { 1.164 + } 1.165 + 1.166 +protected: 1.167 + virtual bool AnswerStackFrame() MOZ_OVERRIDE; 1.168 + 1.169 + virtual PTestShutdownSubsubChild* 1.170 + AllocPTestShutdownSubsubChild(const bool& expectParentDelete) MOZ_OVERRIDE 1.171 + { 1.172 + return new TestShutdownSubsubChild(expectParentDelete); 1.173 + } 1.174 + 1.175 + virtual bool 1.176 + DeallocPTestShutdownSubsubChild(PTestShutdownSubsubChild* actor) MOZ_OVERRIDE 1.177 + { 1.178 + delete actor; 1.179 + return true; 1.180 + } 1.181 + 1.182 + virtual void 1.183 + ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; 1.184 + 1.185 +private: 1.186 + bool mExpectCrash; 1.187 +}; 1.188 + 1.189 + 1.190 +class TestShutdownChild : 1.191 + public PTestShutdownChild 1.192 +{ 1.193 +public: 1.194 + TestShutdownChild() 1.195 + { 1.196 + } 1.197 + virtual ~TestShutdownChild() 1.198 + { 1.199 + } 1.200 + 1.201 +protected: 1.202 + virtual bool 1.203 + RecvStart(); 1.204 + 1.205 + virtual PTestShutdownSubChild* 1.206 + AllocPTestShutdownSubChild( 1.207 + const bool& expectCrash) MOZ_OVERRIDE 1.208 + { 1.209 + return new TestShutdownSubChild(expectCrash); 1.210 + } 1.211 + 1.212 + virtual bool 1.213 + DeallocPTestShutdownSubChild(PTestShutdownSubChild* actor) MOZ_OVERRIDE 1.214 + { 1.215 + delete actor; 1.216 + return true; 1.217 + } 1.218 + 1.219 + virtual void 1.220 + ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; 1.221 +}; 1.222 + 1.223 + 1.224 +} // namespace _ipdltest 1.225 +} // namespace mozilla 1.226 + 1.227 + 1.228 +#endif // ifndef mozilla__ipdltest_TestShutdown_h