Do user request action and wait A11y event. such as window activate, focus changed.
Change-Id: I84534b11bceaad2e1fbcc7e3805bac18e34cfe75
::grpc::Status getScreenSize(::grpc::ServerContext *context,
const ::aurum::ReqGetScreenSize *request,
::aurum::RspGetScreenSize *response) override;
+ ::grpc::Status actionAndWaitEvent(::grpc::ServerContext *context,
+ const ::aurum::ReqActionAndWaitEvent *request,
+ ::aurum::RspActionAndWaitEvent *response) override;
};
#endif
--- /dev/null
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <gio/gio.h>
+#include <grpcpp/grpcpp.h>
+#include "Commands/Command.h"
+#include "ObjectMapper.h"
+#include <aurum.grpc.pb.h>
+#include "config.h"
+
+class ActionAndWaitEventCommand : public Command {
+private:
+ const ::aurum::ReqActionAndWaitEvent *mRequest;
+ ::aurum::RspActionAndWaitEvent *mResponse;
+
+public:
+ ActionAndWaitEventCommand(const ::aurum::ReqActionAndWaitEvent *request,
+ ::aurum::RspActionAndWaitEvent *response);
+ ::grpc::Status execute() override;
+};
#include "Commands/TakeScreenshotCommand.h"
#include "Commands/DumpObjectTreeCommand.h"
#include "Commands/GetScreenSizeCommand.h"
+#include "Commands/ActionAndWaitEventCommand.h"
--- /dev/null
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <string>
+
+#include "Runnable.h"
+#include <aurum.grpc.pb.h>
+
+class ActionAndWaitEventRunnable : public Runnable {
+protected:
+ int mType;
+ std::string mElementId;
+ std::string mKeyCode;
+
+public:
+ ActionAndWaitEventRunnable(int type, std::string elementId, std::string keyCode);
+ void run() const override;
+};
files('src/AurumServiceImpl.cc'),
files('src/ObjectMapper.cc'),
files('src/Runnable/LaunchAppRunnable.cc'),
+ files('src/Runnable/ActionAndWaitEventRunnable.cc'),
]
bootstrap_svr_src += [
files('src/Commands/PostCommand.cc'),
files('src/Commands/DumpObjectTreeCommand.cc'),
files('src/Commands/GetScreenSizeCommand.cc'),
+ files('src/Commands/ActionAndWaitEventCommand.cc'),
]
bootstrap_svr_dep = [
std::unique_ptr<GetScreenSizeCommand> cmd = std::make_unique<GetScreenSizeCommand>(request, response);
return execute(cmd.get(), true);
}
+
+::grpc::Status aurumServiceImpl::actionAndWaitEvent(::grpc::ServerContext *context,
+ const ::aurum::ReqActionAndWaitEvent *request,
+ ::aurum::RspActionAndWaitEvent *response)
+{
+ std::unique_ptr<ActionAndWaitEventCommand> cmd = std::make_unique<ActionAndWaitEventCommand>(request, response);
+ return execute(cmd.get(), true);
+}
--- /dev/null
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "bootstrap.h"
+#include "ActionAndWaitEventCommand.h"
+#include "ActionAndWaitEventRunnable.h"
+#include "UiDevice.h"
+#include <chrono>
+#include <thread>
+
+ActionAndWaitEventCommand::ActionAndWaitEventCommand(const ::aurum::ReqActionAndWaitEvent *request,
+ ::aurum::RspActionAndWaitEvent *response)
+ : mRequest{request}, mResponse{response}
+{
+}
+
+A11yEvent convertEventType(const ::aurum::ReqActionAndWaitEvent_EventType type)
+{
+ if (type == ::aurum::ReqActionAndWaitEvent_EventType::ReqActionAndWaitEvent_EventType_EVENT_WINDOW_ACTIVATE)
+ return A11yEvent::EVENT_WINDOW_ACTIVATE;
+ else if (type == ::aurum::ReqActionAndWaitEvent_EventType::ReqActionAndWaitEvent_EventType_EVENT_WINDOW_DEACTIVATE)
+ return A11yEvent::EVENT_WINDOW_DEACTIVATE;
+ else
+ return A11yEvent::EVENT_STATE_CHANGED_FOCUSED;
+}
+
+::grpc::Status ActionAndWaitEventCommand::execute()
+{
+ LOGI("ActionAndWaitEvent --------------- ");
+ std::unique_ptr<ActionAndWaitEventRunnable> cmd = std::make_unique<ActionAndWaitEventRunnable>(
+ mRequest->type(), mRequest->elementid(), mRequest->xf86keycode());
+ std::shared_ptr<UiDevice> obj = UiDevice::getInstance();
+ obj->executeAndWaitForEvents(cmd.get(), convertEventType(mRequest->eventtype()), mRequest->timeoutms());
+
+ return grpc::Status::OK;
+}
--- /dev/null
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "Aurum.h"
+#include "bootstrap.h"
+#include "ActionAndWaitEventCommand.h"
+#include "ActionAndWaitEventRunnable.h"
+#include <app_control.h>
+
+ActionAndWaitEventRunnable::ActionAndWaitEventRunnable(int type, std::string elementId, std::string keyCode)
+ : mType{type}, mElementId(elementId), mKeyCode(keyCode)
+{
+}
+
+void ActionAndWaitEventRunnable::run() const
+{
+ if (mType == 0) {
+ ObjectMapper *mObjMap = ObjectMapper::getInstance();
+ std::shared_ptr<UiObject> obj = mObjMap->getElement(mElementId);
+
+ if (obj) {
+ LOGD("Click Object Id(%s)", mElementId.c_str());
+ obj->click();
+ }
+ else
+ LOGE("Object Id(%s) is invalid or not exist on view", mElementId.c_str());
+ }
+ else {
+ LOGD("Send KeyEvent(%s)", mKeyCode.c_str());
+ std::shared_ptr<UiDevice> mDevice = UiDevice::getInstance();
+ mDevice->pressKeyCode(mKeyCode, KeyRequestType::STROKE);
+ }
+}
rpc takeScreenshot(ReqTakeScreenshot) returns (stream RspTakeScreenshot) {}
rpc dumpObjectTree(ReqDumpObjectTree) returns (RspDumpObjectTree) {}
rpc getScreenSize(ReqGetScreenSize) returns (RspGetScreenSize) {}
+ rpc actionAndWaitEvent(ReqActionAndWaitEvent) returns (RspActionAndWaitEvent) {}
}
// ------------------------------------ //
RspStatus status = 1;
Rect size = 2;
}
+
+message ReqActionAndWaitEvent {
+ enum ActionType{
+ CLICK = 0;
+ KEY = 1;
+ }
+ enum EventType {
+ EVENT_WINDOW_ACTIVATE = 0;
+ EVENT_WINDOW_DEACTIVATE = 1;
+ EVENT_STATE_CHANGED_FOCUSED = 2;
+ }
+ ActionType type = 1;
+ oneof params {
+ string elementId = 2;
+ string XF86keyCode = 3;
+ }
+ EventType eventType = 4;
+ int32 timeoutMs = 5;
+}
+
+message RspActionAndWaitEvent {
+ RspStatus status = 1;
+}
\ No newline at end of file