Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | #include "TestFailedCtor.h" |
michael@0 | 2 | |
michael@0 | 3 | #include "IPDLUnitTests.h" // fail etc. |
michael@0 | 4 | |
michael@0 | 5 | namespace mozilla { |
michael@0 | 6 | namespace _ipdltest { |
michael@0 | 7 | |
michael@0 | 8 | //----------------------------------------------------------------------------- |
michael@0 | 9 | // parent |
michael@0 | 10 | void |
michael@0 | 11 | TestFailedCtorParent::Main() |
michael@0 | 12 | { |
michael@0 | 13 | PTestFailedCtorSubParent* p = CallPTestFailedCtorSubConstructor(); |
michael@0 | 14 | if (p) |
michael@0 | 15 | fail("expected ctor to fail"); |
michael@0 | 16 | |
michael@0 | 17 | Close(); |
michael@0 | 18 | } |
michael@0 | 19 | |
michael@0 | 20 | PTestFailedCtorSubParent* |
michael@0 | 21 | TestFailedCtorParent::AllocPTestFailedCtorSubParent() |
michael@0 | 22 | { |
michael@0 | 23 | return new TestFailedCtorSubParent(); |
michael@0 | 24 | } |
michael@0 | 25 | bool |
michael@0 | 26 | TestFailedCtorParent::DeallocPTestFailedCtorSubParent(PTestFailedCtorSubParent* actor) |
michael@0 | 27 | { |
michael@0 | 28 | delete actor; |
michael@0 | 29 | return true; |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | PTestFailedCtorSubsubParent* |
michael@0 | 33 | TestFailedCtorSubParent::AllocPTestFailedCtorSubsubParent() |
michael@0 | 34 | { |
michael@0 | 35 | TestFailedCtorSubsub* a = new TestFailedCtorSubsub(); |
michael@0 | 36 | if (!mOne) { |
michael@0 | 37 | return mOne = a; |
michael@0 | 38 | } else if (!mTwo) { |
michael@0 | 39 | return mTwo = a; |
michael@0 | 40 | } else if (!mThree) { |
michael@0 | 41 | return mThree = a; |
michael@0 | 42 | } else { |
michael@0 | 43 | fail("unexpected Alloc()"); |
michael@0 | 44 | return nullptr; |
michael@0 | 45 | } |
michael@0 | 46 | } |
michael@0 | 47 | bool |
michael@0 | 48 | TestFailedCtorSubParent::DeallocPTestFailedCtorSubsubParent(PTestFailedCtorSubsubParent* actor) |
michael@0 | 49 | { |
michael@0 | 50 | static_cast<TestFailedCtorSubsub*>(actor)->mDealloced = true; |
michael@0 | 51 | return true; |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | void |
michael@0 | 55 | TestFailedCtorSubParent::ActorDestroy(ActorDestroyReason why) |
michael@0 | 56 | { |
michael@0 | 57 | |
michael@0 | 58 | if (mOne->mWhy != Deletion) |
michael@0 | 59 | fail("Subsub one got wrong ActorDestroyReason"); |
michael@0 | 60 | if (mTwo->mWhy != AncestorDeletion) |
michael@0 | 61 | fail("Subsub two got wrong ActorDestroyReason"); |
michael@0 | 62 | if (mThree->mWhy != AncestorDeletion) |
michael@0 | 63 | fail("Subsub three got wrong ActorDestroyReason"); |
michael@0 | 64 | |
michael@0 | 65 | if (FailedConstructor != why) |
michael@0 | 66 | fail("unexpected destruction!"); |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | TestFailedCtorSubParent::~TestFailedCtorSubParent() |
michael@0 | 70 | { |
michael@0 | 71 | if (!(mOne->mDealloced && mTwo->mDealloced && mThree->mDealloced)) |
michael@0 | 72 | fail("Not all subsubs were Dealloc'd"); |
michael@0 | 73 | delete mOne; |
michael@0 | 74 | delete mTwo; |
michael@0 | 75 | delete mThree; |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | |
michael@0 | 79 | //----------------------------------------------------------------------------- |
michael@0 | 80 | // child |
michael@0 | 81 | |
michael@0 | 82 | PTestFailedCtorSubChild* |
michael@0 | 83 | TestFailedCtorChild::AllocPTestFailedCtorSubChild() |
michael@0 | 84 | { |
michael@0 | 85 | return new TestFailedCtorSubChild(); |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | bool |
michael@0 | 89 | TestFailedCtorChild::AnswerPTestFailedCtorSubConstructor(PTestFailedCtorSubChild* actor) |
michael@0 | 90 | { |
michael@0 | 91 | PTestFailedCtorSubsubChild* c1 = actor->SendPTestFailedCtorSubsubConstructor(); |
michael@0 | 92 | PTestFailedCtorSubsubChild::Send__delete__(c1); |
michael@0 | 93 | |
michael@0 | 94 | if (!actor->SendPTestFailedCtorSubsubConstructor() || |
michael@0 | 95 | !actor->SendPTestFailedCtorSubsubConstructor() || |
michael@0 | 96 | !actor->SendSync()) |
michael@0 | 97 | fail("setting up test"); |
michael@0 | 98 | |
michael@0 | 99 | // This causes our process to die |
michael@0 | 100 | return false; |
michael@0 | 101 | } |
michael@0 | 102 | |
michael@0 | 103 | bool |
michael@0 | 104 | TestFailedCtorChild::DeallocPTestFailedCtorSubChild(PTestFailedCtorSubChild* actor) |
michael@0 | 105 | { |
michael@0 | 106 | delete actor; |
michael@0 | 107 | return true; |
michael@0 | 108 | } |
michael@0 | 109 | |
michael@0 | 110 | void |
michael@0 | 111 | TestFailedCtorChild::ProcessingError(Result what) |
michael@0 | 112 | { |
michael@0 | 113 | if (OtherProcess() != 0) // thread-mode |
michael@0 | 114 | _exit(0); |
michael@0 | 115 | } |
michael@0 | 116 | |
michael@0 | 117 | PTestFailedCtorSubsubChild* |
michael@0 | 118 | TestFailedCtorSubChild::AllocPTestFailedCtorSubsubChild() |
michael@0 | 119 | { |
michael@0 | 120 | return new TestFailedCtorSubsub(); |
michael@0 | 121 | } |
michael@0 | 122 | |
michael@0 | 123 | bool |
michael@0 | 124 | TestFailedCtorSubChild::DeallocPTestFailedCtorSubsubChild(PTestFailedCtorSubsubChild* actor) |
michael@0 | 125 | { |
michael@0 | 126 | delete actor; |
michael@0 | 127 | return true; |
michael@0 | 128 | } |
michael@0 | 129 | |
michael@0 | 130 | void |
michael@0 | 131 | TestFailedCtorSubChild::ActorDestroy(ActorDestroyReason why) |
michael@0 | 132 | { |
michael@0 | 133 | } |
michael@0 | 134 | |
michael@0 | 135 | |
michael@0 | 136 | } // namespace _ipdltest |
michael@0 | 137 | } // namespace mozilla |