summaryrefslogtreecommitdiffstats
path: root/ipc/ipdl/test/cxx/TestCancel.cpp
blob: 8f983b3de86dd00204d1822819b1708f1475d7c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#include "TestCancel.h"

#include "IPDLUnitTests.h"      // fail etc.

namespace mozilla {
namespace _ipdltest {

//-----------------------------------------------------------------------------
// parent

TestCancelParent::TestCancelParent()
{
    MOZ_COUNT_CTOR(TestCancelParent);
}

TestCancelParent::~TestCancelParent()
{
    MOZ_COUNT_DTOR(TestCancelParent);
}

void
TestCancelParent::Main()
{
    if (SendTest1_1())
	fail("sending Test1_1");

    uint32_t value = 0;
    if (!SendCheckChild(&value))
	fail("Test1 CheckChild");

    if (value != 12)
	fail("Test1 CheckChild reply");
}

bool
TestCancelParent::RecvDone1()
{
    if (!SendStart2())
	fail("sending Start2");

    return true;
}

bool
TestCancelParent::RecvTest2_1()
{
    if (SendTest2_2())
	fail("sending Test2_2");

    return true;
}

bool
TestCancelParent::RecvStart3()
{
    if (SendTest3_1())
	fail("sending Test3_1");

    uint32_t value = 0;
    if (!SendCheckChild(&value))
	fail("Test1 CheckChild");

    if (value != 12)
	fail("Test1 CheckChild reply");

    return true;
}

bool
TestCancelParent::RecvTest3_2()
{
    GetIPCChannel()->CancelCurrentTransaction();
    return true;
}

bool
TestCancelParent::RecvDone()
{
    MessageLoop::current()->PostTask(
	NewNonOwningRunnableMethod(this, &TestCancelParent::Close));
    return true;
}

bool
TestCancelParent::RecvCheckParent(uint32_t *reply)
{
    *reply = 12;
    return true;
}

//-----------------------------------------------------------------------------
// child

bool
TestCancelChild::RecvTest1_1()
{
    GetIPCChannel()->CancelCurrentTransaction();

    uint32_t value = 0;
    if (!SendCheckParent(&value))
	fail("Test1 CheckParent");

    if (value != 12)
	fail("Test1 CheckParent reply");

    if (!SendDone1())
	fail("Test1 CheckParent");

    return true;
}

bool
TestCancelChild::RecvStart2()
{
    if (!SendTest2_1())
	fail("sending Test2_1");

    if (!SendStart3())
	fail("sending Start3");

    return true;
}

bool
TestCancelChild::RecvTest2_2()
{
    GetIPCChannel()->CancelCurrentTransaction();
    return true;
}

bool
TestCancelChild::RecvTest3_1()
{
    if (SendTest3_2())
	fail("sending Test3_2");

    uint32_t value = 0;
    if (!SendCheckParent(&value))
	fail("Test1 CheckParent");

    if (value != 12)
	fail("Test1 CheckParent reply");

    if (!SendDone())
	fail("sending Done");

    return true;
}

bool
TestCancelChild::RecvCheckChild(uint32_t *reply)
{
    *reply = 12;
    return true;
}

TestCancelChild::TestCancelChild()
{
    MOZ_COUNT_CTOR(TestCancelChild);
}

TestCancelChild::~TestCancelChild()
{
    MOZ_COUNT_DTOR(TestCancelChild);
}

} // namespace _ipdltest
} // namespace mozilla