From 9473794637e6f91a31ff05f49dbeb824a6d5e7ac Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 4 Oct 2002 21:07:15 +0000 Subject: [PATCH] Doh! Completely forgot to check what parameters are passed to the main() function of the launched application. Done now. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1374 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tests/kits/app/broster/BRosterCases | 13 ++-- src/tests/kits/app/broster/LaunchTester.cpp | 60 +++++++++++++++++-- .../kits/app/broster/LaunchTesterHelper.cpp | 42 ++++++++++++- .../kits/app/broster/LaunchTesterHelper.h | 10 ++++ .../kits/app/broster/RosterTestAppDefs.h | 2 + .../broster/testapps/RosterLaunchTestApp1.cpp | 8 ++- 6 files changed, 120 insertions(+), 15 deletions(-) diff --git a/src/tests/kits/app/broster/BRosterCases b/src/tests/kits/app/broster/BRosterCases index 043c9cc3d3..c7e6f341d5 100644 --- a/src/tests/kits/app/broster/BRosterCases +++ b/src/tests/kits/app/broster/BRosterCases @@ -261,7 +261,6 @@ case 15:installed type mimeType, preferred app, app type not installed, Should return B_OK and set team to the ID of the team running the application's executable. Should install the app type and set the app hint on it. - case 16:launch the app two times: B_MULTIPLE_LAUNCH | B_ARGV_ONLY => first app: ArgvReceived(), ReadyToRun(), QuitRequested() second app: ArgvReceived(), ReadyToRun(), QuitRequested() @@ -385,8 +384,8 @@ case 5: ref is valid, file has type and app hint, the type's preferred app type's preferred application's executable. Should install the app type and set the app hint on it. case 6: ref is valid, file has type, the type's preferred app - type is not installed, app exists and has signature, file is - executable => + type is not installed, app exists and has signature, file has + executable permission, but is not executable => Should return B_LAUNCH_FAILED_EXECUTABLE. Should not set the app hint on the app or file type. case 7: ref is valid and refers to a link to a file, file has type, @@ -428,8 +427,8 @@ case 5: ref is valid, file has type and app hint, the type's preferred app type's preferred application's executable. Should install the app type and set the app hint on it. case 6: ref is valid, file has type, the type's preferred app - type is not installed, app exists and has signature, file is - executable => + type is not installed, app exists and has signature, file has + executable permission, but is not executable => Should return B_LAUNCH_FAILED_EXECUTABLE. Should not set the app hint on the app or file type. case 7: ref is valid and refers to a link to a file, file has type, @@ -479,8 +478,8 @@ case 5: ref is valid, file has type and app hint, the type's preferred app type and set the app hint on it. ref is converted to path and added as additional argv. case 6: ref is valid, file has type, the type's preferred app - type is not installed, app exists and has signature, file is - executable => + type is not installed, app exists and has signature, file has + executable permission, but is not executable => Should return B_LAUNCH_FAILED_EXECUTABLE. Should not set the app hint on the app or file type. case 7: ref is valid and refers to a link to a file, file has type, diff --git a/src/tests/kits/app/broster/LaunchTester.cpp b/src/tests/kits/app/broster/LaunchTester.cpp index 945e668c2a..0f4fc141a1 100644 --- a/src/tests/kits/app/broster/LaunchTester.cpp +++ b/src/tests/kits/app/broster/LaunchTester.cpp @@ -331,6 +331,7 @@ CommonLaunchTest4(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); CHK(context.CheckMessageMessages(caller, team, cookie)); CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -363,6 +364,7 @@ CommonLaunchTest5(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); CHK(context.CheckMessageMessages(caller, team, cookie)); CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -395,6 +397,7 @@ CommonLaunchTest6(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); CHK(context.CheckMessageMessages(caller, team, cookie)); CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -429,6 +432,7 @@ CommonLaunchTest7(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); CHK(context.CheckMessageMessages(caller, team, cookie)); CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -465,6 +469,7 @@ CommonLaunchTest8(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); CHK(context.CheckMessageMessages(caller, team, cookie)); CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -501,6 +506,7 @@ CommonLaunchTest9(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); CHK(context.CheckMessageMessages(caller, team, cookie)); CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -539,6 +545,7 @@ CommonLaunchTest10(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); CHK(context.CheckMessageMessages(caller, team, cookie)); CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -573,6 +580,7 @@ CommonLaunchTest11(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); CHK(context.CheckMessageMessages(caller, team, cookie)); CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -603,6 +611,7 @@ CommonLaunchTest12(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); CHK(context.CheckMessageMessages(caller, team, cookie)); CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -657,6 +666,7 @@ CommonLaunchTest13(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); CHK(context.CheckMessageMessages(caller, team, cookie)); CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -708,6 +718,7 @@ CommonLaunchTest15(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); CHK(context.CheckMessageMessages(caller, team, cookie)); CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -749,6 +760,7 @@ CommonLaunchTest16(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team1, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team1, cookie, &ref1)); // CHK(context.CheckMessageMessages(caller, team1, cookie)); CHK(context.CheckArgvMessage(caller, team1, cookie, &ref1)); // if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -759,6 +771,7 @@ CommonLaunchTest16(LaunchCaller &caller) // checks 2 cookie = 0; CHK(context.CheckNextMessage(caller2, team2, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller2, team2, cookie, &ref2)); // CHK(context.CheckMessageMessages(caller2, team2, cookie)); CHK(context.CheckArgvMessage(caller2, team2, cookie, &ref2)); // if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -802,6 +815,7 @@ CommonLaunchTest17(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team1, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team1, cookie, &ref1)); CHK(context.CheckMessageMessages(caller, team1, cookie)); CHK(context.CheckArgvMessage(caller, team1, cookie, &ref1)); if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -812,6 +826,7 @@ CommonLaunchTest17(LaunchCaller &caller) // checks 2 cookie = 0; CHK(context.CheckNextMessage(caller2, team2, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller2, team2, cookie, &ref2)); CHK(context.CheckMessageMessages(caller2, team2, cookie)); CHK(context.CheckArgvMessage(caller2, team2, cookie, &ref2)); if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -851,6 +866,7 @@ CommonLaunchTest18(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team1, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team1, cookie, &ref1)); // CHK(context.CheckMessageMessages(caller, team1, cookie)); CHK(context.CheckArgvMessage(caller, team1, cookie, &ref1)); // if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -890,6 +906,7 @@ CommonLaunchTest19(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team1, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team1, cookie, &ref1)); CHK(context.CheckMessageMessages(caller, team1, cookie)); CHK(context.CheckArgvMessage(caller, team1, cookie, &ref1)); if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -940,6 +957,7 @@ CommonLaunchTest20(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team1, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team1, cookie, &ref1)); // CHK(context.CheckMessageMessages(caller, team1, cookie)); CHK(context.CheckArgvMessage(caller, team1, cookie, &ref1)); // if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -950,6 +968,7 @@ CommonLaunchTest20(LaunchCaller &caller) // checks 2 cookie = 0; CHK(context.CheckNextMessage(caller2, team2, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller2, team2, cookie, &ref2)); // CHK(context.CheckMessageMessages(caller2, team2, cookie)); CHK(context.CheckArgvMessage(caller2, team2, cookie, &ref2)); // if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -997,6 +1016,7 @@ CommonLaunchTest21(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team1, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team1, cookie, &ref1)); CHK(context.CheckMessageMessages(caller, team1, cookie)); CHK(context.CheckArgvMessage(caller, team1, cookie, &ref1)); if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -1007,6 +1027,7 @@ CommonLaunchTest21(LaunchCaller &caller) // checks 2 cookie = 0; CHK(context.CheckNextMessage(caller2, team2, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller2, team2, cookie, &ref2)); CHK(context.CheckMessageMessages(caller2, team2, cookie)); CHK(context.CheckArgvMessage(caller2, team2, cookie, &ref2)); if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -1046,6 +1067,7 @@ CommonLaunchTest22(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team1, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team1, cookie, &ref1)); // CHK(context.CheckMessageMessages(caller, team1, cookie)); CHK(context.CheckArgvMessage(caller, team1, cookie, &ref1)); // if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -1085,6 +1107,7 @@ CommonLaunchTest23(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team1, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team1, cookie, &ref1)); CHK(context.CheckMessageMessages(caller, team1, cookie)); CHK(context.CheckArgvMessage(caller, team1, cookie, &ref1)); if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -1133,6 +1156,7 @@ CommonLaunchTest24(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team1, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team1, cookie, &ref1)); // CHK(context.CheckMessageMessages(caller, team1, cookie)); CHK(context.CheckArgvMessage(caller, team1, cookie, &ref1)); // if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -1178,6 +1202,7 @@ CommonLaunchTest25(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team1, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team1, cookie, &ref1)); CHK(context.CheckMessageMessages(caller, team1, cookie)); CHK(context.CheckArgvMessage(caller, team1, cookie, &ref1)); if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -1228,6 +1253,7 @@ CommonLaunchTest26(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team1, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team1, cookie, &ref1)); CHK(context.CheckMessageMessages(caller, team1, cookie)); CHK(context.CheckArgvMessage(caller, team1, cookie, &ref1)); if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -1273,6 +1299,7 @@ CommonLaunchTest27(LaunchCaller &caller) context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team1, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team1, cookie, &ref1)); // CHK(context.CheckMessageMessages(caller, team1, cookie)); CHK(context.CheckArgvMessage(caller, team1, cookie, &ref1)); // if (caller.SupportsRefs() && !caller.SupportsArgv()) @@ -1382,6 +1409,7 @@ void LaunchTester::LaunchTestA4() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); // CHK(context.CheckMessageMessages(caller, team, cookie)); // CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); // CHK(context.CheckRefsMessage(caller, team, cookie)); @@ -1474,6 +1502,7 @@ void LaunchTester::LaunchTestB4() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); // CHK(context.CheckMessageMessages(caller, team, cookie)); // CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); // CHK(context.CheckRefsMessage(caller, team, cookie)); @@ -1508,6 +1537,7 @@ void LaunchTester::LaunchTestB5() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); // CHK(context.CheckMessageMessages(caller, team, cookie)); // CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); // CHK(context.CheckRefsMessage(caller, team, cookie)); @@ -1602,6 +1632,7 @@ void LaunchTester::LaunchTestC4() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref, 0, NULL)); // CHK(context.CheckMessageMessages(caller, team, cookie)); // CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); // CHK(context.CheckRefsMessage(caller, team, cookie)); @@ -1732,6 +1763,7 @@ void LaunchTester::LaunchTestD3() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); CHK(context.CheckMessageMessages(caller, team, cookie)); // CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); CHK(context.CheckRefsMessage(caller, team, cookie)); @@ -1770,6 +1802,7 @@ void LaunchTester::LaunchTestD4() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); CHK(context.CheckMessageMessages(caller, team, cookie)); // CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); CHK(context.CheckRefsMessage(caller, team, cookie)); @@ -1811,6 +1844,7 @@ void LaunchTester::LaunchTestD5() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); CHK(context.CheckMessageMessages(caller, team, cookie)); // CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); CHK(context.CheckRefsMessage(caller, team, cookie)); @@ -1823,8 +1857,8 @@ void LaunchTester::LaunchTestD5() status_t Launch(const entry_ref *ref, const BMessage *initialMessage, team_id *app_team) const @case 6 ref is valid, file has type, the type's preferred app - type is not installed, app exists and has signature, - file is executable + type is not installed, app exists and has signature, file + has executable permission, but is not executable @results Should return B_LAUNCH_FAILED_EXECUTABLE. Should not set the app hint on the app or file type. */ @@ -1877,6 +1911,7 @@ void LaunchTester::LaunchTestD7() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); CHK(context.CheckMessageMessages(caller, team, cookie)); // CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); CHK(context.CheckRefsMessage(caller, team, cookie)); @@ -1953,6 +1988,7 @@ void LaunchTester::LaunchTestD10() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); // CHK(context.CheckMessageMessages(caller, team, cookie)); // CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); CHK(context.CheckRefsMessage(caller, team, cookie)); @@ -2079,6 +2115,7 @@ void LaunchTester::LaunchTestE3() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); CHK(context.CheckMessageMessages(caller, team, cookie)); // CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); CHK(context.CheckRefsMessage(caller, team, cookie)); @@ -2117,6 +2154,7 @@ void LaunchTester::LaunchTestE4() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); CHK(context.CheckMessageMessages(caller, team, cookie)); // CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); CHK(context.CheckRefsMessage(caller, team, cookie)); @@ -2158,6 +2196,7 @@ void LaunchTester::LaunchTestE5() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); CHK(context.CheckMessageMessages(caller, team, cookie)); // CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); CHK(context.CheckRefsMessage(caller, team, cookie)); @@ -2170,8 +2209,8 @@ void LaunchTester::LaunchTestE5() status_t Launch(const entry_ref *ref, const BList *messageList, team_id *appTeam) const @case 6 ref is valid, file has type, the type's preferred app - type is not installed, app exists and has signature, - file is executable + type is not installed, app exists and has signature, file + has executable permission, but is not executable @results Should return B_LAUNCH_FAILED_EXECUTABLE. Should not set the app hint on the app or file type. */ @@ -2223,6 +2262,7 @@ void LaunchTester::LaunchTestE7() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); CHK(context.CheckMessageMessages(caller, team, cookie)); // CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); CHK(context.CheckRefsMessage(caller, team, cookie)); @@ -2299,6 +2339,7 @@ void LaunchTester::LaunchTestE10() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); // CHK(context.CheckMessageMessages(caller, team, cookie)); // CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); CHK(context.CheckRefsMessage(caller, team, cookie)); @@ -2338,6 +2379,7 @@ void LaunchTester::LaunchTestE11() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); // CHK(context.CheckMessageMessages(caller, team, cookie)); // CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); CHK(context.CheckRefsMessage(caller, team, cookie)); @@ -2464,6 +2506,7 @@ void LaunchTester::LaunchTestF3() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); // CHK(context.CheckMessageMessages(caller, team, cookie)); CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); // CHK(context.CheckRefsMessage(caller, team, cookie)); @@ -2502,6 +2545,7 @@ void LaunchTester::LaunchTestF4() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); // CHK(context.CheckMessageMessages(caller, team, cookie)); CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); // CHK(context.CheckRefsMessage(caller, team, cookie)); @@ -2543,6 +2587,7 @@ void LaunchTester::LaunchTestF5() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); // CHK(context.CheckMessageMessages(caller, team, cookie)); CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); // CHK(context.CheckRefsMessage(caller, team, cookie)); @@ -2555,8 +2600,8 @@ void LaunchTester::LaunchTestF5() status_t Launch(const entry_ref *ref, int argc, const char * const *args, team_id *appTeam) const @case 6 ref is valid, file has type, the type's preferred app - type is not installed, app exists and has signature, - file is executable + type is not installed, app exists and has signature, file + has executable permission, but is not executable @results Should return B_LAUNCH_FAILED_EXECUTABLE. Should not set the app hint on the app or file type. */ @@ -2608,6 +2653,7 @@ void LaunchTester::LaunchTestF7() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref)); // CHK(context.CheckMessageMessages(caller, team, cookie)); CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); // CHK(context.CheckRefsMessage(caller, team, cookie)); @@ -2683,6 +2729,7 @@ void LaunchTester::LaunchTestF10() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref, 0, NULL)); // CHK(context.CheckMessageMessages(caller, team, cookie)); // CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); CHK(context.CheckRefsMessage(caller, team, cookie)); @@ -2720,6 +2767,7 @@ void LaunchTester::LaunchTestF11() context.Terminate(); int32 cookie = 0; CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED)); + CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref, 0, NULL)); // CHK(context.CheckMessageMessages(caller, team, cookie)); // CHK(context.CheckArgvMessage(caller, team, cookie, &ref)); CHK(context.CheckRefsMessage(caller, team, cookie)); diff --git a/src/tests/kits/app/broster/LaunchTesterHelper.cpp b/src/tests/kits/app/broster/LaunchTesterHelper.cpp index 14f6521dba..e01a69c6c8 100644 --- a/src/tests/kits/app/broster/LaunchTesterHelper.cpp +++ b/src/tests/kits/app/broster/LaunchTesterHelper.cpp @@ -245,6 +245,7 @@ LaunchContext::HandleMessage(BMessage *message) switch (message->what) { case MSG_STARTED: case MSG_TERMINATED: + case MSG_MAIN_ARGS: case MSG_ARGV_RECEIVED: case MSG_REFS_RECEIVED: case MSG_MESSAGE_RECEIVED: @@ -337,6 +338,34 @@ LaunchContext::CheckNextMessage(LaunchCaller &caller, team_id team, return (message && message->what == what); } +// CheckMainArgsMessage +bool +LaunchContext::CheckMainArgsMessage(LaunchCaller &caller, team_id team, + int32 &cookie, const entry_ref *appRef, + bool useRef) +{ + int32 argc = 0; + const char **argv = NULL; + if (caller.SupportsArgv()) { + argc = kStandardArgc; + argv = kStandardArgv; + } + return CheckMainArgsMessage(caller, team, cookie, appRef, argc, argv, + useRef); +} + +// CheckMainArgsMessage +bool +LaunchContext::CheckMainArgsMessage(LaunchCaller &caller, team_id team, + int32 &cookie, const entry_ref *appRef, + int32 argc, const char **argv, bool useRef) +{ + useRef &= caller.SupportsArgv() && argv && argc > 0; + const entry_ref *ref = (useRef ? caller.Ref() : NULL); + return CheckArgsMessage(caller, team, cookie, appRef, ref, argc, argv, + MSG_MAIN_ARGS); +} + // CheckArgvMessage bool LaunchContext::CheckArgvMessage(LaunchCaller &caller, team_id team, @@ -367,9 +396,20 @@ LaunchContext::CheckArgvMessage(LaunchCaller &caller, team_id team, int32 &cookie, const entry_ref *appRef, const entry_ref *ref , int32 argc, const char **argv) +{ + return CheckArgsMessage(caller, team, cookie, appRef, ref, argc, argv, + MSG_ARGV_RECEIVED); +} + +// CheckArgsMessage +bool +LaunchContext::CheckArgsMessage(LaunchCaller &caller, team_id team, + int32 &cookie, const entry_ref *appRef, + const entry_ref *ref , int32 argc, + const char **argv, uint32 messageCode) { BMessage *message = NextMessageFrom(team, cookie); - bool result = (message && message->what == MSG_ARGV_RECEIVED); + bool result = (message && message->what == messageCode); int32 additionalRef = (ref ? 1 : 0); // check argc int32 foundArgc = -1; diff --git a/src/tests/kits/app/broster/LaunchTesterHelper.h b/src/tests/kits/app/broster/LaunchTesterHelper.h index 33e5db5d98..329b4680c6 100644 --- a/src/tests/kits/app/broster/LaunchTesterHelper.h +++ b/src/tests/kits/app/broster/LaunchTesterHelper.h @@ -63,6 +63,13 @@ public: bigtime_t *time = NULL); bool CheckNextMessage(LaunchCaller &caller, team_id team, int32 &cookie, uint32 what); + bool CheckMainArgsMessage(LaunchCaller &caller, team_id team, + int32 &cookie, const entry_ref *appRef, + bool useRef = true); + bool CheckMainArgsMessage(LaunchCaller &caller, team_id team, + int32 &cookie, const entry_ref *appRef, + int32 argc, const char **argv, + bool useRef = true); bool CheckArgvMessage(LaunchCaller &caller, team_id team, int32 &cookie, const entry_ref *appRef, bool useRef = true); bool CheckArgvMessage(LaunchCaller &caller, team_id team, int32 &cookie, @@ -71,6 +78,9 @@ public: bool CheckArgvMessage(LaunchCaller &caller, team_id team, int32 &cookie, const entry_ref *appRef, const entry_ref *ref, int32 argc, const char **argv); + bool CheckArgsMessage(LaunchCaller &caller, team_id team, int32 &cookie, + const entry_ref *appRef, const entry_ref *ref, + int32 argc, const char **argv, uint32 messageCode); bool CheckMessageMessages(LaunchCaller &caller, team_id team, int32 &cookie); bool CheckMessageMessage(LaunchCaller &caller, team_id team, int32 &cookie, diff --git a/src/tests/kits/app/broster/RosterTestAppDefs.h b/src/tests/kits/app/broster/RosterTestAppDefs.h index 6a3854b8fe..95a3c24c19 100644 --- a/src/tests/kits/app/broster/RosterTestAppDefs.h +++ b/src/tests/kits/app/broster/RosterTestAppDefs.h @@ -6,6 +6,8 @@ enum { MSG_STARTED = 'strt', // "path": B_STRING_TYPE MSG_TERMINATED = 'term', // + MSG_MAIN_ARGS = 'args', // "argc": B_INT32_TYPE, + // "argv": B_STRING_TYPE[] MSG_ARGV_RECEIVED = 'argv', // "argc": B_INT32_TYPE, // "argv": B_STRING_TYPE[] MSG_REFS_RECEIVED = 'refs', // "refs": B_REF_TYPE[] diff --git a/src/tests/kits/app/broster/testapps/RosterLaunchTestApp1.cpp b/src/tests/kits/app/broster/testapps/RosterLaunchTestApp1.cpp index eca318646a..e521475336 100644 --- a/src/tests/kits/app/broster/testapps/RosterLaunchTestApp1.cpp +++ b/src/tests/kits/app/broster/testapps/RosterLaunchTestApp1.cpp @@ -130,7 +130,7 @@ public: // main int -main() +main(int argc, char **argv) { // find app file and get signature from resources char path[B_PATH_NAME_LENGTH]; @@ -165,6 +165,12 @@ main() BMessage message(MSG_STARTED); message.AddString("path", path); unitTesterMessenger.SendMessage(&message); + // send main() args message + BMessage argsMessage(MSG_MAIN_ARGS); + argsMessage.AddInt32("argc", argc); + for (int i = 0; i < argc; i++) + argsMessage.AddString("argv", argv[i]); + unitTesterMessenger.SendMessage(&argsMessage); // run the app app->Run(); delete app;