libaurum: change to handle a text as regex
authorWonki Kim <wonki_.kim@samsung.com>
Wed, 3 Jun 2020 05:56:18 +0000 (14:56 +0900)
committerJongmin Lee <jm105.lee@samsung.com>
Sun, 7 Jun 2020 22:41:45 +0000 (07:41 +0900)
please refer to 'std::ECMAScript' syntax for more information.

Change-Id: Ia96c6cb2872fb3b2b4e5dcf185b28d539cd1f7f6

libaurum/src/PartialMatch.cc
protocol/examples/python/testFeatures.py

index 89e223b..3bac438 100644 (file)
@@ -2,13 +2,15 @@
 
 #include <iostream>
 #include <set>
+#include <regex>
 
 #include <loguru.hpp>
 
 bool PartialMatch::checkCriteria(const std::string *textA, const std::string textB)
 {
     if (!textA) return false;
-    return textA->compare(textB);
+    std::regex re(*textA);
+    return !std::regex_match(textB, re);
 }
 
 bool PartialMatch::checkCriteria(const bool *boolA, const bool boolB)
index 05ec233..1439e8e 100644 (file)
@@ -33,7 +33,7 @@ def setValueClearTest(stub):
 
     for tryCnt in range(10):
         stub.flick(ReqFlick(startPoint=Point(x=160, y=350), endPoint=Point(x=160, y=10), durationMs=500))
-        response = stub.findElement(ReqFindElement(textField='Entry/Editfield, Entry/Text Input'))
+        response = stub.findElement(ReqFindElement(textField='Entry/Editfield.*'))
         if len(response.elements) <= 0: continue
         targetObj = response.elements[0].elementId
         response = stub.getSize(ReqGetSize(elementId=targetObj))
@@ -171,7 +171,7 @@ def flickTest(stub):
     for tryCnt in range(10):
         print('Flick to bottom to find "Spinner" item @ tries:', tryCnt)
         stub.flick(ReqFlick(startPoint=Point(x=160, y=350), endPoint=Point(x=160, y=10), durationMs=10))
-        response = stub.findElement(ReqFindElement(textField='Slider'))
+        response = stub.findElement(ReqFindElement(textField='Spinner.*'))
         time.sleep(0.5)
         print(response)
         if len(response.elements) > 0: return True