mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
About 650 user-facing strings were written in Kotlin and Java, so no translation could reach them and the UI stayed half English in every language. They now live in values/strings.xml. - Dialogs, menus, status lines, toasts and errors shown to the user go through getString/stringResource. - Code that matched on English text now uses IDs: installer and loading stages, Decky stages, storage labels and the Back button's order labels. - Choice lists (upscalers, FPS limits, textures, themes, presets) carry @StringRes labels instead of English. - Robolectric tests read the app's resources (includeAndroidResources). - Six strings nothing used any more are dropped. Existing translations are untouched; the new strings show in English until they are translated.
This commit is contained in:
1 parent
1951d8bfde
commit
0b04678bdc
76 files changed
+2150
-919
No files matched your search
@@ -21,13 +21,14 @@ import java.io.File
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [33])
|
||||
class GameFilesTest {
|
||||
private val app get() = RuntimeEnvironment.getApplication()
|
||||
@get:Rule val tmp = TemporaryFolder()
|
||||
private fun game(id: String = "8400", name: String = "Geometry Wars") =
|
||||
Library.SteamGame(8400, name, null, "internal", id.toULong().toLong())
|
||||
|
||||
@Test fun exportsPortableFilesAndAcceptsFileUriRawPathAndContentUri() {
|
||||
val folder = tmp.newFolder()
|
||||
val file = GameFiles.export(folder, game("18446744073709551615", "A/B: C"))
|
||||
val file = GameFiles.export(app, folder, game("18446744073709551615", "A/B: C"))
|
||||
assertEquals("A_B_ C.steam", file.name)
|
||||
assertEquals("18446744073709551615", file.readText())
|
||||
val context = RuntimeEnvironment.getApplication()
|
||||
@@ -61,21 +62,21 @@ class GameFilesTest {
|
||||
val art = tmp.newFile("cover.jpg").apply { writeBytes(byteArrayOf(1, 2, 3)) }
|
||||
val icon = tmp.newFile("icon.jpg").apply { writeBytes(byteArrayOf(4, 5, 6)) }
|
||||
val game = Library.SteamGame(8400, "Geometry Wars: Retro Evolved", art, "internal", icon = icon)
|
||||
GameFiles.export(folder, game)
|
||||
GameFiles.export(app, folder, game)
|
||||
val image = File(folder, "images/geometry-wars-retro-evolved-icon.jpg")
|
||||
assertArrayEquals(icon.readBytes(), image.readBytes())
|
||||
LibraryCache.save(RuntimeEnvironment.getApplication(), listOf(game))
|
||||
assertEquals(icon, LibraryCache.load(RuntimeEnvironment.getApplication()).single().icon)
|
||||
image.writeText("custom artwork")
|
||||
GameFiles.sync(folder, listOf(game))
|
||||
GameFiles.sync(app, folder, listOf(game))
|
||||
assertEquals("custom artwork", image.readText())
|
||||
GameFiles.sync(folder, emptyList())
|
||||
GameFiles.sync(app, folder, emptyList())
|
||||
assertEquals("custom artwork", image.readText())
|
||||
assertEquals("8400", File(folder, GameFiles.filename(game)).readText())
|
||||
assertEquals(1, folder.listFiles { f -> f.extension == GameFiles.EXTENSION }!!.size)
|
||||
icon.delete()
|
||||
val fallback = tmp.newFolder()
|
||||
GameFiles.export(fallback, game)
|
||||
GameFiles.export(app, fallback, game)
|
||||
assertArrayEquals(art.readBytes(), File(fallback, "images/${image.name}").readBytes())
|
||||
}
|
||||
|
||||
@@ -85,20 +86,20 @@ class GameFilesTest {
|
||||
val note = File(folder, "notes.txt").apply { writeText("Keep me") }
|
||||
val first = game()
|
||||
val second = game("620", "Portal 2")
|
||||
GameFiles.sync(folder, listOf(first, second))
|
||||
GameFiles.sync(app, folder, listOf(first, second))
|
||||
val firstFile = File(folder, GameFiles.filename(first))
|
||||
val secondFile = File(folder, GameFiles.filename(second))
|
||||
val modified = secondFile.apply { writeText("user edit") }
|
||||
val third = game("1", "New install")
|
||||
GameFiles.sync(folder, listOf(first, second, third))
|
||||
GameFiles.sync(app, folder, listOf(first, second, third))
|
||||
assertTrue(File(folder, GameFiles.filename(third)).isFile)
|
||||
assertEquals("user edit", modified.readText())
|
||||
val renamed = game(name = "Geometry Wars: Retro Evolved")
|
||||
GameFiles.sync(folder, listOf(renamed))
|
||||
GameFiles.sync(app, folder, listOf(renamed))
|
||||
assertFalse(firstFile.exists())
|
||||
assertTrue(File(folder, GameFiles.filename(renamed)).isFile)
|
||||
assertEquals("user edit", modified.readText())
|
||||
GameFiles.sync(folder, emptyList())
|
||||
GameFiles.sync(app, folder, emptyList())
|
||||
assertFalse(File(folder, GameFiles.filename(renamed)).exists())
|
||||
assertTrue(unrelated.isFile)
|
||||
assertEquals("Keep me", note.readText())
|
||||
@@ -108,16 +109,16 @@ class GameFilesTest {
|
||||
@Test fun failedExportDoesNotPruneOldInventoryAndNeverOverwritesCollisions() {
|
||||
val folder = tmp.newFolder()
|
||||
val first = game()
|
||||
GameFiles.sync(folder, listOf(first))
|
||||
GameFiles.sync(app, folder, listOf(first))
|
||||
val second = game("620", "Portal 2")
|
||||
val collision = File(folder, GameFiles.filename(second)).apply { writeText("personal file") }
|
||||
val fallback = File(folder, GameFiles.filename(second, disambiguate = true)).apply { writeText("another personal file") }
|
||||
assertThrows(IllegalArgumentException::class.java) { GameFiles.sync(folder, listOf(second)) }
|
||||
assertThrows(IllegalArgumentException::class.java) { GameFiles.sync(app, folder, listOf(second)) }
|
||||
assertEquals("personal file", collision.readText())
|
||||
assertTrue(File(folder, GameFiles.filename(first)).isFile)
|
||||
collision.delete()
|
||||
fallback.delete()
|
||||
GameFiles.sync(folder, listOf(second))
|
||||
GameFiles.sync(app, folder, listOf(second))
|
||||
assertFalse(File(folder, GameFiles.filename(first)).exists())
|
||||
assertTrue(collision.isFile)
|
||||
}
|
||||
@@ -126,7 +127,7 @@ class GameFilesTest {
|
||||
val folder = tmp.newFolder()
|
||||
val games = listOf(game(name = "../.."), game(name = "🎮".repeat(200)), game(name = "\u0000\n"))
|
||||
games.forEach { game ->
|
||||
val file = GameFiles.export(folder, game)
|
||||
val file = GameFiles.export(app, folder, game)
|
||||
assertEquals(folder.canonicalFile, file.canonicalFile.parentFile)
|
||||
assertTrue(file.name.toByteArray().size < 255)
|
||||
}
|
||||
@@ -137,7 +138,7 @@ class GameFilesTest {
|
||||
val outside = tmp.newFile()
|
||||
outside.writeText("8400")
|
||||
java.nio.file.Files.createSymbolicLink(File(folder, GameFiles.filename(game())).toPath(), outside.toPath())
|
||||
assertThrows(IllegalArgumentException::class.java) { GameFiles.export(folder, game()) }
|
||||
assertThrows(IllegalArgumentException::class.java) { GameFiles.export(app, folder, game()) }
|
||||
assertEquals("8400", outside.readText())
|
||||
}
|
||||
|
||||
@@ -145,32 +146,32 @@ class GameFilesTest {
|
||||
val folder = tmp.newFolder()
|
||||
val first = game(name = "Game")
|
||||
val renamed = game(name = "GAME")
|
||||
GameFiles.sync(folder, listOf(first))
|
||||
GameFiles.sync(folder, listOf(renamed))
|
||||
GameFiles.sync(app, folder, listOf(first))
|
||||
GameFiles.sync(app, folder, listOf(renamed))
|
||||
val file = File(folder, GameFiles.filename(renamed))
|
||||
assertTrue(file.isFile)
|
||||
assertEquals("8400", file.inputStream().use(GameFiles::read))
|
||||
assertEquals(1, folder.listFiles()!!.count { it.extension == GameFiles.EXTENSION })
|
||||
GameFiles.sync(folder, emptyList())
|
||||
GameFiles.sync(app, folder, emptyList())
|
||||
assertFalse(file.exists())
|
||||
}
|
||||
|
||||
@Test fun unrelatedInventoryIsPreserved() {
|
||||
val folder = tmp.newFolder()
|
||||
val inventory = File(folder, ".droiddeck-sync.json").apply { writeText("{}") }
|
||||
assertThrows(IllegalArgumentException::class.java) { GameFiles.sync(folder, listOf(game())) }
|
||||
assertThrows(IllegalArgumentException::class.java) { GameFiles.sync(app, folder, listOf(game())) }
|
||||
assertEquals("{}", inventory.readText())
|
||||
assertEquals(0, folder.listFiles()!!.count { it.extension == GameFiles.EXTENSION })
|
||||
}
|
||||
|
||||
@Test fun steamExportContainsOnlyIdForSteamAndAddedGames() {
|
||||
val folder = tmp.newFolder()
|
||||
val file = GameFiles.export(folder, game("620", "Portal 2"))
|
||||
val file = GameFiles.export(app, folder, game("620", "Portal 2"))
|
||||
assertEquals("Portal 2.steam", file.name)
|
||||
assertEquals("620", file.readText())
|
||||
assertEquals("620", GameFiles.readIntent(RuntimeEnvironment.getApplication(), Intent(Intent.ACTION_VIEW, Uri.fromFile(file))))
|
||||
val added = Library.SteamGame(1, "Added Game", null, Library.ADDED, -1L)
|
||||
val addedFile = GameFiles.export(folder, added)
|
||||
val addedFile = GameFiles.export(app, folder, added)
|
||||
assertEquals("Added Game.steam", addedFile.name)
|
||||
assertEquals("18446744073709551615", addedFile.readText())
|
||||
}
|
||||
@@ -181,14 +182,14 @@ class GameFilesTest {
|
||||
val second = game("8400", "A:B")
|
||||
val foreign = File(folder, "Existing.steam").apply { writeText("1") }
|
||||
val existing = game("1", "Existing")
|
||||
GameFiles.sync(folder, listOf(first, second, existing))
|
||||
GameFiles.sync(app, folder, listOf(first, second, existing))
|
||||
val owned = File(folder, "A_B (620).steam")
|
||||
assertEquals("620", owned.readText())
|
||||
assertEquals("8400", File(folder, "A_B (8400).steam").readText())
|
||||
owned.writeText("user edit")
|
||||
GameFiles.sync(folder, listOf(first, second, existing))
|
||||
GameFiles.sync(app, folder, listOf(first, second, existing))
|
||||
assertEquals("user edit", owned.readText())
|
||||
GameFiles.sync(folder, emptyList())
|
||||
GameFiles.sync(app, folder, emptyList())
|
||||
assertEquals("user edit", owned.readText())
|
||||
assertEquals("1", foreign.readText())
|
||||
assertFalse(File(folder, "A_B (8400).steam").exists())
|
||||
@@ -198,13 +199,13 @@ class GameFilesTest {
|
||||
val folder = tmp.newFolder()
|
||||
val collision = File(folder, "Geometry Wars.steam").apply { writeText("other file") }
|
||||
val existing = File(folder, "Geometry Wars (8400).steam").apply { writeText("8400") }
|
||||
GameFiles.sync(folder, listOf(game()))
|
||||
GameFiles.sync(folder, emptyList())
|
||||
GameFiles.sync(app, folder, listOf(game()))
|
||||
GameFiles.sync(app, folder, emptyList())
|
||||
assertEquals("other file", collision.readText())
|
||||
assertEquals("8400", existing.readText())
|
||||
existing.writeText("another file")
|
||||
assertThrows(IllegalArgumentException::class.java) {
|
||||
GameFiles.sync(folder, listOf(game()))
|
||||
GameFiles.sync(app, folder, listOf(game()))
|
||||
}
|
||||
assertEquals("another file", existing.readText())
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.droiddeck.launcher.runtime
|
||||
|
||||
import com.droiddeck.launcher.R
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import org.junit.After
|
||||
@@ -30,15 +31,15 @@ class AppImageManagerTest {
|
||||
|
||||
@Test fun acceptsAnI386ImageForFex() = assertNull(AppImageManager.problem(image(3)))
|
||||
|
||||
@Test fun refusesOtherProcessors() = assertTrue(AppImageManager.problem(image(40))!!.contains("neither"))
|
||||
@Test fun refusesOtherProcessors() = assertTrue(AppImageManager.problem(image(40))!!.text == R.string.appimg_wrong_arch)
|
||||
|
||||
@Test fun refusesTypeOne() = assertTrue(AppImageManager.problem(image(183, type = 1))!!.contains("type 2"))
|
||||
@Test fun refusesTypeOne() = assertTrue(AppImageManager.problem(image(183, type = 1))!!.text == R.string.appimg_wrong_type)
|
||||
|
||||
@Test fun refusesAPlainProgram() = assertTrue(AppImageManager.problem(image(183, magic = false))!!.contains("not an AppImage"))
|
||||
@Test fun refusesAPlainProgram() = assertTrue(AppImageManager.problem(image(183, magic = false))!!.text == R.string.appimg_not_appimage)
|
||||
|
||||
@Test fun refusesSomethingElse() {
|
||||
val f = File(dir, "notes.AppImage").apply { writeText("hello, this is not a program at all") }
|
||||
assertTrue(AppImageManager.problem(f)!!.contains("not an AppImage"))
|
||||
assertTrue(AppImageManager.problem(f)!!.text == R.string.appimg_not_linux)
|
||||
}
|
||||
|
||||
@Test fun idsAreTidyAndUnique() {
|
||||
|
||||
@@ -53,7 +53,7 @@ class DeckyPluginInstallTest {
|
||||
try {
|
||||
DeckyPluginInstall.activate(plugin(temporary.newFolder(), "Unifideck", "Unifideck"), plugins, "Unifideck", settings, ".test")
|
||||
fail("Expected conflicting identity to fail")
|
||||
} catch (_: IllegalArgumentException) {}
|
||||
} catch (_: DeckyPluginInstall.Failure) {}
|
||||
assertEquals("{}", settings.readText())
|
||||
assertEquals("Other", JSONObject(File(plugins, "Unifideck/plugin.json").readText()).getString("name"))
|
||||
}
|
||||
|
||||
@@ -77,12 +77,12 @@ class RuntimeRemovalTest {
|
||||
|
||||
@Test fun reservationBlocksPlayAndInstallBeforeTheWorkerStartsAndFollowersSeeProgress() {
|
||||
val root = runtime()
|
||||
val removal = LinuxRuntimeInstaller.beginUninstall(root)!!
|
||||
val removal = LinuxRuntimeInstaller.beginUninstall(null, root)!!
|
||||
assertTrue(LinuxRuntimeInstaller.isBusy())
|
||||
assertTrue(LinuxRuntimeInstaller.isRemoving())
|
||||
assertFalse(LinuxRuntimeInstaller.isInstalling())
|
||||
assertFalse(LinuxRuntime.isInstalled(null))
|
||||
assertNull(LinuxRuntimeInstaller.beginUninstall(root))
|
||||
assertNull(LinuxRuntimeInstaller.beginUninstall(null, root))
|
||||
assertFalse(LinuxRuntimeInstaller.install(null, null, null))
|
||||
val entered = CountDownLatch(1)
|
||||
val release = CountDownLatch(1)
|
||||
@@ -94,10 +94,10 @@ class RuntimeRemovalTest {
|
||||
try {
|
||||
assertTrue(entered.await(5, TimeUnit.SECONDS))
|
||||
val following = CountDownLatch(1)
|
||||
val stages = mutableListOf<String>()
|
||||
val percents = mutableListOf<Int>()
|
||||
val followerResult = AtomicReference<Boolean>()
|
||||
val follower = Thread {
|
||||
followerResult.set(LinuxRuntimeInstaller.attach { stage, _ -> stages.add(stage); following.countDown() })
|
||||
followerResult.set(LinuxRuntimeInstaller.attach { _, percent -> percents.add(percent); following.countDown() })
|
||||
}
|
||||
follower.start()
|
||||
assertTrue(following.await(5, TimeUnit.SECONDS))
|
||||
@@ -106,7 +106,8 @@ class RuntimeRemovalTest {
|
||||
follower.join(5000)
|
||||
assertEquals(true, result.get())
|
||||
assertEquals(true, followerResult.get())
|
||||
assertEquals("Linux runtime removed", stages.last())
|
||||
// The last stage is "Linux runtime removed", the only one reported at 100.
|
||||
assertEquals(100, percents.last())
|
||||
assertFalse(root.exists())
|
||||
assertFalse(File(dir, "linuxfs.removing").exists())
|
||||
assertFalse(LinuxRuntimeInstaller.isBusy())
|
||||
@@ -120,7 +121,7 @@ class RuntimeRemovalTest {
|
||||
val tree = File(dir, name).apply { mkdirs() }
|
||||
File(tree, "game").writeText("staged")
|
||||
}
|
||||
val removal = LinuxRuntimeInstaller.beginUninstall(File(dir, "linuxfs"))!!
|
||||
val removal = LinuxRuntimeInstaller.beginUninstall(null, File(dir, "linuxfs"))!!
|
||||
assertTrue(removal.run(null))
|
||||
assertTrue(dir.listFiles()!!.isEmpty())
|
||||
}
|
||||
@@ -128,9 +129,11 @@ class RuntimeRemovalTest {
|
||||
@Test fun aPartialRemovalStaysQuarantinedAndRetryable() {
|
||||
val root = runtime()
|
||||
try {
|
||||
val removal = LinuxRuntimeInstaller.beginUninstall(root)!!
|
||||
assertFalse(removal.run { stage, _ ->
|
||||
if (stage.contains("entries"))
|
||||
val removal = LinuxRuntimeInstaller.beginUninstall(null, root)!!
|
||||
// The first stage names the removal, the second counts its first entry.
|
||||
var stages = 0
|
||||
assertFalse(removal.run { _, _ ->
|
||||
if (++stages == 2)
|
||||
Files.setPosixFilePermissions(dir.toPath(), PosixFilePermissions.fromString("r-xr-xr-x"))
|
||||
})
|
||||
assertFalse(root.exists())
|
||||
@@ -138,7 +141,7 @@ class RuntimeRemovalTest {
|
||||
assertFalse(LinuxRuntimeInstaller.isBusy())
|
||||
assertNotNull(LinuxRuntimeInstaller.removalError())
|
||||
} finally { dir.setWritable(true) }
|
||||
assertTrue(LinuxRuntimeInstaller.beginUninstall(root)!!.run(null))
|
||||
assertTrue(LinuxRuntimeInstaller.beginUninstall(null, root)!!.run(null))
|
||||
assertFalse(File(dir, "linuxfs.removing").exists())
|
||||
}
|
||||
|
||||
@@ -146,15 +149,15 @@ class RuntimeRemovalTest {
|
||||
val root = runtime()
|
||||
Files.setPosixFilePermissions(dir.toPath(), PosixFilePermissions.fromString("r-xr-xr-x"))
|
||||
try {
|
||||
val removal = LinuxRuntimeInstaller.beginUninstall(root)!!
|
||||
val stages = mutableListOf<String>()
|
||||
assertFalse(removal.run { stage, _ -> stages.add(stage) })
|
||||
val removal = LinuxRuntimeInstaller.beginUninstall(null, root)!!
|
||||
val percents = mutableListOf<Int>()
|
||||
assertFalse(removal.run { _, percent -> percents.add(percent) })
|
||||
assertTrue(root.exists())
|
||||
assertFalse(LinuxRuntimeInstaller.isBusy())
|
||||
assertTrue(LinuxRuntimeInstaller.removalError()!!.contains("Retry removal"))
|
||||
assertFalse(stages.contains("Linux runtime removed"))
|
||||
assertNotNull(LinuxRuntimeInstaller.removalError())
|
||||
assertFalse(percents.contains(100))
|
||||
} finally { dir.setWritable(true) }
|
||||
assertTrue(LinuxRuntimeInstaller.beginUninstall(root)!!.run(null))
|
||||
assertTrue(LinuxRuntimeInstaller.beginUninstall(null, root)!!.run(null))
|
||||
assertNull(LinuxRuntimeInstaller.removalError())
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ class RuntimeRemovalUiTest {
|
||||
}
|
||||
|
||||
@Test fun directSessionLaunchDuringRemovalFinishesWithoutStartingTheGuest() {
|
||||
val removal = LinuxRuntimeInstaller.beginUninstall(File(dir, "linuxfs"))!!
|
||||
val removal = LinuxRuntimeInstaller.beginUninstall(null, File(dir, "linuxfs"))!!
|
||||
try {
|
||||
val activity = Robolectric.buildActivity(SessionActivity::class.java).create()
|
||||
assertTrue(activity.get().isFinishing)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.droiddeck.launcher.store
|
||||
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.runtime.FlatpakManager
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
@@ -11,10 +12,17 @@ class FlathubApiTest {
|
||||
}
|
||||
|
||||
@Test fun refsReadAsWords() {
|
||||
assertEquals("SuperTux", FlatpakManager.refLabel("app/org.supertuxproject.SuperTux/aarch64/stable"))
|
||||
assertEquals("GNOME runtime 50", FlatpakManager.refLabel("runtime/org.gnome.Platform/aarch64/50"))
|
||||
assertEquals("Freedesktop runtime 26.08", FlatpakManager.refLabel("runtime/org.freedesktop.Platform/aarch64/26.08"))
|
||||
assertEquals("graphics drivers", FlatpakManager.refLabel("runtime/org.freedesktop.Platform.GL.default/aarch64/26.08"))
|
||||
assertEquals("translations", FlatpakManager.refLabel("runtime/org.gnome.Platform.Locale/aarch64/50"))
|
||||
// The words come from string resources; stand in for them with their English.
|
||||
val english = mapOf(
|
||||
R.string.flatpakmgr_ref_runtime_branch to "%1\$s runtime %2\$s",
|
||||
R.string.flatpakmgr_ref_graphics_drivers to "graphics drivers",
|
||||
R.string.flatpakmgr_ref_translations to "translations",
|
||||
)
|
||||
fun label(ref: String) = FlatpakManager.refLabel(ref) { id, args -> english.getValue(id).format(*args) }
|
||||
assertEquals("SuperTux", label("app/org.supertuxproject.SuperTux/aarch64/stable"))
|
||||
assertEquals("GNOME runtime 50", label("runtime/org.gnome.Platform/aarch64/50"))
|
||||
assertEquals("Freedesktop runtime 26.08", label("runtime/org.freedesktop.Platform/aarch64/26.08"))
|
||||
assertEquals("graphics drivers", label("runtime/org.freedesktop.Platform.GL.default/aarch64/26.08"))
|
||||
assertEquals("translations", label("runtime/org.gnome.Platform.Locale/aarch64/50"))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user