1//------------------------------------------------------------------------------
2//	AppRunTester.cpp
3//
4//------------------------------------------------------------------------------
5
6// Standard Includes -----------------------------------------------------------
7#include <stdio.h>
8
9// System Includes -------------------------------------------------------------
10#include <Message.h>
11#include <OS.h>
12#include <Application.h>
13#include <Handler.h>
14#include <Looper.h>
15#include <String.h>
16
17// Project Includes ------------------------------------------------------------
18#include <TestShell.h>
19#include <TestUtils.h>
20#include <cppunit/TestAssert.h>
21
22// Local Includes --------------------------------------------------------------
23#include "AppRunner.h"
24#include "AppRunTester.h"
25
26// Local Defines ---------------------------------------------------------------
27
28// Globals ---------------------------------------------------------------------
29
30//------------------------------------------------------------------------------
31
32// check_output
33static
34void
35check_output(AppRunner &runner, const char *expectedOutput)
36{
37	BString buffer;
38	CHK(runner.GetOutput(&buffer) == B_OK);
39if (buffer != expectedOutput)
40printf("result is `%s', but should be `%s'\n", buffer.String(),
41expectedOutput);
42	CHK(buffer == expectedOutput);
43}
44
45/*
46	thread_id Run()
47	@case 1			launch the app two times: B_MULTIPLE_LAUNCH | B_ARGV_ONLY,
48					no command line args, send B_QUIT_REQUESTED to both of
49					them
50	@results		first app:	ReadyToRun(), QuitRequested()
51					second app:	ReadyToRun(), QuitRequested()
52*/
53void AppRunTester::RunTest1()
54{
55	BApplication app("application/x-vnd.obos-app-run-test");
56	const char *output1 =
57		"error: 0\n"
58		"InitCheck(): 0\n"
59		"BApplication::ReadyToRun()\n"
60		"BApplication::QuitRequested()\n"
61		"BApplication::Run() done: 1\n";
62	const char *output2 = output1;
63	// run the apps
64	AppRunner runner1, runner2;
65	CHK(runner1.Run("AppRunTestApp1") == B_OK);
66	CHK(runner2.Run("AppRunTestApp1") == B_OK);
67	runner1.WaitFor(true);
68	runner2.WaitFor(true);
69	// get the outputs and compare the results
70	check_output(runner1, output1);
71	check_output(runner2, output2);
72}
73
74/*
75	thread_id Run()
76	@case 2			launch the app two times: B_MULTIPLE_LAUNCH | B_ARGV_ONLY,
77					command line args, send B_QUIT_REQUESTED to both of
78					them
79	@results		first app:	ArgvReceived(), ReadyToRun(), QuitRequested()
80					second app:	ArgvReceived(), ReadyToRun(), QuitRequested()
81*/
82void AppRunTester::RunTest2()
83{
84	BApplication app("application/x-vnd.obos-app-run-test");
85	const char *output1 =
86		"error: 0\n"
87		"InitCheck(): 0\n"
88		"BApplication::ArgvReceived()\n"
89		"args: a b\n"
90		"BApplication::ReadyToRun()\n"
91		"BApplication::QuitRequested()\n"
92		"BApplication::Run() done: 1\n";
93	const char *output2 =
94		"error: 0\n"
95		"InitCheck(): 0\n"
96		"BApplication::ArgvReceived()\n"
97		"args: c d e\n"
98		"BApplication::ReadyToRun()\n"
99		"BApplication::QuitRequested()\n"
100		"BApplication::Run() done: 1\n";
101	// run the apps
102	AppRunner runner1, runner2;
103	CHK(runner1.Run("AppRunTestApp1", "a b") == B_OK);
104	CHK(runner2.Run("AppRunTestApp1", "c d e") == B_OK);
105	runner1.WaitFor(true);
106	runner2.WaitFor(true);
107	// get the outputs and compare the results
108	check_output(runner1, output1);
109	check_output(runner2, output2);
110}
111
112/*
113	thread_id Run()
114	@case 3			launch the app two times: B_MULTIPLE_LAUNCH,
115					no command line args, send B_QUIT_REQUESTED to both of them
116	@results		first app:	ReadyToRun(), QuitRequested()
117					second app:	ReadyToRun(), QuitRequested()
118*/
119void AppRunTester::RunTest3()
120{
121	BApplication app("application/x-vnd.obos-app-run-test");
122	const char *output1 =
123		"error: 0\n"
124		"InitCheck(): 0\n"
125		"BApplication::ReadyToRun()\n"
126		"BApplication::QuitRequested()\n"
127		"BApplication::Run() done: 1\n";
128	const char *output2 = output1;
129	// run the apps
130	AppRunner runner1, runner2;
131	CHK(runner1.Run("AppRunTestApp2") == B_OK);
132	CHK(runner2.Run("AppRunTestApp2") == B_OK);
133	runner1.WaitFor(true);
134	runner2.WaitFor(true);
135	// get the outputs and compare the results
136	check_output(runner1, output1);
137	check_output(runner2, output2);
138}
139
140/*
141	thread_id Run()
142	@case 4			launch the app two times: B_MULTIPLE_LAUNCH,
143					command line args, send B_QUIT_REQUESTED to both of them
144	@results		first app:	ArgvReceived(), ReadyToRun(), QuitRequested()
145					second app:	ArgvReceived(), ReadyToRun(), QuitRequested()
146*/
147void AppRunTester::RunTest4()
148{
149	BApplication app("application/x-vnd.obos-app-run-test");
150	const char *output1 =
151		"error: 0\n"
152		"InitCheck(): 0\n"
153		"BApplication::ArgvReceived()\n"
154		"args: a b\n"
155		"BApplication::ReadyToRun()\n"
156		"BApplication::QuitRequested()\n"
157		"BApplication::Run() done: 1\n";
158	const char *output2 =
159		"error: 0\n"
160		"InitCheck(): 0\n"
161		"BApplication::ArgvReceived()\n"
162		"args: c d e\n"
163		"BApplication::ReadyToRun()\n"
164		"BApplication::QuitRequested()\n"
165		"BApplication::Run() done: 1\n";
166	// run the apps
167	AppRunner runner1, runner2;
168	CHK(runner1.Run("AppRunTestApp2", "a b") == B_OK);
169	CHK(runner2.Run("AppRunTestApp2", "c d e") == B_OK);
170	runner1.WaitFor(true);
171	runner2.WaitFor(true);
172	// get the outputs and compare the results
173	check_output(runner1, output1);
174	check_output(runner2, output2);
175}
176
177/*
178	thread_id Run()
179	@case 5			launch the app two times: B_SINGLE_LAUNCH | B_ARGV_ONLY,
180					no command line args, send B_QUIT_REQUESTED to both of them
181	@results		first app:	ReadyToRun(), QuitRequested()
182					second app:	quits
183*/
184void AppRunTester::RunTest5()
185{
186	BApplication app("application/x-vnd.obos-app-run-test");
187	const char *output1 =
188		"error: 0\n"
189		"InitCheck(): 0\n"
190		"BApplication::ReadyToRun()\n"
191		"BApplication::QuitRequested()\n"
192		"BApplication::Run() done: 1\n";
193	const char *output2 =
194		"error: 80002004\n"
195		"InitCheck(): 80002004\n";
196	// run the apps
197	AppRunner runner1, runner2;
198	CHK(runner1.Run("AppRunTestApp3") == B_OK);
199	CHK(runner2.Run("AppRunTestApp3") == B_OK);
200	runner1.WaitFor(true);
201	runner2.WaitFor(true);
202	// get the outputs and compare the results
203	check_output(runner1, output1);
204	check_output(runner2, output2);
205}
206
207/*
208	thread_id Run()
209	@case 6			launch the app two times: B_SINGLE_LAUNCH | B_ARGV_ONLY,
210					command line args, send B_QUIT_REQUESTED to both of them
211	@results		first app:	ArgvReceived(), ReadyToRun(), QuitRequested()
212					second app:	quits
213*/
214void AppRunTester::RunTest6()
215{
216	BApplication app("application/x-vnd.obos-app-run-test");
217	const char *output1 =
218		"error: 0\n"
219		"InitCheck(): 0\n"
220		"BApplication::ArgvReceived()\n"
221		"args: a b\n"
222		"BApplication::ReadyToRun()\n"
223		"BApplication::QuitRequested()\n"
224		"BApplication::Run() done: 1\n";
225	const char *output2 =
226		"error: 80002004\n"
227		"InitCheck(): 80002004\n";
228	// run the apps
229	AppRunner runner1, runner2;
230	CHK(runner1.Run("AppRunTestApp3", "a b") == B_OK);
231	CHK(runner2.Run("AppRunTestApp3", "c d e") == B_OK);
232	runner1.WaitFor(true);
233	runner2.WaitFor(true);
234	// get the outputs and compare the results
235	check_output(runner1, output1);
236	check_output(runner2, output2);
237}
238
239/*
240	thread_id Run()
241	@case 7			launch the app two times: B_SINGLE_LAUNCH,
242					no command line args, send B_QUIT_REQUESTED to both of them
243	@results		first app:	ReadyToRun(), QuitRequested()
244					second app:	quits
245*/
246void AppRunTester::RunTest7()
247{
248	BApplication app("application/x-vnd.obos-app-run-test");
249	const char *output1 =
250		"error: 0\n"
251		"InitCheck(): 0\n"
252		"BApplication::ReadyToRun()\n"
253		"BApplication::QuitRequested()\n"
254		"BApplication::Run() done: 1\n";
255	const char *output2 =
256		"error: 80002004\n"
257		"InitCheck(): 80002004\n";
258	// run the apps
259	AppRunner runner1, runner2;
260	CHK(runner1.Run("AppRunTestApp4") == B_OK);
261	CHK(runner2.Run("AppRunTestApp4") == B_OK);
262	runner1.WaitFor(true);
263	runner2.WaitFor(true);
264	// get the outputs and compare the results
265	check_output(runner1, output1);
266	check_output(runner2, output2);
267}
268
269/*
270	thread_id Run()
271	@case 8			launch the app two times: B_SINGLE_LAUNCH,
272					command line args, send B_QUIT_REQUESTED to both of them
273	@results		first app:	ArgvReceived(), ReadyToRun(), ArgvReceived(),
274					QuitRequested()
275					second app:	quits
276*/
277void AppRunTester::RunTest8()
278{
279	BApplication app("application/x-vnd.obos-app-run-test");
280	const char *output1 =
281		"error: 0\n"
282		"InitCheck(): 0\n"
283		"BApplication::ArgvReceived()\n"
284		"args: a b\n"
285		"BApplication::ReadyToRun()\n"
286		"BApplication::ArgvReceived()\n"
287		"args: c d e\n"
288		"BApplication::QuitRequested()\n"
289		"BApplication::Run() done: 1\n";
290	const char *output2 =
291		"error: 80002004\n"
292		"InitCheck(): 80002004\n";
293	// run the apps
294	AppRunner runner1, runner2;
295	CHK(runner1.Run("AppRunTestApp4", "a b") == B_OK);
296	CHK(runner2.Run("AppRunTestApp4", "c d e") == B_OK);
297	runner1.WaitFor(true);
298	runner2.WaitFor(true);
299	// get the outputs and compare the results
300	check_output(runner1, output1);
301	check_output(runner2, output2);
302}
303
304/*
305	thread_id Run()
306	@case 9			launch two apps with the same signature:
307					B_SINGLE_LAUNCH | B_ARGV_ONLY,
308					no command line args, send B_QUIT_REQUESTED to both of them
309	@results		first app:	ReadyToRun(), QuitRequested()
310					second app:	ReadyToRun(), QuitRequested()
311*/
312void AppRunTester::RunTest9()
313{
314	BApplication app("application/x-vnd.obos-app-run-test");
315	const char *output1 =
316		"error: 0\n"
317		"InitCheck(): 0\n"
318		"BApplication::ReadyToRun()\n"
319		"BApplication::QuitRequested()\n"
320		"BApplication::Run() done: 1\n";
321	const char *output2 = output1;
322	// run the apps
323	AppRunner runner1, runner2;
324	CHK(runner1.Run("AppRunTestApp3") == B_OK);
325	CHK(runner2.Run("AppRunTestApp3a") == B_OK);
326	runner1.WaitFor(true);
327	runner2.WaitFor(true);
328	// get the outputs and compare the results
329	check_output(runner1, output1);
330	check_output(runner2, output2);
331}
332
333/*
334	thread_id Run()
335	@case 10		launch two apps with the same signature:
336					B_SINGLE_LAUNCH | B_ARGV_ONLY,
337					command line args, send B_QUIT_REQUESTED to both of them
338	@results		first app:	ArgvReceived(), ReadyToRun(), QuitRequested()
339					second app:	ArgvReceived(), ReadyToRun(), QuitRequested()
340*/
341void AppRunTester::RunTest10()
342{
343	BApplication app("application/x-vnd.obos-app-run-test");
344	const char *output1 =
345		"error: 0\n"
346		"InitCheck(): 0\n"
347		"BApplication::ArgvReceived()\n"
348		"args: a b\n"
349		"BApplication::ReadyToRun()\n"
350		"BApplication::QuitRequested()\n"
351		"BApplication::Run() done: 1\n";
352	const char *output2 =
353		"error: 0\n"
354		"InitCheck(): 0\n"
355		"BApplication::ArgvReceived()\n"
356		"args: c d e\n"
357		"BApplication::ReadyToRun()\n"
358		"BApplication::QuitRequested()\n"
359		"BApplication::Run() done: 1\n";
360	// run the apps
361	AppRunner runner1, runner2;
362	CHK(runner1.Run("AppRunTestApp3", "a b") == B_OK);
363	CHK(runner2.Run("AppRunTestApp3a", "c d e") == B_OK);
364	runner1.WaitFor(true);
365	runner2.WaitFor(true);
366	// get the outputs and compare the results
367	check_output(runner1, output1);
368	check_output(runner2, output2);
369}
370
371/*
372	thread_id Run()
373	@case 11		launch two apps with the same signature:
374					B_SINGLE_LAUNCH,
375					no command line args, send B_QUIT_REQUESTED to both of them
376	@results		first app:	ReadyToRun(), QuitRequested()
377					second app:	ReadyToRun(), QuitRequested()
378*/
379void AppRunTester::RunTest11()
380{
381	BApplication app("application/x-vnd.obos-app-run-test");
382	const char *output1 =
383		"error: 0\n"
384		"InitCheck(): 0\n"
385		"BApplication::ReadyToRun()\n"
386		"BApplication::QuitRequested()\n"
387		"BApplication::Run() done: 1\n";
388	const char *output2 = output1;
389	// run the apps
390	AppRunner runner1, runner2;
391	CHK(runner1.Run("AppRunTestApp4") == B_OK);
392	CHK(runner2.Run("AppRunTestApp4a") == B_OK);
393	runner1.WaitFor(true);
394	runner2.WaitFor(true);
395	// get the outputs and compare the results
396	check_output(runner1, output1);
397	check_output(runner2, output2);
398}
399
400/*
401	thread_id Run()
402	@case 12		launch two apps with the same signature:
403					B_SINGLE_LAUNCH,
404					command line args, send B_QUIT_REQUESTED to both of them
405	@results		first app:	ArgvReceived(), ReadyToRun(), QuitRequested()
406					second app:	ArgvReceived(), ReadyToRun(), QuitRequested()
407*/
408void AppRunTester::RunTest12()
409{
410	BApplication app("application/x-vnd.obos-app-run-test");
411	const char *output1 =
412		"error: 0\n"
413		"InitCheck(): 0\n"
414		"BApplication::ArgvReceived()\n"
415		"args: a b\n"
416		"BApplication::ReadyToRun()\n"
417		"BApplication::QuitRequested()\n"
418		"BApplication::Run() done: 1\n";
419	const char *output2 =
420		"error: 0\n"
421		"InitCheck(): 0\n"
422		"BApplication::ArgvReceived()\n"
423		"args: c d e\n"
424		"BApplication::ReadyToRun()\n"
425		"BApplication::QuitRequested()\n"
426		"BApplication::Run() done: 1\n";
427	// run the apps
428	AppRunner runner1, runner2;
429	CHK(runner1.Run("AppRunTestApp4", "a b") == B_OK);
430	CHK(runner2.Run("AppRunTestApp4a", "c d e") == B_OK);
431	runner1.WaitFor(true);
432	runner2.WaitFor(true);
433	// get the outputs and compare the results
434	check_output(runner1, output1);
435	check_output(runner2, output2);
436}
437
438/*
439	thread_id Run()
440	@case 13		launch the app two times: B_EXCLUSIVE_LAUNCH | B_ARGV_ONLY,
441					no command line args, send B_QUIT_REQUESTED to both of them
442	@results		first app:	ReadyToRun(), QuitRequested()
443					second app:	quits
444*/
445void AppRunTester::RunTest13()
446{
447	BApplication app("application/x-vnd.obos-app-run-test");
448	const char *output1 =
449		"error: 0\n"
450		"InitCheck(): 0\n"
451		"BApplication::ReadyToRun()\n"
452		"BApplication::QuitRequested()\n"
453		"BApplication::Run() done: 1\n";
454	const char *output2 =
455		"error: 80002004\n"
456		"InitCheck(): 80002004\n";
457	// run the apps
458	AppRunner runner1, runner2;
459	CHK(runner1.Run("AppRunTestApp5") == B_OK);
460	CHK(runner2.Run("AppRunTestApp5") == B_OK);
461	runner1.WaitFor(true);
462	runner2.WaitFor(true);
463	// get the outputs and compare the results
464	check_output(runner1, output1);
465	check_output(runner2, output2);
466}
467
468/*
469	thread_id Run()
470	@case 14		launch the app two times: B_EXCLUSIVE_LAUNCH | B_ARGV_ONLY,
471					command line args, send B_QUIT_REQUESTED to both of them
472	@results		first app:	ArgvReceived(), ReadyToRun(), QuitRequested()
473					second app:	quits
474*/
475void AppRunTester::RunTest14()
476{
477	BApplication app("application/x-vnd.obos-app-run-test");
478	const char *output1 =
479		"error: 0\n"
480		"InitCheck(): 0\n"
481		"BApplication::ArgvReceived()\n"
482		"args: a b\n"
483		"BApplication::ReadyToRun()\n"
484		"BApplication::QuitRequested()\n"
485		"BApplication::Run() done: 1\n";
486	const char *output2 =
487		"error: 80002004\n"
488		"InitCheck(): 80002004\n";
489	// run the apps
490	AppRunner runner1, runner2;
491	CHK(runner1.Run("AppRunTestApp5", "a b") == B_OK);
492	CHK(runner2.Run("AppRunTestApp5", "c d e") == B_OK);
493	runner1.WaitFor(true);
494	runner2.WaitFor(true);
495	// get the outputs and compare the results
496	check_output(runner1, output1);
497	check_output(runner2, output2);
498}
499
500/*
501	thread_id Run()
502	@case 15		launch the app two times: B_EXCLUSIVE_LAUNCH,
503					no command line args, send B_QUIT_REQUESTED to both of them
504	@results		first app:	ReadyToRun(), QuitRequested()
505					second app:	quits
506*/
507void AppRunTester::RunTest15()
508{
509	BApplication app("application/x-vnd.obos-app-run-test");
510	const char *output1 =
511		"error: 0\n"
512		"InitCheck(): 0\n"
513		"BApplication::ReadyToRun()\n"
514		"BApplication::QuitRequested()\n"
515		"BApplication::Run() done: 1\n";
516	const char *output2 =
517		"error: 80002004\n"
518		"InitCheck(): 80002004\n";
519	// run the apps
520	AppRunner runner1, runner2;
521	CHK(runner1.Run("AppRunTestApp6") == B_OK);
522	CHK(runner2.Run("AppRunTestApp6") == B_OK);
523	runner1.WaitFor(true);
524	runner2.WaitFor(true);
525	// get the outputs and compare the results
526	check_output(runner1, output1);
527	check_output(runner2, output2);
528}
529
530/*
531	thread_id Run()
532	@case 16		launch the app two times: B_EXCLUSIVE_LAUNCH,
533					command line args, send B_QUIT_REQUESTED to both of them
534	@results		first app:	ArgvReceived(), ReadyToRun(), ArgvReceived(),
535					QuitRequested()
536					second app:	quits
537*/
538void AppRunTester::RunTest16()
539{
540	BApplication app("application/x-vnd.obos-app-run-test");
541	const char *output1 =
542		"error: 0\n"
543		"InitCheck(): 0\n"
544		"BApplication::ArgvReceived()\n"
545		"args: a b\n"
546		"BApplication::ReadyToRun()\n"
547		"BApplication::ArgvReceived()\n"
548		"args: c d e\n"
549		"BApplication::QuitRequested()\n"
550		"BApplication::Run() done: 1\n";
551	const char *output2 =
552		"error: 80002004\n"
553		"InitCheck(): 80002004\n";
554	// run the apps
555	AppRunner runner1, runner2;
556	CHK(runner1.Run("AppRunTestApp6", "a b") == B_OK);
557	CHK(runner2.Run("AppRunTestApp6", "c d e") == B_OK);
558	runner1.WaitFor(true);
559	runner2.WaitFor(true);
560	// get the outputs and compare the results
561	check_output(runner1, output1);
562	check_output(runner2, output2);
563}
564
565/*
566	thread_id Run()
567	@case 17		launch two apps with the same signature:
568					B_EXCLUSIVE_LAUNCH | B_ARGV_ONLY,
569					no command line args, send B_QUIT_REQUESTED to both of them
570	@results		first app:	ReadyToRun(), QuitRequested()
571					second app:	quits
572*/
573void AppRunTester::RunTest17()
574{
575	BApplication app("application/x-vnd.obos-app-run-test");
576	const char *output1 =
577		"error: 0\n"
578		"InitCheck(): 0\n"
579		"BApplication::ReadyToRun()\n"
580		"BApplication::QuitRequested()\n"
581		"BApplication::Run() done: 1\n";
582	const char *output2 =
583		"error: 80002004\n"
584		"InitCheck(): 80002004\n";
585	// run the apps
586	AppRunner runner1, runner2;
587	CHK(runner1.Run("AppRunTestApp5") == B_OK);
588	CHK(runner2.Run("AppRunTestApp5a") == B_OK);
589	runner1.WaitFor(true);
590	runner2.WaitFor(true);
591	// get the outputs and compare the results
592	check_output(runner1, output1);
593	check_output(runner2, output2);
594}
595
596/*
597	thread_id Run()
598	@case 18		launch two apps with the same signature:
599					B_EXCLUSIVE_LAUNCH | B_ARGV_ONLY,
600					command line args, send B_QUIT_REQUESTED to both of them
601	@results		first app:	ArgvReceived(), ReadyToRun(), QuitRequested()
602					second app:	quits
603*/
604void AppRunTester::RunTest18()
605{
606	BApplication app("application/x-vnd.obos-app-run-test");
607	const char *output1 =
608		"error: 0\n"
609		"InitCheck(): 0\n"
610		"BApplication::ArgvReceived()\n"
611		"args: a b\n"
612		"BApplication::ReadyToRun()\n"
613		"BApplication::QuitRequested()\n"
614		"BApplication::Run() done: 1\n";
615	const char *output2 =
616		"error: 80002004\n"
617		"InitCheck(): 80002004\n";
618	// run the apps
619	AppRunner runner1, runner2;
620	CHK(runner1.Run("AppRunTestApp5", "a b") == B_OK);
621	CHK(runner2.Run("AppRunTestApp5a", "c d e") == B_OK);
622	runner1.WaitFor(true);
623	runner2.WaitFor(true);
624	// get the outputs and compare the results
625	check_output(runner1, output1);
626	check_output(runner2, output2);
627}
628
629/*
630	thread_id Run()
631	@case 19		launch two apps with the same signature: B_EXCLUSIVE_LAUNCH,
632					no command line args, send B_QUIT_REQUESTED to both of them
633	@results		first app:	ReadyToRun(), QuitRequested()
634					second app:	quits
635*/
636void AppRunTester::RunTest19()
637{
638	BApplication app("application/x-vnd.obos-app-run-test");
639	const char *output1 =
640		"error: 0\n"
641		"InitCheck(): 0\n"
642		"BApplication::ReadyToRun()\n"
643		"BApplication::QuitRequested()\n"
644		"BApplication::Run() done: 1\n";
645	const char *output2 =
646		"error: 80002004\n"
647		"InitCheck(): 80002004\n";
648	// run the apps
649	AppRunner runner1, runner2;
650	CHK(runner1.Run("AppRunTestApp6") == B_OK);
651	CHK(runner2.Run("AppRunTestApp6a") == B_OK);
652	runner1.WaitFor(true);
653	runner2.WaitFor(true);
654	// get the outputs and compare the results
655	check_output(runner1, output1);
656	check_output(runner2, output2);
657}
658
659/*
660	thread_id Run()
661	@case 20		launch two apps with the same signature: B_EXCLUSIVE_LAUNCH,
662					command line args, send B_QUIT_REQUESTED to both of them
663	@results		first app:	ArgvReceived(), ReadyToRun(), ArgvReceived(),
664					QuitRequested()
665					second app:	quits
666*/
667void AppRunTester::RunTest20()
668{
669	BApplication app("application/x-vnd.obos-app-run-test");
670	const char *output1 =
671		"error: 0\n"
672		"InitCheck(): 0\n"
673		"BApplication::ArgvReceived()\n"
674		"args: a b\n"
675		"BApplication::ReadyToRun()\n"
676		"BApplication::ArgvReceived()\n"
677		"args: c d e\n"
678		"BApplication::QuitRequested()\n"
679		"BApplication::Run() done: 1\n";
680	const char *output2 =
681		"error: 80002004\n"
682		"InitCheck(): 80002004\n";
683	// run the apps
684	AppRunner runner1, runner2;
685	CHK(runner1.Run("AppRunTestApp6", "a b") == B_OK);
686	CHK(runner2.Run("AppRunTestApp6a", "c d e") == B_OK);
687	runner1.WaitFor(true);
688	runner2.WaitFor(true);
689	// get the outputs and compare the results
690	check_output(runner1, output1);
691	check_output(runner2, output2);
692}
693
694/*
695	thread_id Run()
696	@case 21		launch the app two times: first: B_EXCLUSIVE_LAUNCH,
697					second: B_EXCLUSIVE_LAUNCH | B_ARGV_ONLY,
698					command line args, send B_QUIT_REQUESTED to both of them
699	@results		first app:	ArgvReceived(), ReadyToRun(), ArgvReceived(),
700					QuitRequested()
701					second app:	quits
702*/
703void AppRunTester::RunTest21()
704{
705	BApplication app("application/x-vnd.obos-app-run-test");
706	const char *output1 =
707		"error: 0\n"
708		"InitCheck(): 0\n"
709		"BApplication::ArgvReceived()\n"
710		"args: a b\n"
711		"BApplication::ReadyToRun()\n"
712		"BApplication::ArgvReceived()\n"
713		"args: c d e\n"
714		"BApplication::QuitRequested()\n"
715		"BApplication::Run() done: 1\n";
716	const char *output2 =
717		"error: 80002004\n"
718		"InitCheck(): 80002004\n";
719	// run the apps
720	AppRunner runner1, runner2;
721	CHK(runner1.Run("AppRunTestApp6", "a b") == B_OK);
722	CHK(runner2.Run("AppRunTestApp5", "c d e") == B_OK);
723	runner1.WaitFor(true);
724	runner2.WaitFor(true);
725	// get the outputs and compare the results
726	check_output(runner1, output1);
727	check_output(runner2, output2);
728}
729
730/*
731	thread_id Run()
732	@case 22		launch the app two times:
733					first: B_EXCLUSIVE_LAUNCH | B_ARGV_ONLY,
734					second: B_EXCLUSIVE_LAUNCH,
735					command line args, send B_QUIT_REQUESTED to both of them
736	@results		first app:	ArgvReceived(), ReadyToRun(), QuitRequested()
737					second app:	quits
738*/
739void AppRunTester::RunTest22()
740{
741	BApplication app("application/x-vnd.obos-app-run-test");
742	const char *output1 =
743		"error: 0\n"
744		"InitCheck(): 0\n"
745		"BApplication::ArgvReceived()\n"
746		"args: a b\n"
747		"BApplication::ReadyToRun()\n"
748		"BApplication::QuitRequested()\n"
749		"BApplication::Run() done: 1\n";
750	const char *output2 =
751		"error: 80002004\n"
752		"InitCheck(): 80002004\n";
753	// run the apps
754	AppRunner runner1, runner2;
755	CHK(runner1.Run("AppRunTestApp5", "a b") == B_OK);
756	CHK(runner2.Run("AppRunTestApp6", "c d e") == B_OK);
757	runner1.WaitFor(true);
758	runner2.WaitFor(true);
759	// get the outputs and compare the results
760	check_output(runner1, output1);
761	check_output(runner2, output2);
762}
763
764
765Test* AppRunTester::Suite()
766{
767	TestSuite* SuiteOfTests = new TestSuite;
768
769	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest1);
770	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest2);
771	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest3);
772	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest4);
773	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest5);
774	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest6);
775	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest7);
776	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest8);
777	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest9);
778	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest10);
779	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest11);
780	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest12);
781	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest13);
782	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest14);
783	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest15);
784	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest16);
785	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest17);
786	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest18);
787	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest19);
788	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest20);
789	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest21);
790	ADD_TEST4(BApplication, SuiteOfTests, AppRunTester, RunTest22);
791
792	return SuiteOfTests;
793}
794
795
796
797