ipc/ipdl/test/cxx/TestJSON.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_TestJSON_h
     2 #define mozilla__ipdltest_TestJSON_h 1
     4 #include "mozilla/_ipdltest/IPDLUnitTests.h"
     6 #include "mozilla/_ipdltest/PTestJSONParent.h"
     7 #include "mozilla/_ipdltest/PTestJSONChild.h"
     9 #include "mozilla/_ipdltest/PTestHandleParent.h"
    10 #include "mozilla/_ipdltest/PTestHandleChild.h"
    12 namespace mozilla {
    13 namespace _ipdltest {
    15 class TestHandleParent :
    16     public PTestHandleParent
    17 {
    18 public:
    19     TestHandleParent() { }
    20     virtual ~TestHandleParent() { }
    21 };
    23 class TestJSONParent :
    24     public PTestJSONParent
    25 {
    26 public:
    27     TestJSONParent() { }
    28     virtual ~TestJSONParent() { }
    30     static bool RunTestInProcesses() { return true; }
    31     static bool RunTestInThreads() { return true; }
    33     void Main();
    35 protected:
    36     virtual bool
    37     RecvTest(const JSONVariant& i,
    38              JSONVariant* o) MOZ_OVERRIDE;
    40     virtual PTestHandleParent* AllocPTestHandleParent() MOZ_OVERRIDE
    41     {
    42         return mKid = new TestHandleParent();
    43     }
    45     virtual bool DeallocPTestHandleParent(PTestHandleParent* actor) MOZ_OVERRIDE
    46     {
    47         delete actor;
    48         return true;
    49     }
    51     virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE
    52     {
    53         if (NormalShutdown != why)
    54             fail("unexpected destruction!");  
    55         passed("ok");
    56         QuitParent();
    57     }
    59     PTestHandleParent* mKid;
    60 };
    63 class TestHandleChild :
    64     public PTestHandleChild
    65 {
    66 public:
    67     TestHandleChild() { }
    68     virtual ~TestHandleChild() { }
    69 };
    71 class TestJSONChild :
    72     public PTestJSONChild
    73 {
    74 public:
    75     TestJSONChild() { }
    76     virtual ~TestJSONChild() { }
    78 protected:
    79     virtual bool
    80     RecvStart() MOZ_OVERRIDE;
    82     virtual PTestHandleChild* AllocPTestHandleChild() MOZ_OVERRIDE
    83     {
    84         return mKid = new TestHandleChild();
    85     }
    87     virtual bool DeallocPTestHandleChild(PTestHandleChild* actor) MOZ_OVERRIDE
    88     {
    89         delete actor;
    90         return true;
    91     }
    93     virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE
    94     {
    95         if (NormalShutdown != why)
    96             fail("unexpected destruction!");
    97         QuitChild();
    98     }
   100     PTestHandleChild* mKid;
   101 };
   104 } // namespace _ipdltest
   105 } // namespace mozilla
   108 #endif // ifndef mozilla__ipdltest_TestJSON_h

mercurial