From 69e2828a0edbb29ae628bc62326efbfa0e2f4a38 Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Mon, 6 Sep 2021 17:32:34 +0200 Subject: [PATCH] SerializationTests restore settings file (#5110) --- tests/src/com/unciv/testing/SerializationTests.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/src/com/unciv/testing/SerializationTests.kt b/tests/src/com/unciv/testing/SerializationTests.kt index a05ed5bde8..b510ba4729 100644 --- a/tests/src/com/unciv/testing/SerializationTests.kt +++ b/tests/src/com/unciv/testing/SerializationTests.kt @@ -14,6 +14,7 @@ import com.unciv.models.metadata.GameSettings import com.unciv.models.metadata.Player import com.unciv.models.ruleset.RulesetCache import com.unciv.models.metadata.GameSetupInfo +import org.junit.After import org.junit.Assert import org.junit.Before import org.junit.Test @@ -24,6 +25,7 @@ import org.junit.runner.RunWith class SerializationTests { private var game = GameInfo() + private var settingsBackup = GameSettings() /** A runtime Class object for [kotlin.SynchronizedLazyImpl] to enable helping Gdx.Json to * not StackOverflow on them, as a direct compile time retrieval is forbidden */ @@ -57,6 +59,10 @@ class SerializationTests { } val setup = GameSetupInfo(param, mapParameters) UncivGame.Current = UncivGame("") + + // Both startNewGame and makeCivilizationsMeet will cause a save to storage of our empty settings + settingsBackup = GameSaver.getGeneralSettings() + UncivGame.Current.settings = GameSettings() game = GameStarter.startNewGame(setup) UncivGame.Current.gameInfo = game @@ -69,7 +75,7 @@ class SerializationTests { if (tile.ruleset.tileImprovements.containsKey("City center")) tile.improvement = "City center" unit.destroy() - + // Ensure some diplomacy objects are instantiated val otherCiv = game.getCivilization("Greece") civ.makeCivilizationsMeet(otherCiv) @@ -108,4 +114,9 @@ class SerializationTests { val result = matches.any() Assert.assertFalse("This test will only pass when no serializable lazy fields are found", result) } + + @After + fun cleanup() { + settingsBackup.save() + } }