}), std::move(roles), std::move(states));
}, monitor);
}, { { "name" }, { "roles", EvaluationValueSet() }, { "states", EvaluationValueSet() } } };
+
+ auto generateTapFunction = [&](size_t tapCount) {
+ Optional<EvaluationValue> defValue;
+ if (tapCount > 1)
+ defValue = EvaluationValuePoint{ 300, 300 };
+ return EvaluationValueFunction{ [ &, tapCount](EvaluationValue target) -> EvaluationValue {
+ auto root = getVisibleRoot();
+ if (!root) throw EvaluationFailure{} << "no visible root (context changed didn't happen)";
+ ASSERT(root->getObject());
+ auto dest = target.convertToUIElement();
+
+ auto sleep_until = std::chrono::high_resolution_clock::now() + std::chrono::milliseconds{ 400 };
+ for (auto i = 0u; i < tapCount; ++i)
+ {
+ executeOnMainThread([&]() {
+ auto coord = dest->getScanningCoordinates();
+ auto res = utils::generateTapGesture(coord.x, coord.y, 0.0f);
+ if (!res)
+ throw EvaluationFailure{} << "failed to execute " << tapCount << " tap gesture, " << res.getError().message;
+ });
+ }
+ std::this_thread::sleep_until(sleep_until);
+
+ return EvaluationValue{};
+ }, { { "target" } } };
+ };
+ variables["TAP"] = generateTapFunction(1);
+ variables["DOUBLE_TAP"] = generateTapFunction(2);
+ variables["TRIPLE_TAP"] = generateTapFunction(3);
+
+ auto generateFlickFunction = [&](int x0, int y0, int x1, int y1) {
+ return EvaluationValueFunction{ [ &, x0, y0, x1, y1]() -> EvaluationValue {
+ auto root = getVisibleRoot();
+ if (!root) throw EvaluationFailure{} << "no visible root (context changed didn't happen)";
+ ASSERT(root->getObject());
+
+ executeOnMainThread([&]()
+ {
+ utils::generateDragGesture(x0, y0, x1, y1, 10, 0.0);
+ });
+ std::this_thread::sleep_for(std::chrono::milliseconds{ 150 });
+ return EvaluationValue{};
+ }, { } };
+ };
+ variables["FLICK_RIGHT"] = generateFlickFunction(200, 200, 400, 200);
+ variables["FLICK_LEFT"] = generateFlickFunction(400, 200, 200, 200);
+ variables["FLICK_UP"] = generateFlickFunction(300, 400, 300, 200);
+ variables["FLICK_DOWN"] = generateFlickFunction(300, 200, 300, 400);
}
class PredicateWaitInterface : public EvaluationValueWaitInterface
auto impl = std::make_shared<WaitTTS>(this, std::chrono::milliseconds{ static_cast<size_t>(timeout * 1000) }, std::move(pattern));
return EvaluationValue{ impl };
};
- variables["tts"] = EvaluationValueFunction{ std::move(waitTTS), { { "pattern", "" }, { "timeout", 3.0 } } };
+ variables["tts"] = EvaluationValueFunction{ std::move(waitTTS), { { "pattern", "" }, { "timeout", 5.0 } } };
auto waitGui = [&](std::string name, double timeout) -> EvaluationValue {
auto impl = std::make_shared<WaitGui>(this, std::chrono::milliseconds{ static_cast<size_t>(timeout * 1000) }, std::move(name));
return EvaluationValue{ impl };
};
- variables["gui"] = EvaluationValueFunction{ std::move(waitGui), { { "name", "" }, { "timeout", 3.0 } } };
+ variables["gui"] = EvaluationValueFunction{ std::move(waitGui), { { "name", "" }, { "timeout", 5.0 } } };
}
void BatchExecutor::insertActivities()
{
for (auto activityName : ActivityFactory::getInstance()->getAllActivityTypes()) {
+ if (variables.find(activityName) != variables.end())
+ continue;
variables[activityName] = [ = ](EvaluationValueFunction::Args args) -> EvaluationValue {
auto activity = executeOnMainThread([&]()
{