Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
1 #include "TestActorPunning.h"
3 #include "IPDLUnitTests.h" // fail etc.
5 namespace mozilla {
6 namespace _ipdltest {
8 //-----------------------------------------------------------------------------
9 // parent
11 void
12 TestActorPunningParent::Main()
13 {
14 if (!SendStart())
15 fail("sending Start");
16 }
18 bool
19 TestActorPunningParent::RecvPun(PTestActorPunningSubParent* a, const Bad& bad)
20 {
21 if (a->SendBad())
22 fail("bad!");
23 fail("shouldn't have received this message in the first place");
24 return true;
25 }
27 PTestActorPunningPunnedParent*
28 TestActorPunningParent::AllocPTestActorPunningPunnedParent()
29 {
30 return new TestActorPunningPunnedParent();
31 }
33 bool
34 TestActorPunningParent::DeallocPTestActorPunningPunnedParent(PTestActorPunningPunnedParent* a)
35 {
36 delete a;
37 return true;
38 }
40 PTestActorPunningSubParent*
41 TestActorPunningParent::AllocPTestActorPunningSubParent()
42 {
43 return new TestActorPunningSubParent();
44 }
46 bool
47 TestActorPunningParent::DeallocPTestActorPunningSubParent(PTestActorPunningSubParent* a)
48 {
49 delete a;
50 return true;
51 }
53 //-----------------------------------------------------------------------------
54 // child
56 PTestActorPunningPunnedChild*
57 TestActorPunningChild::AllocPTestActorPunningPunnedChild()
58 {
59 return new TestActorPunningPunnedChild();
60 }
62 bool
63 TestActorPunningChild::DeallocPTestActorPunningPunnedChild(PTestActorPunningPunnedChild*)
64 {
65 fail("should have died by now");
66 return true;
67 }
69 PTestActorPunningSubChild*
70 TestActorPunningChild::AllocPTestActorPunningSubChild()
71 {
72 return new TestActorPunningSubChild();
73 }
75 bool
76 TestActorPunningChild::DeallocPTestActorPunningSubChild(PTestActorPunningSubChild*)
77 {
78 fail("should have died by now");
79 return true;
80 }
82 bool
83 TestActorPunningChild::RecvStart()
84 {
85 SendPTestActorPunningSubConstructor();
86 SendPTestActorPunningPunnedConstructor();
87 PTestActorPunningSubChild* a = SendPTestActorPunningSubConstructor();
88 // We can't assert whether this succeeds or fails, due to race
89 // conditions.
90 SendPun(a, Bad());
91 return true;
92 }
94 bool
95 TestActorPunningSubChild::RecvBad()
96 {
97 fail("things are going really badly right now");
98 return true;
99 }
102 } // namespace _ipdltest
103 } // namespace mozilla
105 namespace IPC {
106 using namespace mozilla::_ipdltest;
107 using namespace mozilla::ipc;
109 /*static*/ void
110 ParamTraits<Bad>::Write(Message* aMsg, const paramType& aParam)
111 {
112 char* ptr = aMsg->BeginWriteData(4);
113 ptr -= intptr_t(sizeof(int));
114 ptr -= intptr_t(sizeof(ActorHandle));
115 ActorHandle* ah = reinterpret_cast<ActorHandle*>(ptr);
116 if (ah->mId != -3)
117 fail("guessed wrong offset (value is %d, should be -3)", ah->mId);
118 ah->mId = -2;
119 }
121 /*static*/ bool
122 ParamTraits<Bad>::Read(const Message* aMsg, void** aIter, paramType* aResult)
123 {
124 const char* ptr;
125 int len;
126 aMsg->ReadData(aIter, &ptr, &len);
127 return true;
128 }
130 } // namespace IPC