gets screen size from system API.
puts system date time for screenshot file name.
Change-Id: I9a2ad8ebefd8f09421b2cb0de70ea0167d6feba3
#include "IDevice.h"
#include "Accessible.h"
#include "Point2D.h"
+#include "Size2D.h"
#include "Rect.h"
#include "PartialMatch.h"
#include "Comparer.h"
*/
long long getSystemTime(TimeRequestType type) override;
+ /**
+ * @brief TBD
+ * @since_tizen 6.5
+ */
+ const Size2D<int> getScreenSize() override;
+
protected:
/**
* @brief TBD
* @brief TBD
*/
int mWheelDevice;
+
+ /**
+ * @brief TBD
+ */
+ Size2D<int> mScreenSize;
};
\ No newline at end of file
*/
long long getSystemTime(TimeRequestType type) override;
+ /**
+ * @brief Gets device screen size.
+ *
+ * @return @Size2D
+ *
+ * @since_tizen 6.5
+ */
+ const Size2D<int> getScreenSize() override;
+
protected:
/**
* @brief Press and release given key during duration time.
struct timespec tStart;
bool isTimerStarted;
std::set<int> mTouchSeq;
+
+ /**
+ * @brief TBD
+ */
+ Size2D<int> mScreenSize;
};
\ No newline at end of file
#pragma once
#include "config.h"
-
+#include "Rect.h"
+#include "Size2D.h"
#include <string>
/**
* @since_tizen 5.5
*/
virtual long long getSystemTime(TimeRequestType type) = 0;
+
+ /**
+ * @brief Gets device screen size.
+ *
+ * @return @Size2D
+ *
+ * @since_tizen 6.5
+ */
+ virtual const Size2D<int> getScreenSize() = 0;
};
\ No newline at end of file
--- /dev/null
+#pragma once
+
+/**
+ * @brief Size2D Class.
+ * This class for represent specific obejct's size as width and height.
+ *
+ * @since_tizen 6.5
+ */
+template <typename T>
+class Size2D {
+public:
+ /**
+ * @brief Size2D contructor with value.
+ *
+ * @since_tizen 6.5
+ */
+ Size2D() : width{0}, height{0} {}
+
+ /**
+ * @brief Size2D contructor with source.
+ *
+ * @since_tizen 6.5
+ */
+ Size2D(const Size2D &src)
+ {
+ width = src.width;
+ height = src.height;
+ }
+
+ /**
+ * @brief Size2D contructor with type.
+ *
+ * @since_tizen 6.5
+ */
+ Size2D(const T &width, const T &height)
+ {
+ this->width = width;
+ this->height = height;
+ }
+
+ /**
+ * @brief Size2D operator for "==".
+ *
+ * @since_tizen 6.5
+ */
+ inline bool operator==(const Size2D<T>& rhs)
+ {
+ return this->width == rhs.width && this->height == rhs.height;
+ }
+
+ /**
+ * @brief Size2D operator for "!=".
+ *
+ * @since_tizen 6.5
+ */
+ inline bool operator!=(const Size2D<T>& rhs)
+ {
+ return !(*this == rhs);
+ }
+
+ T width;
+ T height;
+};
*/
long long getSystemTime(TimeRequestType type) override;
+ /**
+ * @brief Gets device screen size.
+ *
+ * @return @Size2D
+ *
+ * @since_tizen 6.5
+ */
+ const Size2D<int> getScreenSize() override;
public:
/**
'./inc/Misc/bitmask.h',
'./inc/Misc/Point2D.h',
'./inc/Misc/Rect.h',
+ './inc/Misc/Size2D.h',
'./inc/Aurum.h',
]
+#include "Aurum.h"
+
#include "MockDeviceImpl.h"
#include <functional>
return (long long)t.tv_sec * 1000L + (long long)(t.tv_nsec / MICRO_SEC);
}
+const Size2D<int> MockDeviceImpl::getScreenSize()
+{
+ return mScreenSize;
+}
+
bool MockDeviceImpl::strokeKeyCode(std::string keycode, unsigned int intv)
{
return false;
obj->mFakeTouchHandle = efl_util_input_initialize_generator(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN);
obj->mFakeKeyboardHandle =
efl_util_input_initialize_generator(EFL_UTIL_INPUT_DEVTYPE_KEYBOARD);
+
+ int width = 0;
+ int height = 0;
+ system_info_get_platform_int("http://tizen.org/feature/screen.width", &width);
+ system_info_get_platform_int("http://tizen.org/feature/screen.height", &height);
+
+ mScreenSize = Size2D<int>{width, height};
}
TizenDeviceImpl::~TizenDeviceImpl()
efl_util_screenshot_h screenshot = NULL;
tbm_surface_h tbm_surface = NULL;
- int width = 0, height = 0;
- if (system_info_get_platform_int("http://tizen.org/feature/screen.width", &width) ||
- system_info_get_platform_int("http://tizen.org/feature/screen.height", &height))
- return false;
-
- screenshot = efl_util_screenshot_initialize(width, height);
+ screenshot = efl_util_screenshot_initialize(mScreenSize.width, mScreenSize.height);
if (screenshot) {
tbm_surface = efl_util_screenshot_take_tbm_surface(screenshot);
}
+const Size2D<int> TizenDeviceImpl::getScreenSize()
+{
+ TizenDeviceImpl *obj = static_cast<TizenDeviceImpl *>(this);
+ return obj->mScreenSize;
+}
+
int TizenDeviceImpl::grabTouchSeqNumber()
{
for (unsigned int i = 0 ; i < MAX_FINGER_NUMBER; i++) {
{
return mDeviceImpl->getSystemTime(type);
}
+
+const Size2D<int> UiDevice::getScreenSize()
+{
+ return mDeviceImpl->getScreenSize();
+}
{
LOGI("TakeScreenshot --------------- ");
- std::string path = "/tmp/screenshot.png";
+ struct tm timeinfo;
+ time_t now = time(0);
+ if (!localtime_r(&now, &timeinfo)) {
+ LOGE("fail to get localtime. Screenshot cancelled");
+ return grpc::Status::CANCELLED;
+ }
+
+ char name[128];
+ std::snprintf(name, 128, "/tmp/screenshot-%d-%d-%d-%d:%d:%d.png",
+ (timeinfo.tm_year + 1900), (timeinfo.tm_mon + 1), timeinfo.tm_mday,
+ timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec);
+ std::string path(name);
std::shared_ptr<UiDevice> mDevice = UiDevice::getInstance();
mDevice->takeScreenshot(path, 1.0, 1);
std::ifstream ifs(path, std::ifstream::binary);
::aurum::RspTakeScreenshot rsp;
- int size = 1920 * 1080;
+ int size = mDevice->getScreenSize().width * mDevice->getScreenSize().height;
char buf[size];
while (!ifs.eof()) {