11541Srgrimes//------------------------------------------------------------------------------ 21541Srgrimes// RosterWatchingTester.cpp 31541Srgrimes// 41541Srgrimes//------------------------------------------------------------------------------ 51541Srgrimes 61541Srgrimes// Standard Includes ----------------------------------------------------------- 71541Srgrimes#include <stdio.h> 81541Srgrimes#include <stdlib.h> 91541Srgrimes#include <utime.h> 101541Srgrimes 111541Srgrimes// System Includes ------------------------------------------------------------- 121541Srgrimes#include <Message.h> 131541Srgrimes#include <OS.h> 141541Srgrimes#include <AppFileInfo.h> 151541Srgrimes#include <Application.h> 161541Srgrimes#include <File.h> 171541Srgrimes#include <FindDirectory.h> 181541Srgrimes#include <Handler.h> 191541Srgrimes#include <Looper.h> 201541Srgrimes#include <Message.h> 211541Srgrimes#include <MessageQueue.h> 221541Srgrimes#include <Path.h> 231541Srgrimes#include <Roster.h> 241541Srgrimes#include <String.h> 251541Srgrimes 261541Srgrimes// Project Includes ------------------------------------------------------------ 271541Srgrimes#include <TestShell.h> 281541Srgrimes#include <TestUtils.h> 291541Srgrimes#include <cppunit/TestAssert.h> 301541Srgrimes 311541Srgrimes// Local Includes -------------------------------------------------------------- 321541Srgrimes#include "AppRunner.h" 3314478Shsu#include "RosterWatchingTester.h" 3450477Speter#include "LaunchTesterHelper.h" 351541Srgrimes#include "RosterTestAppDefs.h" 361541Srgrimes 3745260Sbde// Local Defines --------------------------------------------------------------- 385052Sbde 392165Spaul// Globals --------------------------------------------------------------------- 4018444Sbde 4118444Sbde//------------------------------------------------------------------------------ 4218444Sbde 4318429Sbdestatic const char *testerSignature 4418429Sbde = "application/x-vnd.obos-roster-watching-test"; 451541Srgrimesstatic const char *appType1 = "application/x-vnd.obos-roster-watching-app1"; 461541Srgrimesstatic const char *appType2 = "application/x-vnd.obos-roster-watching-app2"; 471541Srgrimesstatic const char *appType3 = "application/x-vnd.obos-roster-watching-app3"; 481541Srgrimesstatic const char *appType4 = "application/x-vnd.obos-roster-watching-app4"; 491541Srgrimes//static const char *appType5 = "application/x-vnd.obos-roster-watching-app5"; 501541Srgrimes 511541Srgrimesstatic const char *testDir = "/tmp/testdir"; 521541Srgrimesstatic const char *appFile1 = "/tmp/testdir/app1"; 531541Srgrimesstatic const char *appFile2 = "/tmp/testdir/app2"; 541541Srgrimesstatic const char *appFile3 = "/tmp/testdir/app3"; 551541Srgrimesstatic const char *appFile4 = "/tmp/testdir/app4"; 561541Srgrimes//static const char *appFile5 = "/tmp/testdir/app5"; 571541Srgrimes 581541Srgrimes 594027Sphk// ref_for_path 601541Srgrimesstatic 611541Srgrimesentry_ref 621541Srgrimesref_for_path(const char *filename, bool traverse = true) 631541Srgrimes{ 6436735Sdfr entry_ref ref; 6537601Sdfr BEntry entry; 6637601Sdfr CHK(entry.SetTo(filename, traverse) == B_OK); 6736735Sdfr CHK(entry.GetRef(&ref) == B_OK); 6836735Sdfr return ref; 691541Srgrimes} 701541Srgrimes 711541Srgrimes// create_app 721541Srgrimesstatic 731541Srgrimesentry_ref 741541Srgrimescreate_app(const char *filename, const char *signature, 751541Srgrimes bool install = false, bool makeExecutable = true, 761541Srgrimes uint32 appFlags = B_SINGLE_LAUNCH) 7714478Shsu{ 781541Srgrimes BString testApp; 791541Srgrimes CHK(find_test_app("RosterWatchingTestApp1", &testApp) == B_OK); 801541Srgrimes system((string("cp ") + testApp.String() + " " + filename).c_str()); 811541Srgrimes if (makeExecutable) 825052Sbde system((string("chmod a+x ") + filename).c_str()); 835052Sbde BFile file; 845052Sbde CHK(file.SetTo(filename, B_READ_WRITE) == B_OK); 851541Srgrimes BAppFileInfo appFileInfo; 861541Srgrimes CHK(appFileInfo.SetTo(&file) == B_OK); 871541Srgrimes if (signature) 8814478Shsu CHK(appFileInfo.SetSignature(signature) == B_OK); 8914478Shsu CHK(appFileInfo.SetAppFlags(appFlags) == B_OK); 9014478Shsu if (install && signature) 9114478Shsu CHK(BMimeType(signature).Install() == B_OK); 9214478Shsu // We write the signature into a separate attribute, just in case we 9314478Shsu // decide to also test files without BEOS:APP_SIG attribute. 941541Srgrimes BString signatureString(signature); 951541Srgrimes file.WriteAttrString("signature", &signatureString); 961541Srgrimes return ref_for_path(filename); 971541Srgrimes} 9842264Sjkh 991541Srgrimes// app_info_for_team 1001541Srgrimesstatic 1011541Srgrimesapp_info 1028876Srgrimesapp_info_for_team(team_id team) 1031541Srgrimes{ 1041541Srgrimes app_info info; 1051541Srgrimes CHK(be_roster->GetRunningAppInfo(team, &info) == B_OK); 1068876Srgrimes return info; 1078876Srgrimes} 1081541Srgrimes 1091541Srgrimes// check_watching_message 1101541Srgrimesvoid 11114478Shsucheck_watching_message(LaunchContext &context, team_id team, int32 &cookie, 1121541Srgrimes const app_info &info, uint32 messageCode) 11314478Shsu{ 11414478Shsu // wait for and get the message 11514478Shsu CHK(context.WaitForMessage(team, MSG_MESSAGE_RECEIVED, false, 11614478Shsu B_INFINITE_TIMEOUT, cookie)); 11714478Shsu BMessage *container = context.NextMessageFrom(team, cookie); 11814478Shsu CHK(container != NULL); 11914478Shsu CHK(container->what == MSG_MESSAGE_RECEIVED); 1201541Srgrimes BMessage message; 12114478Shsu CHK(container->FindMessage("message", &message) == B_OK); 12214478Shsu // check the message 12314478Shsuif (message.what != messageCode) 12414478Shsuprintf("message.what: %.4s vs messageCode: %.4s\n", (char*)&message.what, 1251541Srgrimes(char*)&messageCode); 12614478Shsu CHK(message.what == messageCode); 12714478Shsu // team 1281541Srgrimes team_id foundTeam; 12914478Shsu CHK(message.FindInt32("be:team", &foundTeam) == B_OK); 13014478Shsu CHK(foundTeam == info.team); 1311541Srgrimes // thread 13214478Shsu thread_id thread; 1331541Srgrimes CHK(message.FindInt32("be:thread", &thread) == B_OK); 1341541Srgrimes CHK(thread == info.thread); 1351541Srgrimes // signature 1361541Srgrimes const char *signature = NULL; 1371541Srgrimes CHK(message.FindString("be:signature", &signature) == B_OK); 13814478Shsu CHK(!strcmp(signature, info.signature)); 13914478Shsu // ref 14014478Shsu entry_ref ref; 14114478Shsu CHK(message.FindRef("be:ref", &ref) == B_OK); 14214478Shsu CHK(ref == info.ref); 14314478Shsu // flags 14414478Shsu uint32 flags; 14514478Shsu CHK(message.FindInt32("be:flags", (int32*)&flags) == B_OK); 14614478Shsu CHK(flags == info.flags); 14714478Shsu} 14814478Shsu 14914478Shsu 1501541Srgrimes// setUp 15114478Shsuvoid 15214478ShsuRosterWatchingTester::setUp() 15314478Shsu{ 15414478Shsu RosterLaunchApp *app = new RosterLaunchApp(testerSignature); 15514478Shsu fApplication = app; 15614478Shsu app->SetHandler(new RosterBroadcastHandler); 15714478Shsu system((string("mkdir ") + testDir).c_str()); 1581541Srgrimes} 15914478Shsu 1601541Srgrimes// tearDown 16114478Shsuvoid 16214478ShsuRosterWatchingTester::tearDown() 16314478Shsu{ 1641541Srgrimes BMimeType(appType1).Delete(); 1651541Srgrimes BMimeType(appType2).Delete(); 16614478Shsu BMimeType(appType3).Delete(); 16714478Shsu BMimeType(appType4).Delete(); 16814478Shsu// BMimeType(appType5).Delete(); 1691541Srgrimes delete fApplication; 17014478Shsu system((string("rm -rf ") + testDir).c_str()); 17114478Shsu} 17214478Shsu 17314478Shsu// SimpleAppLauncher 17414478Shsuclass SimpleAppLauncher : public LaunchCaller { 1751541Srgrimespublic: 17614478Shsu SimpleAppLauncher() : fRef() {} 17714478Shsu SimpleAppLauncher(const entry_ref &ref) : fRef(ref) {} 1781541Srgrimes virtual ~SimpleAppLauncher() {} 1791541Srgrimes virtual status_t operator()(const char *type, BList *messages, int32 argc, 1801541Srgrimes const char **argv, team_id *team) 1811541Srgrimes { 1821541Srgrimes return be_roster->Launch(&fRef, (BMessage*)NULL, team); 1831541Srgrimes } 1841541Srgrimes virtual bool SupportsRefs() const { return true; } 1851541Srgrimes virtual const entry_ref *Ref() const { return &fRef; } 1861541Srgrimes 1871541Srgrimes virtual LaunchCaller *CloneInternal() 1881541Srgrimes { 1891541Srgrimes return new SimpleAppLauncher; 1901541Srgrimes } 1911541Srgrimes 1921541Srgrimesprotected: 1931541Srgrimes entry_ref fRef; 1941541Srgrimes}; 1951541Srgrimes 1961541Srgrimes 1971541Srgrimes/* 1981541Srgrimes status_t StartWatching(BMessenger target, uint32 eventMask) const 1991541Srgrimes status_t StopWatching(BMessenger target) const 2001541Srgrimes @case 1 {Start,Stop}Watching() with invalid messenger or invalid 2011541Srgrimes flags; StopWatching() non-watching messenger => 2021541Srgrimes @results Should return B_OK; B_BAD_VALUE. 2031541Srgrimes*/ 2041541Srgrimesvoid RosterWatchingTester::WatchingTest1() 2051541Srgrimes{ 20615571Sasami BRoster roster; 20745260Sbde BMessenger target; 20849617Simp // not valid, not watching 2091541Srgrimes CHK(roster.StopWatching(target) == B_BAD_VALUE); 21050551Sphk // not valid 21145260Sbde CHK(roster.StartWatching(target, B_REQUEST_LAUNCHED | B_REQUEST_QUIT 21216363Sasami | B_REQUEST_ACTIVATED) == B_OK); 21316363Sasami CHK(roster.StopWatching(target) == B_OK); 2141541Srgrimes // invalid flags 2151541Srgrimes CHK(roster.StartWatching(target, 0) == B_OK); 2161541Srgrimes CHK(roster.StopWatching(target) == B_OK); 2171541Srgrimes // valid, but not watching 2181541Srgrimes CHK(roster.StopWatching(be_app_messenger) == B_BAD_VALUE); 2191541Srgrimes} 2201541Srgrimes 2211541Srgrimes/* 2221541Srgrimes status_t StartWatching(BMessenger target, uint32 eventMask) const 2231541Srgrimes status_t StopWatching(BMessenger target) const 2241541Srgrimes @case 2 several apps, several watchers, different eventMasks 2251541Srgrimes @results Should return B_OK... 2261541Srgrimes Watching ends, when target has become invalid and the next watching 22715571Sasami message is tried to be sent. 22833469Sjkh*/ 22949617Simpvoid RosterWatchingTester::WatchingTest2() 23014478Shsu{ 2311541Srgrimes LaunchContext context; 2321541Srgrimes BRoster roster; 2331541Srgrimes // launch app 1 2341541Srgrimes entry_ref ref1(create_app(appFile1, appType1)); 2351541Srgrimes SimpleAppLauncher caller1(ref1); 2361541Srgrimes team_id team1; 2371541Srgrimes CHK(context(caller1, appType1, &team1) == B_OK); 2381541Srgrimes context.WaitForMessage(team1, MSG_READY_TO_RUN); 2391541Srgrimes BMessenger target1(NULL, team1); 2401541Srgrimes app_info appInfo1(app_info_for_team(team1)); 2411541Srgrimes CHK(roster.StartWatching(target1, B_REQUEST_LAUNCHED | B_REQUEST_QUIT 2421541Srgrimes | B_REQUEST_ACTIVATED) == B_OK); 2431541Srgrimes // messages: app 1 2441541Srgrimes int32 cookie1 = 0; 2451541Srgrimes CHK(context.CheckNextMessage(caller1, team1, cookie1, MSG_STARTED)); 2461541Srgrimes CHK(context.CheckMainArgsMessage(caller1, team1, cookie1, &ref1, false)); 2471541Srgrimes CHK(context.CheckNextMessage(caller1, team1, cookie1, MSG_READY_TO_RUN)); 2481541Srgrimes // launch app 2 2491541Srgrimes entry_ref ref2(create_app(appFile2, appType2, false, true, 2501541Srgrimes B_SINGLE_LAUNCH | B_ARGV_ONLY)); 2511541Srgrimes SimpleAppLauncher caller2(ref2); 2521541Srgrimes team_id team2; 2531541Srgrimes CHK(context(caller2, appType2, &team2) == B_OK); 25445260Sbde context.WaitForMessage(team2, MSG_READY_TO_RUN); 25545260Sbde BMessenger target2(context.AppMessengerFor(team2)); 2561541Srgrimes CHK(target2.IsValid()); 2571541Srgrimes app_info appInfo2(app_info_for_team(team2)); 2581541Srgrimes CHK(roster.StartWatching(target2, B_REQUEST_LAUNCHED) == B_OK); 2591541Srgrimes // messages: app 2 2601541Srgrimes int32 cookie2 = 0; 2611541Srgrimes CHK(context.CheckNextMessage(caller2, team2, cookie2, MSG_STARTED)); 2621541Srgrimes CHK(context.CheckMainArgsMessage(caller2, team2, cookie2, &ref2, false)); 2631541Srgrimes CHK(context.CheckNextMessage(caller2, team2, cookie2, MSG_READY_TO_RUN)); 2641541Srgrimes // messages: app 1 2651541Srgrimes check_watching_message(context, team1, cookie1, appInfo2, 2661541Srgrimes B_SOME_APP_LAUNCHED); 2671541Srgrimes // launch app 3 2681541Srgrimes entry_ref ref3(create_app(appFile3, appType3)); 2691541Srgrimes SimpleAppLauncher caller3(ref3); 2701541Srgrimes team_id team3; 2711541Srgrimes CHK(context(caller3, appType3, &team3) == B_OK); 27244948Sgrog context.WaitForMessage(team3, MSG_READY_TO_RUN); 27314478Shsu BMessenger target3(NULL, team3); 2741541Srgrimes app_info appInfo3(app_info_for_team(team3)); 2751541Srgrimes CHK(roster.StartWatching(target3, B_REQUEST_QUIT) == B_OK); 2761541Srgrimes // messages: app 3 2771541Srgrimes int32 cookie3 = 0; 2781541Srgrimes CHK(context.CheckNextMessage(caller3, team3, cookie3, MSG_STARTED)); 2791541Srgrimes CHK(context.CheckMainArgsMessage(caller3, team3, cookie3, &ref3, false)); 2801541Srgrimes CHK(context.CheckNextMessage(caller3, team3, cookie3, MSG_READY_TO_RUN)); 2811541Srgrimes // messages: app 2 2821541Srgrimes check_watching_message(context, team2, cookie2, appInfo3, 2831541Srgrimes B_SOME_APP_LAUNCHED); 2841541Srgrimes // messages: app 1 2851541Srgrimes check_watching_message(context, team1, cookie1, appInfo3, 2861541Srgrimes B_SOME_APP_LAUNCHED); 2871541Srgrimes // launch app 4 2881541Srgrimes entry_ref ref4(create_app(appFile4, appType4)); 2891541Srgrimes SimpleAppLauncher caller4(ref4); 2901541Srgrimes team_id team4; 2911541Srgrimes CHK(context(caller4, appType4, &team4) == B_OK); 2921541Srgrimes context.WaitForMessage(team4, MSG_READY_TO_RUN); 2931541Srgrimes BMessenger target4(NULL, team4); 2941541Srgrimes app_info appInfo4(app_info_for_team(team4)); 2951541Srgrimes // messages: app 4 2961541Srgrimes int32 cookie4 = 0; 2971541Srgrimes CHK(context.CheckNextMessage(caller4, team4, cookie4, MSG_STARTED)); 2981541Srgrimes CHK(context.CheckMainArgsMessage(caller4, team4, cookie4, &ref4, false)); 2991541Srgrimes CHK(context.CheckNextMessage(caller4, team4, cookie4, MSG_READY_TO_RUN)); 3001541Srgrimes // messages: app 3 3011541Srgrimes // none 3021541Srgrimes // messages: app 2 3031541Srgrimes check_watching_message(context, team2, cookie2, appInfo4, 3041541Srgrimes B_SOME_APP_LAUNCHED); 3051541Srgrimes // messages: app 1 3061541Srgrimes check_watching_message(context, team1, cookie1, appInfo4, 3071541Srgrimes B_SOME_APP_LAUNCHED); 3081541Srgrimes // terminate app 4 30914478Shsu context.TerminateApp(team4); 31014478Shsu // messages: app 3 3111541Srgrimes check_watching_message(context, team3, cookie3, appInfo4, 3121541Srgrimes B_SOME_APP_QUIT); 3131541Srgrimes // messages: app 2 3141541Srgrimes // none 31545260Sbde // messages: app 1 31645260Sbde check_watching_message(context, team1, cookie1, appInfo4, 31745260Sbde B_SOME_APP_QUIT); 3181541Srgrimes // stop watching app 1 3191541Srgrimes CHK(roster.StopWatching(target1) == B_OK); 3201541Srgrimes // terminate app 2 32114478Shsu context.TerminateApp(team2); 32214478Shsu CHK(roster.StopWatching(target2) == B_OK); 3231541Srgrimes // messages: app 3 3241541Srgrimes check_watching_message(context, team3, cookie3, appInfo2, 3251541Srgrimes B_SOME_APP_QUIT); 3261541Srgrimes // messages: app 1 3271541Srgrimes // none 3281541Srgrimes // terminate app 3 3291549Srgrimes context.TerminateApp(team3); 3301549Srgrimes// Haiku handles app termination a bit different. At the point, when the 33150551Sphk// application unregisters itself from the registrar, its port is still 33216363Sasami// valid. 33316363Sasami#ifdef TEST_R5 33416363Sasami CHK(roster.StopWatching(target3) == B_BAD_VALUE); 33516363Sasami#else 33616363Sasami CHK(roster.StopWatching(target3) == B_OK); 33716363Sasami#endif 33816363Sasami // messages: app 1 33916363Sasami // none 34016363Sasami // remaining messages 34116363Sasami context.Terminate(); 34216363Sasami // app 1 34316363Sasami CHK(context.CheckNextMessage(caller1, team1, cookie1, MSG_QUIT_REQUESTED)); 34416363Sasami CHK(context.CheckNextMessage(caller1, team1, cookie1, MSG_TERMINATED)); 34516363Sasami // app 2 34616363Sasami CHK(context.CheckNextMessage(caller2, team2, cookie2, MSG_QUIT_REQUESTED)); 34716363Sasami CHK(context.CheckNextMessage(caller2, team2, cookie2, MSG_TERMINATED)); 34816363Sasami // app 3 34916363Sasami CHK(context.CheckNextMessage(caller3, team3, cookie3, MSG_QUIT_REQUESTED)); 35016363Sasami CHK(context.CheckNextMessage(caller3, team3, cookie3, MSG_TERMINATED)); 35116363Sasami // app 4 35216363Sasami CHK(context.CheckNextMessage(caller4, team4, cookie4, MSG_QUIT_REQUESTED)); 35316363Sasami CHK(context.CheckNextMessage(caller4, team4, cookie4, MSG_TERMINATED)); 35416363Sasami} 35516363Sasami 35616363Sasami/* 35716363Sasami status_t StartWatching(BMessenger target, uint32 eventMask) const 35816363Sasami status_t StopWatching(BMessenger target) const 3591549Srgrimes @case 3 call StartWatching() twice, second time with different 3601549Srgrimes masks 3611549Srgrimes @results Should return B_OK. The second call simply overrides the 3623742Spaul first one. 3631549Srgrimes*/ 3641549Srgrimesvoid RosterWatchingTester::WatchingTest3() 3651549Srgrimes{ 3661549Srgrimes LaunchContext context; 3671549Srgrimes BRoster roster; 3681549Srgrimes // launch app 1 3691549Srgrimes entry_ref ref1(create_app(appFile1, appType1)); 3701549Srgrimes SimpleAppLauncher caller1(ref1); 3711549Srgrimes team_id team1; 3721549Srgrimes CHK(context(caller1, appType1, &team1) == B_OK); 37337466Sbde context.WaitForMessage(team1, MSG_READY_TO_RUN); 37437466Sbde BMessenger target1(NULL, team1); 3751549Srgrimes app_info appInfo1(app_info_for_team(team1)); 37616363Sasami CHK(roster.StartWatching(target1, B_REQUEST_LAUNCHED | B_REQUEST_QUIT 3771549Srgrimes | B_REQUEST_ACTIVATED) == B_OK); 3781549Srgrimes // messages: app 1 3791549Srgrimes int32 cookie1 = 0; 3801549Srgrimes CHK(context.CheckNextMessage(caller1, team1, cookie1, MSG_STARTED)); 3811541Srgrimes CHK(context.CheckMainArgsMessage(caller1, team1, cookie1, &ref1, false)); 3821541Srgrimes CHK(context.CheckNextMessage(caller1, team1, cookie1, MSG_READY_TO_RUN)); 3831541Srgrimes // app 1: another StartWatching() with different event mask 3841541Srgrimes CHK(roster.StartWatching(target1, B_REQUEST_QUIT) == B_OK); 3851541Srgrimes // launch app 2 3861541Srgrimes entry_ref ref2(create_app(appFile2, appType2, false, true, 3871541Srgrimes B_SINGLE_LAUNCH | B_ARGV_ONLY)); 3881541Srgrimes SimpleAppLauncher caller2(ref2); 3891541Srgrimes team_id team2; 3901541Srgrimes CHK(context(caller2, appType2, &team2) == B_OK); 3911541Srgrimes context.WaitForMessage(team2, MSG_READY_TO_RUN); 3921541Srgrimes BMessenger target2(context.AppMessengerFor(team2)); 3938552Sdg CHK(target2.IsValid()); 3941541Srgrimes app_info appInfo2(app_info_for_team(team2)); 3955052Sbde CHK(roster.StartWatching(target2, B_REQUEST_QUIT) == B_OK); 3965052Sbde // messages: app 2 3975052Sbde int32 cookie2 = 0; 3985052Sbde CHK(context.CheckNextMessage(caller2, team2, cookie2, MSG_STARTED)); 3995052Sbde CHK(context.CheckMainArgsMessage(caller2, team2, cookie2, &ref2, false)); 4005052Sbde CHK(context.CheckNextMessage(caller2, team2, cookie2, MSG_READY_TO_RUN)); 4018876Srgrimes // messages: app 1 4025052Sbde // none 4035052Sbde // app 2: another StartWatching() with different event mask 4045052Sbde CHK(roster.StartWatching(target2, B_REQUEST_LAUNCHED) == B_OK); 4058193Sjulian // launch app 3 4068193Sjulian entry_ref ref3(create_app(appFile3, appType3)); 4078193Sjulian SimpleAppLauncher caller3(ref3); 4088193Sjulian team_id team3; 4098193Sjulian CHK(context(caller3, appType3, &team3) == B_OK); 4108193Sjulian context.WaitForMessage(team3, MSG_READY_TO_RUN); 4118193Sjulian BMessenger target3(NULL, team3); 41221986Sdg app_info appInfo3(app_info_for_team(team3)); 4138193Sjulian // messages: app 3 4148193Sjulian int32 cookie3 = 0; 4155052Sbde CHK(context.CheckNextMessage(caller3, team3, cookie3, MSG_STARTED)); 41633742Sdg CHK(context.CheckMainArgsMessage(caller3, team3, cookie3, &ref3, false)); 41733742Sdg CHK(context.CheckNextMessage(caller3, team3, cookie3, MSG_READY_TO_RUN)); 41846679Sphk // messages: app 2 41946679Sphk check_watching_message(context, team2, cookie2, appInfo3, 42046679Sphk B_SOME_APP_LAUNCHED); 42146679Sphk // messages: app 1 42246679Sphk // none 42346679Sphk // terminate app 3 42446679Sphk context.TerminateApp(team3); 42546679Sphk // messages: app 3 42646679Sphk // none 42746679Sphk // messages: app 2 42846679Sphk // none 42946679Sphk // messages: app 1 4305052Sbde check_watching_message(context, team1, cookie1, appInfo3, 4315052Sbde B_SOME_APP_QUIT); 43221986Sdg // terminate app 2 4331541Srgrimes context.TerminateApp(team2); 43446679Sphk CHK(roster.StopWatching(target2) == B_OK); 43546679Sphk // messages: app 1 43646679Sphk check_watching_message(context, team1, cookie1, appInfo2, 43746679Sphk B_SOME_APP_QUIT); 43846679Sphk // remaining messages 43946679Sphk context.Terminate(); 4403940Sjkh // app 1 4414462Sbde CHK(context.CheckNextMessage(caller1, team1, cookie1, MSG_QUIT_REQUESTED)); 44232995Sbde CHK(context.CheckNextMessage(caller1, team1, cookie1, MSG_TERMINATED)); 44312478Sbde // app 2 44412478Sbde CHK(context.CheckNextMessage(caller2, team2, cookie2, MSG_QUIT_REQUESTED)); 4457090Sbde CHK(context.CheckNextMessage(caller2, team2, cookie2, MSG_TERMINATED)); 4467090Sbde // app 3 44751227Sbde CHK(context.CheckNextMessage(caller3, team3, cookie3, MSG_QUIT_REQUESTED)); 44851227Sbde CHK(context.CheckNextMessage(caller3, team3, cookie3, MSG_TERMINATED)); 4493940Sjkh} 4505052Sbde 45149771Sphk 45229683SgibbsTest* RosterWatchingTester::Suite() 4535052Sbde{ 4545052Sbde TestSuite* SuiteOfTests = new TestSuite; 45549771Sphk 45648417Speter ADD_TEST4(BRoster, SuiteOfTests, RosterWatchingTester, WatchingTest1); 45748417Speter ADD_TEST4(BRoster, SuiteOfTests, RosterWatchingTester, WatchingTest2); 45848417Speter ADD_TEST4(BRoster, SuiteOfTests, RosterWatchingTester, WatchingTest3); 4593940Sjkh 4605052Sbde return SuiteOfTests; 4615052Sbde} 4625052Sbde 4635052Sbde