void process() method in Activity.
void markAsCompleted() method in Activity.
Change-Id: I1de7f9a266b32919add25607e3a0ee55b5909d5c
: completed(false), type(activityType)
{}
-std::string Activity::getType()
+std::string Activity::getType() const
{
return type;
}
-bool Activity::isCompleted()
+bool Activity::isCompleted() const
{
return completed;
}
+
+void Activity::markAsCompleted()
+{
+ completed = true;
+}
Activity(const std::string &activityType);
virtual ~Activity() = default;
- std::string getType();
+ std::string getType() const;
virtual void initialize()
{}
- virtual bool process() = 0;
+ virtual void process() = 0;
+
+ bool isCompleted() const;
+ void markAsCompleted();
+
- virtual bool isCompleted();
protected:
bool completed;
#define RETURN_ON_ERROR(ret) do { \
if (ret != APP_CONTROL_ERROR_NONE) { \
CHECK_ERROR(ret); \
- return true; \
+ markAsCompleted(); \
+ return; \
} \
} while (false)
}
}
- bool process() override
+ void process() override
{
auto ret = app_control_create(&appControlHandle);
RETURN_ON_ERROR(ret);
ret = app_control_send_launch_request(appControlHandle, NULL, NULL);
RETURN_ON_ERROR(ret);
- return true;
+ markAsCompleted();
}
protected:
virtual int addExtraDataToCall()
: Activity(activityType)
{}
- bool process() override
+ void process() 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);
- return true;
+ markAsCompleted();
}
};
: Activity(activityType)
{}
- bool process() override
+ void process() override
{
DBus::DBusClient dbus{dbusLocators::callmgr::BUS, dbusLocators::callmgr::OBJ_PATH, dbusLocators::callmgr::INTERFACE, DBus::ConnectionType::SYSTEM};
dbus.method<int()>("RejectCall").call();
- return true;
+ markAsCompleted();
}
};
: Activity(activityType)
{}
- bool process() override
+ void process() 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);
- return true;
+ markAsCompleted();
}
};
: Activity(activityType)
{}
- bool process() override
+ void process() override
{
auto method = Singleton<VConfInterface>::instance().get(VCONF_KEY_SCAN_METHOD, 0);
- if (!method)
- return true;
+ if (!method) {
+ markAsCompleted();
+ return;
+ }
method = method % 2 + 1;
Singleton<VConfInterface>::instance().set(VCONF_KEY_SCAN_METHOD, method);
Singleton<UniversalSwitch>::instance().getScreenScannerManager()->startAutoscanning();
- return true;
+ markAsCompleted();
}
};
: Activity(activityType)
{}
- bool process() override
+ void process() 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;
changeProfile(false, false);
break;
}
- return true;
+ markAsCompleted();
}
void changeProfile(bool sound, bool vibration)
: Activity(activityType)
{}
- bool process() override
+ void process() override
{
changeKeyValue([](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;
});
- return true;
+ markAsCompleted();
}
};
: Activity(activityType)
{}
- bool process() override
+ void process() override
{
changeKeyValue([](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;
});
- return true;
+ markAsCompleted();
}
};
: UIActivity(activityType)
{}
- bool process() override
+ void process() override
{
ASSERT(uiElement, "process invoked before uiElement initialization");
uiElement->increment();
- return true;
+ markAsCompleted();
}
};
: UIActivity(activityType)
{}
- bool process() override
+ void process() override
{
ASSERT(uiElement, "process invoked before uiElement initialization");
uiElement->decrement();
- return true;
+ markAsCompleted();
}
};
: UIActivity(activityType)
{}
- bool process() override
+ void process() override
{
auto point = uiElement->getScanningCoordinates();
DBus::DBusClient dbus {dbusLocators::accessibilityEMod::BUS, dbusLocators::accessibilityEMod::OBJ_PATH, dbusLocators::accessibilityEMod::INTERFACE, DBus::ConnectionType::SYSTEM};
SwipeType swipeType = DerivedType::swipeType;
dbus.method<void(int, int, int)>("DispatchGestureEvent").call(swipeType, point.x, point.y);
- return true;
+ markAsCompleted();
}
};
: Activity(activityType)
{}
- bool process() override
+ void process() override
{
utils::EventGenerator::generateKeyPress(DerivedType::buttonCode, DerivedType::multiplicity);
- return true;
+ markAsCompleted();
}
};
constexpr static const char *activityType = DerivedType::activityType;
MoveElementActivity() : Activity(activityType) {}
- bool process() override
+ void process() override
{
auto s = Singleton<UniversalSwitch>::instance().getScreenScannerManager();
if (s) DerivedType::move(s);
else ERROR("ScreenScannerManager not found");
- return true;
+ markAsCompleted();
}
};
PowerKeyMenuActivity()
: Activity(activityType) {}
- bool process() override
+ void process() override
{
auto bundleHandle = std::unique_ptr<bundle, int(*)(bundle *)>(bundle_create(), bundle_free);
if (!bundleHandle) {
- ERROR("bundle_create failure");
- return true;
+ markAsCompleted();
+ return;
}
auto ret = bundle_add(bundleHandle.get(), POPUP_CONTENT, POPUP_NAME_POWERKEY);
if (ret < 0) {
ERROR("Failed to add bundle (%s,%s), error: %d", POPUP_CONTENT, POPUP_NAME_POWERKEY, ret);
- return true;
+ markAsCompleted();
+ return;
}
ret = syspopup_launch(const_cast<char *>(POPUP_POWERKEY), bundleHandle.get());
if (ret < 0)
ERROR("Failed to launch popup, error: %d", ret);
- return true;
+ markAsCompleted();
}
private:
: Activity(activityType)
{}
- bool process() override
+ void process() override
{
DerivedType::changeQuickpanelState();
- return true;
+ markAsCompleted();
}
};
{
public:
ScreenshotActivity();
- bool process() override;
+ void process() override;
constexpr static const char *activityType = "SCREENSHOT";
ScreenshotActivity::ScreenshotActivity() : UIActivity(activityType) {}
-bool ScreenshotActivity::process()
+void ScreenshotActivity::process()
{
char *path = nullptr;
storage_get_directory(STORAGE_TYPE_INTERNAL, STORAGE_DIRECTORY_IMAGES, &path);
if (directory.empty()) {
ERROR("No storage path");
- return true;
+ markAsCompleted();
+ return;
}
auto filename = directory + "/" + generateFileName();
else
ERROR("No main window");
- completed = true;
+ markAsCompleted();
return ecore::TimerRepetitionPolicy::cancel;
});
-
- return false;
}
~SelectActivity();
SelectActivity(SelectActivity &&) = delete;
- bool process() override;
+ void process() override;
void update(const std::shared_ptr<UIElement> &elem) override;
void update(const std::shared_ptr<MenuItem> &menuitem) override;
removeMenu();
}
-bool SelectActivity::process()
+void SelectActivity::process()
{
DEBUG("Select - process called");
- if (completed)
- return true;
if (timer.isSet()) {
timer.reset();
if (screenScannerManager)
screenScannerManager->acceptAutoscanning();
-
- return false;
}
void SelectActivity::update(const std::shared_ptr<UIElement> &elem)
if (!menuItem->isRepeatable()) {
removeMenu();
- completed = true;
+ markAsCompleted();
}
notify(std::make_shared<ActivityChangeRequest>(menuItem->getActivityType(), realUiElement));
removeMenu();
nestedMenusLabels.pop_back();
if (nestedMenusLabels.empty())
- completed = true;
+ markAsCompleted();
else
refreshMenu();
}
void SelectActivity::sendTapActivityChangeRequest()
{
ASSERT(realUiElement, "realUiElement is NULL");
- completed = true;
+ markAsCompleted();
notify(std::make_shared<ActivityChangeRequest>("TAP", realUiElement));
}
return;
}
- bool completed = activities.top()->process();
-
- if (completed) {
- DEBUG("Pop from stack: %s", activities.top()->getType().c_str());
- activities.pop();
- }
+ activities.top()->process();
//TODO: check if activity change request observers are properly detached from activity object removed from activity stack
}
: UIActivity(activityType)
{}
- bool process() override
+ void process() override
{
if (!uiElement) {
ERROR("process invoked before uiElement initialization");
- return true;
+ markAsCompleted();
+ return;
}
uiElement->activate();
- return true;
+ markAsCompleted();
}
};
: Activity(activityType)
{}
- bool process() override
+ void process() override
{
Singleton<VConfInterface>::instance().set(VCONF_KEY_AUTO_SCAN_ENABLED, true);
- return true;
+ markAsCompleted();
}
};
: Activity(activityType)
{}
- bool process() override
+ void process() override
{
Singleton<VConfInterface>::instance().set(VCONF_KEY_AUTO_SCAN_ENABLED, false);
- return true;
+ markAsCompleted();
}
};
: Activity(activityType)
{}
- bool process() override
+ void process() override
{
auto isEnabled = Singleton<VConfInterface>::instance().get(VCONF_KEY_FEEDBACK_SOUND_ENABLED, false);
Singleton<VConfInterface>::instance().set(VCONF_KEY_FEEDBACK_SOUND_ENABLED, !isEnabled);
- return true;
+ markAsCompleted();
}
};
: Activity(activityType)
{}
- bool process() override
+ void process() override
{
auto isEnabled = Singleton<VConfInterface>::instance().get(VCONF_KEY_FEEDBACK_VOICE_ENABLED, true);
Singleton<VConfInterface>::instance().set(VCONF_KEY_FEEDBACK_VOICE_ENABLED, !isEnabled);
- return true;
+ markAsCompleted();
}
};
#include <sound_manager.h>
-#define RETURN_ON_ERROR(status) do { \
- if (status != SOUND_MANAGER_ERROR_NONE) { \
- ERROR("Sound manager error %d", status); \
- return true; \
- } \
+#define RETURN_ON_ERROR(status) do { \
+ if (status != SOUND_MANAGER_ERROR_NONE) { \
+ ERROR("Sound manager error %d", status); \
+ markAsCompleted(); \
+ return; \
+ } \
} while (false)
#define RETURN_DEFAULT_SOUND_TYPE_ON_ERROR(status) do { \
: Activity(activityType)
{}
- bool process() override
+ void process() override
{
int volume = 0;
int maxVolume = 0;
volume = utils::clamp(volume + DerivedType::step, minVolume, maxVolume);
RETURN_ON_ERROR(sound_manager_set_volume(soundType, volume));
- return true;
+ markAsCompleted();
}
virtual sound_type_e getSoundType() const
EXPECT_EQ(activity->getType(), "TWO_STEP_PROCESS_ACTIVITY");
simulateKeyPress(keyMappedToTwoStepProcessActivity_);
- auto isEmpty = switchManager_->getActivities().empty();
- EXPECT_EQ(isEmpty, true);
+ activity = switchManager_->getActivities().top();
+ EXPECT_NE(activity, nullptr);
+ if (activity)
+ EXPECT_TRUE(activity->isCompleted());
}
/*
TEST_F(ActivityProcessingFixture, ActivityAbandoned)
{
initialEnvironmentExpect();
- auto activity = switchManager_->getActivities().top();
- EXPECT_NE(activity, nullptr);
- if (activity)
- EXPECT_EQ(activity->getType(), "TWO_STEP_PROCESS_ACTIVITY");
+
+ auto twoStepProcessActivity = switchManager_->getActivities().top();
+ EXPECT_NE(twoStepProcessActivity, nullptr);
+ if (!twoStepProcessActivity)
+ return;
+
+ EXPECT_EQ(twoStepProcessActivity->getType(), "TWO_STEP_PROCESS_ACTIVITY");
+ EXPECT_FALSE(twoStepProcessActivity->isCompleted());
simulateKeyPress(keyMappedToThreeStepProcessActivity_);
+
EXPECT_EQ(switchManager_->getActivities().size(), 2u);
- activity = switchManager_->getActivities().top();
- EXPECT_NE(activity, nullptr);
- if (activity)
- EXPECT_EQ(activity->getType(), "THREE_STEP_PROCESS_ACTIVITY");
+
+ auto threeStepProcessActivity = switchManager_->getActivities().top();
+ EXPECT_NE(threeStepProcessActivity, nullptr);
+ if (!threeStepProcessActivity)
+ return;
+
+ EXPECT_EQ(threeStepProcessActivity->getType(), "THREE_STEP_PROCESS_ACTIVITY");
+ EXPECT_FALSE(twoStepProcessActivity->isCompleted());
+ EXPECT_FALSE(threeStepProcessActivity->isCompleted());
simulateKeyPress(keyMappedToThreeStepProcessActivity_);
EXPECT_EQ(switchManager_->getActivities().size(), 2u);
- activity = switchManager_->getActivities().top();
+ EXPECT_EQ(threeStepProcessActivity, switchManager_->getActivities().top());
+ EXPECT_FALSE(twoStepProcessActivity->isCompleted());
+ EXPECT_FALSE(threeStepProcessActivity->isCompleted());
- EXPECT_NE(activity, nullptr);
- if (activity)
- EXPECT_EQ(activity->getType(), "THREE_STEP_PROCESS_ACTIVITY");
simulateKeyPress(keyMappedToThreeStepProcessActivity_);
+
+ EXPECT_EQ(switchManager_->getActivities().size(), 2u);
+ EXPECT_EQ(threeStepProcessActivity, switchManager_->getActivities().top());
+ EXPECT_FALSE(twoStepProcessActivity->isCompleted());
+ EXPECT_TRUE(threeStepProcessActivity->isCompleted());
+
+ simulateKeyPress(keyMappedToTwoStepProcessActivity_);
+
EXPECT_EQ(switchManager_->getActivities().size(), 1u);
- activity = switchManager_->getActivities().top();
- EXPECT_NE(activity, nullptr);
- if (activity)
- EXPECT_EQ(activity->getType(), "TWO_STEP_PROCESS_ACTIVITY");
+ EXPECT_EQ(twoStepProcessActivity, switchManager_->getActivities().top());
+ EXPECT_TRUE(twoStepProcessActivity->isCompleted());
}
static constexpr const char *activityType = "TWO_STEP_PROCESS_ACTIVITY";
TwoStepProcessActivity(): Activity(activityType) {}
- bool process() override
+ void process() override
{
- return ++state > 1;
+ if (++state > 1)
+ markAsCompleted();
};
int state = 0;
};
static constexpr const char *activityType = "THREE_STEP_PROCESS_ACTIVITY";
ThreeStepProcessActivity(): Activity(activityType) {}
- bool process() override
+ void process() override
{
- return ++state > 2;
+ if (++state > 2)
+ markAsCompleted();
};
int state = 0;
};