aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
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 5138454bd8..293fb79175 100644
--- a/engines/testbed/cloud.cpp
+++ b/engines/testbed/cloud.cpp
@@ -41,6 +41,7 @@ CloudTestSuite::CloudTestSuite() {
addTest("ListDirectory", &CloudTests::testDirectoryListing, true);
addTest("CreateDirectory", &CloudTests::testDirectoryCreating, true);
addTest("FileUpload", &CloudTests::testUploading, true);
+ addTest("FileDownload", &CloudTests::testDownloading, true);
}
/*
@@ -128,6 +129,15 @@ void CloudTests::fileUploadedCallback(Cloud::Storage::UploadResponse response) {
Testsuite::logPrintf("Info! It's id = '%s' and size = '%lu'\n", response.value.id().c_str(), response.value.size());
}
+void CloudTests::fileDownloadedCallback(Cloud::Storage::BoolResponse response) {
+ ConfParams.setCloudTestCallbackCalled(true);
+ if (response.value) {
+ Testsuite::logPrintf("Info! File downloaded!\n");
+ } else {
+ Testsuite::logPrintf("Info! Failed to download the file!\n");
+ }
+}
+
void CloudTests::errorCallback(Networking::ErrorResponse response) {
ConfParams.setCloudTestErrorCallbackCalled(true);
Testsuite::logPrintf("Info! Error Callback was called\n");
@@ -387,4 +397,51 @@ TestExitStatus CloudTests::testUploading() {
return kTestPassed;
}
+TestExitStatus CloudTests::testDownloading() {
+ 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 download() method.\n"
+ "In this test we'll try to download that 'testbed/testfile.txt' file.";
+
+ if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
+ Testsuite::logPrintf("Info! Skipping test : download()\n");
+ return kTestSkipped;
+ }
+
+ const Common::String &path = ConfMan.get("path");
+ Common::FSDirectory gameRoot(path);
+ Common::FSNode node = gameRoot.getFSNode().getChild("downloaded_file.txt");
+ Common::String filepath = node.getPath();
+ if (CloudMan.getCurrentStorage()->download(
+ "/testbed/testfile.txt",
+ filepath.c_str(),
+ new Common::GlobalFunctionCallback<Cloud::Storage::BoolResponse>(&fileDownloadedCallback),
+ 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_file.txt' file?", "Yes", "No", kOptionRight)) {
+ Testsuite::logDetailedPrintf("Error! File was not downloaded!\n");
+ return kTestFailed;
+ }
+
+ Testsuite::logDetailedPrintf("File was downloaded\n");
+ return kTestPassed;
+}
+
} // End of namespace Testbed
diff --git a/engines/testbed/cloud.h b/engines/testbed/cloud.h
index 177ac740a9..266bd32437 100644
--- a/engines/testbed/cloud.h
+++ b/engines/testbed/cloud.h
@@ -40,12 +40,14 @@ void infoCallback(Cloud::Storage::StorageInfoResponse response);
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 errorCallback(Networking::ErrorResponse response);
TestExitStatus testInfo();
TestExitStatus testDirectoryListing();
TestExitStatus testDirectoryCreating();
TestExitStatus testUploading();
+TestExitStatus testDownloading();
} // End of namespace CloudTests