aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorAlexander Tkachev2016-07-18 17:06:09 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commit817d831255ad37f82c21ba7f00c4795a536d33fb (patch)
tree7b7c7aabf1b63cd075f469b0f7f39c439f0a321e /engines
parent830c7b578caaec95594e190d6727892b1973df62 (diff)
downloadscummvm-rg350-817d831255ad37f82c21ba7f00c4795a536d33fb.tar.gz
scummvm-rg350-817d831255ad37f82c21ba7f00c4795a536d33fb.tar.bz2
scummvm-rg350-817d831255ad37f82c21ba7f00c4795a536d33fb.zip
TESTBED: Add more Webserver tests
Diffstat (limited to 'engines')
-rw-r--r--engines/testbed/webserver.cpp135
-rw-r--r--engines/testbed/webserver.h5
2 files changed, 140 insertions, 0 deletions
diff --git a/engines/testbed/webserver.cpp b/engines/testbed/webserver.cpp
index f17b5a6f8c..feb2911704 100644
--- a/engines/testbed/webserver.cpp
+++ b/engines/testbed/webserver.cpp
@@ -30,6 +30,11 @@ namespace Testbed {
WebserverTestSuite::WebserverTestSuite() {
addTest("ResolveIP", &WebserverTests::testIP, true);
addTest("IndexPage", &WebserverTests::testIndexPage, true);
+ addTest("FilesPage", &WebserverTests::testFilesPageInvalidParameterValue, true);
+ addTest("CreateDirectory", &WebserverTests::testFilesPageCreateDirectory, true);
+ addTest("UploadFile", &WebserverTests::testFilesPageUploadFile, true);
+ addTest("UploadDirectory", &WebserverTests::testFilesPageUploadDirectory, true);
+ addTest("DownloadFile", &WebserverTests::testFilesPageDownloadFile, true);
}
///// TESTS GO HERE /////
@@ -99,4 +104,134 @@ TestExitStatus WebserverTests::testIndexPage() {
return kTestPassed;
}
+TestExitStatus WebserverTests::testFilesPageInvalidParameterValue() {
+ if (!startServer()) {
+ Testsuite::logPrintf("Error! Can't start local webserver!\n");
+ return kTestFailed;
+ }
+
+ Common::String info = "Testing Webserver's files page.\n"
+ "In this test we'll try to pass invalid parameter to files page.";
+
+ if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
+ Testsuite::logPrintf("Info! Skipping test : files page (invalid parameter)\n");
+ return kTestSkipped;
+ }
+
+ Networking::Browser::openUrl(LocalServer.getAddress()+"files?path=error");
+ if (Testsuite::handleInteractiveInput(
+ Common::String::format("The %sfiles?path=error page displays error message?", LocalServer.getAddress().c_str()),
+ "Yes", "No", kOptionRight)) {
+ Testsuite::logDetailedPrintf("Error! No error message on invalid parameter in '/files'!\n");
+ return kTestFailed;
+ }
+
+ Testsuite::logDetailedPrintf("Server's files page detects invalid paramters fine\n");
+ return kTestPassed;
+}
+
+TestExitStatus WebserverTests::testFilesPageCreateDirectory() {
+ if (!startServer()) {
+ Testsuite::logPrintf("Error! Can't start local webserver!\n");
+ return kTestFailed;
+ }
+
+ Common::String info = "Testing Webserver's files page Create Directory feature.\n"
+ "In this test you'll try to create directory.";
+
+ if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
+ Testsuite::logPrintf("Info! Skipping test : files page create directory\n");
+ return kTestSkipped;
+ }
+
+ Networking::Browser::openUrl(LocalServer.getAddress() + "files?path=/root/");
+ if (Testsuite::handleInteractiveInput(
+ Common::String::format("You could go to %sfiles page, navigate to some directory with write access and create a directory there?", LocalServer.getAddress().c_str()),
+ "Yes", "No", kOptionRight)) {
+ Testsuite::logDetailedPrintf("Error! Create Directory is not working!\n");
+ return kTestFailed;
+ }
+
+ Testsuite::logDetailedPrintf("Create Directory is OK\n");
+ return kTestPassed;
+}
+
+TestExitStatus WebserverTests::testFilesPageUploadFile() {
+ if (!startServer()) {
+ Testsuite::logPrintf("Error! Can't start local webserver!\n");
+ return kTestFailed;
+ }
+
+ Common::String info = "Testing Webserver's files page Upload Files feature.\n"
+ "In this test you'll try to upload a file.";
+
+ if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
+ Testsuite::logPrintf("Info! Skipping test : files page file upload\n");
+ return kTestSkipped;
+ }
+
+ Networking::Browser::openUrl(LocalServer.getAddress() + "files?path=/root/");
+ if (Testsuite::handleInteractiveInput(
+ Common::String::format("You're able to upload a file in some directory with write access through %sfiles page?", LocalServer.getAddress().c_str()),
+ "Yes", "No", kOptionRight)) {
+ Testsuite::logDetailedPrintf("Error! Upload Files is not working!\n");
+ return kTestFailed;
+ }
+
+ Testsuite::logDetailedPrintf("Upload Files is OK\n");
+ return kTestPassed;
+}
+
+TestExitStatus WebserverTests::testFilesPageUploadDirectory() {
+ if (!startServer()) {
+ Testsuite::logPrintf("Error! Can't start local webserver!\n");
+ return kTestFailed;
+ }
+
+ Common::String info = "Testing Webserver's files page Upload Directory feature.\n"
+ "In this test you'll try to upload a directory (works in Chrome only).";
+
+ if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
+ Testsuite::logPrintf("Info! Skipping test : files page directory upload\n");
+ return kTestSkipped;
+ }
+
+ Networking::Browser::openUrl(LocalServer.getAddress() + "files?path=/root/");
+ if (Testsuite::handleInteractiveInput(
+ Common::String::format("You're able to upload a directory into some directory with write access through %sfiles page using Chrome?", LocalServer.getAddress().c_str()),
+ "Yes", "No", kOptionRight)) {
+ Testsuite::logDetailedPrintf("Error! Upload Directory is not working!\n");
+ return kTestFailed;
+ }
+
+ Testsuite::logDetailedPrintf("Upload Directory is OK\n");
+ return kTestPassed;
+}
+
+TestExitStatus WebserverTests::testFilesPageDownloadFile() {
+ if (!startServer()) {
+ Testsuite::logPrintf("Error! Can't start local webserver!\n");
+ return kTestFailed;
+ }
+
+ Common::String info = "Testing Webserver's files downloading feature.\n"
+ "In this test you'll try to download a file.";
+
+ if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
+ Testsuite::logPrintf("Info! Skipping test : files page download\n");
+ return kTestSkipped;
+ }
+
+ Networking::Browser::openUrl(LocalServer.getAddress() + "files?path=/root/");
+ if (Testsuite::handleInteractiveInput(
+ Common::String::format("You're able to download a file through %sfiles page?", LocalServer.getAddress().c_str()),
+ "Yes", "No", kOptionRight)) {
+ Testsuite::logDetailedPrintf("Error! Files downloading is not working!\n");
+ return kTestFailed;
+ }
+
+ Testsuite::logDetailedPrintf("Files downloading is OK\n");
+ return kTestPassed;
+}
+
} // End of namespace Testbed
diff --git a/engines/testbed/webserver.h b/engines/testbed/webserver.h
index bdb37400b5..3f3083469e 100644
--- a/engines/testbed/webserver.h
+++ b/engines/testbed/webserver.h
@@ -34,6 +34,11 @@ namespace WebserverTests {
bool startServer();
TestExitStatus testIP();
TestExitStatus testIndexPage();
+TestExitStatus testFilesPageInvalidParameterValue();
+TestExitStatus testFilesPageCreateDirectory();
+TestExitStatus testFilesPageUploadFile();
+TestExitStatus testFilesPageUploadDirectory();
+TestExitStatus testFilesPageDownloadFile();
} // End of namespace WebserverTests