libaurum: add a logic to wait for idle
authorWonki Kim <wonki_.kim@samsung.com>
Wed, 3 Jun 2020 05:56:01 +0000 (14:56 +0900)
committerJongmin Lee <jm105.lee@samsung.com>
Sun, 7 Jun 2020 22:41:45 +0000 (07:41 +0900)
everytime aurum does some action, ui will change consequently.
and libaurum should have to wait for idle of ui objects.
this patch add add the logic

Change-Id: I101327be163ce65163bfb6b3a5c0d69518dff91c

libaurum/inc/UiDevice.h
libaurum/src/UiDevice.cc

index 7153ae2..46634a3 100644 (file)
@@ -60,7 +60,7 @@ public:
 
 private:
     std::vector<std::unique_ptr<AccessibleNode>> getWindowRoot() const;
-
+    bool waitForIdle() const;
 private:
     UiDevice();
     UiDevice(DeviceType type, IDevice *impl);
index 64fd676..bdb0cbd 100644 (file)
@@ -6,6 +6,8 @@
 #include <unistd.h>
 #include <utility>
 #include <vector>
+#include <chrono>
+#include <thread>
 
 UiDevice::UiDevice() : UiDevice(DeviceType::DEFAULT, nullptr) {}
 
@@ -84,71 +86,101 @@ std::unique_ptr<UiObject> UiDevice::waitFor(
 {
     return mWaiter->waitFor(condition);
 }
+bool UiDevice::waitForIdle() const
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds{167});
+    return true;
+}
 
 bool UiDevice::click(const int x, const int y)
 {
-    return mDeviceImpl->click(x, y);
+    bool result =  mDeviceImpl->click(x, y);
+    waitForIdle();
+    return result;
 }
 
 bool UiDevice::click(const int x, const int y, const unsigned int intv)
 {
-    return mDeviceImpl->click(x, y, intv);
+    bool result = mDeviceImpl->click(x, y, intv);
+    waitForIdle();
+    return result;
 }
 
 bool UiDevice::drag(const int sx, const int sy, const int ex, const int ey,
-                    const int steps)
+                    const int steps, const int durationMs)
 {
-    return mDeviceImpl->drag(sx, sy, ex, ey, steps);
+    bool result =  mDeviceImpl->drag(sx, sy, ex, ey, steps, durationMs);
+    waitForIdle();
+    return result;
 }
 
 bool UiDevice::touchDown(const int x, const int y)
 {
-    return mDeviceImpl->touchDown(x, y);
+    bool result =  mDeviceImpl->touchDown(x, y);
+
+    return result;
 }
 
 bool UiDevice::touchMove(const int x, const int y)
 {
-    return mDeviceImpl->touchMove(x, y);
+    bool result =  mDeviceImpl->touchMove(x, y);
+    return result;
 }
 
 bool UiDevice::touchUp(const int x, const int y)
 {
-    return mDeviceImpl->touchUp(x, y);
+    bool result =  mDeviceImpl->touchUp(x, y);
+    waitForIdle();
+    return result;
 }
 
 bool UiDevice::pressBack()
 {
-    return mDeviceImpl->pressBack();
+    bool result =  mDeviceImpl->pressBack();
+    waitForIdle();
+    return result;
 }
 
 bool UiDevice::pressHome()
 {
-    return mDeviceImpl->pressHome();
+    bool result =  mDeviceImpl->pressHome();
+    waitForIdle();
+    return result;
 }
 
 bool UiDevice::pressMenu()
 {
-    return mDeviceImpl->pressMenu();
+    bool result =  mDeviceImpl->pressMenu();
+    waitForIdle();
+    return result;
 }
 
 bool UiDevice::pressVolUp()
 {
-    return mDeviceImpl->pressVolUp();
+    bool result =  mDeviceImpl->pressVolUp();
+    waitForIdle();
+    return result;
 }
 
 bool UiDevice::pressVolDown()
 {
-    return mDeviceImpl->pressVolDown();
+    bool result =  mDeviceImpl->pressVolDown();
+    waitForIdle();
+    return result;
 }
 
 bool UiDevice::pressPower()
 {
-    return mDeviceImpl->pressPower();
+    bool result =  mDeviceImpl->pressPower();
+    waitForIdle();
+    return result;
 }
 
 bool UiDevice::pressKeyCode(std::string keycode)
 {
-    return mDeviceImpl->pressKeyCode(keycode);
+    bool result =  mDeviceImpl->pressKeyCode(keycode);
+    waitForIdle();
+    return result;
 }
 
 bool UiDevice::takeScreenshot(std::string path, float scale, int quality)