Added BRoster test cases, for today only for IsRunning().

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@659 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2002-08-08 22:05:09 +00:00
parent c2e8b5572c
commit 28d519fe4e
5 changed files with 302 additions and 0 deletions

View File

@ -0,0 +1,90 @@
BRoster()
none
bool IsRunning(const char *signature) const
case 1: signature is NULL =>
Should return false.
case 2: signature is not NULL, but no app with this signature is running =>
Should return false.
case 3: signature is not NULL and an (two) app(s) with this signature is (are)
running; quit one; quit the second one =>
Should return true; true; false.
bool IsRunning(entry_ref *ref) const
case 1: ref is NULL =>
Should return false.
case 2: ref is not NULL, but no app with this ref is running =>
Should return false.
case 3: ref is not NULL and an (two) app(s) with this ref is (are)
running; quit one; quit the second one =>
Should return true; true; false.
team_id TeamFor(const char *signature) const
case 1: signature is NULL =>
Should return B_BAD_VALUE.
case 2: signature is not NULL, but no app with this signature is running =>
Should return B_ERROR.
case 3: signature is not NULL and an (two) app(s) with this signature is (are)
running; quit one; quit the second one =>
Should return the ID of one of the teams; the ID of the second teams;
B_ERROR.
team_id TeamFor(entry_ref *ref) const
case 1: ref is NULL =>
Should return B_BAD_VALUE.
case 2: ref is not NULL, but no app with this ref is running =>
Should return B_ERROR.
case 3: ref is not NULL and an (two) app(s) with this ref is (are)
running; quit one; quit the second one =>
Should return the ID of one of the teams; the ID of the second teams;
B_ERROR.
status_t GetAppInfo(const char *signature, app_info *info) const
case 1: signature is NULL or info is NULL =>
Should return B_BAD_VALUE.
case 2: signature/info are not NULL, but no app with this signature is
running =>
Should return B_ERROR.
case 3: signature/info are not NULL and an (two) app(s) with this signature
is (are) running; quit one; quit the second one =>
Should
- fill the app info with the data of one of the apps and return B_OK;
- fill the app info with the data of the second apps and return B_OK;
- return B_ERROR.
status_t GetAppInfo(entry_ref *ref, app_info *info) const
case 1: ref is NULL or info is NULL =>
Should return B_BAD_VALUE.
case 2: ref/info are not NULL, but no app with this ref is running =>
Should return B_ERROR.
case 3: ref/info are not NULL and an (two) app(s) with this ref
is (are) running; quit one; quit the second one =>
Should
- fill the app info with the data of one of the apps and return B_OK;
- fill the app info with the data of the second apps and return B_OK;
- return B_ERROR.
status_t GetRunningAppInfo(team_id team, app_info *info) const
case 1: info is NULL =>
Should return B_BAD_VALUE.
case 2: info is not NULL, but no app with the team ID is running =>
Should return B_BAD_TEAM_ID.
case 3: info is not NULL, and an app with the team ID is running =>
Should fill the app info and return B_OK.
void GetAppList(BList *teamIDList) const
case 1: teamIDList is NULL =>
Should return B_BAD_VALUE.
case 2: teamIDList is not NULL and not empty =>
Should append the team IDs of all running apps to teamIDList.
void GetAppList(const char *signature, BList *teamIDList) const
case 1: signature or teamIDList are NULL =>
Should return B_BAD_VALUE.
case 2: teamIDList is not NULL and not empty, signature is not NULL, but no
app with this signature is running =>
Should not modify teamIDList.
case 3: teamIDList is not NULL and not empty, signature is not NULL, but no
app with this signature is running =>
Should append the team IDs of all running apps with the supplied
signature to teamIDList.

View File

