Roster watching tests added.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1579 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -105,6 +105,7 @@ CommonTestLib libapptest.so
|
|||||||
LaunchTester.cpp
|
LaunchTester.cpp
|
||||||
LaunchTesterHelper.cpp
|
LaunchTesterHelper.cpp
|
||||||
RecentAppsTestApp.cpp
|
RecentAppsTestApp.cpp
|
||||||
|
RosterWatchingTester.cpp
|
||||||
TeamForTester.cpp
|
TeamForTester.cpp
|
||||||
|
|
||||||
# RegistrarThreadManager
|
# RegistrarThreadManager
|
||||||
|
|||||||
@@ -582,4 +582,16 @@ case 3: valid message, several apps, one is B_ARGV_ONLY, invalid replyTo =>
|
|||||||
B_ARGV_ONLY) apps.
|
B_ARGV_ONLY) apps.
|
||||||
Replies go to the roster!
|
Replies go to the roster!
|
||||||
|
|
||||||
|
status_t StartWatching(BMessenger target, uint32 eventMask) const
|
||||||
|
status_t StopWatching(BMessenger target) const
|
||||||
|
case 1: {Start,Stop}Watching() with invalid messenger or invalid flags,
|
||||||
|
StopWatching() non-watching messenger =>
|
||||||
|
Should return B_OK/B_BAD_VALUE.
|
||||||
|
case 2: several apps, several watchers, different eventMasks =>
|
||||||
|
Should return B_OK...
|
||||||
|
Watching ends, when target has become invalid and the next watching
|
||||||
|
message is tried to be sent.
|
||||||
|
case 3: call StartWatching() twice, second time with different mask =>
|
||||||
|
Should return B_OK. The second call simply overrides the first one.
|
||||||
|
TODO: Watching app activation.
|
||||||
|
|
||||||
|
|||||||
@@ -312,6 +312,18 @@ LaunchContext::Terminate()
|
|||||||
wait_for_thread(fTerminator, &dummy);
|
wait_for_thread(fTerminator, &dummy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TerminateApp
|
||||||
|
void
|
||||||
|
LaunchContext::TerminateApp(team_id team, bool wait)
|
||||||
|
{
|
||||||
|
fLock.Lock();
|
||||||
|
if (AppInfo *info = AppInfoFor(team))
|
||||||
|
TerminateApp(info);
|
||||||
|
fLock.Unlock();
|
||||||
|
if (wait)
|
||||||
|
WaitForMessage(team, MSG_TERMINATED);
|
||||||
|
}
|
||||||
|
|
||||||
// TeamAt
|
// TeamAt
|
||||||
team_id
|
team_id
|
||||||
LaunchContext::TeamAt(int32 index) const
|
LaunchContext::TeamAt(int32 index) const
|
||||||
@@ -323,6 +335,50 @@ LaunchContext::TeamAt(int32 index) const
|
|||||||
return team;
|
return team;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AppMessengerFor
|
||||||
|
BMessenger
|
||||||
|
LaunchContext::AppMessengerFor(team_id team) const
|
||||||
|
{
|
||||||
|
BAutolock _lock(fLock);
|
||||||
|
BMessenger result;
|
||||||
|
if (AppInfo *info = AppInfoFor(team)) {
|
||||||
|
// We need to do some hacking.
|
||||||
|
BMessenger messenger;
|
||||||
|
struct fake_messenger {
|
||||||
|
port_id fPort;
|
||||||
|
int32 fHandlerToken;
|
||||||
|
team_id fTeam;
|
||||||
|
int32 extra0;
|
||||||
|
int32 extra1;
|
||||||
|
bool fPreferredTarget;
|
||||||
|
bool extra2;
|
||||||
|
bool extra3;
|
||||||
|
bool extra4;
|
||||||
|
} &fake = *(fake_messenger*)&messenger;
|
||||||
|
status_t error = B_OK;
|
||||||
|
fake.fTeam = team;
|
||||||
|
// find app looper port
|
||||||
|
bool found = false;
|
||||||
|
int32 cookie = 0;
|
||||||
|
port_info info;
|
||||||
|
while (error == B_OK && !found) {
|
||||||
|
error = get_next_port_info(fake.fTeam, &cookie, &info);
|
||||||
|
found = (error == B_OK
|
||||||
|
&& (!strcmp("AppLooperPort", info.name)
|
||||||
|
|| !strcmp("rAppLooperPort", info.name)));
|
||||||
|
}
|
||||||
|
// init messenger
|
||||||
|
if (error == B_OK) {
|
||||||
|
fake.fPort = info.port;
|
||||||
|
fake.fHandlerToken = 0;
|
||||||
|
fake.fPreferredTarget = true;
|
||||||
|
}
|
||||||
|
if (error == B_OK)
|
||||||
|
result = messenger;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// NextMessageFrom
|
// NextMessageFrom
|
||||||
BMessage*
|
BMessage*
|
||||||
LaunchContext::NextMessageFrom(team_id team, int32 &cookie, bigtime_t *time)
|
LaunchContext::NextMessageFrom(team_id team, int32 &cookie, bigtime_t *time)
|
||||||
@@ -342,11 +398,6 @@ LaunchContext::CheckNextMessage(LaunchCaller &caller, team_id team,
|
|||||||
int32 &cookie, uint32 what)
|
int32 &cookie, uint32 what)
|
||||||
{
|
{
|
||||||
BMessage *message = NextMessageFrom(team, cookie);
|
BMessage *message = NextMessageFrom(team, cookie);
|
||||||
if (!message)
|
|
||||||
printf("LaunchContext::CheckNextMessage(): no more messages\n");
|
|
||||||
else if (message->what != what)
|
|
||||||
printf("LaunchContext::CheckNextMessage(): %.4s vs %.4s\n",
|
|
||||||
(char*)&message->what, (char*)&what);
|
|
||||||
return (message && message->what == what);
|
return (message && message->what == what);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -563,13 +614,13 @@ LaunchContext::WaitForMessage(uint32 messageCode, bool fromNow,
|
|||||||
// WaitForMessage
|
// WaitForMessage
|
||||||
bool
|
bool
|
||||||
LaunchContext::WaitForMessage(team_id team, uint32 messageCode, bool fromNow,
|
LaunchContext::WaitForMessage(team_id team, uint32 messageCode, bool fromNow,
|
||||||
bigtime_t timeout)
|
bigtime_t timeout, int32 startIndex)
|
||||||
{
|
{
|
||||||
status_t error = B_ERROR;
|
status_t error = B_ERROR;
|
||||||
fLock.Lock();
|
fLock.Lock();
|
||||||
if (AppInfo *info = AppInfoFor(team)) {
|
if (AppInfo *info = AppInfoFor(team)) {
|
||||||
error = B_OK;
|
error = B_OK;
|
||||||
if (fromNow || !info->FindMessage(messageCode)) {
|
if (fromNow || !info->FindMessage(messageCode, startIndex)) {
|
||||||
// add sleeper
|
// add sleeper
|
||||||
Sleeper *sleeper = new Sleeper;
|
Sleeper *sleeper = new Sleeper;
|
||||||
error = sleeper->Init(messageCode);
|
error = sleeper->Init(messageCode);
|
||||||
|
|||||||
@@ -50,9 +50,12 @@ public:
|
|||||||
void HandleMessage(BMessage *message);
|
void HandleMessage(BMessage *message);
|
||||||
|
|
||||||
void Terminate();
|
void Terminate();
|
||||||
|
void TerminateApp(team_id team, bool wait = true);
|
||||||
|
|
||||||
team_id TeamAt(int32 index) const;
|
team_id TeamAt(int32 index) const;
|
||||||
|
|
||||||
|
BMessenger AppMessengerFor(team_id team) const;
|
||||||
|
|
||||||
BMessage *NextMessageFrom(team_id team, int32 &cookie,
|
BMessage *NextMessageFrom(team_id team, int32 &cookie,
|
||||||
bigtime_t *time = NULL);
|
bigtime_t *time = NULL);
|
||||||
bool CheckNextMessage(LaunchCaller &caller, team_id team, int32 &cookie,
|
bool CheckNextMessage(LaunchCaller &caller, team_id team, int32 &cookie,
|
||||||
@@ -88,7 +91,8 @@ public:
|
|||||||
bool WaitForMessage(uint32 messageCode, bool fromNow = false,
|
bool WaitForMessage(uint32 messageCode, bool fromNow = false,
|
||||||
bigtime_t timeout = B_INFINITE_TIMEOUT);
|
bigtime_t timeout = B_INFINITE_TIMEOUT);
|
||||||
bool WaitForMessage(team_id team, uint32 messageCode, bool fromNow = false,
|
bool WaitForMessage(team_id team, uint32 messageCode, bool fromNow = false,
|
||||||
bigtime_t timeout = B_INFINITE_TIMEOUT);
|
bigtime_t timeout = B_INFINITE_TIMEOUT,
|
||||||
|
int32 startIndex = 0);
|
||||||
|
|
||||||
BList *StandardMessages();
|
BList *StandardMessages();
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "GetRecentTester.h"
|
#include "GetRecentTester.h"
|
||||||
#include "IsRunningTester.h"
|
#include "IsRunningTester.h"
|
||||||
#include "LaunchTester.h"
|
#include "LaunchTester.h"
|
||||||
|
#include "RosterWatchingTester.h"
|
||||||
#include "TeamForTester.h"
|
#include "TeamForTester.h"
|
||||||
|
|
||||||
CppUnit::Test* RosterTestSuite()
|
CppUnit::Test* RosterTestSuite()
|
||||||
@@ -19,6 +20,7 @@ CppUnit::Test* RosterTestSuite()
|
|||||||
testSuite->addTest(GetRecentTester::Suite());
|
testSuite->addTest(GetRecentTester::Suite());
|
||||||
testSuite->addTest(IsRunningTester::Suite());
|
testSuite->addTest(IsRunningTester::Suite());
|
||||||
testSuite->addTest(LaunchTester::Suite());
|
testSuite->addTest(LaunchTester::Suite());
|
||||||
|
testSuite->addTest(RosterWatchingTester::Suite());
|
||||||
testSuite->addTest(TeamForTester::Suite());
|
testSuite->addTest(TeamForTester::Suite());
|
||||||
|
|
||||||
return testSuite;
|
return testSuite;
|
||||||
|
|||||||
@@ -73,3 +73,4 @@ SimpleBRosterTestApp RecentAppsTestEmptyApp.cpp RecentAppsTestApp.cpp ;
|
|||||||
SimpleBRosterTestApp RecentAppsTestControlApp.cpp RecentAppsTestApp.cpp ;
|
SimpleBRosterTestApp RecentAppsTestControlApp.cpp RecentAppsTestApp.cpp ;
|
||||||
SimpleBRosterTestApp RosterBroadcastTestApp1.cpp ;
|
SimpleBRosterTestApp RosterBroadcastTestApp1.cpp ;
|
||||||
SimpleBRosterTestApp RosterLaunchTestApp1.cpp ;
|
SimpleBRosterTestApp RosterLaunchTestApp1.cpp ;
|
||||||
|
SimpleBRosterTestApp RosterWatchingTestApp1.cpp ;
|
||||||
|
|||||||
Reference in New Issue
Block a user