ipc/ipdl/test/cxx/TestJSON.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/ipdl/test/cxx/TestJSON.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,108 @@
     1.4 +#ifndef mozilla__ipdltest_TestJSON_h
     1.5 +#define mozilla__ipdltest_TestJSON_h 1
     1.6 +
     1.7 +#include "mozilla/_ipdltest/IPDLUnitTests.h"
     1.8 +
     1.9 +#include "mozilla/_ipdltest/PTestJSONParent.h"
    1.10 +#include "mozilla/_ipdltest/PTestJSONChild.h"
    1.11 +
    1.12 +#include "mozilla/_ipdltest/PTestHandleParent.h"
    1.13 +#include "mozilla/_ipdltest/PTestHandleChild.h"
    1.14 +
    1.15 +namespace mozilla {
    1.16 +namespace _ipdltest {
    1.17 +
    1.18 +class TestHandleParent :
    1.19 +    public PTestHandleParent
    1.20 +{
    1.21 +public:
    1.22 +    TestHandleParent() { }
    1.23 +    virtual ~TestHandleParent() { }
    1.24 +};
    1.25 +
    1.26 +class TestJSONParent :
    1.27 +    public PTestJSONParent
    1.28 +{
    1.29 +public:
    1.30 +    TestJSONParent() { }
    1.31 +    virtual ~TestJSONParent() { }
    1.32 +
    1.33 +    static bool RunTestInProcesses() { return true; }
    1.34 +    static bool RunTestInThreads() { return true; }
    1.35 +
    1.36 +    void Main();
    1.37 +
    1.38 +protected:
    1.39 +    virtual bool
    1.40 +    RecvTest(const JSONVariant& i,
    1.41 +             JSONVariant* o) MOZ_OVERRIDE;
    1.42 +
    1.43 +    virtual PTestHandleParent* AllocPTestHandleParent() MOZ_OVERRIDE
    1.44 +    {
    1.45 +        return mKid = new TestHandleParent();
    1.46 +    }
    1.47 +
    1.48 +    virtual bool DeallocPTestHandleParent(PTestHandleParent* actor) MOZ_OVERRIDE
    1.49 +    {
    1.50 +        delete actor;
    1.51 +        return true;
    1.52 +    }
    1.53 +
    1.54 +    virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE
    1.55 +    {
    1.56 +        if (NormalShutdown != why)
    1.57 +            fail("unexpected destruction!");  
    1.58 +        passed("ok");
    1.59 +        QuitParent();
    1.60 +    }
    1.61 +
    1.62 +    PTestHandleParent* mKid;
    1.63 +};
    1.64 +
    1.65 +
    1.66 +class TestHandleChild :
    1.67 +    public PTestHandleChild
    1.68 +{
    1.69 +public:
    1.70 +    TestHandleChild() { }
    1.71 +    virtual ~TestHandleChild() { }
    1.72 +};
    1.73 +
    1.74 +class TestJSONChild :
    1.75 +    public PTestJSONChild
    1.76 +{
    1.77 +public:
    1.78 +    TestJSONChild() { }
    1.79 +    virtual ~TestJSONChild() { }
    1.80 +
    1.81 +protected:
    1.82 +    virtual bool
    1.83 +    RecvStart() MOZ_OVERRIDE;
    1.84 +
    1.85 +    virtual PTestHandleChild* AllocPTestHandleChild() MOZ_OVERRIDE
    1.86 +    {
    1.87 +        return mKid = new TestHandleChild();
    1.88 +    }
    1.89 +
    1.90 +    virtual bool DeallocPTestHandleChild(PTestHandleChild* actor) MOZ_OVERRIDE
    1.91 +    {
    1.92 +        delete actor;
    1.93 +        return true;
    1.94 +    }
    1.95 +
    1.96 +    virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE
    1.97 +    {
    1.98 +        if (NormalShutdown != why)
    1.99 +            fail("unexpected destruction!");
   1.100 +        QuitChild();
   1.101 +    }
   1.102 +
   1.103 +    PTestHandleChild* mKid;
   1.104 +};
   1.105 +
   1.106 +
   1.107 +} // namespace _ipdltest
   1.108 +} // namespace mozilla
   1.109 +
   1.110 +
   1.111 +#endif // ifndef mozilla__ipdltest_TestJSON_h

mercurial