diff --git a/test_runner/docs/ascii/flank.jar_-android-test-environment.adoc b/test_runner/docs/ascii/flank.jar_-android-test-environment.adoc index 4c5553896f..a643b038e2 100644 --- a/test_runner/docs/ascii/flank.jar_-android-test-environment.adoc +++ b/test_runner/docs/ascii/flank.jar_-android-test-environment.adoc @@ -4,7 +4,7 @@ == Name flank.jar --android-test-environment - Print available devices, OS versions, provided software list and network configuration to test against +-android-test-environment - Print available devices, OS versions, locales, provided software list and network configuration to test against // end::picocli-generated-man-section-name[] @@ -19,7 +19,7 @@ flank.jar // tag::picocli-generated-man-section-description[] == Description -Print available Android devices, Android OS versions list, provided software and network configuration to test against +Print available Android devices, Android OS versions list, locales, provided software and network configuration to test against // end::picocli-generated-man-section-description[] diff --git a/test_runner/docs/ascii/flank.jar_-android.adoc b/test_runner/docs/ascii/flank.jar_-android.adoc index bb3b9fe3bf..a1d5fc9f77 100644 --- a/test_runner/docs/ascii/flank.jar_-android.adoc +++ b/test_runner/docs/ascii/flank.jar_-android.adoc @@ -38,8 +38,11 @@ flank.jar *versions*:: Information about available software versions +*locales*:: + Information about available locales on device + *test-environment*:: - Print available devices, OS versions, provided software list and network configuration to test against + Print available devices, OS versions, locales, provided software list and network configuration to test against *orientations*:: Information about available orientations diff --git a/test_runner/docs/ascii/flank.jar_-firebase-test-android-test-environment.adoc b/test_runner/docs/ascii/flank.jar_-firebase-test-android-test-environment.adoc index 332ee77266..fe38e91711 100644 --- a/test_runner/docs/ascii/flank.jar_-firebase-test-android-test-environment.adoc +++ b/test_runner/docs/ascii/flank.jar_-firebase-test-android-test-environment.adoc @@ -4,7 +4,7 @@ == Name flank.jar --firebase-test-android-test-environment - Print available devices, OS versions, provided software list and network configuration to test against +-firebase-test-android-test-environment - Print available devices, OS versions, locales, provided software list and network configuration to test against // end::picocli-generated-man-section-name[] @@ -19,7 +19,7 @@ flank.jar // tag::picocli-generated-man-section-description[] == Description -Print available Android devices, Android OS versions list, provided software and network configuration to test against +Print available Android devices, Android OS versions list, locales, provided software and network configuration to test against // end::picocli-generated-man-section-description[] diff --git a/test_runner/docs/ascii/flank.jar_-firebase-test-android.adoc b/test_runner/docs/ascii/flank.jar_-firebase-test-android.adoc index 61f40b50c0..517a7c16d3 100644 --- a/test_runner/docs/ascii/flank.jar_-firebase-test-android.adoc +++ b/test_runner/docs/ascii/flank.jar_-firebase-test-android.adoc @@ -38,8 +38,11 @@ flank.jar *versions*:: Information about available software versions +*locales*:: + Information about available locales on device + *test-environment*:: - Print available devices, OS versions, provided software list and network configuration to test against + Print available devices, OS versions, locales, provided software list and network configuration to test against *orientations*:: Information about available orientations diff --git a/test_runner/src/main/kotlin/ftl/android/AndroidCatalog.kt b/test_runner/src/main/kotlin/ftl/android/AndroidCatalog.kt index 2fbdac0730..e221d901d1 100644 --- a/test_runner/src/main/kotlin/ftl/android/AndroidCatalog.kt +++ b/test_runner/src/main/kotlin/ftl/android/AndroidCatalog.kt @@ -29,6 +29,8 @@ object AndroidCatalog { fun supportedVersionsAsTable(projectId: String) = deviceCatalog(projectId).versions.asPrintableTable() fun supportedOrientationsAsTable(projectId: String) = deviceCatalog(projectId).runtimeConfiguration.orientations.asPrintableTable() + + fun localesAsTable(projectId: String) = deviceCatalog(projectId).runtimeConfiguration.locales.asPrintableTable() fun androidModelIds(projectId: String) = modelMap.getOrPut(projectId) { deviceCatalog(projectId).models.map { it.id } } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/AndroidCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/AndroidCommand.kt index 6bb5f4b8e7..21f562f4ce 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/AndroidCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/AndroidCommand.kt @@ -3,6 +3,7 @@ package ftl.cli.firebase.test import ftl.cli.firebase.test.android.AndroidDoctorCommand import ftl.cli.firebase.test.android.AndroidRunCommand import ftl.cli.firebase.test.android.AndroidTestEnvironmentCommand +import ftl.cli.firebase.test.android.configuration.AndroidLocalesCommand import ftl.cli.firebase.test.android.models.AndroidModelsCommand import ftl.cli.firebase.test.android.orientations.AndroidOrientationsCommand import ftl.cli.firebase.test.android.versions.AndroidVersionsCommand @@ -17,8 +18,9 @@ import picocli.CommandLine.Command AndroidDoctorCommand::class, AndroidModelsCommand::class, AndroidVersionsCommand::class, - AndroidTestEnvironmentCommand::class, AndroidOrientationsCommand::class + AndroidLocalesCommand::class, + AndroidTestEnvironmentCommand::class ], usageHelpAutoWidth = true ) diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidTestEnvironmentCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidTestEnvironmentCommand.kt index c509abf407..50bab111e7 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidTestEnvironmentCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidTestEnvironmentCommand.kt @@ -2,6 +2,7 @@ package ftl.cli.firebase.test.android import ftl.android.AndroidCatalog.devicesCatalogAsTable import ftl.android.AndroidCatalog.supportedOrientationsAsTable +import ftl.android.AndroidCatalog.localesAsTable import ftl.android.AndroidCatalog.supportedVersionsAsTable import ftl.args.AndroidArgs import ftl.config.FtlConstants @@ -17,8 +18,8 @@ import java.nio.file.Paths descriptionHeading = "%n@|bold,underline Description:|@%n%n", parameterListHeading = "%n@|bold,underline Parameters:|@%n", optionListHeading = "%n@|bold,underline Options:|@%n", - header = ["Print available devices, OS versions, provided software list and network configuration to test against"], - description = ["Print available Android devices, Android OS versions list, provided software and network configuration to test against"], + header = ["Print available devices, OS versions, locales, provided software list and network configuration to test against"], + description = ["Print available Android devices, Android OS versions list, locales, provided software and network configuration to test against"], usageHelpAutoWidth = true ) class AndroidTestEnvironmentCommand : Runnable { @@ -26,6 +27,7 @@ class AndroidTestEnvironmentCommand : Runnable { val projectId = AndroidArgs.load(Paths.get(configPath)).project println(devicesCatalogAsTable(projectId)) println(supportedVersionsAsTable(projectId)) + println(localesAsTable(projectId)) println(providedSoftwareAsTable()) println(networkConfigurationAsTable()) println(supportedOrientationsAsTable(projectId)) diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/configuration/AndroidLocalesCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/configuration/AndroidLocalesCommand.kt new file mode 100644 index 0000000000..7029cc1215 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/configuration/AndroidLocalesCommand.kt @@ -0,0 +1,21 @@ +package ftl.cli.firebase.test.android.configuration + +import picocli.CommandLine + +@CommandLine.Command( + name = "locales", + headerHeading = "", + synopsisHeading = "%n", + descriptionHeading = "%n@|bold,underline Description:|@%n%n", + parameterListHeading = "%n@|bold,underline Parameters:|@%n", + optionListHeading = "%n@|bold,underline Options:|@%n", + header = ["Information about available locales on device"], + description = ["Information about available locales on device. For example prints list of available locales to test against"], + subcommands = [AndroidLocalesListCommand::class], + usageHelpAutoWidth = true +) +class AndroidLocalesCommand : Runnable { + override fun run() { + CommandLine.usage(AndroidLocalesCommand(), System.out) + } +} diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/configuration/AndroidLocalesListCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/configuration/AndroidLocalesListCommand.kt new file mode 100644 index 0000000000..7e983e54a7 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/configuration/AndroidLocalesListCommand.kt @@ -0,0 +1,30 @@ +package ftl.cli.firebase.test.android.configuration + +import ftl.android.AndroidCatalog +import ftl.args.AndroidArgs +import ftl.config.FtlConstants +import picocli.CommandLine +import java.nio.file.Paths + +@CommandLine.Command( + name = "list", + headerHeading = "", + synopsisHeading = "%n", + descriptionHeading = "%n@|bold,underline Description:|@%n%n", + parameterListHeading = "%n@|bold,underline Parameters:|@%n", + optionListHeading = "%n@|bold,underline Options:|@%n", + header = ["Print current list of locales available to test against"], + description = ["Print current list of Android locales available to test against"], + usageHelpAutoWidth = true +) +class AndroidLocalesListCommand : Runnable { + override fun run() { + println(AndroidCatalog.localesAsTable(projectId = AndroidArgs.load(Paths.get(configPath)).project)) + } + + @CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"]) + var configPath: String = FtlConstants.defaultAndroidConfig + + @CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) + var usageHelpRequested: Boolean = false +} diff --git a/test_runner/src/test/kotlin/ftl/android/AndroidCatalogTest.kt b/test_runner/src/test/kotlin/ftl/android/AndroidCatalogTest.kt index 0b5fffb274..aebb9cec09 100644 --- a/test_runner/src/test/kotlin/ftl/android/AndroidCatalogTest.kt +++ b/test_runner/src/test/kotlin/ftl/android/AndroidCatalogTest.kt @@ -107,4 +107,24 @@ class AndroidCatalogTest { // number of separators match assertThat(headers.count { it == '│' }).isEqualTo(expectedSeparatorCount) } + + @Test + fun `should print available locales as table`() { + // given + val expectedHeaders = + arrayOf("LOCALE", "NAME", "REGION", "TAGS") + val expectedSeparatorCount = expectedHeaders.size + 1 + + // when + val devicesTable = AndroidCatalog.localesAsTable(projectId) + val headers = devicesTable.lines()[1] + + // then + // has all necessary headers + expectedHeaders.forEach { + assertThat(headers.contains(it)).isTrue() + } + // number of separators match + assertThat(headers.count { it == '│' }).isEqualTo(expectedSeparatorCount) + } } diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/configuration/AndroidLocalesListCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/configuration/AndroidLocalesListCommandTest.kt new file mode 100644 index 0000000000..649f60ac52 --- /dev/null +++ b/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/configuration/AndroidLocalesListCommandTest.kt @@ -0,0 +1,16 @@ +package ftl.cli.firebase.test.android.configuration + +import com.google.common.truth.Truth.assertThat +import org.junit.Test +import picocli.CommandLine + +class AndroidLocalesListCommandTest { + + @Test + fun androidLocalesListCommandShouldParseConfig() { + val cmd = AndroidLocalesListCommand() + CommandLine(cmd).parseArgs("--config=a") + + assertThat(cmd.configPath).isEqualTo("a") + } +}