From aff336f5441880ebec8e6e51bcd24cefb7d6be3c Mon Sep 17 00:00:00 2001 From: Wonki Kim Date: Wed, 3 Jun 2020 14:56:01 +0900 Subject: [PATCH] libaurum: add a logic to wait for idle 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 | 2 +- libaurum/src/UiDevice.cc | 60 +++++++++++++++++++++++++++++++++++++----------- 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/libaurum/inc/UiDevice.h b/libaurum/inc/UiDevice.h index 7153ae2..46634a3 100644 --- a/libaurum/inc/UiDevice.h +++ b/libaurum/inc/UiDevice.h @@ -60,7 +60,7 @@ public: private: std::vector> getWindowRoot() const; - + bool waitForIdle() const; private: UiDevice(); UiDevice(DeviceType type, IDevice *impl); diff --git a/libaurum/src/UiDevice.cc b/libaurum/src/UiDevice.cc index 64fd676..bdb0cbd 100644 --- a/libaurum/src/UiDevice.cc +++ b/libaurum/src/UiDevice.cc @@ -6,6 +6,8 @@ #include #include #include +#include +#include UiDevice::UiDevice() : UiDevice(DeviceType::DEFAULT, nullptr) {} @@ -84,71 +86,101 @@ std::unique_ptr 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) -- 2.7.4