Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for emulator devices #1711

Merged
merged 2 commits into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test_runner/src/main/kotlin/ftl/android/AndroidCatalog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ object AndroidCatalog {
logLn("Unable to find device type for $modelId. PHYSICAL used as fallback in cost calculations")
}

return form.equals(DeviceType.VIRTUAL.name, ignoreCase = true)
return form.equals(DeviceType.VIRTUAL.name, ignoreCase = true) || form.equals(DeviceType.EMULATOR.name, ignoreCase = true)
}
}

enum class DeviceType {
VIRTUAL, PHYSICAL
VIRTUAL, PHYSICAL, EMULATOR
}

sealed class DeviceConfigCheck
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ const val RESOLUTION = "RESOLUTION"
const val OS_VERSION_IDS = "OS_VERSION_IDS"
const val TAGS = "TAGS"
const val PHYSICAL_DEVICE = "PHYSICAL"
const val VIRTUAL_DEVICE = "VIRTUAL"
const val EMULATOR_DEVICE = "EMULATOR"
const val OS_VERSION_ID = "OS_VERSION_ID"
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ftl.environment.android

import com.google.testing.model.AndroidModel
import ftl.environment.EMULATOR_DEVICE
import ftl.environment.FORM
import ftl.environment.MAKE
import ftl.environment.MODEL_ID
Expand All @@ -10,6 +11,7 @@ import ftl.environment.PHYSICAL_DEVICE
import ftl.environment.RESOLUTION
import ftl.environment.TAGS
import ftl.environment.TestEnvironmentInfo
import ftl.environment.VIRTUAL_DEVICE
import ftl.environment.createTableColumnFor
import ftl.environment.getOrCreateList
import ftl.environment.orUnknown
Expand Down Expand Up @@ -47,5 +49,10 @@ private val AndroidModel.resolution
get() = if (screenX == null || screenY == null) "UNKNOWN" else "$screenY x $screenX"

private val formToSystemOutColorMapper: (String) -> SystemOutColor = {
if (it == PHYSICAL_DEVICE) SystemOutColor.YELLOW else SystemOutColor.BLUE
when (it) {
PHYSICAL_DEVICE -> SystemOutColor.YELLOW
VIRTUAL_DEVICE -> SystemOutColor.BLUE
EMULATOR_DEVICE -> SystemOutColor.GREEN
else -> SystemOutColor.DEFAULT
}
}
10 changes: 5 additions & 5 deletions test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class AndroidArgsTest {
app: $appApk
test: $testApk
device:
- model: shamu
- model: walleye
version: 18
"""
).validate()
Expand Down Expand Up @@ -836,7 +836,7 @@ AndroidArgs
@Test
fun `cli device`() {
val cli = AndroidRunCommand()
CommandLine(cli).parseArgs("--device=model=shamu,version=22,locale=zh_CN,orientation=default")
CommandLine(cli).parseArgs("--device=model=walleye,version=27,locale=zh_CN,orientation=default")

val yaml = """
gcloud:
Expand All @@ -849,7 +849,7 @@ AndroidArgs
assertThat(defaultDevices.size).isEqualTo(1)

val androidArgs = AndroidArgs.load(yaml, cli).validate()
val expectedDevice = Device("shamu", "22", "zh_CN", "default", isVirtual = false)
val expectedDevice = Device("walleye", "27", "zh_CN", "default", isVirtual = false)
val actualDevices = androidArgs.devices
assertThat(actualDevices.first()).isEqualTo(expectedDevice)
assertThat(actualDevices.size).isEqualTo(1)
Expand All @@ -858,7 +858,7 @@ AndroidArgs
@Test
fun `cli device repeat`() {
val cli = AndroidRunCommand()
val deviceCmd = "--device=model=shamu,version=22,locale=zh_CN,orientation=default"
val deviceCmd = "--device=model=walleye,version=27,locale=zh_CN,orientation=default"
CommandLine(cli).parseArgs(deviceCmd, deviceCmd)

val yaml = """
Expand All @@ -867,7 +867,7 @@ AndroidArgs
test: $testApk
"""
val androidArgs = AndroidArgs.load(yaml, cli).validate()
val expectedDevice = Device("shamu", "22", "zh_CN", "default", false)
val expectedDevice = Device("walleye", "27", "zh_CN", "default", false)
val actualDevices = androidArgs.devices
assertThat(actualDevices.size).isEqualTo(2)
assertThat(actualDevices[0]).isEqualTo(expectedDevice)
Expand Down
Loading