ipc/ipdl/test/cxx/TestSelfManageRoot.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 #ifndef mozilla__ipdltest_TestSelfManageRoot_h
michael@0 2 #define mozilla__ipdltest_TestSelfManageRoot_h 1
michael@0 3
michael@0 4 #include "mozilla/_ipdltest/IPDLUnitTests.h"
michael@0 5
michael@0 6 #include "mozilla/_ipdltest/PTestSelfManageRootParent.h"
michael@0 7 #include "mozilla/_ipdltest/PTestSelfManageRootChild.h"
michael@0 8 #include "mozilla/_ipdltest/PTestSelfManageParent.h"
michael@0 9 #include "mozilla/_ipdltest/PTestSelfManageChild.h"
michael@0 10
michael@0 11
michael@0 12 namespace mozilla {
michael@0 13 namespace _ipdltest {
michael@0 14
michael@0 15 //-----------------------------------------------------------------------------
michael@0 16 // Parent side
michael@0 17
michael@0 18 class TestSelfManageParent :
michael@0 19 public PTestSelfManageParent
michael@0 20 {
michael@0 21 public:
michael@0 22 TestSelfManageParent() {
michael@0 23 MOZ_COUNT_CTOR(TestSelfManageParent);
michael@0 24 }
michael@0 25 virtual ~TestSelfManageParent() {
michael@0 26 MOZ_COUNT_DTOR(TestSelfManageParent);
michael@0 27 }
michael@0 28
michael@0 29 ActorDestroyReason mWhy;
michael@0 30
michael@0 31 protected:
michael@0 32 virtual PTestSelfManageParent* AllocPTestSelfManageParent() MOZ_OVERRIDE {
michael@0 33 return new TestSelfManageParent();
michael@0 34 }
michael@0 35
michael@0 36 virtual bool DeallocPTestSelfManageParent(PTestSelfManageParent* a) MOZ_OVERRIDE {
michael@0 37 return true;
michael@0 38 }
michael@0 39
michael@0 40 virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE {
michael@0 41 mWhy = why;
michael@0 42 }
michael@0 43 };
michael@0 44
michael@0 45 class TestSelfManageRootParent :
michael@0 46 public PTestSelfManageRootParent
michael@0 47 {
michael@0 48 public:
michael@0 49 TestSelfManageRootParent() {
michael@0 50 MOZ_COUNT_CTOR(TestSelfManageRootParent);
michael@0 51 }
michael@0 52 virtual ~TestSelfManageRootParent() {
michael@0 53 MOZ_COUNT_DTOR(TestSelfManageRootParent);
michael@0 54 }
michael@0 55
michael@0 56 static bool RunTestInProcesses() { return true; }
michael@0 57 static bool RunTestInThreads() { return true; }
michael@0 58
michael@0 59 void Main();
michael@0 60
michael@0 61 protected:
michael@0 62 virtual PTestSelfManageParent* AllocPTestSelfManageParent() MOZ_OVERRIDE {
michael@0 63 return new TestSelfManageParent();
michael@0 64 }
michael@0 65
michael@0 66 virtual bool DeallocPTestSelfManageParent(PTestSelfManageParent* a) MOZ_OVERRIDE {
michael@0 67 return true;
michael@0 68 }
michael@0 69
michael@0 70 virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE
michael@0 71 {
michael@0 72 if (NormalShutdown != why)
michael@0 73 fail("unexpected destruction!");
michael@0 74 passed("ok");
michael@0 75 QuitParent();
michael@0 76 }
michael@0 77 };
michael@0 78
michael@0 79 //-----------------------------------------------------------------------------
michael@0 80 // Child side
michael@0 81
michael@0 82 class TestSelfManageChild :
michael@0 83 public PTestSelfManageChild
michael@0 84 {
michael@0 85 public:
michael@0 86 TestSelfManageChild() {
michael@0 87 MOZ_COUNT_CTOR(TestSelfManageChild);
michael@0 88 }
michael@0 89 virtual ~TestSelfManageChild() {
michael@0 90 MOZ_COUNT_DTOR(TestSelfManageChild);
michael@0 91 }
michael@0 92
michael@0 93 protected:
michael@0 94 virtual PTestSelfManageChild* AllocPTestSelfManageChild() MOZ_OVERRIDE {
michael@0 95 return new TestSelfManageChild();
michael@0 96 }
michael@0 97
michael@0 98 virtual bool DeallocPTestSelfManageChild(PTestSelfManageChild* a) MOZ_OVERRIDE {
michael@0 99 delete a;
michael@0 100 return true;
michael@0 101 }
michael@0 102
michael@0 103 virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE { }
michael@0 104 };
michael@0 105
michael@0 106 class TestSelfManageRootChild :
michael@0 107 public PTestSelfManageRootChild
michael@0 108 {
michael@0 109 public:
michael@0 110 TestSelfManageRootChild() {
michael@0 111 MOZ_COUNT_CTOR(TestSelfManageRootChild);
michael@0 112 }
michael@0 113 virtual ~TestSelfManageRootChild() {
michael@0 114 MOZ_COUNT_DTOR(TestSelfManageRootChild);
michael@0 115 }
michael@0 116
michael@0 117 void Main();
michael@0 118
michael@0 119 protected:
michael@0 120 virtual PTestSelfManageChild* AllocPTestSelfManageChild() MOZ_OVERRIDE {
michael@0 121 return new TestSelfManageChild();
michael@0 122 }
michael@0 123
michael@0 124 virtual bool DeallocPTestSelfManageChild(PTestSelfManageChild* a) MOZ_OVERRIDE {
michael@0 125 delete a;
michael@0 126 return true;
michael@0 127 }
michael@0 128
michael@0 129 virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE
michael@0 130 {
michael@0 131 if (NormalShutdown != why)
michael@0 132 fail("unexpected destruction!");
michael@0 133 QuitChild();
michael@0 134 }
michael@0 135 };
michael@0 136
michael@0 137 } // namespace _ipdltest
michael@0 138 } // namespace mozilla
michael@0 139
michael@0 140
michael@0 141 #endif // ifndef mozilla__ipdltest_TestSelfManageRoot_h

mercurial