::grpc::Status execute() override;
};
+class AttributeGetter {
+private:
+public:
+ static AttributeGetter *Creator(::aurum::ReqGetAttribute_RequestType type);
+ virtual bool getPerform(UiObject *obj, ::aurum::RspGetAttribute* mResponse){}
+};
+
+class VisibleGetter : public AttributeGetter{
+private:
+public:
+ bool getPerform(UiObject *obj, ::aurum::RspGetAttribute* rsp) override;
+};
+
#endif
\ No newline at end of file
LongClickCommand(const ::aurum::ReqClick* request,
::aurum::RspClick* response);
::grpc::Status execute() override;
+private:
+ const static unsigned int LOGNCLICK_INTERVAL = 50;
};
#endif
\ No newline at end of file
#include <UiObject.h>
#include <loguru.hpp>
+#include <string>
+
ClearCommand::ClearCommand(const ::aurum::ReqClear* request,
::aurum::RspClear* response)
: mRequest{request}, mResponse{response}
LOG_SCOPE_F(INFO, "Clear --------------- ");
ObjectMapper* mObjMap = ObjectMapper::getInstance();
UiObject* obj = mObjMap->getElement(mRequest->elementid());
+
if (obj) {
- ;
+ std::string empty{};
+ obj->setText(empty);
+ mResponse->set_status(::aurum::RspStatus::OK);
}
+
return grpc::Status::OK;
}
\ No newline at end of file
#include "ClickCommand.h"
#include "UiObject.h"
+#include "UiDevice.h"
#include <loguru.hpp>
} else
mResponse->set_status(::aurum::RspStatus::ERROR);
} else if (type == ::aurum::ReqClick_RequestType_COORD) {
- mResponse->set_status(::aurum::RspStatus::ERROR);
+ UiDevice* obj = UiDevice::getInstance(DeviceType::DEFAULT);
+ const ::aurum::Point& point = mRequest->coordination();
+ obj->click(point.x(), point.y());
+ mResponse->set_status(::aurum::RspStatus::OK);
} else if (type == ::aurum::ReqClick_RequestType_ATSPI) {
mResponse->set_status(::aurum::RspStatus::ERROR);
}
::grpc::Status FlickCommand::execute()
{
LOG_SCOPE_F(INFO, "Flick --------------- ");
- // ObjectMapper *mObjMap = ObjectMapper::getInstance();
const ::aurum::Point &startPoint = mRequest->startpoint();
const ::aurum::Point &endPoint = mRequest->endpoint();
int durationMs = mRequest->durationms();
UiDevice *device = UiDevice::getInstance(DeviceType::DEFAULT);
-
- device->drag(10, 200, 400, 400, durationMs);
+ device->drag(startPoint.x(), startPoint.y(), endPoint.x(), endPoint.y(), durationMs);
+ mResponse->set_status(::aurum::RspStatus::OK);
return grpc::Status::OK;
}
\ No newline at end of file
#include "GetAttributeCommand.h"
#include <loguru.hpp>
+#include <UiDevice.h>
+#include <UiObject.h>
+
GetAttributeCommand::GetAttributeCommand(
const ::aurum::ReqGetAttribute* request, ::aurum::RspGetAttribute* response)
: mRequest{request}, mResponse{response}
::grpc::Status GetAttributeCommand::execute()
{
LOG_SCOPE_F(INFO, "GetAttribute --------------- ");
- // ObjectMapper *mObjMap = ObjectMapper::getInstance();
+ ObjectMapper* mObjMap = ObjectMapper::getInstance();
+ UiObject* obj = mObjMap->getElement(mRequest->elementid());
+
+ ::aurum::ReqGetAttribute_RequestType type = mRequest->attribute();
+ AttributeGetter *getter = AttributeGetter::Creator(type);
+
+ if (getter)
+ getter->getPerform(obj, mResponse);
+
return grpc::Status::OK;
-}
\ No newline at end of file
+}
+
+AttributeGetter* AttributeGetter::Creator(::aurum::ReqGetAttribute_RequestType type)
+{
+ switch(type)
+ {
+ case ::aurum::ReqGetAttribute_RequestType::ReqGetAttribute_RequestType_VISIBLE:
+ return new VisibleGetter();
+ default:
+ return nullptr;
+ }
+}
+
+bool VisibleGetter::getPerform(UiObject *obj, ::aurum::RspGetAttribute* rsp)
+{
+ bool isVisible = obj->isVisible();
+
+ rsp->set_boolvalue(isVisible);
+ rsp->set_status(aurum::RspStatus::OK);
+
+ return true;
+}
+AttributeGetter::~AttributeGetter(){}
+VisibleGetter::~VisibleGetter(){}
\ No newline at end of file
#include "GetSizeCommand.h"
#include <loguru.hpp>
+#include <UiObject.h>
+
GetSizeCommand::GetSizeCommand(const ::aurum::ReqGetSize* request,
::aurum::RspGetSize* response)
: mRequest{request}, mResponse{response}
::grpc::Status GetSizeCommand::execute()
{
LOG_SCOPE_F(INFO, "GetSize --------------- ");
- // ObjectMapper *mObjMap = ObjectMapper::getInstance();
+ ObjectMapper *mObjMap = ObjectMapper::getInstance();
+ UiObject* obj = mObjMap->getElement(mRequest->elementid());
+
+ const Rect<int> &size = obj->getBoundingBox();
+
+ ::aurum::Rect rect;
+ rect.set_x(size.mTopLeft.x);
+ rect.set_y(size.mTopLeft.y);
+ rect.set_width(size.width());
+ rect.set_height(size.height());
+
+ mResponse->mutable_size()->CopyFrom(rect);
+
return grpc::Status::OK;
}
\ No newline at end of file
#include "GetValueCommand.h"
#include <loguru.hpp>
+#include <UiObject.h>
+
GetValueCommand::GetValueCommand(const ::aurum::ReqGetValue* request,
::aurum::RspGetValue* response)
: mRequest{request}, mResponse{response}
::grpc::Status GetValueCommand::execute()
{
LOG_SCOPE_F(INFO, "GetValue --------------- ");
- // ObjectMapper *mObjMap = ObjectMapper::getInstance();
+ ObjectMapper* mObjMap = ObjectMapper::getInstance();
+ UiObject* obj = mObjMap->getElement(mRequest->elementid());
+
+ if (obj) {
+ std::string text = obj->getText();
+ mResponse->set_stringvalue(text.c_str());
+ mResponse->set_status(::aurum::RspStatus::OK);
+ }
+
return grpc::Status::OK;
}
\ No newline at end of file
#include "LongClickCommand.h"
#include <loguru.hpp>
+#include <UiObject.h>
+#include <UiDevice.h>
+
LongClickCommand::LongClickCommand(const ::aurum::ReqClick* request,
::aurum::RspClick* response)
: mRequest{request}, mResponse{response}
::grpc::Status LongClickCommand::execute()
{
LOG_SCOPE_F(INFO, "LongClick --------------- ");
- // ObjectMapper *mObjMap = ObjectMapper::getInstance();
+
+ ObjectMapper* mObjMap = ObjectMapper::getInstance();
+ ::aurum::ReqClick_RequestType type = mRequest->type();
+
+ if (type == ::aurum::ReqClick_RequestType_ELEMENTID) {
+ UiObject* obj = mObjMap->getElement(mRequest->elementid());
+ if (obj) {
+ obj->longClick(LOGNCLICK_INTERVAL);
+ mResponse->set_status(::aurum::RspStatus::OK);
+ } else
+ mResponse->set_status(::aurum::RspStatus::ERROR);
+ } else if (type == ::aurum::ReqClick_RequestType_COORD) {
+ UiDevice* obj = UiDevice::getInstance(DeviceType::DEFAULT);
+ const ::aurum::Point& point = mRequest->coordination();
+ obj->click(point.x(), point.y(), LOGNCLICK_INTERVAL);
+ mResponse->set_status(::aurum::RspStatus::OK);
+ } else if (type == ::aurum::ReqClick_RequestType_ATSPI) {
+ mResponse->set_status(::aurum::RspStatus::ERROR);
+ }
+
return grpc::Status::OK;
}
\ No newline at end of file
mDevice->pressHome();
else if (type == ::aurum::ReqKey_KeyType::ReqKey_KeyType_MENU)
mDevice->pressMenu();
- else {
- // TODO : handle keycode
+ else if (type == ::aurum::ReqKey_KeyType::ReqKey_KeyType_VOLUP)
+ mDevice->pressVolUp();
+ else if (type == ::aurum::ReqKey_KeyType::ReqKey_KeyType_VOLDOWN)
+ mDevice->pressVolDown();
+ else if (type == ::aurum::ReqKey_KeyType::ReqKey_KeyType_POWER)
+ mDevice->pressPower();
+ else if (type == ::aurum::ReqKey_KeyType::ReqKey_KeyType_KEY) {
+ ; // TODO
+ }
+ else if (type == ::aurum::ReqKey_KeyType::ReqKey_KeyType_XF86) {
+ ; // TODO
}
return grpc::Status::OK;
}
\ No newline at end of file
SELECTABLE = 0X0100,
SELECTED = 0X0200,
+ VISIBILITY = 0X0400,
};
template <typename T>
bool isScrollable() const;
bool isSelectable() const;
bool isSelected() const;
+ bool isVisible() const;
public:
void print(int) const;
~TM1Impl();
bool click(const int x, const int y) override;
+ bool click(const int x, const int y, const unsigned int intv) override;
+
bool drag(const int sx, const int sy, const int ex, const int ey,
const int steps) override;
#ifdef GBS_BUILD
efl_util_inputgen_h mFakeTouchHandle;
efl_util_inputgen_h mFakeKeyboardHandle;
-
#endif
+ static const unsigned int INTV_CLICK = 5;
};
#endif
\ No newline at end of file
virtual ~IDevice() {}
virtual bool click(const int x, const int y) = 0;
+ virtual bool click(const int x, const int y, const unsigned int intv) = 0;
virtual bool drag(const int sx, const int sy, const int ex, const int ey,
const int steps) = 0;
class UiDevice : public IDevice, public ISearchable {
public:
bool click(const int x, const int y) override;
+ bool click(const int x, const int y, const unsigned int intv) override;
+
bool drag(const int sx, const int sy, const int ex, const int ey,
const int steps) override;
std::string getText() const;
void setText(std::string &text);
+ const Rect<int> getBoundingBox() const;
+
bool isCheckable() const;
bool isChecked() const;
bool isClickable() const;
bool isScrollable() const;
bool isSelectable() const;
bool isSelected() const;
+ bool isVisible() const;
void click() const;
+ void longClick(const unsigned int intv = LOGNCLICK_INTERVAL) const;
void refresh() const;
private:
UiObject();
const AccessibleNode *getAccessibleNode() const;
+ static const unsigned int LOGNCLICK_INTERVAL = 50;
private:
const UiDevice * mDevice;
return hasFeatureProperty(NodeFeatureProperties::SELECTED);
}
+bool AccessibleNode::isVisible() const
+{
+ return hasFeatureProperty(NodeFeatureProperties::VISIBILITY);
+}
+
AtspiAccessible *AccessibleNode::getAccessible()
{
return mNode;
bool TM1Impl::click(const int x, const int y)
{
- LOG_SCOPE_F(INFO, "click at (%d, %d)", x, y);
+ click(x, y, INTV_CLICK);
+}
+
+bool TM1Impl::click(const int x, const int y, const unsigned int intv)
+{
+LOG_SCOPE_F(INFO, "click at (%d, %d)", x, y);
#ifdef GBSBUILD
efl_util_input_generate_touch(mFakeTouchHandle, 0,
EFL_UTIL_INPUT_TOUCH_BEGIN, x, y);
- usleep(5*10000);
+ usleep(intv*10000);
efl_util_input_generate_touch(mFakeTouchHandle, 0, EFL_UTIL_INPUT_TOUCH_END,
x, y);
return true;
#endif
}
+
bool TM1Impl::touchDown(const int x, const int y)
{
#ifdef GBSBUILD
return mDeviceImpl->click(x, y);
}
+bool UiDevice::click(const int x, const int y, const unsigned int intv)
+{
+ return mDeviceImpl->click(x, y, intv);
+}
+
bool UiDevice::drag(const int sx, const int sy, const int ex, const int ey,
const int steps)
{
return getAccessibleNode()->isSelected();
}
+bool UiObject::isVisible() const
+{
+ return getAccessibleNode()->isVisible();
+}
+
void UiObject::refresh() const
{
mNode->refresh();
}
+const Rect<int> UiObject::getBoundingBox() const
+{
+ mNode->refresh();
+ return mNode->getBoundingBox();
+}
+
void UiObject::click() const
{
LOG_SCOPE_F(INFO, "click on obj %p", this);
// todo click implementation
}
+void UiObject::longClick(const unsigned int intv) const
+{
+ LOG_SCOPE_F(INFO, "click on obj %p", this);
+ mNode->refresh();
+ const Rect<int> rect = mNode->getBoundingBox();
+ std::cout << rect.mTopLeft.x << ", " << rect.mTopLeft.y << std::endl;
+ const Point2D<int> midPoint = rect.midPoint();
+ const_cast<UiDevice *>(mDevice)->click(midPoint.x, midPoint.y, intv);
+}
+
const AccessibleNode *UiObject::getAccessibleNode() const
{
if (mNode == nullptr) throw;