xref: /haiku/src/tests/kits/app/bmessenger/BMessengerCases (revision f801a327554e9f58acf619a452ca95ceb21dae5d)
152a38012SejakowatzBMessenger()
252a38012Sejakowatzcase 1:	IsValid() should return false.
352a38012Sejakowatz		IsTargetLocal() should return false.
452a38012Sejakowatz		Target() should return NULL and NULL for looper.
552a38012Sejakowatz		Team() should return -1.
652a38012Sejakowatz
752a38012SejakowatzBMessenger(const BHandler *handler, const BLooper *looper, status_t *result)
852a38012Sejakowatzcase 1:	handler is NULL, looper is NULL, result is NULL =>
952a38012Sejakowatz		IsValid() and IsTargetLocal() should return false
1052a38012Sejakowatz		Target() should return NULL and NULL for looper.
1152a38012Sejakowatz		Team() should return -1.
1252a38012Sejakowatzcase 2:	handler is NULL, looper is NULL, result is not NULL =>
1352a38012Sejakowatz		IsValid() and IsTargetLocal() should return false.
1452a38012Sejakowatz		Target() should return NULL and NULL for looper.
1552a38012Sejakowatz		Team() should return -1.
1652a38012Sejakowatz		result is set to B_BAD_VALUE.
1752a38012Sejakowatzcase 3:	handler is NULL, looper is not NULL, result is not NULL =>
1852a38012Sejakowatz		IsValid() and IsTargetLocal() should return true.
1952a38012Sejakowatz		Target() should return NULL and the correct value for looper.
2052a38012Sejakowatz		Team() should return this team.
2152a38012Sejakowatz		result is set to B_OK.
2252a38012Sejakowatzcase 4:	handler is not NULL, looper is NULL, result is not NULL,
2352a38012Sejakowatz		handler doesn't belong to a looper =>
2452a38012Sejakowatz		IsValid() and IsTargetLocal() should return false.
2552a38012Sejakowatz		Target() should return NULL and NULL for looper.
2652a38012Sejakowatz		Team() should return -1.
2752a38012Sejakowatz		result is set to B_MISMATCHED_VALUES.
2852a38012Sejakowatzcase 5:	handler is not NULL, looper is NULL, result is not NULL
2952a38012Sejakowatz		handler does belong to a looper =>
3052a38012Sejakowatz		IsValid() and IsTargetLocal() should return true.
3152a38012Sejakowatz		Target() should return the correct handler and handler->Looper()
3252a38012Sejakowatz		for looper.
3352a38012Sejakowatz		Team() should return this team.
3452a38012Sejakowatz		result is set to B_OK.
3552a38012Sejakowatzcase 6:	handler is not NULL, looper is not NULL, result is not NULL
3652a38012Sejakowatz		handler does belong to the looper =>
3752a38012Sejakowatz		IsValid() and IsTargetLocal() should return true.
3852a38012Sejakowatz		Target() should return the correct handler and the correct value
3952a38012Sejakowatz		for looper.
4052a38012Sejakowatz		Team() should return this team.
4152a38012Sejakowatz		result is set to B_OK.
4252a38012Sejakowatzcase 7:	handler is not NULL, looper is not NULL, result is not NULL
4352a38012Sejakowatz		handler does belong to a different looper =>
4452a38012Sejakowatz		IsValid() and IsTargetLocal() should return false.
4552a38012Sejakowatz		Target() should return NULL and NULL for looper.
4652a38012Sejakowatz		Team() should return -1.
4752a38012Sejakowatz		result is set to B_MISMATCHED_VALUES.
4852a38012Sejakowatz
4952a38012SejakowatzBMessenger(const BMessenger &from)
5052a38012Sejakowatzcase 1:	from is uninitialized =>
5152a38012Sejakowatz		IsValid() and IsTargetLocal() should return false
5252a38012Sejakowatz		Target() should return NULL and NULL for looper.
5352a38012Sejakowatz		Team() should return -1.
5452a38012Sejakowatzcase 2:	from is properly initialized to a local target =>
5552a38012Sejakowatz		IsValid() and IsTargetLocal() should return true
5652a38012Sejakowatz		Target() should return the same values as for from.
5752a38012Sejakowatz		Team() should return this team.
5852a38012Sejakowatz
5952a38012SejakowatzBMessenger(const char *signature, team_id team, status_t *result)
60*f801a327SIngo Weinholdcase 1:	signature is NULL, team is -1, result is (not) NULL =>
61*f801a327SIngo Weinhold		IsValid() and IsTargetLocal() should return false
62*f801a327SIngo Weinhold		Target() should return NULL and NULL for looper.
63*f801a327SIngo Weinhold		Team() should return -1.
64*f801a327SIngo Weinhold		(result should be set to B_BAD_TYPE.)
65*f801a327SIngo Weinholdcase 2:	signature is not NULL, but identifies no running application,
66*f801a327SIngo Weinhold		team is -1, result is (not) NULL =>
67*f801a327SIngo Weinhold		IsValid() and IsTargetLocal() should return false
68*f801a327SIngo Weinhold		Target() should return NULL and NULL for looper.
69*f801a327SIngo Weinhold		Team() should return -1.
70*f801a327SIngo Weinhold		(result should be set to B_BAD_VALUE.)
71*f801a327SIngo Weinholdcase 3:	signature is NULL, team is > 0, but identifies no running application,
72*f801a327SIngo Weinhold		result is (not) NULL =>
73*f801a327SIngo Weinhold		IsValid() and IsTargetLocal() should return false
74*f801a327SIngo Weinhold		Target() should return NULL and NULL for looper.
75*f801a327SIngo Weinhold		Team() should return -1.
76*f801a327SIngo Weinhold		(result should be set to B_BAD_TEAM_ID.)
77*f801a327SIngo Weinholdcase 4:	signature is not NULL and identifies a running B_ARGV_ONLY application,
78*f801a327SIngo Weinhold		team is -1, result is (not) NULL =>
79*f801a327SIngo Weinhold		IsValid() and IsTargetLocal() should return false
80*f801a327SIngo Weinhold		Target() should return NULL and NULL for looper.
81*f801a327SIngo Weinhold		Team() should return the remote app's team ID.
82*f801a327SIngo Weinhold		(result should be set to B_BAD_TYPE.)
83*f801a327SIngo Weinholdcase 5:	signature is NULL,
84*f801a327SIngo Weinhold		team is > 0 and identifies a running B_ARGV_ONLY application,
85*f801a327SIngo Weinhold		result is (not) NULL =>
86*f801a327SIngo Weinhold		IsValid() and IsTargetLocal() should return false
87*f801a327SIngo Weinhold		Target() should return NULL and NULL for looper.
88*f801a327SIngo Weinhold		Team() should return the remote app's team ID.
89*f801a327SIngo Weinhold		(result should be set to B_BAD_TYPE.)
90*f801a327SIngo Weinholdcase 6:	signature is not NULL and identifies a "normal" running application,
91*f801a327SIngo Weinhold		team is -1, result is (not) NULL =>
92*f801a327SIngo Weinhold		IsValid() should return true
93*f801a327SIngo Weinhold		IsTargetLocal() should return false
94*f801a327SIngo Weinhold		Target() should return NULL and NULL for looper.
95*f801a327SIngo Weinhold		Team() should return the team ID of the remote application.
96*f801a327SIngo Weinhold		(result should be set to B_OK.)
97*f801a327SIngo Weinholdcase 7:	signature is NULL,
98*f801a327SIngo Weinhold		team is > 0 and identifies a "normal" running application,
99*f801a327SIngo Weinhold		result is (not) NULL =>
100*f801a327SIngo Weinhold		IsValid() should return true, false after the app terminated
101*f801a327SIngo Weinhold		IsTargetLocal() should return false
102*f801a327SIngo Weinhold		Target() should return NULL and NULL for looper.
103*f801a327SIngo Weinhold		Team() should return the team ID of the remote application (team).
104*f801a327SIngo Weinhold		(result should be set to B_OK.)
105*f801a327SIngo Weinholdcase 8:	signature is not NULL and team is > 0, but both identify different
106*f801a327SIngo Weinhold		applications, result is (not) NULL =>
107*f801a327SIngo Weinhold		IsValid() and IsTargetLocal() should return false
108*f801a327SIngo Weinhold		Target() should return NULL and NULL for looper.
109*f801a327SIngo Weinhold		Team() should return -1.
110*f801a327SIngo Weinhold		(result should be set to B_MISMATCHED_VALUES.)
111*f801a327SIngo Weinholdcase 9:	signature is not NULL,
112*f801a327SIngo Weinhold		team is > 0 and both identify the same application (more than one
113*f801a327SIngo Weinhold		app with the given signature are running), result is (not) NULL =>
114*f801a327SIngo Weinhold		IsValid() should return true
115*f801a327SIngo Weinhold		IsTargetLocal() should return false
116*f801a327SIngo Weinhold		Target() should return NULL and NULL for looper.
117*f801a327SIngo Weinhold		Team() should return the team ID of the remote application (team).
118*f801a327SIngo Weinhold		(result should be set to B_OK.)
11952a38012Sejakowatz
1204f139d77SIngo Weinholdbool IsTargetLocal() const
1214f139d77SIngo Weinholdcase 1:	this is uninitialized =>
1224f139d77SIngo Weinhold		should return false.
1234f139d77SIngo Weinholdcase 2:	this is initialized to local target with preferred handler =>
1244f139d77SIngo Weinhold		should return true.
1254f139d77SIngo Weinholdcase 3:	this is initialized to local target with specific handler =>
1264f139d77SIngo Weinhold		should return true.
1274f139d77SIngo Weinholdcase 4:	this is initialized to local target with preferred handler =>
1284f139d77SIngo Weinhold		should return false.
1294f139d77SIngo Weinholdcase 5:	this is initialized to remote target with specific handler =>
1304f139d77SIngo Weinhold		should return false.
1314f139d77SIngo Weinhold
132c1289294SIngo WeinholdBHandler *Target(BLooper **looper) const
133c1289294SIngo Weinholdcase 1:	this is uninitialized, looper is NULL =>
134c1289294SIngo Weinhold		should return NULL.
135c1289294SIngo Weinholdcase 2:	this is initialized to local target with preferred handler,
136c1289294SIngo Weinhold		looper is NULL =>
137c1289294SIngo Weinhold		should return NULL.
138c1289294SIngo Weinholdcase 3:	this is initialized to local target with specific handler,
139c1289294SIngo Weinhold		looper is NULL =>
140c1289294SIngo Weinhold		should return correct handler.
141c1289294SIngo Weinholdcase 4:	this is initialized to remote target with preferred handler,
142c1289294SIngo Weinhold		looper is NULL =>
143c1289294SIngo Weinhold		should return NULL.
144c1289294SIngo Weinholdcase 5:	this is initialized to remote target with specific handler,
145c1289294SIngo Weinhold		looper is NULL =>
146c1289294SIngo Weinhold		should return NULL.
1477ce28c04SIngo Weinholdother cases included in BMessenger(...) cases
1484f139d77SIngo Weinhold
149c1289294SIngo Weinholdbool LockTarget() const
150c1289294SIngo Weinholdcase 1:	this is uninitialized =>
151c1289294SIngo Weinhold		should return false.
152c1289294SIngo Weinholdcase 2:	this is initialized to local target with preferred handler,
153c1289294SIngo Weinhold		looper is not locked =>
154c1289294SIngo Weinhold		should lock the looper and return true.
155c1289294SIngo Weinholdcase 3:	this is initialized to local target with specific handler,
156c1289294SIngo Weinhold		looper is not locked =>
157c1289294SIngo Weinhold		should lock the looper and return true.
158c1289294SIngo Weinholdcase 4:	this is initialized to local target with preferred handler,
159c1289294SIngo Weinhold		looper is locked by another thread =>
160c1289294SIngo Weinhold		should block until the looper is unlocked, lock it and return true.
161c1289294SIngo Weinholdcase 5:	this is initialized to local target with specific handler,
162c1289294SIngo Weinhold		looper is locked by another thread =>
163c1289294SIngo Weinhold		should block until the looper is unlocked, lock it and return true.
164c1289294SIngo Weinholdcase 6:	this is initialized to remote target with preferred handler,
165c1289294SIngo Weinhold		looper is not locked =>
166c1289294SIngo Weinhold		should not lock the looper and return false.
167c1289294SIngo Weinholdcase 7:	this is initialized to remote target with specific handler,
168c1289294SIngo Weinhold		looper is not locked =>
169c1289294SIngo Weinhold		should not lock the looper and return false.
170c1289294SIngo Weinhold
171c1289294SIngo Weinholdstatus_t LockTargetWithTimeout(bigtime_t timeout) const
1727ce28c04SIngo Weinholdcase 1:	this is uninitialized =>
1737ce28c04SIngo Weinhold		should return B_BAD_VALUE.
1747ce28c04SIngo Weinholdcase 2:	this is initialized to local target with preferred handler,
1757ce28c04SIngo Weinhold		looper is not locked =>
1767ce28c04SIngo Weinhold		should lock the looper and return B_OK.
1777ce28c04SIngo Weinholdcase 3:	this is initialized to local target with specific handler,
1787ce28c04SIngo Weinhold		looper is not locked =>
1797ce28c04SIngo Weinhold		should lock the looper and return B_OK.
1807ce28c04SIngo Weinholdcase 4:	this is initialized to local target with preferred handler,
1817ce28c04SIngo Weinhold		looper is locked by another thread, timeout is 100ms =>
1827ce28c04SIngo Weinhold		should block until the looper is unlocked (after 50ms), lock it
1837ce28c04SIngo Weinhold		and return B_OK.
1847ce28c04SIngo Weinholdcase 5:	this is initialized to local target with preferred handler,
1857ce28c04SIngo Weinhold		looper is locked by another thread, timeout is 25ms =>
1867ce28c04SIngo Weinhold		should block for 25ms, not until the looper is unlocked (after 50ms),
1877ce28c04SIngo Weinhold		should return B_TIMED_OUT.
1887ce28c04SIngo Weinholdcase 6:	this is initialized to local target with specific handler,
1897ce28c04SIngo Weinhold		looper is locked by another thread, timeout is 100ms =>
1907ce28c04SIngo Weinhold		should block until the looper is unlocked (after 50ms), lock it
1917ce28c04SIngo Weinhold		and return B_OK.
1927ce28c04SIngo Weinholdcase 7:	this is initialized to local target with specific handler,
1937ce28c04SIngo Weinhold		looper is locked by another thread, timeout is 25ms =>
1947ce28c04SIngo Weinhold		should block for 25ms, not until the looper is unlocked (after 50ms),
1957ce28c04SIngo Weinhold		should return B_TIMED_OUT.
1967ce28c04SIngo Weinholdcase 8:	this is initialized to remote target with preferred handler,
1977ce28c04SIngo Weinhold		looper is not locked =>
1987ce28c04SIngo Weinhold		should not lock the looper and return B_BAD_VALUE.
1997ce28c04SIngo Weinholdcase 9:	this is initialized to remote target with specific handler,
2007ce28c04SIngo Weinhold		looper is not locked =>
2017ce28c04SIngo Weinhold		should not lock the looper and return B_BAD_VALUE.
2027ce28c04SIngo Weinhold
2037ce28c04SIngo Weinholdbool IsValid() const
2047ce28c04SIngo Weinholdincluded in BMessenger(...) cases
2057ce28c04SIngo Weinhold
2067ce28c04SIngo Weinholdteam_id Team() const
2077ce28c04SIngo Weinholdincluded in BMessenger(...) cases
2087ce28c04SIngo Weinhold
2097ce28c04SIngo WeinholdBMessenger &operator=(const BMessenger &from)
2107ce28c04SIngo Weinholdcase 1:	from is uninitialized =>
2117ce28c04SIngo Weinhold		IsValid() and IsTargetLocal() should return false
2127ce28c04SIngo Weinhold		Target() should return NULL and NULL for looper.
2137ce28c04SIngo Weinhold		Team() should return -1.
2147ce28c04SIngo Weinholdcase 2:	from is properly initialized to a local target (preferred handler) =>
2157ce28c04SIngo Weinhold		IsValid() and IsTargetLocal() should return true
2167ce28c04SIngo Weinhold		Target() should return the same values as for from.
2177ce28c04SIngo Weinhold		Team() should return this team.
2187ce28c04SIngo Weinholdcase 3:	from is properly initialized to a local target (specific handler) =>
2197ce28c04SIngo Weinhold		IsValid() and IsTargetLocal() should return true
2207ce28c04SIngo Weinhold		Target() should return the same values as for from.
2217ce28c04SIngo Weinhold		Team() should return this team.
2227ce28c04SIngo Weinhold
2237ce28c04SIngo Weinholdbool operator==(const BMessenger &other) const
2247ce28c04SIngo Weinholdcase 1:	this and other are uninitialized =>
2257ce28c04SIngo Weinhold		should return true.
2267ce28c04SIngo Weinholdcase 2:	this is initialized, other is uninitialized, and vice versa =>
2277ce28c04SIngo Weinhold		should return false.
2287ce28c04SIngo Weinholdcase 3:	this and other are initialized, different cases:
2297ce28c04SIngo Weinhold		- same object => true
2307ce28c04SIngo Weinhold		- different objects same target => true
2317ce28c04SIngo Weinhold		- looper preferred handler vs. same looper but the looper itself as
2327ce28c04SIngo Weinhold		  handler => false
2337ce28c04SIngo Weinhold		- looper preferred handler vs. other looper preferred handler => false
2347ce28c04SIngo Weinhold		- looper preferred handler vs. other looper specific handler => false
2357ce28c04SIngo Weinhold		- local looper vs. remote looper => false
2367ce28c04SIngo Weinhold
2377ce28c04SIngo Weinholdbool operator!=(const BMessenger &a, const BMessenger &b)
2387ce28c04SIngo Weinholdincluded in == cases
2397ce28c04SIngo Weinhold
2407ce28c04SIngo Weinholdbool operator<(const BMessenger &a, const BMessenger &b)
241014ff001SIngo Weinholdcase 1:	set fields of a and b manually =>
242014ff001SIngo Weinhold		should return whatever the reference implementation returns.
243014ff001SIngo Weinhold
244014ff001SIngo Weinholdstatus_t SendMessage(uint32 command, BHandler *replyTo) const
245014ff001SIngo Weinholdcase 1:	this is uninitialized, replyTo is NULL =>
246014ff001SIngo Weinhold		should return B_BAD_PORT_ID.
247014ff001SIngo Weinholdcase 2:	this is uninitialized, replyTo points to a valid handler  =>
248014ff001SIngo Weinhold		should return B_BAD_PORT_ID.
2496d24e9d8SIngo Weinholdcase 3:	this is initialized to a local/remote target with preferred/specific
2506d24e9d8SIngo Weinhold		handler, replyTo is NULL =>
251014ff001SIngo Weinhold		should deliver the message and return B_OK.
2526d24e9d8SIngo Weinholdcase 4:	this is initialized to a local/remote target with preferred/specific
2536d24e9d8SIngo Weinhold		handler, replyTo points to a valid handler =>
254014ff001SIngo Weinhold		should deliver the message and return B_OK, a reply should be posted
255014ff001SIngo Weinhold		to the reply handler.
256014ff001SIngo Weinhold
257014ff001SIngo Weinholdstatus_t SendMessage(BMessage *message, BHandler *replyTo,
258014ff001SIngo Weinhold					 bigtime_t timeout) const
259014ff001SIngo Weinholdcase 1:	message is NULL, replyTo is NULL, timeout is B_INFINITE_TIMEOUT =>
260014ff001SIngo Weinhold		should return B_BAD_VALUE.
261014ff001SIngo Weinholdother cases similar to those of SendMessage(uint32, BHandler *). Each one with
262014ff001SIngo Weinholda timeout of B_INFINITE_TIMEOUT, 0 and some ms. For the last two
263014ff001SIngo Weinholdtimeouts in failure cases B_WOULD_BLOCK/B_TIMED_OUT should be returned.
264014ff001SIngo Weinhold
265014ff001SIngo Weinholdstatus_t SendMessage(BMessage *message, BMessenger replyTo,
266014ff001SIngo Weinhold					 bigtime_t timeout) const
267014ff001SIngo Weinholdcases similar to those of SendMessage(BMessage *, BHandler *, bigtime_t).
268014ff001SIngo WeinholdAn invalid replyTo messenger causes the same behavior as a NULL handler.
269014ff001SIngo Weinhold
270014ff001SIngo Weinholdstatus_t SendMessage(uint32 command, BMessage *reply) const
271014ff001SIngo Weinholdcase 1:	this is uninitialized, reply is NULL =>
272014ff001SIngo Weinhold		should return B_BAD_PORT_ID or B_BAD_VALUE.
273014ff001SIngo Weinholdcase 2:	this is uninitialized, replyTo points to a valid message  =>
274014ff001SIngo Weinhold		should return B_BAD_PORT_ID.
2756d24e9d8SIngo Weinholdcase 3:	this is initialized to a local/remote target with preferred/specific
2766d24e9d8SIngo Weinhold		handler, reply is NULL =>
277014ff001SIngo Weinhold		should return B_BAD_VALUE.
2786d24e9d8SIngo Weinholdcase 4:	this is initialized to a local/remote target with preferred/specific
2796d24e9d8SIngo Weinhold		handler, reply points to a valid message =>
280014ff001SIngo Weinhold		should deliver the message, wait for a reply and return B_OK,
281014ff001SIngo Weinhold		reply should contain the reply.
282014ff001SIngo Weinhold
283014ff001SIngo Weinholdstatus_t SendMessage(BMessage *message, BMessage *reply,
284014ff001SIngo Weinhold					 bigtime_t deliveryTimeout,
285014ff001SIngo Weinhold					 bigtime_t replyTimeout) const
286014ff001SIngo Weinholdcases similar to those of SendMessage(uint32, BMessage *). deliveryTimeout and
287014ff001SIngo WeinholdreplyTimeout are B_INFINITE_TIMEOUT, 0 or some ms. In timeout cases
288014ff001SIngo WeinholdB_WOULD_BLOCK/B_TIMED_OUT should be returned.
289014ff001SIngo Weinhold
2907ce28c04SIngo Weinhold
291