aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorAlexander Tkachev2016-07-18 14:34:17 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commit4e2725135674515821247307ab8358069d1db48c (patch)
treed66170dd521f89327992932633b0478a7f298bbc /engines
parent7a34abe39e7fc5dc7ece81db5be84701599d4be2 (diff)
downloadscummvm-rg350-4e2725135674515821247307ab8358069d1db48c.tar.gz
scummvm-rg350-4e2725135674515821247307ab8358069d1db48c.tar.bz2
scummvm-rg350-4e2725135674515821247307ab8358069d1db48c.zip
TESTBED: Add CloudTests::testFolderDownloading()
Diffstat (limited to 'engines')
-rw-r--r--engines/testbed/cloud.cpp57
-rw-r--r--engines/testbed/cloud.h2
2 files changed, 59 insertions, 0 deletions
diff --git a/engines/testbed/cloud.cpp b/engines/testbed/cloud.cpp
index 293fb79175..9c6563c292 100644
--- a/engines/testbed/cloud.cpp
+++ b/engines/testbed/cloud.cpp
@@ -42,6 +42,7 @@ CloudTestSuite::CloudTestSuite() {
addTest("CreateDirectory", &CloudTests::testDirectoryCreating, true);
addTest("FileUpload", &CloudTests::testUploading, true);
addTest("FileDownload", &CloudTests::testDownloading, true);
+ addTest("FolderDownload", &CloudTests::testFolderDownloading, true);
}
/*
@@ -138,6 +139,15 @@ void CloudTests::fileDownloadedCallback(Cloud::Storage::BoolResponse response) {
}
}
+void CloudTests::directoryDownloadedCallback(Cloud::Storage::FileArrayResponse response) {
+ ConfParams.setCloudTestCallbackCalled(true);
+ if (response.value.size() == 0) {
+ Testsuite::logPrintf("Info! Directory is downloaded successfully!\n");
+ } else {
+ Testsuite::logPrintf("Warning! %lu files were not downloaded during folder downloading!\n", response.value.size());
+ }
+}
+
void CloudTests::errorCallback(Networking::ErrorResponse response) {
ConfParams.setCloudTestErrorCallbackCalled(true);
Testsuite::logPrintf("Info! Error Callback was called\n");
@@ -444,4 +454,51 @@ TestExitStatus CloudTests::testDownloading() {
return kTestPassed;
}
+TestExitStatus CloudTests::testFolderDownloading() {
+ ConfParams.setCloudTestCallbackCalled(false);
+ ConfParams.setCloudTestErrorCallbackCalled(false);
+
+ if (CloudMan.getCurrentStorage() == nullptr) {
+ Testsuite::logPrintf("Couldn't find connected Storage\n");
+ return kTestFailed;
+ }
+
+ Common::String info = "Testing Cloud Storage API downloadFolder() method.\n"
+ "In this test we'll try to download remote 'testbed/' directory.";
+
+ if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
+ Testsuite::logPrintf("Info! Skipping test : downloadFolder()\n");
+ return kTestSkipped;
+ }
+
+ const Common::String &path = ConfMan.get("path");
+ Common::FSDirectory gameRoot(path);
+ Common::FSNode node = gameRoot.getFSNode().getChild("downloaded_directory");
+ Common::String filepath = node.getPath();
+ if (CloudMan.downloadFolder(
+ "/testbed/",
+ filepath.c_str(),
+ new Common::GlobalFunctionCallback<Cloud::Storage::FileArrayResponse>(&directoryDownloadedCallback),
+ new Common::GlobalFunctionCallback<Networking::ErrorResponse>(&errorCallback)
+ ) == nullptr) {
+ Testsuite::logPrintf("Warning! No Request is returned!\n");
+ }
+
+ if (!waitForCallbackMore()) return kTestSkipped;
+ Testsuite::clearScreen();
+
+ if (ConfParams.isCloudTestErrorCallbackCalled()) {
+ Testsuite::logPrintf("Error callback was called\n");
+ return kTestFailed;
+ }
+
+ if (Testsuite::handleInteractiveInput("Was the CloudMan able to download into 'testbed/downloaded_directory'?", "Yes", "No", kOptionRight)) {
+ Testsuite::logDetailedPrintf("Error! Directory was not downloaded!\n");
+ return kTestFailed;
+ }
+
+ Testsuite::logDetailedPrintf("Directory was downloaded\n");
+ return kTestPassed;
+}
+
} // End of namespace Testbed
diff --git a/engines/testbed/cloud.h b/engines/testbed/cloud.h
index 266bd32437..e9df51c27b 100644
--- a/engines/testbed/cloud.h
+++ b/engines/testbed/cloud.h
@@ -41,6 +41,7 @@ void directoryListedCallback(Cloud::Storage::FileArrayResponse response);
void directoryCreatedCallback(Cloud::Storage::BoolResponse response);
void fileUploadedCallback(Cloud::Storage::UploadResponse response);
void fileDownloadedCallback(Cloud::Storage::BoolResponse response);
+void directoryDownloadedCallback(Cloud::Storage::FileArrayResponse response);
void errorCallback(Networking::ErrorResponse response);
TestExitStatus testInfo();
@@ -48,6 +49,7 @@ TestExitStatus testDirectoryListing();
TestExitStatus testDirectoryCreating();
TestExitStatus testUploading();
TestExitStatus testDownloading();
+TestExitStatus testFolderDownloading();
} // End of namespace CloudTests