ipc/ipdl/test/cxx/TestStackHooks.h

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 #ifndef mozilla__ipdltest_TestStackHooks_h
     2 #define mozilla__ipdltest_TestStackHooks_h 1
     4 #include "mozilla/_ipdltest/IPDLUnitTests.h"
     6 #include "mozilla/_ipdltest/PTestStackHooksParent.h"
     7 #include "mozilla/_ipdltest/PTestStackHooksChild.h"
     9 namespace mozilla {
    10 namespace _ipdltest {
    13 class TestStackHooksParent :
    14     public PTestStackHooksParent
    15 {
    16 public:
    17     TestStackHooksParent();
    18     virtual ~TestStackHooksParent();
    20     static bool RunTestInProcesses() { return true; }
    21     static bool RunTestInThreads() { return true; }
    23     void Main();
    25 protected:    
    26     virtual bool RecvAsync() MOZ_OVERRIDE {
    27         if (!mOnStack)
    28             fail("not on C++ stack?!");
    29         return true;
    30     }
    32     virtual bool RecvSync() MOZ_OVERRIDE {
    33         if (!mOnStack)
    34             fail("not on C++ stack?!");
    35         return true;
    36     }
    38     virtual bool AnswerRpc() MOZ_OVERRIDE {
    39         if (!mOnStack)
    40             fail("not on C++ stack?!");
    41         return true;
    42     }
    44     virtual bool AnswerStackFrame() MOZ_OVERRIDE;
    46     virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE
    47     {
    48         if (NormalShutdown != why)
    49             fail("unexpected destruction!");  
    50         passed("ok");
    51         QuitParent();
    52     }
    54     virtual void EnteredCxxStack() MOZ_OVERRIDE {
    55         mOnStack = true;
    56     }
    57     virtual void ExitedCxxStack() MOZ_OVERRIDE {
    58         mOnStack = false;
    59     }
    61     virtual void EnteredCall() MOZ_OVERRIDE {
    62         ++mIncallDepth;
    63     }
    64     virtual void ExitedCall() MOZ_OVERRIDE {
    65         --mIncallDepth;
    66     }
    68 private:
    69     bool mOnStack;
    70     int mIncallDepth;
    71 };
    74 class TestStackHooksChild :
    75     public PTestStackHooksChild
    76 {
    77 public:
    78     TestStackHooksChild();
    79     virtual ~TestStackHooksChild();
    81     void RunTests();
    83 protected:
    84     virtual bool RecvStart() MOZ_OVERRIDE;
    86     virtual bool AnswerStackFrame() MOZ_OVERRIDE;
    88     virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE
    89     {
    90         if (NormalShutdown != why)
    91             fail("unexpected destruction!");
    93         if (mEntered != mExited)
    94             fail("unbalanced enter/exit notifications");
    96         if (mOnStack)
    97             fail("computing mOnStack went awry; should have failed above assertion");
    99         QuitChild();
   100     }
   102     virtual void EnteredCxxStack() MOZ_OVERRIDE {
   103         ++mEntered;
   104         mOnStack = true;
   105     }
   106     virtual void ExitedCxxStack() MOZ_OVERRIDE {
   107         ++mExited;
   108         mOnStack = false;
   109     }
   111     virtual void EnteredCall() MOZ_OVERRIDE {
   112         ++mIncallDepth;
   113     }
   114     virtual void ExitedCall() MOZ_OVERRIDE {
   115         --mIncallDepth;
   116     }
   118 private:
   119     bool mOnStack;
   120     int mEntered;
   121     int mExited;
   122     int mIncallDepth;
   123 };
   126 } // namespace _ipdltest
   127 } // namespace mozilla
   130 #endif // ifndef mozilla__ipdltest_TestStackHooks_h

mercurial