From e500bd93e1c2cea34405abd82ddd81cd09147150 Mon Sep 17 00:00:00 2001 From: 53845714nF Date: Thu, 23 May 2024 15:15:39 +0200 Subject: [PATCH] rename function to takeScreenshotAsBase64 --- lib/CMakeLists.txt | 4 ++-- lib/include/Spix/TestServer.h | 2 +- lib/src/AnyRpcServer.cpp | 6 +++--- .../{ScreenshotRemote.cpp => ScreenshotBase64.cpp} | 8 ++++---- .../Commands/{ScreenshotRemote.h => ScreenshotBase64.h} | 4 ++-- lib/src/Scene/Mock/MockScene.cpp | 2 +- lib/src/Scene/Mock/MockScene.h | 2 +- lib/src/Scene/Qt/QtScene.cpp | 2 +- lib/src/Scene/Qt/QtScene.h | 2 +- lib/src/Scene/Scene.h | 2 +- lib/src/TestServer.cpp | 6 +++--- 11 files changed, 20 insertions(+), 20 deletions(-) rename lib/src/Commands/{ScreenshotRemote.cpp => ScreenshotBase64.cpp} (60%) rename lib/src/Commands/{ScreenshotRemote.h => ScreenshotBase64.h} (70%) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 8962b9d..29fbac4 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -60,8 +60,8 @@ set(SOURCES src/Commands/Quit.h src/Commands/Screenshot.cpp src/Commands/Screenshot.h - src/Commands/ScreenshotRemote.cpp - src/Commands/ScreenshotRemote.h + src/Commands/ScreenshotBase64.cpp + src/Commands/ScreenshotBase64.h src/Commands/SetProperty.cpp src/Commands/SetProperty.h src/Commands/Wait.cpp diff --git a/lib/include/Spix/TestServer.h b/lib/include/Spix/TestServer.h index 925a59f..92ccce2 100644 --- a/lib/include/Spix/TestServer.h +++ b/lib/include/Spix/TestServer.h @@ -66,7 +66,7 @@ class SPIX_EXPORT TestServer { std::vector getErrors(); void takeScreenshot(ItemPath targetItem, std::string filePath); - std::string takeScreenshotRemote(ItemPath targetItem); + std::string takeScreenshotAsBase64(ItemPath targetItem); void quit(); protected: diff --git a/lib/src/AnyRpcServer.cpp b/lib/src/AnyRpcServer.cpp index 44be6dc..fb6c3c5 100644 --- a/lib/src/AnyRpcServer.cpp +++ b/lib/src/AnyRpcServer.cpp @@ -117,9 +117,9 @@ AnyRpcServer::AnyRpcServer(int anyrpcPort) return takeScreenshot(std::move(targetItem), std::move(filePath)); }); - utils::AddFunctionToAnyRpc(methodManager, "takeScreenshotRemote", - "Take a screenshot of the object and send as base64 string | takeScreenshotRemote(string pathToTargetedItem)", - [this](std::string targetItem) { return takeScreenshotRemote(std::move(targetItem)); }); + utils::AddFunctionToAnyRpc(methodManager, "takeScreenshotAsBase64", + "Take a screenshot of the object and send as base64 string | takeScreenshotAsBase64(string pathToTargetedItem)", + [this](std::string targetItem) { return takeScreenshotAsBase64(std::move(targetItem)); }); utils::AddFunctionToAnyRpc(methodManager, "quit", "Close the app | quit()", [this] { quit(); }); diff --git a/lib/src/Commands/ScreenshotRemote.cpp b/lib/src/Commands/ScreenshotBase64.cpp similarity index 60% rename from lib/src/Commands/ScreenshotRemote.cpp rename to lib/src/Commands/ScreenshotBase64.cpp index a802215..9ed93e7 100644 --- a/lib/src/Commands/ScreenshotRemote.cpp +++ b/lib/src/Commands/ScreenshotBase64.cpp @@ -4,21 +4,21 @@ * See LICENSE.txt file in the project root for full license information. ****/ -#include "ScreenshotRemote.h" +#include "ScreenshotBase64.h" #include namespace spix { namespace cmd { -ScreenshotRemote::ScreenshotRemote(ItemPath targetItemPath, std::promise promise) +ScreenshotAsBase64::ScreenshotAsBase64(ItemPath targetItemPath, std::promise promise) : m_itemPath {std::move(targetItemPath)} , m_promise(std::move(promise)) { } -void ScreenshotRemote::execute(CommandEnvironment& env) +void ScreenshotAsBase64::execute(CommandEnvironment& env) { - auto value = env.scene().takeScreenshotRemote(m_itemPath); + auto value = env.scene().takeScreenshotAsBase64(m_itemPath); m_promise.set_value(value); } diff --git a/lib/src/Commands/ScreenshotRemote.h b/lib/src/Commands/ScreenshotBase64.h similarity index 70% rename from lib/src/Commands/ScreenshotRemote.h rename to lib/src/Commands/ScreenshotBase64.h index f34d20a..477bf17 100644 --- a/lib/src/Commands/ScreenshotRemote.h +++ b/lib/src/Commands/ScreenshotBase64.h @@ -8,9 +8,9 @@ namespace spix { namespace cmd { -class ScreenshotRemote : public Command { +class ScreenshotAsBase64 : public Command { public: - ScreenshotRemote(ItemPath targetItemPath, std::promise promise); + ScreenshotAsBase64(ItemPath targetItemPath, std::promise promise); void execute(CommandEnvironment& env) override; diff --git a/lib/src/Scene/Mock/MockScene.cpp b/lib/src/Scene/Mock/MockScene.cpp index ac081e1..586eac9 100644 --- a/lib/src/Scene/Mock/MockScene.cpp +++ b/lib/src/Scene/Mock/MockScene.cpp @@ -28,7 +28,7 @@ void MockScene::takeScreenshot(const ItemPath&, const std::string&) { } -std::string MockScene::takeScreenshotRemote(const ItemPath&) +std::string MockScene::takeScreenshotAsBase64(const ItemPath&) { return "Base64 String"; } diff --git a/lib/src/Scene/Mock/MockScene.h b/lib/src/Scene/Mock/MockScene.h index 5f16da0..8a9b757 100644 --- a/lib/src/Scene/Mock/MockScene.h +++ b/lib/src/Scene/Mock/MockScene.h @@ -25,7 +25,7 @@ class SPIX_EXPORT MockScene : public Scene { // Tasks void takeScreenshot(const ItemPath& targetItem, const std::string& filePath) override; - std::string takeScreenshotRemote(const ItemPath& targetItem); + std::string takeScreenshotAsBase64(const ItemPath& targetItem); // Mock stuff void addItemAtPath(MockItem item, const ItemPath& path); MockEvents& mockEvents(); diff --git a/lib/src/Scene/Qt/QtScene.cpp b/lib/src/Scene/Qt/QtScene.cpp index d442123..d320e7d 100644 --- a/lib/src/Scene/Qt/QtScene.cpp +++ b/lib/src/Scene/Qt/QtScene.cpp @@ -141,7 +141,7 @@ void QtScene::takeScreenshot(const ItemPath& targetItem, const std::string& file image.save(QString::fromStdString(filePath)); } -std::string QtScene::takeScreenshotRemote(const ItemPath& targetItem) +std::string QtScene::takeScreenshotAsBase64(const ItemPath& targetItem) { auto item = getQQuickItemAtPath(targetItem); if (!item) { diff --git a/lib/src/Scene/Qt/QtScene.h b/lib/src/Scene/Qt/QtScene.h index 8ff9cf2..1897845 100644 --- a/lib/src/Scene/Qt/QtScene.h +++ b/lib/src/Scene/Qt/QtScene.h @@ -29,7 +29,7 @@ class QtScene : public Scene { // Tasks void takeScreenshot(const ItemPath& targetItem, const std::string& filePath) override; - std::string takeScreenshotRemote(const ItemPath& targetItem); + std::string takeScreenshotAsBase64(const ItemPath& targetItem); private: QtEvents m_events; diff --git a/lib/src/Scene/Scene.h b/lib/src/Scene/Scene.h index 9ea4739..91e53cc 100644 --- a/lib/src/Scene/Scene.h +++ b/lib/src/Scene/Scene.h @@ -37,7 +37,7 @@ class Scene { // Tasks virtual void takeScreenshot(const ItemPath& targetItem, const std::string& filePath) = 0; - virtual std::string takeScreenshotRemote(const ItemPath& targetItem) = 0; + virtual std::string takeScreenshotAsBase64(const ItemPath& targetItem) = 0; }; } // namespace spix diff --git a/lib/src/TestServer.cpp b/lib/src/TestServer.cpp index 8b44481..157cc71 100644 --- a/lib/src/TestServer.cpp +++ b/lib/src/TestServer.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include @@ -178,11 +178,11 @@ void TestServer::takeScreenshot(ItemPath targetItem, std::string filePath) m_cmdExec->enqueueCommand(targetItem, std::move(filePath)); } -std::string TestServer::takeScreenshotRemote(ItemPath targetItem) +std::string TestServer::takeScreenshotAsBase64(ItemPath targetItem) { std::promise promise; auto result = promise.get_future(); - auto cmd = std::make_unique(targetItem, std::move(promise)); + auto cmd = std::make_unique(targetItem, std::move(promise)); m_cmdExec->enqueueCommand(std::move(cmd)); return result.get();