Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | #ifndef mozilla__ipdltest_TestStackHooks_h |
michael@0 | 2 | #define mozilla__ipdltest_TestStackHooks_h 1 |
michael@0 | 3 | |
michael@0 | 4 | #include "mozilla/_ipdltest/IPDLUnitTests.h" |
michael@0 | 5 | |
michael@0 | 6 | #include "mozilla/_ipdltest/PTestStackHooksParent.h" |
michael@0 | 7 | #include "mozilla/_ipdltest/PTestStackHooksChild.h" |
michael@0 | 8 | |
michael@0 | 9 | namespace mozilla { |
michael@0 | 10 | namespace _ipdltest { |
michael@0 | 11 | |
michael@0 | 12 | |
michael@0 | 13 | class TestStackHooksParent : |
michael@0 | 14 | public PTestStackHooksParent |
michael@0 | 15 | { |
michael@0 | 16 | public: |
michael@0 | 17 | TestStackHooksParent(); |
michael@0 | 18 | virtual ~TestStackHooksParent(); |
michael@0 | 19 | |
michael@0 | 20 | static bool RunTestInProcesses() { return true; } |
michael@0 | 21 | static bool RunTestInThreads() { return true; } |
michael@0 | 22 | |
michael@0 | 23 | void Main(); |
michael@0 | 24 | |
michael@0 | 25 | protected: |
michael@0 | 26 | virtual bool RecvAsync() MOZ_OVERRIDE { |
michael@0 | 27 | if (!mOnStack) |
michael@0 | 28 | fail("not on C++ stack?!"); |
michael@0 | 29 | return true; |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | virtual bool RecvSync() MOZ_OVERRIDE { |
michael@0 | 33 | if (!mOnStack) |
michael@0 | 34 | fail("not on C++ stack?!"); |
michael@0 | 35 | return true; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | virtual bool AnswerRpc() MOZ_OVERRIDE { |
michael@0 | 39 | if (!mOnStack) |
michael@0 | 40 | fail("not on C++ stack?!"); |
michael@0 | 41 | return true; |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | virtual bool AnswerStackFrame() MOZ_OVERRIDE; |
michael@0 | 45 | |
michael@0 | 46 | virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE |
michael@0 | 47 | { |
michael@0 | 48 | if (NormalShutdown != why) |
michael@0 | 49 | fail("unexpected destruction!"); |
michael@0 | 50 | passed("ok"); |
michael@0 | 51 | QuitParent(); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | virtual void EnteredCxxStack() MOZ_OVERRIDE { |
michael@0 | 55 | mOnStack = true; |
michael@0 | 56 | } |
michael@0 | 57 | virtual void ExitedCxxStack() MOZ_OVERRIDE { |
michael@0 | 58 | mOnStack = false; |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | virtual void EnteredCall() MOZ_OVERRIDE { |
michael@0 | 62 | ++mIncallDepth; |
michael@0 | 63 | } |
michael@0 | 64 | virtual void ExitedCall() MOZ_OVERRIDE { |
michael@0 | 65 | --mIncallDepth; |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | private: |
michael@0 | 69 | bool mOnStack; |
michael@0 | 70 | int mIncallDepth; |
michael@0 | 71 | }; |
michael@0 | 72 | |
michael@0 | 73 | |
michael@0 | 74 | class TestStackHooksChild : |
michael@0 | 75 | public PTestStackHooksChild |
michael@0 | 76 | { |
michael@0 | 77 | public: |
michael@0 | 78 | TestStackHooksChild(); |
michael@0 | 79 | virtual ~TestStackHooksChild(); |
michael@0 | 80 | |
michael@0 | 81 | void RunTests(); |
michael@0 | 82 | |
michael@0 | 83 | protected: |
michael@0 | 84 | virtual bool RecvStart() MOZ_OVERRIDE; |
michael@0 | 85 | |
michael@0 | 86 | virtual bool AnswerStackFrame() MOZ_OVERRIDE; |
michael@0 | 87 | |
michael@0 | 88 | virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE |
michael@0 | 89 | { |
michael@0 | 90 | if (NormalShutdown != why) |
michael@0 | 91 | fail("unexpected destruction!"); |
michael@0 | 92 | |
michael@0 | 93 | if (mEntered != mExited) |
michael@0 | 94 | fail("unbalanced enter/exit notifications"); |
michael@0 | 95 | |
michael@0 | 96 | if (mOnStack) |
michael@0 | 97 | fail("computing mOnStack went awry; should have failed above assertion"); |
michael@0 | 98 | |
michael@0 | 99 | QuitChild(); |
michael@0 | 100 | } |
michael@0 | 101 | |
michael@0 | 102 | virtual void EnteredCxxStack() MOZ_OVERRIDE { |
michael@0 | 103 | ++mEntered; |
michael@0 | 104 | mOnStack = true; |
michael@0 | 105 | } |
michael@0 | 106 | virtual void ExitedCxxStack() MOZ_OVERRIDE { |
michael@0 | 107 | ++mExited; |
michael@0 | 108 | mOnStack = false; |
michael@0 | 109 | } |
michael@0 | 110 | |
michael@0 | 111 | virtual void EnteredCall() MOZ_OVERRIDE { |
michael@0 | 112 | ++mIncallDepth; |
michael@0 | 113 | } |
michael@0 | 114 | virtual void ExitedCall() MOZ_OVERRIDE { |
michael@0 | 115 | --mIncallDepth; |
michael@0 | 116 | } |
michael@0 | 117 | |
michael@0 | 118 | private: |
michael@0 | 119 | bool mOnStack; |
michael@0 | 120 | int mEntered; |
michael@0 | 121 | int mExited; |
michael@0 | 122 | int mIncallDepth; |
michael@0 | 123 | }; |
michael@0 | 124 | |
michael@0 | 125 | |
michael@0 | 126 | } // namespace _ipdltest |
michael@0 | 127 | } // namespace mozilla |
michael@0 | 128 | |
michael@0 | 129 | |
michael@0 | 130 | #endif // ifndef mozilla__ipdltest_TestStackHooks_h |