Added TURN_WHEEL function to BatchRunner 07/209407/5
authorAdrian Wojciechowski <a.wojciecho3@partner.samsung.com>
Fri, 5 Jul 2019 08:37:15 +0000 (10:37 +0200)
committerAdrian Wojciechowski <a.wojciecho3@partner.samsung.com>
Fri, 5 Jul 2019 14:23:07 +0000 (16:23 +0200)
Change-Id: I8e1099ea7da90aee22e8e1c6c87b82ab6a264118

src/batch/BatchRunner.cpp

index 29662e1f1f4a422fec596f943f47ab4d886f061e..e4c4408ab092a59383f58b3ffca15dc19af0d5c0 100644 (file)
@@ -1057,6 +1057,27 @@ void BatchExecutor::insertMethods()
        variables["FLICK_LEFT"] = generateFlickFunction(400, 200, 200, 200);
        variables["FLICK_UP"] = generateFlickFunction(300, 600, 300, 200);
        variables["FLICK_DOWN"] = generateFlickFunction(300, 200, 300, 600);
+
+       auto generateWheelTurnFunction = [&]() {
+               return EvaluationValueFunction{ [&](bool clockwise, int multiplicity) -> EvaluationValue {
+
+                       if (multiplicity <= 0)
+                               throw EvaluationFailure{} << "Invalid multiplicity (must be more that 0)";
+
+                       auto delay = multiplicity > 1 ? 0.75 : 0;
+
+                       executeOnMainThread([&]()
+                       {
+                               utils::generateWheelTurn(clockwise, multiplicity, delay);
+                       });
+
+                       int await = 1000 * (multiplicity * delay);
+                       std::this_thread::sleep_for(std::chrono::milliseconds{ await });
+
+                       return EvaluationValue{};
+               },  { {"clockwise", true}, {"multiplicity", 1} } };
+       };
+       variables["TURN_WHEEL"] = generateWheelTurnFunction();
 }
 
 class PredicateWaitInterface : public EvaluationValueWaitInterface