Added key press function in batch mode 47/211247/1
authorAdrian Wojciechowski <a.wojciecho3@partner.samsung.com>
Wed, 31 Jul 2019 10:35:27 +0000 (12:35 +0200)
committerAdrian Wojciechowski <a.wojciecho3@partner.samsung.com>
Wed, 31 Jul 2019 10:35:27 +0000 (12:35 +0200)
Change-Id: I1aae78b1114a8f8c4bd42021e9634fe181fc4d5e

src/batch/BatchRunner.cpp

index 48715ba2d4787a2f6be40d4671174082d4a08607..214f4952fbf4ee4c7047f2ccf786484ac4c2bb4d 100644 (file)
@@ -1110,6 +1110,30 @@ void BatchExecutor::insertMethods()
                        },  { {"clockwise", true}, {"multiplicity", 1} } };
        };
        variables["TURN_WHEEL"] = generateWheelTurnFunction();
+
+       auto generateKeyPressFunction = [&]() {
+               return EvaluationValueFunction{ [&](std::string keyId, unsigned multiplicity, double hold_time) -> EvaluationValue {
+
+                               if (keyId == "")
+                                       throw EvaluationFailure{} << "Invalid keyId";
+
+                               if (multiplicity <= 0)
+                                       throw EvaluationFailure{} << "Invalid multiplicity (must be more that 0)";
+
+                               if (hold_time < 0)
+                                       throw EvaluationFailure{} << "Invalid hold time (must be more or equal 0)";
+
+                               executeOnMainThread([&]()
+                               {
+                                       utils::generateKeyPress(keyId, multiplicity, hold_time);
+                               });
+
+                               std::this_thread::sleep_for(std::chrono::milliseconds{ 800 });
+
+                               return EvaluationValue{};
+                       },  { {"keyId" }, {"multiplicity", 1 }, {"holdTime", 0} } };
+       };
+       variables["PRESS_KEY"] = generateKeyPressFunction();
 }
 
 class PredicateWaitInterface : public EvaluationValueWaitInterface