1 //------------------------------------------------------------------------------
4 //------------------------------------------------------------------------------
6 // Standard Includes -----------------------------------------------------------
9 // System Includes -------------------------------------------------------------
17 // Project Includes ------------------------------------------------------------
18 #include <TestShell.h>
19 #include <TestUtils.h>
20 #include <cppunit/TestAssert.h>
22 // Local Includes --------------------------------------------------------------
23 #include "AppRunner.h"
24 #include "IsRunningTester.h"
26 // Local Defines ---------------------------------------------------------------
28 // Globals ---------------------------------------------------------------------
30 //------------------------------------------------------------------------------
33 bool IsRunning(const char *signature) const
34 @case 1 signature is NULL
35 @results Should return false.
37 void IsRunningTester::IsRunningTestA1()
39 // R5: crashes when passing a NULL signature
42 CHK(roster
.IsRunning((const char*)NULL
) == false);
47 bool IsRunning(const char *signature) const
48 @case 2 signature is not NULL, but no app with this signature is
50 @results Should return false.
52 void IsRunningTester::IsRunningTestA2()
55 CHK(roster
.IsRunning("application/x-vnd.obos-app-run-testapp1") == false);
59 bool IsRunning(const char *signature) const
60 @case 3 signature is not NULL and an (two) app(s) with this
61 signature is (are) running; quit one; quit the second one
62 @results Should return true; true; false.
64 void IsRunningTester::IsRunningTestA3()
66 // run the remote apps
67 AppRunner
runner1(true);
68 AppRunner
runner2(true);
69 CHK(runner1
.Run("AppRunTestApp1") == B_OK
);
70 CHK(runner2
.Run("AppRunTestApp1") == B_OK
);
71 // create the BRoster and perform the tests
73 CHK(roster
.IsRunning("application/x-vnd.obos-app-run-testapp1") == true);
75 runner1
.WaitFor(true);
76 CHK(roster
.IsRunning("application/x-vnd.obos-app-run-testapp1") == true);
78 runner2
.WaitFor(true);
79 CHK(roster
.IsRunning("application/x-vnd.obos-app-run-testapp1") == false);
83 bool IsRunning(entry_ref *ref) const
85 @results Should return false.
87 void IsRunningTester::IsRunningTestB1()
89 // R5: crashes when passing a NULL ref
92 CHK(roster
.IsRunning((entry_ref
*)NULL
) == false);
97 bool IsRunning(entry_ref *ref) const
98 @case 2 ref is not NULL, but no app with this ref is running
99 @results Should return false.
101 void IsRunningTester::IsRunningTestB2()
105 CHK(find_test_app("AppRunTestApp1", &ref
) == B_OK
);
106 CHK(roster
.IsRunning(&ref
) == false);
110 bool IsRunning(entry_ref *ref) const
111 @case 3 ref is not NULL and an (two) app(s) with this ref is (are)
112 running; quit one; quit the second one
113 @results Should return true; true; false.
115 void IsRunningTester::IsRunningTestB3()
118 CHK(find_test_app("AppRunTestApp1", &ref
) == B_OK
);
119 // run the remote apps
120 AppRunner
runner1(true);
121 AppRunner
runner2(true);
122 CHK(runner1
.Run("AppRunTestApp1") == B_OK
);
123 CHK(runner2
.Run("AppRunTestApp1") == B_OK
);
124 // create the BRoster and perform the tests
126 CHK(roster
.IsRunning(&ref
) == true);
128 runner1
.WaitFor(true);
129 CHK(roster
.IsRunning(&ref
) == true);
131 runner2
.WaitFor(true);
132 CHK(roster
.IsRunning(&ref
) == false);
136 Test
* IsRunningTester::Suite()
138 TestSuite
* SuiteOfTests
= new TestSuite
;
140 ADD_TEST4(BRoster
, SuiteOfTests
, IsRunningTester
, IsRunningTestA1
);
141 ADD_TEST4(BRoster
, SuiteOfTests
, IsRunningTester
, IsRunningTestA2
);
142 ADD_TEST4(BRoster
, SuiteOfTests
, IsRunningTester
, IsRunningTestA3
);
144 ADD_TEST4(BRoster
, SuiteOfTests
, IsRunningTester
, IsRunningTestB1
);
145 ADD_TEST4(BRoster
, SuiteOfTests
, IsRunningTester
, IsRunningTestB2
);
146 ADD_TEST4(BRoster
, SuiteOfTests
, IsRunningTester
, IsRunningTestB3
);