Added NULL parameter tests for BMessageRunner::GetInfo().
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1510 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -67,6 +67,7 @@ CommonTestLib libapptest.so
|
||||
# BMessageRunner
|
||||
MessageRunnerTest.cpp
|
||||
BMessageRunnerTester.cpp
|
||||
GetInfoTester.cpp
|
||||
MessageRunnerTestHelpers.cpp
|
||||
SetCountTester.cpp
|
||||
SetIntervalTester.cpp
|
||||
|
||||
@@ -140,3 +140,13 @@ case 7: object is properly initialized and has still some messages to deliver,
|
||||
InitCheck() should return B_OK.
|
||||
GetInfo() should return B_OK and the new count.
|
||||
The timer is NOT reset. Unlimited number of messages.
|
||||
|
||||
status_t GetInfo(bigtime_t *interval, int32 *count) const
|
||||
case 1: object is properly initialized, interval or count are NULL =>
|
||||
Should return B_OK.
|
||||
InitCheck() should return B_OK.
|
||||
case 2: object is not properly initialized, interval or count are NULL =>
|
||||
Should return B_BAD_VALUE.
|
||||
InitCheck() should return B_ERROR.
|
||||
Other cases are side effects of other methods' tests.
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.4 KiB |
@@ -0,0 +1,101 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// GetInfoTester.cpp
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
#include <stdio.h>
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <Application.h>
|
||||
#include <Handler.h>
|
||||
#include <Looper.h>
|
||||
#include <Message.h>
|
||||
#include <MessageRunner.h>
|
||||
#include <Messenger.h>
|
||||
#include <OS.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
#include <TestShell.h>
|
||||
#include <TestUtils.h>
|
||||
#include <cppunit/TestAssert.h>
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
#include "MessageRunnerTestHelpers.h"
|
||||
#include "GetInfoTester.h"
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
static const char *kTesterSignature
|
||||
= "application/x-vnd.obos-messagerunner-getinfo-test";
|
||||
|
||||
static const bigtime_t kMinTimeInterval = 50000;
|
||||
|
||||
/*
|
||||
status_t GetInfo(bigtime_t *interval, int32 *count) const
|
||||
@case 1 object is properly initialized, interval or count are NULL
|
||||
@results Should return B_OK.
|
||||
InitCheck() should return B_OK.
|
||||
*/
|
||||
void GetInfoTester::GetInfo1()
|
||||
{
|
||||
// R5: crashes when passing a NULL parameter.
|
||||
#ifndef TEST_R5
|
||||
MessageRunnerTestApp app(kTesterSignature);
|
||||
BMessenger target;
|
||||
BMessage message(MSG_RUNNER_MESSAGE);
|
||||
bigtime_t interval = 100000;
|
||||
int32 count = 5;
|
||||
BMessageRunner runner(target, &message, interval, count);
|
||||
CHK(runner.InitCheck() == B_OK);
|
||||
bigtime_t readInterval = 0;
|
||||
int32 readCount = 0;
|
||||
CHK(runner.GetInfo(&readInterval, NULL) == B_OK);
|
||||
CHK(readInterval == interval);
|
||||
CHK(runner.GetInfo(NULL, &readCount) == B_OK);
|
||||
CHK(readCount == count);
|
||||
CHK(runner.GetInfo(NULL, NULL) == B_OK);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
status_t GetInfo(bigtime_t *interval, int32 *count) const
|
||||
@case 2 object is not properly initialized, interval or count are
|
||||
NULL
|
||||
@results Should return B_BAD_VALUE.
|
||||
InitCheck() should return B_ERROR.
|
||||
*/
|
||||
void GetInfoTester::GetInfo2()
|
||||
{
|
||||
// R5: crashes when passing a NULL parameter.
|
||||
#ifndef TEST_R5
|
||||
MessageRunnerTestApp app(kTesterSignature);
|
||||
BMessenger target;
|
||||
BMessage message(MSG_RUNNER_MESSAGE);
|
||||
bigtime_t interval = 100000;
|
||||
int32 count = 0;
|
||||
BMessageRunner runner(target, &message, interval, count);
|
||||
CHK(runner.InitCheck() == B_ERROR);
|
||||
bigtime_t readInterval = 0;
|
||||
int32 readCount = 0;
|
||||
CHK(runner.GetInfo(&readInterval, NULL) == B_BAD_VALUE);
|
||||
CHK(runner.GetInfo(NULL, &readCount) == B_BAD_VALUE);
|
||||
CHK(runner.GetInfo(NULL, NULL) == B_BAD_VALUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Test* GetInfoTester::Suite()
|
||||
{
|
||||
TestSuite* SuiteOfTests = new TestSuite;
|
||||
|
||||
ADD_TEST4(BMessageRunner, SuiteOfTests, GetInfoTester, GetInfo1);
|
||||
ADD_TEST4(BMessageRunner, SuiteOfTests, GetInfoTester, GetInfo2);
|
||||
|
||||
return SuiteOfTests;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// GetInfoTester.h
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef GET_INFO_TESTER_H
|
||||
#define GET_INFO_TESTER_H
|
||||
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
#include "../common.h"
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
|
||||
class GetInfoTester : public TestCase
|
||||
{
|
||||
public:
|
||||
GetInfoTester() {;}
|
||||
GetInfoTester(std::string name) : TestCase(name) {;}
|
||||
|
||||
void GetInfo1();
|
||||
void GetInfo2();
|
||||
|
||||
static Test* Suite();
|
||||
};
|
||||
|
||||
#endif // GET_INFO_TESTER_H
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "../common.h"
|
||||
#include "BMessageRunnerTester.h"
|
||||
#include "GetInfoTester.h"
|
||||
#include "SetCountTester.h"
|
||||
#include "SetIntervalTester.h"
|
||||
|
||||
@@ -7,6 +8,7 @@ CppUnit::Test* MessageRunnerTestSuite()
|
||||
{
|
||||
CppUnit::TestSuite *testSuite = new CppUnit::TestSuite();
|
||||
|
||||
testSuite->addTest(GetInfoTester::Suite());
|
||||
testSuite->addTest(SetCountTester::Suite());
|
||||
testSuite->addTest(SetIntervalTester::Suite());
|
||||
testSuite->addTest(TBMessageRunnerTester::Suite());
|
||||
|
||||
Reference in New Issue
Block a user