diff options
author | Alexander Tkachev | 2016-07-18 14:58:10 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | 04888cf454fb3243e82d424d46af1e2ca74d0b8c (patch) | |
tree | 2e3e2e4a3529e600957e6b12d9441e773dceab9a /engines/testbed/cloud.cpp | |
parent | 4e2725135674515821247307ab8358069d1db48c (diff) | |
download | scummvm-rg350-04888cf454fb3243e82d424d46af1e2ca74d0b8c.tar.gz scummvm-rg350-04888cf454fb3243e82d424d46af1e2ca74d0b8c.tar.bz2 scummvm-rg350-04888cf454fb3243e82d424d46af1e2ca74d0b8c.zip |
TESTBED: Add CloudTests::testSavesSync()
Diffstat (limited to 'engines/testbed/cloud.cpp')
-rw-r--r-- | engines/testbed/cloud.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/engines/testbed/cloud.cpp b/engines/testbed/cloud.cpp index 9c6563c292..9d10d7d051 100644 --- a/engines/testbed/cloud.cpp +++ b/engines/testbed/cloud.cpp @@ -43,6 +43,7 @@ CloudTestSuite::CloudTestSuite() { addTest("FileUpload", &CloudTests::testUploading, true); addTest("FileDownload", &CloudTests::testDownloading, true); addTest("FolderDownload", &CloudTests::testFolderDownloading, true); + addTest("SyncSaves", &CloudTests::testSavesSync, true); } /* @@ -148,6 +149,15 @@ void CloudTests::directoryDownloadedCallback(Cloud::Storage::FileArrayResponse r } } +void CloudTests::savesSyncedCallback(Cloud::Storage::BoolResponse response) { + ConfParams.setCloudTestCallbackCalled(true); + if (response.value) { + Testsuite::logPrintf("Info! Saves are synced successfully!\n"); + } else { + Testsuite::logPrintf("Warning! Saves were not synced!\n"); + } +} + void CloudTests::errorCallback(Networking::ErrorResponse response) { ConfParams.setCloudTestErrorCallbackCalled(true); Testsuite::logPrintf("Info! Error Callback was called\n"); @@ -501,4 +511,49 @@ TestExitStatus CloudTests::testFolderDownloading() { return kTestPassed; } +TestExitStatus CloudTests::testSavesSync() { + 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 syncSaves() method.\n" + "In this test we'll try to sync your saves."; + + if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { + Testsuite::logPrintf("Info! Skipping test : syncSaves()\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.syncSaves( + new Common::GlobalFunctionCallback<Cloud::Storage::BoolResponse>(&savesSyncedCallback), + 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 sync saves?", "Yes", "No", kOptionRight)) { + Testsuite::logDetailedPrintf("Error! Saves were not synced!\n"); + return kTestFailed; + } + + Testsuite::logDetailedPrintf("Saves were synced successfully\n"); + return kTestPassed; +} + } // End of namespace Testbed |