Skip to content

Commit

Permalink
#884 added printing available locales for Android devices
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Adamczyk authored and adamfilipow92 committed Jul 23, 2020
1 parent 70475bc commit cc1b858
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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[]

Expand All @@ -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[]

Expand Down
5 changes: 4 additions & 1 deletion test_runner/docs/ascii/flank.jar_-android.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[]

Expand All @@ -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[]

Expand Down
5 changes: 4 additions & 1 deletion test_runner/docs/ascii/flank.jar_-firebase-test-android.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions test_runner/src/main/kotlin/ftl/android/AndroidCatalog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,8 +18,9 @@ import picocli.CommandLine.Command
AndroidDoctorCommand::class,
AndroidModelsCommand::class,
AndroidVersionsCommand::class,
AndroidTestEnvironmentCommand::class,
AndroidOrientationsCommand::class
AndroidLocalesCommand::class,
AndroidTestEnvironmentCommand::class
],
usageHelpAutoWidth = true
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,15 +18,16 @@ 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 {
override fun run() {
val projectId = AndroidArgs.load(Paths.get(configPath)).project
println(devicesCatalogAsTable(projectId))
println(supportedVersionsAsTable(projectId))
println(localesAsTable(projectId))
println(providedSoftwareAsTable())
println(networkConfigurationAsTable())
println(supportedOrientationsAsTable(projectId))
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
}
Original file line number Diff line number Diff line change
@@ -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
}
20 changes: 20 additions & 0 deletions test_runner/src/test/kotlin/ftl/android/AndroidCatalogTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
@@ -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")
}
}

0 comments on commit cc1b858

Please sign in to comment.