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