void driver (void) { printf ("caller1 () => %d\n", caller1 ()); printf ("caller2 () => %d\n", caller2 ()); printf ("caller3 () => %d\n", caller3 ()); printf ("caller4 () => %d\n", caller4 ()); printf ("caller5 () => %d\n", caller5 ()); }
/* status_t Broadcast(BMessage *message, BMessenger replyTo) const @case 3 valid message, several apps, one is B_ARGV_ONLY, invalid replyTo @results Should return B_OK and send the message to all (including the B_ARGV_ONLY) apps. Replies go to the roster! */ void BroadcastTester::BroadcastTestB3() { LaunchContext context; BRoster roster; // launch app 1 entry_ref ref1(create_app(appFile1, appType1)); SimpleAppLauncher caller1(ref1); team_id team1; CHK(context(caller1, appType1, &team1) == B_OK); // launch app 2 entry_ref ref2(create_app(appFile2, appType2, false, true, B_SINGLE_LAUNCH | B_ARGV_ONLY)); SimpleAppLauncher caller2(ref2); team_id team2; CHK(context(caller2, appType2, &team2) == B_OK); // launch app 3 entry_ref ref3(create_app(appFile3, appType3)); SimpleAppLauncher caller3(ref3); team_id team3; CHK(context(caller3, appType3, &team3) == B_OK); // launch app 4 entry_ref ref4(create_app(appFile4, appType4)); SimpleAppLauncher caller4(ref4); team_id team4; CHK(context(caller4, appType4, &team4) == B_OK); // wait for the apps to run context.WaitForMessage(team1, MSG_READY_TO_RUN); context.WaitForMessage(team2, MSG_READY_TO_RUN); context.WaitForMessage(team3, MSG_READY_TO_RUN); context.WaitForMessage(team4, MSG_READY_TO_RUN); // broadcast a message BMessage message(MSG_1); BMessenger replyTo; CHK(roster.Broadcast(&message, replyTo) == B_OK); // wait for the apps to report the receipt of the message context.WaitForMessage(team1, MSG_MESSAGE_RECEIVED); context.WaitForMessage(team2, MSG_MESSAGE_RECEIVED); context.WaitForMessage(team3, MSG_MESSAGE_RECEIVED); context.WaitForMessage(team4, MSG_MESSAGE_RECEIVED); // check the messages context.Terminate(); // app 1 int32 cookie = 0; CHK(context.CheckNextMessage(caller1, team1, cookie, MSG_STARTED)); CHK(context.CheckMainArgsMessage(caller1, team1, cookie, &ref1, false)); CHK(context.CheckNextMessage(caller1, team1, cookie, MSG_READY_TO_RUN)); CHK(context.CheckMessageMessage(caller1, team1, cookie, &message)); // CHK(context.CheckNextMessage(caller1, team1, cookie, MSG_2)); CHK(context.CheckNextMessage(caller1, team1, cookie, MSG_QUIT_REQUESTED)); CHK(context.CheckNextMessage(caller1, team1, cookie, MSG_TERMINATED)); // app 2 cookie = 0; CHK(context.CheckNextMessage(caller2, team2, cookie, MSG_STARTED)); CHK(context.CheckMainArgsMessage(caller2, team2, cookie, &ref2, false)); CHK(context.CheckNextMessage(caller2, team2, cookie, MSG_READY_TO_RUN)); CHK(context.CheckMessageMessage(caller2, team2, cookie, &message)); // CHK(context.CheckNextMessage(caller2, team2, cookie, MSG_2)); CHK(context.CheckNextMessage(caller2, team2, cookie, MSG_QUIT_REQUESTED)); CHK(context.CheckNextMessage(caller2, team2, cookie, MSG_TERMINATED)); // app 3 cookie = 0; CHK(context.CheckNextMessage(caller3, team3, cookie, MSG_STARTED)); CHK(context.CheckMainArgsMessage(caller3, team3, cookie, &ref3, false)); CHK(context.CheckNextMessage(caller3, team3, cookie, MSG_READY_TO_RUN)); CHK(context.CheckMessageMessage(caller3, team3, cookie, &message)); // CHK(context.CheckNextMessage(caller3, team3, cookie, MSG_2)); CHK(context.CheckNextMessage(caller3, team3, cookie, MSG_QUIT_REQUESTED)); CHK(context.CheckNextMessage(caller3, team3, cookie, MSG_TERMINATED)); // app 4 cookie = 0; CHK(context.CheckNextMessage(caller4, team4, cookie, MSG_STARTED)); CHK(context.CheckMainArgsMessage(caller4, team4, cookie, &ref4, false)); CHK(context.CheckNextMessage(caller4, team4, cookie, MSG_READY_TO_RUN)); CHK(context.CheckMessageMessage(caller4, team4, cookie, &message)); // CHK(context.CheckNextMessage(caller4, team4, cookie, MSG_2)); CHK(context.CheckNextMessage(caller4, team4, cookie, MSG_QUIT_REQUESTED)); CHK(context.CheckNextMessage(caller4, team4, cookie, MSG_TERMINATED)); }