@ -0,0 +1,151 @@
//------------------------------------------------------------------------------
// IsRunningTester.cpp
//
//------------------------------------------------------------------------------
// Standard Includes -----------------------------------------------------------
#include <stdio.h>
// System Includes -------------------------------------------------------------
#include <be/app/Message.h>
#include <be/kernel/OS.h>
#include <Handler.h>
#include <Looper.h>
#include <Roster.h>
#include <String.h>
// Project Includes ------------------------------------------------------------
#include <TestShell.h>
#include <TestUtils.h>
#include <cppunit/TestAssert.h>
// Local Includes --------------------------------------------------------------
#include "AppRunner.h"
#include "IsRunningTester.h"
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
//------------------------------------------------------------------------------
/*
bool IsRunning(const char *signature) const
@case 1 signature is NULL
@results Should return false.
*/
void IsRunningTester::IsRunningTestA1()
{
// R5: crashes when passing a NULL signature
#ifndef TEST_R5
BRoster roster;
CHK(roster.IsRunning((const char*)NULL) == false);
#endif
}
/*
bool IsRunning(const char *signature) const
@case 2 signature is not NULL, but no app with this signature is
running
@results Should return false.
*/
void IsRunningTester::IsRunningTestA2()
{
BRoster roster;
CHK(roster.IsRunning("application/x-vnd.obos-app-run-testapp1") == false);
}
/*
bool IsRunning(const char *signature) const
@case 3 signature is not NULL and an (two) app(s) with this
signature is (are) running; quit one; quit the second one
@results Should return true; true; false.
*/
void IsRunningTester::IsRunningTestA3()
{
// run the remote apps
AppRunner runner1(true);
AppRunner runner2(true);
CHK(runner1.Run("AppRunTestApp1") == B_OK);
CHK(runner2.Run("AppRunTestApp1") == B_OK);
// create the BRoster and perform the tests
BRoster roster;
CHK(roster.IsRunning("application/x-vnd.obos-app-run-testapp1") == true);
// quit app 1
runner1.WaitFor(true);
CHK(roster.IsRunning("application/x-vnd.obos-app-run-testapp1") == true);
// quit app 2
runner2.WaitFor(true);
CHK(roster.IsRunning("application/x-vnd.obos-app-run-testapp1") == false);
}
/*
bool IsRunning(entry_ref *ref) const
@case 1 ref is NULL
@results Should return false.
*/
void IsRunningTester::IsRunningTestB1()
{
// R5: crashes when passing a NULL ref
#ifndef TEST_R5
BRoster roster;
CHK(roster.IsRunning((entry_ref*)NULL) == false);
#endif
}
/*
bool IsRunning(entry_ref *ref) const
@case 2 ref is not NULL, but no app with this ref is running
@results Should return false.
*/
void IsRunningTester::IsRunningTestB2()
{
BRoster roster;
entry_ref ref;
CHK(find_test_app("AppRunTestApp1", &ref) == B_OK);
CHK(roster.IsRunning(&ref) == false);
}
/*
bool IsRunning(entry_ref *ref) const
@case 3 ref is not NULL and an (two) app(s) with this ref is (are)
running; quit one; quit the second one
@results Should return true; true; false.
*/
void IsRunningTester::IsRunningTestB3()
{
entry_ref ref;
CHK(find_test_app("AppRunTestApp1", &ref) == B_OK);
// run the remote apps
AppRunner runner1(true);
AppRunner runner2(true);
CHK(runner1.Run("AppRunTestApp1") == B_OK);
CHK(runner2.Run("AppRunTestApp1") == B_OK);
// create the BRoster and perform the tests
BRoster roster;
CHK(roster.IsRunning(&ref) == true);
// quit app 1
runner1.WaitFor(true);
CHK(roster.IsRunning(&ref) == true);
// quit app 2
runner2.WaitFor(true);
CHK(roster.IsRunning(&ref) == false);
}
Test* IsRunningTester::Suite()
{
TestSuite* SuiteOfTests = new TestSuite;
ADD_TEST4(BApplication, SuiteOfTests, IsRunningTester, IsRunningTestA1);
ADD_TEST4(BApplication, SuiteOfTests, IsRunningTester, IsRunningTestA2);
ADD_TEST4(BApplication, SuiteOfTests, IsRunningTester, IsRunningTestA3);
ADD_TEST4(BApplication, SuiteOfTests, IsRunningTester, IsRunningTestB1);
ADD_TEST4(BApplication, SuiteOfTests, IsRunningTester, IsRunningTestB2);
ADD_TEST4(BApplication, SuiteOfTests, IsRunningTester, IsRunningTestB3);
return SuiteOfTests;
}

View File

@ -0,0 +1,40 @@
//------------------------------------------------------------------------------
// IsRunningTester.h
//
//------------------------------------------------------------------------------
#ifndef IS_RUNNING_TESTER_H
#define IS_RUNNING_TESTER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
#include "../common.h"
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class IsRunningTester : public TestCase
{
public:
IsRunningTester() {;}
IsRunningTester(std::string name) : TestCase(name) {;}
void IsRunningTestA1();
void IsRunningTestA2();
void IsRunningTestA3();
void IsRunningTestB1();
void IsRunningTestB2();
void IsRunningTestB3();
static Test* Suite();
};
#endif // IS_RUNNING_TESTER_H

View File

@ -0,0 +1,12 @@
#include "../common.h"
#include "IsRunningTester.h"
CppUnit::Test* RosterTestSuite()
{
CppUnit::TestSuite *testSuite = new CppUnit::TestSuite();
testSuite->addTest(IsRunningTester::Suite());
return testSuite;
}

View File

@ -0,0 +1,9 @@
#ifndef _roster_test_h_
#define _roster_test_h_
class CppUnit::Test;
CppUnit::Test* RosterTestSuite();
#endif // _roster_test_h_