endif
libaurum_dep = [
+ dependency('capi-system-info'),
+ dependency('libtdm'),
dependency('atspi-2'),
dependency('gio-2.0'),
dependency('threads'),
#include <time.h>
#include <Ecore.h>
+#include <tdm_helper.h>
+#include <tbm_surface.h>
+#include <system_info.h>
+
TizenImpl::TizenImpl()
: mFakeTouchHandle{0}, mFakeKeyboardHandle{0}, mFakeWheelHandle{0}, isTimerStarted{false}, mTouchSeq{}
{
bool TizenImpl::takeScreenshot(std::string path, float scale, int quality)
{
- return false;
+ efl_util_screenshot_h screenshot = NULL;
+ tbm_surface_h tbm_surface = NULL;
+
+ int width, height;
+ system_info_get_platform_int("http://tizen.org/feature/screen.width", &width);
+ system_info_get_platform_int("http://tizen.org/feature/screen.height", &height);
+
+ screenshot = efl_util_screenshot_initialize(width, height);
+
+ if (screenshot) {
+ tbm_surface = efl_util_screenshot_take_tbm_surface(screenshot);
+ if (tbm_surface) {
+ char path_cstr[PATH_MAX];
+ strcpy(path_cstr, path.c_str());
+ tdm_helper_dump_buffer(tbm_surface, path_cstr);
+ sync();
+ }
+ efl_util_screenshot_deinitialize(screenshot);
+ }
+
+ return true;
}
class Clock {
::grpc::Status sendKey(::grpc::ServerContext *context,
const ::aurum::ReqKey *request,
::aurum::RspKey * response) override;
+ ::grpc::Status takeScreenshot(
+ ::grpc::ServerContext *context,
+ const ::aurum::ReqTakeScreenshot * request,
+ ::grpc::ServerWriter< ::aurum::RspTakeScreenshot>* writer) override;
};
-#endif
\ No newline at end of file
+#endif
#include "Commands/GetLocationCommand.h"
#include "Commands/SendKeyCommand.h"
+#include "Commands/TakeScreenshotCommand.h"
#endif
\ No newline at end of file
--- /dev/null
+#ifndef TAKE_SCREENSHOT_COMMAND_H
+#define TAKE_SCREENSHOT_COMMAND_H
+
+#include <gio/gio.h>
+#include <grpcpp/grpcpp.h>
+#include "Commands/Command.h"
+#include "ObjectMapper.h"
+#include <aurum.grpc.pb.h>
+#include "config.h"
+
+class TakeScreenshotCommand : public Command {
+private:
+ const ::aurum::ReqTakeScreenshot* mRequest;
+ ::grpc::ServerWriter< ::aurum::RspTakeScreenshot>* mWriter;
+
+public:
+ TakeScreenshotCommand(const ::aurum::ReqTakeScreenshot* request,
+ ::grpc::ServerWriter< ::aurum::RspTakeScreenshot>* writer);
+ ::grpc::Status execute() override;
+};
+
+#endif
files('src/Commands/TouchUpCommand.cc'),
files('src/Commands/SyncCommand.cc'),
files('src/Commands/KillServerCommand.cc'),
+ files('src/Commands/TakeScreenshotCommand.cc'),
files('src/Commands/Command.cc'),
files('src/Commands/PreCommand.cc'),
files('src/Commands/PostCommand.cc'),
std::unique_ptr<SendKeyCommand> cmd = std::make_unique<SendKeyCommand>(request, response);
return execute(cmd.get());
}
+::grpc::Status aurumServiceImpl::takeScreenshot(
+ ::grpc::ServerContext* context,
+ const ::aurum::ReqTakeScreenshot* request,
+ ::grpc::ServerWriter< ::aurum::RspTakeScreenshot>* writer)
+{
+ std::unique_ptr<TakeScreenshotCommand> cmd = std::make_unique<TakeScreenshotCommand>(request, writer);
+ return execute(cmd.get());
+}
--- /dev/null
+#include "TakeScreenshotCommand.h"
+#include <loguru.hpp>
+#include "UiObject.h"
+#include "UiDevice.h"
+#include <fstream>
+
+TakeScreenshotCommand::TakeScreenshotCommand(
+ const ::aurum::ReqTakeScreenshot* request,
+ ::grpc::ServerWriter< ::aurum::RspTakeScreenshot>* writer)
+ : mRequest{request}, mWriter{writer}
+{
+}
+
+::grpc::Status TakeScreenshotCommand::execute()
+{
+ LOG_SCOPE_F(INFO, "TakeScreenshot --------------- ");
+
+ std::string path = "/tmp/screenshot.png";
+ UiDevice* mDevice = UiDevice::getInstance(DeviceType::DEFAULT);
+ mDevice->takeScreenshot(path, 1.0, 1);
+
+ std::ifstream ifs(path, std::ifstream::binary);
+ ::aurum::RspTakeScreenshot rsp;
+ int size = 1024 * 1024;
+ char buf[size];
+
+ while (!ifs.eof()) {
+ ifs.read(buf, size);
+ rsp.set_image(buf, ifs.gcount());
+ mWriter->Write(rsp);
+ }
+ ifs.close();
+
+ return grpc::Status::OK;
+}
rpc getDeviceTime(ReqGetDeviceTime) returns (RspGetDeviceTime) {}
rpc getLocation(ReqGetLocation) returns (RspGetLocation) {}
rpc sendKey(ReqKey) returns (RspKey) {}
+ rpc takeScreenshot(ReqTakeScreenshot) returns (stream RspTakeScreenshot) {}
}
// ------------------------------------ //
RspStatus status = 1;
}
+message ReqTakeScreenshot{
+}
+message RspTakeScreenshot{
+ bytes image = 1;
+}
+
// ------------------------------------ //
message ReqEmpty {
if response.lat < 0: return False
return True
+def takeScreenshotTest(stub):
+ responses = stub.takeScreenshot(ReqTakeScreenshot())
+ image = open("screenshot.png", "wb")
+ for response in responses:
+ image.write(response.image)
+ image.close()
+ return True;
+
def defaultSetup(stub):
if stub.getAppInfo(ReqGetAppInfo(packageName='com.samsung.ui-widget-sample')).isRunning:
stub.closeApp(ReqCloseApp(packageName='com.samsung.ui-widget-sample'))
runTest(stub, touchTest)
runTest(stub, sendKeyTest)
runTest(stub, setValueClearTest)
+ runTest(stub, takeScreenshotTest)
runTestWithoutSetupAndTearDown(stub, installAppTest)
runTestWithoutSetupAndTearDown(stub, launchAppTest)
runTestWithoutSetupAndTearDown(stub, getAppInfoTest)