#include "ActivityChangeRequest.hpp"
#include "Subject.hpp"
+#include "DoneCallback.hpp"
#include <memory>
virtual void initialize()
{}
- virtual void process() = 0;
+ virtual void process(DoneCallback) = 0;
bool isCompleted() const;
void markAsCompleted();
-
-
protected:
bool completed;
}
}
- void process() override
+ void process(DoneCallback) override
{
launch();
markAsCompleted();
: Activity(activityType)
{}
- void process() override
+ void process(DoneCallback) override
{
DBus::DBusClient dbus{dbusLocators::callmgr::BUS, dbusLocators::callmgr::OBJ_PATH, dbusLocators::callmgr::INTERFACE, DBus::ConnectionType::SYSTEM};
dbus.method<int(int)>("AnswerCall").call(CM_TEL_CALL_ANSWER_TYPE_NORMAL);
: Activity(activityType)
{}
- void process() override
+ void process(DoneCallback) override
{
DBus::DBusClient dbus{dbusLocators::callmgr::BUS, dbusLocators::callmgr::OBJ_PATH, dbusLocators::callmgr::INTERFACE, DBus::ConnectionType::SYSTEM};
dbus.method<int()>("RejectCall").call();
: Activity(activityType)
{}
- void process() override
+ void process(DoneCallback) override
{
DBus::DBusClient dbus{dbusLocators::callmgr::BUS, dbusLocators::callmgr::OBJ_PATH, dbusLocators::callmgr::INTERFACE, DBus::ConnectionType::SYSTEM};
dbus.method<int(unsigned, int)>("EndCall").call(0, CM_TEL_CALL_RELEASE_TYPE_ALL_CALLS);
constexpr static const char *activityType = DerivedType::activityType;
ChangeIntTypeVconfKeysActivity() : Activity(activityType) {}
- void process() override
+ void process(DoneCallback) override
{
static_assert(GET_SIZE(DerivedType::KEYS) == GET_SIZE(DerivedType::STATES), "Incorrect activity");
constexpr static const char *activityType = DerivedType::activityType;
SetIntTypeVconfKeyActivity() : Activity(activityType) {}
- void process() override
+ void process(DoneCallback) override
{
Singleton<VConfInterface>::instance().set(DerivedType::KEY, DerivedType::STATE);
markAsCompleted();
static constexpr const char *activityType = "PARAGRAPH";
static constexpr const char *KEY = VCONF_KEY_GRANULARITY_UNIT;
static constexpr int STATE = PARAGRAPH;
-};
\ No newline at end of file
+};
: Activity(activityType)
{}
- void process() override
+ void process(DoneCallback) override
{
auto sound = Singleton<VConfInterface>::instance().get(VCONF_KEY_SOUND_ENABLED, true) ? 1 : 0;
auto vibration = Singleton<VConfInterface>::instance().get(VCONF_KEY_VIBRATION_ENABLED, false) ? 1 : 0;
: Activity(activityType)
{}
- void process() override
+ void process(DoneCallback doneCb) override
{
- changeKeyValue([](double currentValue) {
+ changeKeyValue([doneCb = std::move(doneCb)](double currentValue) {
auto newValue = currentValue - VCONF_KEY_AUTO_SCAN_INTERVAL_VALUE_INCREMENT;
return newValue < VCONF_KEY_AUTO_SCAN_INTERVAL_VALUE_MIN ? VCONF_KEY_AUTO_SCAN_INTERVAL_VALUE_MIN : newValue;
});
: Activity(activityType)
{}
- void process() override
+ void process(DoneCallback doneCb) override
{
- changeKeyValue([](double currentValue) {
+ changeKeyValue([doneCb = std::move(doneCb)](double currentValue) {
auto newValue = currentValue + VCONF_KEY_AUTO_SCAN_INTERVAL_VALUE_INCREMENT;
return newValue > VCONF_KEY_AUTO_SCAN_INTERVAL_VALUE_MAX ? VCONF_KEY_AUTO_SCAN_INTERVAL_VALUE_MAX : newValue;
});
: UIActivity(activityType)
{}
- void process() override
+ void process(DoneCallback doneCb) override
{
ASSERT(uiElement, "process invoked before uiElement initialization");
- uiElement->increment();
+ uiElement->increment(std::move(doneCb));
markAsCompleted();
}
};
: UIActivity(activityType)
{}
- void process() override
+ void process(DoneCallback doneCb) override
{
ASSERT(uiElement, "process invoked before uiElement initialization");
- uiElement->decrement();
+ uiElement->decrement(std::move(doneCb));
markAsCompleted();
}
};
--- /dev/null
+#include "DoneCallback.hpp"
+#include "ecore.hpp"
+
+class DoneCallback::Data : public std::enable_shared_from_this<DoneCallback::Data>
+{
+public:
+ Data(std::function<void()> doneCb) : doneCb(std::move(doneCb)) { }
+
+ ~Data()
+ {
+ callAndReset();
+ }
+
+ void callAndReset()
+ {
+ if (doneCb) {
+ doneCb();
+ doneCb = {};
+ }
+ }
+ void callAfterTimeElapsed(std::chrono::milliseconds ms)
+ {
+ if (doneCb && !timer.isSet()) {
+ timer.reset(ms.count() / 1000.0, [self = shared_from_this()]() {
+ self->callAndReset();
+ return ecore::TimerRepetitionPolicy::cancel;
+ });
+ }
+ }
+private:
+ std::function<void()> doneCb;
+ ecore::Timer timer;
+};
+
+DoneCallback::DoneCallback(std::function<void()> doneCb)
+{
+ if (doneCb) {
+ dataPtr = std::make_shared<DoneCallback::Data>(std::move(doneCb));
+ }
+}
+
+void DoneCallback::callAfterTimeElapsed(std::chrono::milliseconds ms) const
+{
+ if (dataPtr)
+ dataPtr->callAfterTimeElapsed(ms);
+}
+
+void DoneCallback::callAfterTimeElapsed(std::chrono::high_resolution_clock::time_point tm) const
+{
+ if (dataPtr) {
+ auto now = std::chrono::high_resolution_clock::now();
+ dataPtr->callAfterTimeElapsed(now < tm ? std::chrono::duration_cast<std::chrono::milliseconds>(tm - now) : 0ms);
+ }
+}
--- /dev/null
+#ifndef DONE_CALLBACK_HPP
+#define DONE_CALLBACK_HPP
+
+#include <chrono>
+#include <memory>
+#include <functional>
+
+using namespace std::literals::chrono_literals;
+
+/**
+ * @brief Namespace with activities' delays
+ *
+ * Delays for activities, so any side effects will be completed before done callback is called
+ */
+namespace sideEffectDelays
+{
+ /**
+ * @brief delay for completion of TAP activity (either select in selection interface or activate action)
+ */
+ static constexpr auto activate = 100ms;
+ /**
+ * @brief delay for completion of set current value atspi call
+ */
+ static constexpr auto changeValue = 10ms;
+ /**
+ * @brief delay for completion of drag gestxure
+ */
+ static constexpr auto eModDrag = 100ms;
+ /**
+ * @brief delay for completion of gesture executed via e-mod
+ */
+ static constexpr auto eModGesture = 100ms;
+ /**
+ * @brief delay for completion of rotation executed via e-mod
+ */
+ static constexpr auto eModRotationGesture = 100ms;
+ /**
+ * @brief delay for completion of power-key activity (summon of power off popup)
+ */
+ static constexpr auto powerKey = 100ms;
+ /**
+ * @brief delay for completion of open quick panel activity (summon of quick panel)
+ */
+ static constexpr auto openQuickPanel = 100ms;
+ /**
+ * @brief delay for completion of toggle quick panel activity
+ */
+ static constexpr auto toggleQuickPanel = 100ms;
+}
+
+/**
+ * @brief Notification object, which will execute functor once activity's side effects are done
+ *
+ * DoneCallback's functor will be executed, once activity's side effects are completed.
+ * Note, that for many activities this will be only an estimation.
+ */
+class DoneCallback
+{
+public:
+ /**
+ * @brief Constructs default, empty object, no callback will be called
+ */
+ DoneCallback() = default;
+ /**
+ * @brief Constructs callback with functor, which will be called after side effects are done
+ */
+ DoneCallback(std::function<void()> doneCb);
+
+ /**
+ * @brief Calls callback after given time from now
+ *
+ * Schedule completion callback to be called after given time from now.
+ * Only first call to callAfterTimeElapsed on the same object matters, next ones will be ignored.
+ */
+ void callAfterTimeElapsed(std::chrono::milliseconds) const;
+
+ /**
+ * @brief Calls callback at given point in time
+ *
+ * Schedule completion callback to be called at given point in time
+ * Only first call to callAfterTimeElapsed on the same object matters, next ones will be ignored.
+ */
+ void callAfterTimeElapsed(std::chrono::high_resolution_clock::time_point) const;
+private:
+ class Data;
+ std::shared_ptr<Data> dataPtr;
+};
+
+#endif
uiElements.push_back(elem);
}
- void process() override
+ void process(DoneCallback doneCb) override
{
ASSERT(uiElements.size() == DerivedType::REQUIRED_UIELEMENTS);
DEBUG("Drag %d, %d, %d, %d, %d, %f", from.x, from.y, to.x, to.y, MIDDLE_STEPS_COUNT, pressTime);
dbus.method<void(int, int, int, int, int, double)>("DispatchDragEvent").
call(from.x, from.y, to.x, to.y, MIDDLE_STEPS_COUNT, pressTime);
+ doneCb.callAfterTimeElapsed(sideEffectDelays::eModDrag);
}
private:
std::vector<std::shared_ptr<UIElement>> uiElements;
CancelActivity() : Activity(activityType)
{}
- void process() override
+ void process(DoneCallback) override
{
markAsCompleted();
DEBUG("cancelled");
public:
constexpr static const char *activityType = "COPY";
- void process() override
+ void process(DoneCallback) override
{
getAtspiInterfaces();
public:
constexpr static const char *activityType = "CUT";
- void process() override
+ void process(DoneCallback) override
{
getAtspiInterfaces();
public:
constexpr static const char *activityType = "PASTE";
- void process() override
+ void process(DoneCallback) override
{
getAtspiInterfaces();
public:
constexpr static const char *activityType = "SELECT_ALL";
- void process() override
+ void process(DoneCallback) override
{
getAtspiInterfaces();
using EditTextActivity<DerivedType>::getAtspiInterfaces;
using EditTextActivity<DerivedType>::markAsCompleted;
- void process() override
+ void process(DoneCallback) override
{
getAtspiInterfaces();
move(DerivedType::DIRECTION, getGranularity(), getMode());
: UIActivity(activityType)
{}
- void process() override
+ void process(DoneCallback doneCb) override
{
auto dbus = DBus::DBusClient {dbusLocators::accessibilityEMod::BUS,
dbusLocators::accessibilityEMod::OBJ_PATH,
dbusLocators::accessibilityEMod::INTERFACE,
DBus::ConnectionType::SYSTEM};
- DerivedType::dispatchEvent(dbus, uiElement.get());
+ DerivedType::dispatchEvent(dbus, uiElement.get(), std::move(doneCb));
markAsCompleted();
}
};
class DispatchGestureEventActivity : public GestureActivity<DerivedType>
{
public:
- static void dispatchEvent(DBus::DBusClient &dbus, const UIElement *uiElement)
+ static void dispatchEvent(DBus::DBusClient &dbus, const UIElement *uiElement, DoneCallback doneCb)
{
auto point = uiElement->getScanningCoordinates();
const auto swipeType = DerivedType::swipeType;
dbus.method<void(int, int, int)>("DispatchGestureEvent").call(swipeType, point.x, point.y);
+ doneCb.callAfterTimeElapsed(sideEffectDelays::eModGesture);
}
};
class DispatchCustomGestureEventActivity : public GestureActivity<DerivedType>
{
public:
- static void dispatchEvent(DBus::DBusClient &dbus, const UIElement *uiElement)
+ static void dispatchEvent(DBus::DBusClient &dbus, const UIElement *uiElement, DoneCallback doneCb)
{
//move: x in range 25% - 75% , and y = 50% of screen dimensions
auto screenSize = Singleton<UniversalSwitch>::instance().getMainWindow()->getDimensions().size;
}
DEBUG("Swipe %d, %d, %d, %d, %d", startPoint.x, startPoint.y, endPoint.x, endPoint.y, DEFAULT_STEPS_NUMBER);
dbus.method<void(int, int, int, int, int, double)>("DispatchDragEvent").call(startPoint.x, startPoint.y, endPoint.x, endPoint.y, DEFAULT_STEPS_NUMBER, DEFAULT_HOLD_TIME);
+ doneCb.callAfterTimeElapsed(sideEffectDelays::eModDrag);
}
};
public:
static constexpr const char *activityType = "RIGHT_PAGE";
static constexpr SwipeType swipeType = SWIPE_LEFT;
-};
\ No newline at end of file
+};
: Activity(activityType)
{}
- void process() override
+ void process(DoneCallback doneCb) override
{
- utils::EventGenerator::generateKeyPress(DerivedType::buttonCode, DerivedType::multiplicity);
+ utils::EventGenerator::generateKeyPress(DerivedType::buttonCode, std::move(doneCb), DerivedType::multiplicity);
markAsCompleted();
}
};
static constexpr const char *activityType = "HOME_BUTTON_X3";
static constexpr const char *buttonCode = "XF86Home";
static constexpr unsigned multiplicity = 3;
-};
\ No newline at end of file
+};
constexpr static const char *activityType = DerivedType::activityType;
MoveElementActivity() : Activity(activityType) {}
- void process() override
+ void process(DoneCallback doneCb) override
{
auto s = Singleton<UniversalSwitch>::instance().getScreenScannerManager();
- if (s) DerivedType::move(s);
+ if (s) DerivedType::move(s, std::move(doneCb));
else ERROR("ScreenScannerManager not found");
markAsCompleted();
}
{
public:
constexpr static const char *activityType = "MOVE_TO_NEXT_ITEM";
- static void move(auto scannerManager)
+ static void move(auto scannerManager, DoneCallback)
{
scannerManager->next();
}
{
public:
constexpr static const char *activityType = "MOVE_TO_PREV_ITEM";
- static void move(auto scannerManager)
+ static void move(auto scannerManager, DoneCallback)
{
scannerManager->prev();
}
PowerKeyMenuActivity()
: Activity(activityType) {}
- void process() override
+ void process(DoneCallback doneCb) override
{
auto bundleHandle = std::unique_ptr<bundle, int(*)(bundle *)>(bundle_create(), bundle_free);
if (!bundleHandle) {
ERROR("Failed to launch popup, error: %d", ret);
markAsCompleted();
+ doneCb.callAfterTimeElapsed(sideEffectDelays::powerKey);
}
private:
static constexpr const char *POPUP_CONTENT = "_SYSPOPUP_CONTENT_";
static constexpr const char *POPUP_NAME_POWERKEY = "powerkey";
static constexpr const char *POPUP_POWERKEY = "powerkey-syspopup";
-};
\ No newline at end of file
+};
: Activity(activityType)
{}
- void process() override
+ void process(DoneCallback doneCb) override
{
- DerivedType::changeQuickpanelState();
+ DerivedType::changeQuickpanelState(std::move(doneCb));
markAsCompleted();
}
};
public:
static constexpr const char *activityType = "OPEN_QUICKPANEL";
- static void changeQuickpanelState()
+ static void changeQuickpanelState(DoneCallback doneCb)
{
Singleton<UniversalSwitch>::instance().getMainWindow()->getQuickpanel()->show();
+ doneCb.callAfterTimeElapsed(sideEffectDelays::openQuickPanel);
}
};
public:
static constexpr const char *activityType = "TOGGLE_QUICKPANEL";
- static void changeQuickpanelState()
+ static void changeQuickpanelState(DoneCallback doneCb)
{
auto quickpanel = Singleton<UniversalSwitch>::instance().getMainWindow()->getQuickpanel();
if (quickpanel->isVisible())
quickpanel->hide();
else
quickpanel->show();
+ doneCb.callAfterTimeElapsed(sideEffectDelays::toggleQuickPanel);
}
-};
\ No newline at end of file
+};
RotateActivity() : Activity(activityType)
{}
- void process() override
+ void process(DoneCallback doneCb) override
{
Singleton<VConfInterface>::instance().set(VCONF_KEY_AUTO_ROTATE, false);
auto dbus = DBus::DBusClient {dbusLocators::accessibilityEMod::BUS,
auto rotation = DerivedType::ROTATION;
dbus.method<void(int)>("DispatchRotationEvent").call(rotation);
markAsCompleted();
+ doneCb.callAfterTimeElapsed(sideEffectDelays::eModRotationGesture);
}
};
public:
static constexpr const char *activityType = "ROTATE_LEFT";
static constexpr int ROTATION = 270;
-};
\ No newline at end of file
+};
#include "Window.hpp"
#include "utils.hpp"
#include "Atspi.hpp"
+#include "DoneCallback.hpp"
#include <Elementary.h>
if (!currentNavState.childIndex) {
if (currentNavState.parent == rootNavigationElement) {
if (properties.isEscapeFrameEnabled()) {
- utils::EventGenerator::generateKeyPress(BACK_BUTTON_CODE);
+ utils::EventGenerator::generateKeyPress(BACK_BUTTON_CODE,
+ DoneCallback{[callback = std::move(callback)] {
+ callback({});
+ } });
eraseFrame();
state = State::END;
} else {
{
public:
ScreenshotActivity();
- void process() override;
+ void process(DoneCallback doneCb) override;
constexpr static const char *activityType = "SCREENSHOT";
private:
- static void capture(const std::string &, Size);
+ static void capture(const std::string &, Size, DoneCallback);
static std::string generateFileName();
ecore::Timer timer;
ScreenshotActivity::ScreenshotActivity() : UIActivity(activityType) {}
-void ScreenshotActivity::process()
+void ScreenshotActivity::process(DoneCallback doneCb)
{
char *path = nullptr;
storage_get_directory(STORAGE_TYPE_INTERNAL, STORAGE_DIRECTORY_IMAGES, &path);
}
auto filename = directory + "/" + generateFileName();
- timer.reset(DELAY, [this, filename]() {
+ timer.reset(DELAY, [this, filename, doneCb]() {
auto mainWindow = Singleton<UniversalSwitch>::instance().getMainWindow();
if (mainWindow)
- capture(filename, mainWindow->getDimensions().size);
+ capture(filename, mainWindow->getDimensions().size, std::move(doneCb));
else
ERROR("No main window");
}
-void ScreenshotActivity::capture(const std::string &filename, Size size)
+void ScreenshotActivity::capture(const std::string &filename, Size size, DoneCallback doneCb)
{
auto screenshotHandle = std::unique_ptr<_efl_util_screenshot_h, int (*)(_efl_util_screenshot_h *)> {
efl_util_screenshot_initialize(size.width, size.height), efl_util_screenshot_deinitialize
std::stringstream ss;
ss << std::put_time(std::localtime(&formated), "%Y%m%d-%H%M%S") << ".png";
return ss.str();
-}
\ No newline at end of file
+}
constexpr static const char *activityType = "SCROLL_SPEED_UP";
ScrollSpeedUpActivity() : UIActivity(activityType) {}
- void process() override
+ void process(DoneCallback) override
{
auto sd = Singleton<UniversalSwitch>::instance().getScrollActivitiesData();
if (sd)
constexpr static const char *activityType = "SCROLL_SLOW_DOWN";
ScrollSlowDownActivity() : UIActivity(activityType) {}
- void process() override
+ void process(DoneCallback) override
{
auto sd = Singleton<UniversalSwitch>::instance().getScrollActivitiesData();
if (sd)
constexpr static const char *activityType = "SCROLL_PAGE_UP";
ScrollPageUpActivity() : UIActivity(activityType) {}
- void process() override
+ void process(DoneCallback) override
{
auto sd = Singleton<UniversalSwitch>::instance().getScrollActivitiesData();
if (sd)
constexpr static const char *activityType = "SCROLL_PAGE_DOWN";
ScrollPageDownActivity() : UIActivity(activityType) {}
- void process() override
+ void process(DoneCallback) override
{
auto sd = Singleton<UniversalSwitch>::instance().getScrollActivitiesData();
if (sd)
constexpr static const char *activityType = "SCROLL_TO_TOP";
ScrollToTopActivity() : UIActivity(activityType) {}
- void process() override
+ void process(DoneCallback) override
{
auto sd = Singleton<UniversalSwitch>::instance().getScrollActivitiesData();
if (sd)
~SelectActivity();
SelectActivity(SelectActivity &&) = delete;
- void process() override;
+ void process(DoneCallback) override;
void update(const std::shared_ptr<UIElement> &elem) override;
void update(const std::shared_ptr<MenuItem> &menuitem) override;
VConfInterface::CallbackHandle autoTapWaitingPeriodCallbackHandle;
ecore::Timer timer;
double autoTapWaitingPeriod;
+ DoneCallback activityDoneCallback;
};
SelectActivity::SelectActivity(): UIActivity(activityType), popup(nullptr, evas_object_del),
auto screenScannerManager = Singleton<UniversalSwitch>::instance().getScreenScannerManager();
if (screenScannerManager)
screenScannerManager->cancelForcingScanningMethod();
+ activityDoneCallback = {};
}
void SelectActivity::deleteScrollActivitiesData()
scrollActivitiesData = {};
}
-void SelectActivity::process()
+void SelectActivity::process(DoneCallback callback)
{
DEBUG("Select - process called");
if (screenScannerManager)
screenScannerManager->acceptAutoscanning();
+
+ activityDoneCallback = std::move(callback);
}
void SelectActivity::update(const std::shared_ptr<UIElement> &elem)
screenScannerManager->cancelForcingScanningMethod();
if (isMenuShown()) {
ASSERT(!realUiElements.empty());
- elem->activate(); /*elem is popup menu item*/
+ elem->activate({}); /*elem is popup menu item*/
return;
}
return;
}
- activities.top()->process();
+ activities.top()->process({});
//TODO: check if activity change request observers are properly detached from activity object removed from activity stack
}
: UIActivity(activityType)
{}
- void process() override
+ void process(DoneCallback doneCb) override
{
if (!uiElement) {
ERROR("process invoked before uiElement initialization");
return;
}
- uiElement->activate();
+ uiElement->activate(std::move(doneCb));
markAsCompleted();
}
: Activity(activityType)
{}
- void process() override
+ void process(DoneCallback) override
{
Singleton<VConfInterface>::instance().set(VCONF_KEY_AUTO_SCAN_ENABLED, true);
markAsCompleted();
: Activity(activityType)
{}
- void process() override
+ void process(DoneCallback) override
{
Singleton<VConfInterface>::instance().set(VCONF_KEY_AUTO_SCAN_ENABLED, false);
markAsCompleted();
{
return Singleton<VConfInterface>::instance().get(DerivedType::KEY, false);
}
- void process() override
+ void process(DoneCallback) override
{
toggleVconfKey();
markAsCompleted();
static constexpr const char *activityType = "TOGGLE_AUTO_SCROLL_ENABLED_ACTIVITY";
static constexpr const char *KEY = VCONF_KEY_AUTO_SCROLL_ENABLED;
- void process() override
+ void process(DoneCallback) override
{
bool isEnabled = toggleVconfKey();
toggleAutoScroll(isEnabled);
#include "UIElement.hpp"
#include "UniversalSwitch.hpp"
#include "UniversalSwitchLog.hpp"
+#include "DoneCallback.hpp"
#include <thread>
#include <chrono>
namespace
{
- void doSelect(std::shared_ptr<Atspi> atspi, const std::shared_ptr<AtspiAccessible> &obj)
+ void doSelect(std::shared_ptr<Atspi> atspi, const std::shared_ptr<AtspiAccessible> &obj, DoneCallback doneCb)
{
atspi->getParent(obj,
- [ = ](DBus::ValueOrError<std::shared_ptr<AtspiAccessible>> parent) {
+ [ =, doneCb = std::move(doneCb)](DBus::ValueOrError<std::shared_ptr<AtspiAccessible>> parent) {
if (!parent) {
DEBUG("no parent");
return;
}
atspi->getIndexInParent(obj,
- [ = ](DBus::ValueOrError<int> index) {
+ [ =, doneCb = std::move(doneCb)](DBus::ValueOrError<int> index) {
if (!index) {
DEBUG("cant get index in parent");
return;
}
atspi->getSelectionInterface(std::get<0>(parent),
- [ = ](DBus::ValueOrError<std::shared_ptr<AtspiSelection>> sel) {
+ [ =, doneCb = std::move(doneCb)](DBus::ValueOrError<std::shared_ptr<AtspiSelection>> sel) {
if (!sel) {
DEBUG("no selection interface");
return;
}
atspi->selectChild(std::get<0>(sel), std::get<0>(index),
- [](DBus::ValueOrError<void> isSuccessful) {
+ [doneCb = std::move(doneCb)](DBus::ValueOrError<void> isSuccessful) {
if (!isSuccessful) {
DEBUG("failed to select");
return;
}
DEBUG("selected");
+ doneCb.callAfterTimeElapsed(sideEffectDelays::activate);
});
});
});
});
}
- void doActivate(std::shared_ptr<Atspi> atspi, const std::shared_ptr<AtspiAccessible> obj)
+ void doActivate(std::shared_ptr<Atspi> atspi, const std::shared_ptr<AtspiAccessible> obj, DoneCallback doneCb)
{
atspi->getActionInterface(obj,
- [atspi, obj](DBus::ValueOrError<std::shared_ptr<AtspiAction>> action) {
+ [atspi, obj, doneCb = std::move(doneCb)](DBus::ValueOrError<std::shared_ptr<AtspiAction>> action) {
if (!action) {
- doSelect(atspi, obj);
+ doSelect(atspi, obj, std::move(doneCb));
return;
}
atspi->doActionName(std::get<0>(action), "activate",
- [atspi, obj](DBus::ValueOrError<bool> status) {
+ [atspi, obj, doneCb = std::move(doneCb)](DBus::ValueOrError<bool> status) {
if (!status || !std::get<0>(status)) {
- doSelect(atspi, obj);
+ doSelect(atspi, obj, std::move(doneCb));
return;
}
DEBUG("activated");
+ doneCb.callAfterTimeElapsed(sideEffectDelays::activate);
});
});
}
}
-void UIElement::activate()
+void UIElement::activate(DoneCallback doneCb)
{
if (!obj) {
DEBUG("obj is nullptr");
return;
}
DEBUG("invoking object %s", atspi->getUniqueId(obj).c_str());
- doActivate(atspi, obj);
+ doActivate(atspi, obj, std::move(doneCb));
}
namespace
INCREMENT, DECREMENT
};
- void changeValue(const std::shared_ptr<Atspi> &atspi, std::shared_ptr<AtspiAccessible> obj, ChangeDirection change)
+ void changeValue(const std::shared_ptr<Atspi> &atspi, std::shared_ptr<AtspiAccessible> obj,
+ ChangeDirection change, DoneCallback doneCb)
{
- auto setCurrentValue = [atspi, change](auto valueInterface, auto currentValue, auto maximumValue, auto minimumValue) {
+ auto setCurrentValue = [atspi, change, doneCb = std::move(doneCb)](auto valueInterface, auto currentValue, auto maximumValue, auto minimumValue) {
auto stepSize = (maximumValue - minimumValue) / NUMBER_OF_STEPS;
auto newValue = 0.0;
switch (change) {
}
atspi->setCurrentValue(valueInterface, newValue,
- [](DBus::ValueOrError<void> isSuccessful) {
- if (!isSuccessful)
+ [doneCb = std::move(doneCb)](DBus::ValueOrError<void> isSuccessful) {
+ if (!isSuccessful) {
DEBUG("Value change failed");
+ } else {
+ doneCb.callAfterTimeElapsed(sideEffectDelays::changeValue);
+ }
});
};
}
}
-void UIElement::increment()
+void UIElement::increment(DoneCallback doneCb)
{
- changeValue(atspi, obj, ChangeDirection::INCREMENT);
+ changeValue(atspi, obj, ChangeDirection::INCREMENT, std::move(doneCb));
}
-void UIElement::decrement()
+void UIElement::decrement(DoneCallback doneCb)
{
- changeValue(atspi, obj, ChangeDirection::DECREMENT);
+ changeValue(atspi, obj, ChangeDirection::DECREMENT, std::move(doneCb));
}
void UIElement::printDebug()
#include <vector>
#include <utility>
+class DoneCallback;
+
class UIElement : public std::enable_shared_from_this<UIElement>
{
public:
Point getScanningCoordinates() const;
ApplicationCategory getApplicationCategory() const;
- void activate();
- void increment();
- void decrement();
+ void activate(DoneCallback);
+ void increment(DoneCallback);
+ void decrement(DoneCallback);
void printDebug();
#include <memory>
-
class Atspi;
class CompositeSwitchProvider;
class Configuration;
std::shared_ptr<ScrollActivitiesData> getScrollActivitiesData() const;
void setScrollActivitiesData(std::shared_ptr<ScrollActivitiesData>);
+ std::string getTestFilePath() const;
+ void setTestFilePath(const std::string &path);
+ void setTestOutputPath(const std::string &path);
+
void initialize();
void terminate();
VConfInterface::CallbackHandle callbackHandle;
bool isScanningOn = false;
bool isDisplayOn = false;
+ std::string testFilePath, testOutputPath;
};
#endif
: Activity(activityType)
{}
- void process() override
+ void process(DoneCallback) override
{
setVolume();
markAsCompleted();
#include "utils.hpp"
#include "UniversalSwitchLog.hpp"
+#include "DoneCallback.hpp"
#include <efl_util.h>
ecore::Timer EventGenerator::timer = {};
- void EventGenerator::generateKeyPress(const std::string &keyId, unsigned multiplicity, PressType type)
+ void EventGenerator::generateKeyPress(const std::string &keyId, DoneCallback doneCb, unsigned multiplicity, PressType type)
{
DEBUG("key: %s, multiplicity: %d", keyId.c_str(), multiplicity);
GeneratorData genData{keyId, multiplicity, delay};
- timer.reset(NO_DELAY, [genData]() {
- return createKeyDownEvent(genData);
+ timer.reset(NO_DELAY, [genData, doneCb = std::move(doneCb)]() {
+ return createKeyDownEvent(genData, std::move(doneCb));
});
}
- ecore::TimerRepetitionPolicy EventGenerator::createKeyDownEvent(GeneratorData genData)
+ ecore::TimerRepetitionPolicy EventGenerator::createKeyDownEvent(GeneratorData genData, DoneCallback doneCb)
{
DEBUG("invoked");
EflKeyInputGenerator inputgen;
inputgen.generateKeyDown(genData.key);
- timer.reset(genData.releaseDelay, [genData]() {
- return createKeyUpEvent(genData);
+ timer.reset(genData.releaseDelay, [genData, doneCb = std::move(doneCb)]() {
+ return createKeyUpEvent(genData, std::move(doneCb));
});
return ecore::TimerRepetitionPolicy::cancel;
}
- ecore::TimerRepetitionPolicy EventGenerator::createKeyUpEvent(GeneratorData genData)
+ ecore::TimerRepetitionPolicy EventGenerator::createKeyUpEvent(GeneratorData genData, DoneCallback doneCb)
{
DEBUG("invoked");
--(genData.multiplicity);
if (genData.multiplicity > 0)
- timer.reset(SHORT_DELAY, [genData]() {
- return createKeyDownEvent(genData);
+ timer.reset(SHORT_DELAY, [genData, doneCb = std::move(doneCb)]() {
+ return createKeyDownEvent(genData, std::move(doneCb));
});
return ecore::TimerRepetitionPolicy::cancel;
#include <string>
+class DoneCallback;
+
#define PRINT_ERROR_IF(condition) \
do { \
if (condition) \
double releaseDelay;
};
- static void generateKeyPress(const std::string &keyId, unsigned multiplicity = SINGLE_PRESS, PressType type = PressType::SHORT);
+ static void generateKeyPress(const std::string &keyId, DoneCallback doneCb, unsigned multiplicity = SINGLE_PRESS,
+ PressType type = PressType::SHORT);
private:
- static ecore::TimerRepetitionPolicy createKeyDownEvent(GeneratorData genData);
- static ecore::TimerRepetitionPolicy createKeyUpEvent(GeneratorData genData);
+ static ecore::TimerRepetitionPolicy createKeyDownEvent(GeneratorData genData, DoneCallback doneCb);
+ static ecore::TimerRepetitionPolicy createKeyUpEvent(GeneratorData genData, DoneCallback doneCb);
static ecore::Timer timer;
static constexpr const char *activityType = "TWO_STEP_PROCESS_ACTIVITY";
TwoStepProcessActivity(): Activity(activityType) {}
- void process() override
+ void process(DoneCallback) override
{
if (++state > 1)
markAsCompleted();
static constexpr const char *activityType = "THREE_STEP_PROCESS_ACTIVITY";
ThreeStepProcessActivity(): Activity(activityType) {}
- void process() override
+ void process(DoneCallback) override
{
if (++state > 2)
markAsCompleted();
void simulateKeyPress(const std::string &key)
{
eventTimer.reset(SMALL_DELAY_, [&key]() {
- utils::EventGenerator::generateKeyPress(key);
+ utils::EventGenerator::generateKeyPress(key, {});
return ecore::TimerRepetitionPolicy::cancel;
});
mainloopTimer.reset(ESTIMATED_TIME_REQUIRED_TO_SAFELY_PASSING_THROUGH_TESTS_, []() {