1 //------------------------------------------------------------------------------
4 //------------------------------------------------------------------------------
6 // Standard Includes -----------------------------------------------------------
9 // System Includes -------------------------------------------------------------
10 #include <Application.h>
14 #include <MessageRunner.h>
15 #include <Messenger.h>
18 // Project Includes ------------------------------------------------------------
19 #include <TestShell.h>
20 #include <TestUtils.h>
21 #include <cppunit/TestAssert.h>
23 // Local Includes --------------------------------------------------------------
24 #include "MessageRunnerTestHelpers.h"
25 #include "GetInfoTester.h"
27 // Local Defines ---------------------------------------------------------------
29 // Globals ---------------------------------------------------------------------
31 //------------------------------------------------------------------------------
34 static const char *kTesterSignature
35 = "application/x-vnd.obos-messagerunner-getinfo-test";
38 static const bigtime_t kMinTimeInterval
= 50000;
41 status_t GetInfo(bigtime_t *interval, int32 *count) const
42 @case 1 object is properly initialized, interval or count are NULL
43 @results Should return B_OK.
44 InitCheck() should return B_OK.
46 void GetInfoTester::GetInfo1()
48 // R5: crashes when passing a NULL parameter.
50 MessageRunnerTestApp
app(kTesterSignature
);
52 BMessage
message(MSG_RUNNER_MESSAGE
);
53 bigtime_t interval
= 100000;
55 BMessageRunner
runner(target
, &message
, interval
, count
);
56 CHK(runner
.InitCheck() == B_OK
);
57 bigtime_t readInterval
= 0;
59 CHK(runner
.GetInfo(&readInterval
, NULL
) == B_OK
);
60 CHK(readInterval
== interval
);
61 CHK(runner
.GetInfo(NULL
, &readCount
) == B_OK
);
62 CHK(readCount
== count
);
63 CHK(runner
.GetInfo(NULL
, NULL
) == B_OK
);
68 status_t GetInfo(bigtime_t *interval, int32 *count) const
69 @case 2 object is not properly initialized, interval or count are
71 @results Should return B_BAD_VALUE.
72 InitCheck() should return B_ERROR.
74 void GetInfoTester::GetInfo2()
76 // R5: crashes when passing a NULL parameter.
78 MessageRunnerTestApp
app(kTesterSignature
);
80 BMessage
message(MSG_RUNNER_MESSAGE
);
81 bigtime_t interval
= 100000;
83 BMessageRunner
runner(target
, &message
, interval
, count
);
84 CHK(runner
.InitCheck() == B_ERROR
);
85 bigtime_t readInterval
= 0;
87 CHK(runner
.GetInfo(&readInterval
, NULL
) == B_BAD_VALUE
);
88 CHK(runner
.GetInfo(NULL
, &readCount
) == B_BAD_VALUE
);
89 CHK(runner
.GetInfo(NULL
, NULL
) == B_BAD_VALUE
);
94 Test
* GetInfoTester::Suite()
96 TestSuite
* SuiteOfTests
= new TestSuite
;
98 ADD_TEST4(BMessageRunner
, SuiteOfTests
, GetInfoTester
, GetInfo1
);
99 ADD_TEST4(BMessageRunner
, SuiteOfTests
, GetInfoTester
, GetInfo2
);