Files
BiLauncher/tests/qml/tst_dialogs.qml
T
galeon 41599fa82f
tests / linux (push) Failing after 2m18s
tests / windows (push) Skipped
tests / macos (push) Skipped
tests / package-smoke-linux (push) Skipped
tests / package-smoke-windows (push) Skipped
tests / package-smoke-macos (push) Skipped
new unit tests, hehe 67
Signed-off-by: galeon <dertiellis@gmail.com>
2026-10-12 13:14:08 +03:00

120 lines
4.7 KiB
QML

import QtQuick
import QtTest
import BiLauncher
// Диалоги с настоящим LauncherBackend. Данные для них подготавливает tst_qml.cpp:
// кеш манифеста версий (1.20.1, 25w33a, b1.7.3), установленная 1.20.1,
// кеш каталога сезонных сборок с одной сборкой. Сеть закрыта FakeInternet.
TestCase {
id: testCase
name: "Dialogs"
width: 1280
height: 720
visible: true
when: windowShown
LauncherBackend { id: launcherBackend }
Component { id: versionPickerComponent; VersionPickerDialog { backend: launcherBackend } }
Component { id: javaPickerComponent; JavaPickerDialog { backend: launcherBackend } }
Component { id: buildsComponent; BuildsDialog { backend: launcherBackend } }
Component { id: seasonalComponent; SeasonalBuildsDialog { backend: launcherBackend } }
Component { id: signalSpy; SignalSpy {} }
function openAndWait(dialog) {
tryVerify(() => dialog.opened, 3000, "диалог не открылся")
}
function test_versionPickerFiltersCatalog() {
const picker = createTemporaryObject(versionPickerComponent, testCase)
verify(picker)
tryVerify(() => launcherBackend.versionCatalog.length >= 3)
picker.openFor("1.20.1")
openAndWait(picker)
compare(picker.category, "release")
compare(picker.visibleEntries.length, 1)
compare(picker.visibleEntries[0].id, "1.20.1")
verify(picker.visibleEntries[0].installed)
compare(picker.indexOfSelected(), 0)
picker.category = "snapshot"
compare(picker.visibleEntries.length, 1)
compare(picker.visibleEntries[0].id, "25w33a")
compare(picker.categoryOf("b1.7.3"), "old_beta")
compare(picker.categoryOf("no-such"), "release")
picker.category = "release"
picker.filterText = "1.19"
compare(picker.visibleEntries.length, 0)
picker.filterText = ""
picker.installedOnly = true
compare(picker.visibleEntries.length, 1)
const chosen = signalSpy.createObject(testCase, { target: picker, signalName: "versionChosen" })
picker.selectedId = "1.20.1"
picker.acceptSelection()
compare(chosen.count, 1)
compare(chosen.signalArguments[0][0], "1.20.1")
tryVerify(() => !picker.visible)
}
function test_javaPickerOpensWithRequirement() {
const picker = createTemporaryObject(javaPickerComponent, testCase)
verify(picker)
picker.openFor("", 17)
openAndWait(picker)
compare(picker.requiredMajor, 17)
compare(picker.category, "java")
compare(picker.selectedEntry, null)
const chosen = signalSpy.createObject(testCase, { target: picker, signalName: "runtimeChosen" })
picker.acceptSelection() // ничего не выбрано — ничего не происходит
compare(chosen.count, 0)
picker.close()
}
function test_buildsDialogEditsBackend() {
const dialog = createTemporaryObject(buildsComponent, testCase)
verify(dialog)
const before = launcherBackend.customBuildNames.length
const name = dialog.newBuildName()
verify(name.length > 0)
verify(launcherBackend.customBuildNames.indexOf(name) === -1)
launcherBackend.addCustomBuild(name, "", "1.20.1")
tryVerify(() => !launcherBackend.busy, 20000)
compare(launcherBackend.customBuildNames.length, before + 1)
dialog.open()
openAndWait(dialog)
dialog.selectBuild(before)
compare(dialog.editIndex, before)
dialog.commit({ serverUrl: "play.example.com" })
compare(launcherBackend.customBuildAt(before).serverUrl, "play.example.com")
verify(dialog.newBuildName() !== name)
dialog.close()
}
function test_seasonalDialogShowsCatalog() {
const dialog = createTemporaryObject(seasonalComponent, testCase)
verify(dialog)
dialog.openCatalog()
openAndWait(dialog)
tryVerify(() => launcherBackend.seasonalCatalog.length === 1)
const entry = launcherBackend.seasonalCatalog[0]
compare(entry.id, "season-qml")
compare(dialog.cellText(entry, "loaderLabel"), entry.loaderTitle + " 0.16.10")
compare(dialog.formatMb(3 * 1024 * 1024), "3.0")
compare(dialog.formatMb(0), "")
dialog.close()
}
function test_languageSwitchUpdatesTexts() {
const en = Loc.t.app.tooltip.openMods
launcherBackend.updateSettings({ language: "ru" })
verify(Loc.t.app.tooltip.openMods !== en)
launcherBackend.updateSettings({ language: "en" })
compare(Loc.t.app.tooltip.openMods, en)
}
}