Skip to content

Commit

Permalink
rename function to takeScreenshotAsBase64
Browse files Browse the repository at this point in the history
  • Loading branch information
53845714nF committed May 23, 2024
1 parent a81d3e6 commit 9f7047c
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/include/Spix/TestServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class SPIX_EXPORT TestServer {
std::vector<std::string> getErrors();

void takeScreenshot(ItemPath targetItem, std::string filePath);
std::string takeScreenshotRemote(ItemPath targetItem);
std::string takeScreenshotAsBase64(ItemPath targetItem);
void quit();

protected:
Expand Down
6 changes: 3 additions & 3 deletions lib/src/AnyRpcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ AnyRpcServer::AnyRpcServer(int anyrpcPort)
return takeScreenshot(std::move(targetItem), std::move(filePath));
});

utils::AddFunctionToAnyRpc<std::string(std::string)>(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<std::string(std::string)>(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<void()>(methodManager, "quit", "Close the app | quit()", [this] { quit(); });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
* See LICENSE.txt file in the project root for full license information.
****/

#include "ScreenshotRemote.h"
#include "ScreenshotBse64.h"

#include <Scene/Scene.h>
namespace spix {
namespace cmd {

ScreenshotRemote::ScreenshotRemote(ItemPath targetItemPath, std::promise<std::string> promise)
ScreenshotAsBase64::ScreenshotAsBase64(ItemPath targetItemPath, std::promise<std::string> 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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
namespace spix {
namespace cmd {

class ScreenshotRemote : public Command {
class ScreenshotAsBase64 : public Command {
public:
ScreenshotRemote(ItemPath targetItemPath, std::promise<std::string> promise);
ScreenshotAsBase64(ItemPath targetItemPath, std::promise<std::string> promise);

void execute(CommandEnvironment& env) override;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/Scene/Mock/MockScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/Scene/Mock/MockScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion lib/src/Scene/Qt/QtScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/Scene/Qt/QtScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/Scene/Scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions lib/src/TestServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <Commands/InvokeMethod.h>
#include <Commands/Quit.h>
#include <Commands/Screenshot.h>
#include <Commands/ScreenshotRemote.h>
#include <Commands/ScreenshotBase64.h>
#include <Commands/SetProperty.h>
#include <Commands/Wait.h>

Expand Down Expand Up @@ -178,7 +178,7 @@ void TestServer::takeScreenshot(ItemPath targetItem, std::string filePath)
m_cmdExec->enqueueCommand<cmd::Screenshot>(targetItem, std::move(filePath));
}

std::string TestServer::takeScreenshotRemote(ItemPath targetItem)
std::string TestServer::takeScreenshotAsBase64(ItemPath targetItem)
{
std::promise<std::string> promise;
auto result = promise.get_future();
Expand Down

0 comments on commit 9f7047c

Please sign in to comment.