diff --git a/src/tests/kits/app/bapplication/BApplicationTester.cpp b/src/tests/kits/app/bapplication/BApplicationTester.cpp index ea2869dfac..1a68743f7d 100644 --- a/src/tests/kits/app/bapplication/BApplicationTester.cpp +++ b/src/tests/kits/app/bapplication/BApplicationTester.cpp @@ -40,10 +40,14 @@ test_app(const char *app, const char *expectedResult) appPath.CharacterEscape(" \t\n!\"'`$&()?*+{}[]<>|", '\\'); appPath += "/kits/app/"; appPath += app; +#ifdef TEST_R5 + appPath += "_r5"; +#endif // run the app AppRunner runner; CHK(runner.Run(appPath.String()) == B_OK); - snooze(100000); + while (!runner.HasQuitted()) + snooze(10000); // read the output and compare the result char buffer[1024]; ssize_t read = runner.ReadOutput(buffer, sizeof(buffer) - 1); @@ -68,12 +72,73 @@ void TBApplicationTester::BApplication1() "the \"application\" media type.\n"); } +/* + BApplication(const char *signature) + @case 2 signature is no valid MIME string + @results Should print error message and quit. + */ +void TBApplicationTester::BApplication2() +{ + test_app("BApplicationTestApp2", + "bad signature (no valid MIME string), must begin with " + "\"application/\" and can't conflict with existing registered " + "mime types inside the \"application\" media type.\n"); +} + +/* + BApplication(const char *signature) + @case 3 signature is a valid MIME string, but doesn't have the + "application" supertype + @results Should print error message and quit. + */ +void TBApplicationTester::BApplication3() +{ + test_app("BApplicationTestApp3", + "bad signature (image/gif), must begin with \"application/\" and " + "can't conflict with existing registered mime types inside " + "the \"application\" media type.\n"); +} + +/* + BApplication(const char *signature) + @case 4 signature is a valid MIME string with "application" + supertype, but a different one than in the app + attributes/resources + @results Should print warning message and continue. + InitCheck() should return B_OK. + */ +void TBApplicationTester::BApplication4() +{ + test_app("BApplicationTestApp4", + "Signature in rsrc doesn't match constructor arg. " + "(application/x-vnd.obos-bapplication-testapp4," + "application/x-vnd.obos-bapplication-testapp4-or-not)\n" + "InitCheck(): 0\n"); + +} + +/* + BApplication(const char *signature) + @case 5 signature is a valid MIME string with "application" + supertype, and the same as in the app attributes/resources + @results Shouldn't print anything at all and continue. + InitCheck() should return B_OK. + */ +void TBApplicationTester::BApplication5() +{ + test_app("BApplicationTestApp5", "InitCheck(): 0\n"); +} + Test* TBApplicationTester::Suite() { TestSuite* SuiteOfTests = new TestSuite; ADD_TEST4(BApplication, SuiteOfTests, TBApplicationTester, BApplication1); + ADD_TEST4(BApplication, SuiteOfTests, TBApplicationTester, BApplication2); + ADD_TEST4(BApplication, SuiteOfTests, TBApplicationTester, BApplication3); + ADD_TEST4(BApplication, SuiteOfTests, TBApplicationTester, BApplication4); + ADD_TEST4(BApplication, SuiteOfTests, TBApplicationTester, BApplication5); return SuiteOfTests; } diff --git a/src/tests/kits/app/bapplication/BApplicationTester.h b/src/tests/kits/app/bapplication/BApplicationTester.h index 9429f8ec8a..3f81399ef6 100644 --- a/src/tests/kits/app/bapplication/BApplicationTester.h +++ b/src/tests/kits/app/bapplication/BApplicationTester.h @@ -26,6 +26,10 @@ class TBApplicationTester : public TestCase TBApplicationTester(std::string name) : TestCase(name) {;} void BApplication1(); + void BApplication2(); + void BApplication3(); + void BApplication4(); + void BApplication5(); static Test* Suite(); }; diff --git a/src/tests/kits/app/bapplication/testapps/BApplicationTestApp2.cpp b/src/tests/kits/app/bapplication/testapps/BApplicationTestApp2.cpp new file mode 100644 index 0000000000..00e1334356 --- /dev/null +++ b/src/tests/kits/app/bapplication/testapps/BApplicationTestApp2.cpp @@ -0,0 +1,11 @@ +// BApplicationTestApp2.cpp + +#include + +int +main() +{ + BApplication app("no valid MIME string"); + return 0; +} + diff --git a/src/tests/kits/app/bapplication/testapps/BApplicationTestApp3.cpp b/src/tests/kits/app/bapplication/testapps/BApplicationTestApp3.cpp new file mode 100644 index 0000000000..bb432124d2 --- /dev/null +++ b/src/tests/kits/app/bapplication/testapps/BApplicationTestApp3.cpp @@ -0,0 +1,11 @@ +// BApplicationTestApp3.cpp + +#include + +int +main() +{ + BApplication app("image/gif"); + return 0; +} + diff --git a/src/tests/kits/app/bapplication/testapps/BApplicationTestApp4.cpp b/src/tests/kits/app/bapplication/testapps/BApplicationTestApp4.cpp new file mode 100644 index 0000000000..a473045771 --- /dev/null +++ b/src/tests/kits/app/bapplication/testapps/BApplicationTestApp4.cpp @@ -0,0 +1,14 @@ +// BApplicationTestApp4.cpp + +#include + +#include + +int +main() +{ + BApplication app("application/x-vnd.obos-bapplication-testapp4"); + printf("InitCheck(): %lx\n", app.InitCheck()); + return 0; +} + diff --git a/src/tests/kits/app/bapplication/testapps/BApplicationTestApp4.rsrc b/src/tests/kits/app/bapplication/testapps/BApplicationTestApp4.rsrc new file mode 100644 index 0000000000..b2f05b3b16 Binary files /dev/null and b/src/tests/kits/app/bapplication/testapps/BApplicationTestApp4.rsrc differ diff --git a/src/tests/kits/app/bapplication/testapps/BApplicationTestApp5.cpp b/src/tests/kits/app/bapplication/testapps/BApplicationTestApp5.cpp new file mode 100644 index 0000000000..fda589342d --- /dev/null +++ b/src/tests/kits/app/bapplication/testapps/BApplicationTestApp5.cpp @@ -0,0 +1,14 @@ +// BApplicationTestApp5.cpp + +#include + +#include + +int +main() +{ + BApplication app("application/x-vnd.obos-bapplication-testapp5"); + printf("InitCheck(): %lx\n", app.InitCheck()); + return 0; +} + diff --git a/src/tests/kits/app/bapplication/testapps/BApplicationTestApp5.rsrc b/src/tests/kits/app/bapplication/testapps/BApplicationTestApp5.rsrc new file mode 100644 index 0000000000..1ca1850578 Binary files /dev/null and b/src/tests/kits/app/bapplication/testapps/BApplicationTestApp5.rsrc differ diff --git a/src/tests/kits/app/bapplication/testapps/Jamfile b/src/tests/kits/app/bapplication/testapps/Jamfile index c90e81fcd7..56748a6647 100644 --- a/src/tests/kits/app/bapplication/testapps/Jamfile +++ b/src/tests/kits/app/bapplication/testapps/Jamfile @@ -7,3 +7,39 @@ CommonUnitTest BApplicationTestApp1 : be stdc++.r4 : app support ; + +CommonUnitTest BApplicationTestApp2 + : BApplicationTestApp2.cpp + : kits app + : libopenbeos.so be stdc++.r4 + : be stdc++.r4 + : app support +; + +CommonUnitTest BApplicationTestApp3 + : BApplicationTestApp3.cpp + : kits app + : libopenbeos.so be stdc++.r4 + : be stdc++.r4 + : app support +; + +AddResources BApplicationTestApp4 : BApplicationTestApp4.rsrc ; +AddResources BApplicationTestApp4_r5 : BApplicationTestApp4.rsrc ; +CommonUnitTest BApplicationTestApp4 + : BApplicationTestApp4.cpp + : kits app + : libopenbeos.so be stdc++.r4 + : be stdc++.r4 + : app support +; + +AddResources BApplicationTestApp5 : BApplicationTestApp5.rsrc ; +AddResources BApplicationTestApp5_r5 : BApplicationTestApp5.rsrc ; +CommonUnitTest BApplicationTestApp5 + : BApplicationTestApp5.cpp + : kits app + : libopenbeos.so be stdc++.r4 + : be stdc++.r4 + : app support +;