Skip to content

Commit

Permalink
Remove unused classes from maestro-ios-driver (#2038)
Browse files Browse the repository at this point in the history
* cleanup maestro-ios-driver: delete unused AccessibilityNode and Frame classes

* run intellij cleanup action across all project
  • Loading branch information
bartekpacia authored Sep 10, 2024
1 parent 87ed1f2 commit 475acc1
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ class Service(
return@post
}

newLocation.setTime(System.currentTimeMillis())
newLocation.time = System.currentTimeMillis()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
newLocation.elapsedRealtimeNanos = SystemClock.elapsedRealtimeNanos()
}
Expand Down
8 changes: 4 additions & 4 deletions maestro-cli/src/main/java/maestro/cli/device/DeviceService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ object DeviceService {

fun listConnectedDevices(): List<Device.Connected> {
return listDevices()
.filterIsInstance(Device.Connected::class.java)
.filterIsInstance<Device.Connected>()
}

fun <T : Device> List<T>.withPlatform(platform: Platform?) =
filter { platform == null || it.platform == platform }

fun listAvailableForLaunchDevices(): List<Device.AvailableForLaunch> {
return listDevices()
.filterIsInstance(Device.AvailableForLaunch::class.java)
.filterIsInstance<Device.AvailableForLaunch>()
}

private fun listDevices(): List<Device> {
Expand Down Expand Up @@ -249,11 +249,11 @@ object DeviceService {
fun isDeviceAvailableToLaunch(deviceName: String, platform: Platform): Device.AvailableForLaunch? {
return if (platform == Platform.IOS) {
listIOSDevices()
.filterIsInstance(Device.AvailableForLaunch::class.java)
.filterIsInstance<Device.AvailableForLaunch>()
.find { it.description.contains(deviceName, ignoreCase = true) }
} else {
listAndroidDevices()
.filterIsInstance(Device.AvailableForLaunch::class.java)
.filterIsInstance<Device.AvailableForLaunch>()
.find { it.description.contains(deviceName, ignoreCase = true) }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ object PickDeviceView {
private fun <T> pickIndex(data: List<T>): T {
println()
while (!Thread.interrupted()) {
val index = readLine()?.toIntOrNull() ?: 0
val index = readlnOrNull()?.toIntOrNull() ?: 0

if (index < 1 || index > data.size) {
printEnterNumberPrompt()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ class AndroidDriver(
return false
}

override fun waitForAppToSettle(initialHierarchy: ViewHierarchy?, appId: String?, timeoutMs: Int?): ViewHierarchy? {
override fun waitForAppToSettle(initialHierarchy: ViewHierarchy?, appId: String?, timeoutMs: Int?): ViewHierarchy {
return if (appId != null) {
waitForWindowToSettle(appId, initialHierarchy, timeoutMs)
} else {
Expand Down
10 changes: 5 additions & 5 deletions maestro-client/src/main/java/maestro/drivers/WebDriver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ class WebDriver(val isStudio: Boolean) : Driver {
}

override fun open() {
System.setProperty("webdriver.chrome.silentOutput", "true");
System.setProperty(ChromeDriverService.CHROME_DRIVER_SILENT_OUTPUT_PROPERTY, "true");
Logger.getLogger("org.openqa.selenium").level = Level.OFF;
Logger.getLogger("org.openqa.selenium.devtools.CdpVersionFinder").level = Level.OFF;
System.setProperty("webdriver.chrome.silentOutput", "true")
System.setProperty(ChromeDriverService.CHROME_DRIVER_SILENT_OUTPUT_PROPERTY, "true")
Logger.getLogger("org.openqa.selenium").level = Level.OFF
Logger.getLogger("org.openqa.selenium.devtools.CdpVersionFinder").level = Level.OFF

val driverService = ChromeDriverService.Builder()
.withLogLevel(ChromiumDriverLogLevel.OFF)
Expand Down Expand Up @@ -373,7 +373,7 @@ class WebDriver(val isStudio: Boolean) : Driver {
return true
}

override fun waitForAppToSettle(initialHierarchy: ViewHierarchy?, appId: String?, timeoutMs: Int?): ViewHierarchy? {
override fun waitForAppToSettle(initialHierarchy: ViewHierarchy?, appId: String?, timeoutMs: Int?): ViewHierarchy {
return ScreenshotUtils.waitForAppToSettle(initialHierarchy, this)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ data class GetEventsResponse(
val events: List<MockEvent>
)

class MockInteractor(
) {
class MockInteractor {
private val client = OkHttpClient.Builder()
.readTimeout(5, TimeUnit.MINUTES)
.writeTimeout(5, TimeUnit.MINUTES)
Expand Down Expand Up @@ -133,4 +132,4 @@ class MockInteractor(

fun main() {
MockInteractor().getMockEvents()
}
}
8 changes: 4 additions & 4 deletions maestro-client/src/main/resources/maestro-web.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
for (var n=0;n < allNodes.length;n++) {
if (allNodes[n].hasAttribute('id') && allNodes[n].id == domElement.id) uniqueIdCount++;
if (uniqueIdCount > 1) break;
};
}
if ( uniqueIdCount == 1) {
segs.unshift('id("' + domElement.getAttribute('id') + '")');
return segs.join('/');
Expand All @@ -73,10 +73,10 @@
segs.unshift(domElement.localName.toLowerCase() + '[@class="' + domElement.getAttribute('class') + '"]');
} else {
for (i = 1, sib = domElement.previousSibling; sib; sib = sib.previousSibling) {
if (sib.localName == domElement.localName) i++; };
if (sib.localName == domElement.localName) i++; }
segs.unshift(domElement.localName.toLowerCase() + '[' + i + ']');
};
};
}
}
return segs.length ? '/' + segs.join('/') : null;
}
}( window.maestro = window.maestro || {} ));
29 changes: 0 additions & 29 deletions maestro-ios-driver/src/main/kotlin/hierarchy/AccessibilityNode.kt

This file was deleted.

10 changes: 0 additions & 10 deletions maestro-ios-driver/src/main/kotlin/hierarchy/Frame.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ class Orchestra(
if (selector == null) {
return maestro.viewHierarchy()
}
val parentViewHierarchy = findElementViewHierarchy(selector.childOf, timeout);
val parentViewHierarchy = findElementViewHierarchy(selector.childOf, timeout)
val (description, filterFunc) = buildFilter(selector = selector)
return maestro.findElementWithTimeout(
timeout,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,7 @@ class FakeDriver : Driver {
override fun isKeyboardVisible(): Boolean {
ensureOpen()

if (events.contains(Event.HideKeyboard)) {
return false
}
return true
return !events.contains(Event.HideKeyboard)
}

override fun swipe(start: Point, end: Point, durationMs: Long) {
Expand Down Expand Up @@ -360,7 +357,7 @@ class FakeDriver : Driver {
}
}

override fun waitForAppToSettle(initialHierarchy: ViewHierarchy?, appId: String?, timeoutMs: Int?): ViewHierarchy? {
override fun waitForAppToSettle(initialHierarchy: ViewHierarchy?, appId: String?, timeoutMs: Int?): ViewHierarchy {
return ScreenshotUtils.waitForAppToSettle(initialHierarchy, this, timeoutMs)
}

Expand Down
8 changes: 4 additions & 4 deletions maestro-test/src/test/kotlin/maestro/test/JsEngineTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ abstract class JsEngineTest {
.withHeader(HttpHeaders.CONTENT_TYPE, "application/json")
.withHeader(testHeader, "first")
.withHeader(testHeader, "second")
.withBody(body);
.withBody(body)

WireMock.stubFor(
WireMock.get("/json").willReturn(response)
stubFor(
get("/json").willReturn(response)
)

val script = """
Expand Down Expand Up @@ -253,4 +253,4 @@ abstract class JsEngineTest {
// Then
assertThat(result.toString()).isEqualTo("POST endpoint")
}
}
}

0 comments on commit 475acc1

Please sign in to comment.