From 197f57377d394cdb2ea9e47ff77d9b1379264201 Mon Sep 17 00:00:00 2001 From: yuancjun <153783375+yuancjun@users.noreply.github.com> Date: Tue, 16 Jul 2024 14:48:00 +0800 Subject: [PATCH] Fix: The API [GET /uiObject/{oid}/getBounds] returns the view's bounds property. --- .../com/dtmilano/android/culebratester2/location/UiObject.kt | 2 +- .../dtmilano/android/culebratester2/KtorApplicationTest.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/dtmilano/android/culebratester2/location/UiObject.kt b/app/src/main/java/com/dtmilano/android/culebratester2/location/UiObject.kt index 132c528..4a508f4 100644 --- a/app/src/main/java/com/dtmilano/android/culebratester2/location/UiObject.kt +++ b/app/src/main/java/com/dtmilano/android/culebratester2/location/UiObject.kt @@ -201,7 +201,7 @@ class UiObject { fun response(): Rect { uiObject(oid, objectStore)?.let { - val (top, left, right, bottom) = it.bounds + val (left, top, right, bottom) = it.bounds return@response Rect(left = left, top = top, right = right, bottom = bottom) } throw notFound(oid) diff --git a/app/src/test/java/com/dtmilano/android/culebratester2/KtorApplicationTest.kt b/app/src/test/java/com/dtmilano/android/culebratester2/KtorApplicationTest.kt index fd96ef9..5a3723a 100644 --- a/app/src/test/java/com/dtmilano/android/culebratester2/KtorApplicationTest.kt +++ b/app/src/test/java/com/dtmilano/android/culebratester2/KtorApplicationTest.kt @@ -235,7 +235,7 @@ class KtorApplicationTest { on { className } doReturn MOCK_CLASS_NAME on { text } doReturn "Hello Culebra!" on { contentDescription } doReturn "Hello Culebra content description" - on { bounds } doReturn android.graphics.Rect(100, 100, 600, 900) + on { bounds } doReturn android.graphics.Rect(100, 200, 600, 900) } uiObject22 = mock { @@ -1029,8 +1029,8 @@ class KtorApplicationTest { handleRequest(HttpMethod.Get, "/v2/uiObject/$oid/getBounds").apply { assertEquals(HttpStatusCode.OK, response.status()) val rect = jsonResponse() - assertEquals(100, rect.top) assertEquals(100, rect.left) + assertEquals(200, rect.top) assertEquals(600, rect.right) assertEquals(900, rect.bottom) }