blob: cce0ca34fae995e2df96da46328220f7d0ca10db (
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
|
#if defined(OS_POSIX)
#include <unistd.h> // sleep()
#endif
#include "TestSyncWakeup.h"
#include "IPDLUnitTests.h" // fail etc.
namespace mozilla {
namespace _ipdltest {
//-----------------------------------------------------------------------------
// parent
TestSyncWakeupParent::TestSyncWakeupParent()
{
MOZ_COUNT_CTOR(TestSyncWakeupParent);
}
TestSyncWakeupParent::~TestSyncWakeupParent()
{
MOZ_COUNT_DTOR(TestSyncWakeupParent);
}
void
TestSyncWakeupParent::Main()
{
if (!SendStart())
fail("sending Start()");
}
bool
TestSyncWakeupParent::AnswerStackFrame()
{
if (!CallStackFrame())
fail("calling StackFrame()");
return true;
}
bool
TestSyncWakeupParent::RecvSync1()
{
if (!SendNote1())
fail("sending Note1()");
// XXX ugh ... need to ensure that the async message and sync
// reply come in "far enough" apart that this test doesn't pass on
// accident
#if defined(OS_POSIX)
// NB: can't use PR_Sleep (i.e. Sleep() on windows) because it's
// only spec'd to block the current thread, not the current
// process. We need the IO thread to sleep as well.
puts(" (sleeping for 5 seconds. sorry!)");
sleep(5);
#endif
return true;
}
bool
TestSyncWakeupParent::RecvSync2()
{
if (!SendNote2())
fail("sending Note2()");
#if defined(OS_POSIX)
// see above
sleep(5);
puts(" (sleeping for 5 seconds. sorry!)");
#endif
return true;
}
//-----------------------------------------------------------------------------
// child
TestSyncWakeupChild::TestSyncWakeupChild() : mDone(false)
{
MOZ_COUNT_CTOR(TestSyncWakeupChild);
}
TestSyncWakeupChild::~TestSyncWakeupChild()
{
MOZ_COUNT_DTOR(TestSyncWakeupChild);
}
bool
TestSyncWakeupChild::RecvStart()
{
// First test: the parent fires back an async message while
// replying to a sync one
if (!SendSync1())
fail("sending Sync()");
// drop back into the event loop to get Note1(), then kick off the
// second test
return true;
}
bool
TestSyncWakeupChild::RecvNote1()
{
// Second test: the parent fires back an async message while
// replying to a sync one, with a frame on the RPC stack
if (!CallStackFrame())
fail("calling StackFrame()");
if (!mDone)
fail("should have received Note2()!");
Close();
return true;
}
bool
TestSyncWakeupChild::AnswerStackFrame()
{
if (!SendSync2())
fail("sending Sync()");
return true;
}
bool
TestSyncWakeupChild::RecvNote2()
{
mDone = true;
return true;
}
} // namespace _ipdltest
} // namespace mozilla
|