2 case 1: IsValid() should return false.
3 IsTargetLocal() should return false.
4 Target() should return NULL and NULL for looper.
5 Team() should return -1.
7 BMessenger(const BHandler *handler, const BLooper *looper, status_t *result)
8 case 1: handler is NULL, looper is NULL, result is NULL =>
9 IsValid() and IsTargetLocal() should return false
10 Target() should return NULL and NULL for looper.
11 Team() should return -1.
12 case 2: handler is NULL, looper is NULL, result is not NULL =>
13 IsValid() and IsTargetLocal() should return false.
14 Target() should return NULL and NULL for looper.
15 Team() should return -1.
16 result is set to B_BAD_VALUE.
17 case 3: handler is NULL, looper is not NULL, result is not NULL =>
18 IsValid() and IsTargetLocal() should return true.
19 Target() should return NULL and the correct value for looper.
20 Team() should return this team.
21 result is set to B_OK.
22 case 4: handler is not NULL, looper is NULL, result is not NULL,
23 handler doesn't belong to a looper =>
24 IsValid() and IsTargetLocal() should return false.
25 Target() should return NULL and NULL for looper.
26 Team() should return -1.
27 result is set to B_MISMATCHED_VALUES.
28 case 5: handler is not NULL, looper is NULL, result is not NULL
29 handler does belong to a looper =>
30 IsValid() and IsTargetLocal() should return true.
31 Target() should return the correct handler and handler->Looper()
33 Team() should return this team.
34 result is set to B_OK.
35 case 6: handler is not NULL, looper is not NULL, result is not NULL
36 handler does belong to the looper =>
37 IsValid() and IsTargetLocal() should return true.
38 Target() should return the correct handler and the correct value
40 Team() should return this team.
41 result is set to B_OK.
42 case 7: handler is not NULL, looper is not NULL, result is not NULL
43 handler does belong to a different looper =>
44 IsValid() and IsTargetLocal() should return false.
45 Target() should return NULL and NULL for looper.
46 Team() should return -1.
47 result is set to B_MISMATCHED_VALUES.
49 BMessenger(const BMessenger &from)
50 case 1: from is uninitialized =>
51 IsValid() and IsTargetLocal() should return false
52 Target() should return NULL and NULL for looper.
53 Team() should return -1.
54 case 2: from is properly initialized to a local target =>
55 IsValid() and IsTargetLocal() should return true
56 Target() should return the same values as for from.
57 Team() should return this team.
59 BMessenger(const char *signature, team_id team, status_t *result)
60 case 1: signature is NULL, team is -1, result is (not) NULL =>
61 IsValid() and IsTargetLocal() should return false
62 Target() should return NULL and NULL for looper.
63 Team() should return -1.
64 (result should be set to B_BAD_TYPE.)
65 case 2: signature is not NULL, but identifies no running application,
66 team is -1, result is (not) NULL =>
67 IsValid() and IsTargetLocal() should return false
68 Target() should return NULL and NULL for looper.
69 Team() should return -1.
70 (result should be set to B_BAD_VALUE.)
71 case 3: signature is NULL, team is > 0, but identifies no running application,
72 result is (not) NULL =>
73 IsValid() and IsTargetLocal() should return false
74 Target() should return NULL and NULL for looper.
75 Team() should return -1.
76 (result should be set to B_BAD_TEAM_ID.)
77 case 4: signature is not NULL and identifies a running B_ARGV_ONLY application,
78 team is -1, result is (not) NULL =>
79 IsValid() and IsTargetLocal() should return false
80 Target() should return NULL and NULL for looper.
81 Team() should return the remote app's team ID.
82 (result should be set to B_BAD_TYPE.)
83 case 5: signature is NULL,
84 team is > 0 and identifies a running B_ARGV_ONLY application,
85 result is (not) NULL =>
86 IsValid() and IsTargetLocal() should return false
87 Target() should return NULL and NULL for looper.
88 Team() should return the remote app's team ID.
89 (result should be set to B_BAD_TYPE.)
90 case 6: signature is not NULL and identifies a "normal" running application,
91 team is -1, result is (not) NULL =>
92 IsValid() should return true
93 IsTargetLocal() should return false
94 Target() should return NULL and NULL for looper.
95 Team() should return the team ID of the remote application.
96 (result should be set to B_OK.)
97 case 7: signature is NULL,
98 team is > 0 and identifies a "normal" running application,
99 result is (not) NULL =>
100 IsValid() should return true, false after the app terminated
101 IsTargetLocal() should return false
102 Target() should return NULL and NULL for looper.
103 Team() should return the team ID of the remote application (team).
104 (result should be set to B_OK.)
105 case 8: signature is not NULL and team is > 0, but both identify different
106 applications, result is (not) NULL =>
107 IsValid() and IsTargetLocal() should return false
108 Target() should return NULL and NULL for looper.
109 Team() should return -1.
110 (result should be set to B_MISMATCHED_VALUES.)
111 case 9: signature is not NULL,
112 team is > 0 and both identify the same application (more than one
113 app with the given signature are running), result is (not) NULL =>
114 IsValid() should return true
115 IsTargetLocal() should return false
116 Target() should return NULL and NULL for looper.
117 Team() should return the team ID of the remote application (team).
118 (result should be set to B_OK.)
120 bool IsTargetLocal() const
121 case 1: this is uninitialized =>
123 case 2: this is initialized to local target with preferred handler =>
125 case 3: this is initialized to local target with specific handler =>
127 case 4: this is initialized to local target with preferred handler =>
129 case 5: this is initialized to remote target with specific handler =>
132 BHandler *Target(BLooper **looper) const
133 case 1: this is uninitialized, looper is NULL =>
135 case 2: this is initialized to local target with preferred handler,
138 case 3: this is initialized to local target with specific handler,
140 should return correct handler.
141 case 4: this is initialized to remote target with preferred handler,
144 case 5: this is initialized to remote target with specific handler,
147 other cases included in BMessenger(...) cases
149 bool LockTarget() const
150 case 1: this is uninitialized =>
152 case 2: this is initialized to local target with preferred handler,
153 looper is not locked =>
154 should lock the looper and return true.
155 case 3: this is initialized to local target with specific handler,
156 looper is not locked =>
157 should lock the looper and return true.
158 case 4: this is initialized to local target with preferred handler,
159 looper is locked by another thread =>
160 should block until the looper is unlocked, lock it and return true.
161 case 5: this is initialized to local target with specific handler,
162 looper is locked by another thread =>
163 should block until the looper is unlocked, lock it and return true.
164 case 6: this is initialized to remote target with preferred handler,
165 looper is not locked =>
166 should not lock the looper and return false.
167 case 7: this is initialized to remote target with specific handler,
168 looper is not locked =>
169 should not lock the looper and return false.
171 status_t LockTargetWithTimeout(bigtime_t timeout) const
172 case 1: this is uninitialized =>
173 should return B_BAD_VALUE.
174 case 2: this is initialized to local target with preferred handler,
175 looper is not locked =>
176 should lock the looper and return B_OK.
177 case 3: this is initialized to local target with specific handler,
178 looper is not locked =>
179 should lock the looper and return B_OK.
180 case 4: this is initialized to local target with preferred handler,
181 looper is locked by another thread, timeout is 100ms =>
182 should block until the looper is unlocked (after 50ms), lock it
184 case 5: this is initialized to local target with preferred handler,
185 looper is locked by another thread, timeout is 25ms =>
186 should block for 25ms, not until the looper is unlocked (after 50ms),
187 should return B_TIMED_OUT.
188 case 6: this is initialized to local target with specific handler,
189 looper is locked by another thread, timeout is 100ms =>
190 should block until the looper is unlocked (after 50ms), lock it
192 case 7: this is initialized to local target with specific handler,
193 looper is locked by another thread, timeout is 25ms =>
194 should block for 25ms, not until the looper is unlocked (after 50ms),
195 should return B_TIMED_OUT.
196 case 8: this is initialized to remote target with preferred handler,
197 looper is not locked =>
198 should not lock the looper and return B_BAD_VALUE.
199 case 9: this is initialized to remote target with specific handler,
200 looper is not locked =>
201 should not lock the looper and return B_BAD_VALUE.
204 included in BMessenger(...) cases
207 included in BMessenger(...) cases
209 BMessenger &operator=(const BMessenger &from)
210 case 1: from is uninitialized =>
211 IsValid() and IsTargetLocal() should return false
212 Target() should return NULL and NULL for looper.
213 Team() should return -1.
214 case 2: from is properly initialized to a local target (preferred handler) =>
215 IsValid() and IsTargetLocal() should return true
216 Target() should return the same values as for from.
217 Team() should return this team.
218 case 3: from is properly initialized to a local target (specific handler) =>
219 IsValid() and IsTargetLocal() should return true
220 Target() should return the same values as for from.
221 Team() should return this team.
223 bool operator==(const BMessenger &other) const
224 case 1: this and other are uninitialized =>
226 case 2: this is initialized, other is uninitialized, and vice versa =>
228 case 3: this and other are initialized, different cases:
229 - same object => true
230 - different objects same target => true
231 - looper preferred handler vs. same looper but the looper itself as
233 - looper preferred handler vs. other looper preferred handler => false
234 - looper preferred handler vs. other looper specific handler => false
235 - local looper vs. remote looper => false
237 bool operator!=(const BMessenger &a, const BMessenger &b)
240 bool operator<(const BMessenger &a, const BMessenger &b)
241 case 1: set fields of a and b manually =>
242 should return whatever the reference implementation returns.
244 status_t SendMessage(uint32 command, BHandler *replyTo) const
245 case 1: this is uninitialized, replyTo is NULL =>
246 should return B_BAD_PORT_ID.
247 case 2: this is uninitialized, replyTo points to a valid handler =>
248 should return B_BAD_PORT_ID.
249 case 3: this is initialized to a local/remote target with preferred/specific
250 handler, replyTo is NULL =>
251 should deliver the message and return B_OK.
252 case 4: this is initialized to a local/remote target with preferred/specific
253 handler, replyTo points to a valid handler =>
254 should deliver the message and return B_OK, a reply should be posted
255 to the reply handler.
257 status_t SendMessage(BMessage *message, BHandler *replyTo,
258 bigtime_t timeout) const
259 case 1: message is NULL, replyTo is NULL, timeout is B_INFINITE_TIMEOUT =>
260 should return B_BAD_VALUE.
261 other cases similar to those of SendMessage(uint32, BHandler *). Each one with
262 a timeout of B_INFINITE_TIMEOUT, 0 and some ms. For the last two
263 timeouts in failure cases B_WOULD_BLOCK/B_TIMED_OUT should be returned.
265 status_t SendMessage(BMessage *message, BMessenger replyTo,
266 bigtime_t timeout) const
267 cases similar to those of SendMessage(BMessage *, BHandler *, bigtime_t).
268 An invalid replyTo messenger causes the same behavior as a NULL handler.
270 status_t SendMessage(uint32 command, BMessage *reply) const
271 case 1: this is uninitialized, reply is NULL =>
272 should return B_BAD_PORT_ID or B_BAD_VALUE.
273 case 2: this is uninitialized, replyTo points to a valid message =>
274 should return B_BAD_PORT_ID.
275 case 3: this is initialized to a local/remote target with preferred/specific
276 handler, reply is NULL =>
277 should return B_BAD_VALUE.
278 case 4: this is initialized to a local/remote target with preferred/specific
279 handler, reply points to a valid message =>
280 should deliver the message, wait for a reply and return B_OK,
281 reply should contain the reply.
283 status_t SendMessage(BMessage *message, BMessage *reply,
284 bigtime_t deliveryTimeout,
285 bigtime_t replyTimeout) const
286 cases similar to those of SendMessage(uint32, BMessage *). deliveryTimeout and
287 replyTimeout are B_INFINITE_TIMEOUT, 0 or some ms. In timeout cases
288 B_WOULD_BLOCK/B_TIMED_OUT should be returned.