mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-06 01:53:25 -08:00
[Fonts] Retire max font size setting into theme CardText min/max range
This commit is contained in:
parent
90665e6e8b
commit
748f9fb40d
19 changed files with 486 additions and 53 deletions
|
|
@ -408,19 +408,6 @@ TEST_F(SettingsDefaultsTest, Appearance_StyleUserList_Default)
|
|||
ASSERT_EQ(s.getStyleUserList(), true);
|
||||
}
|
||||
|
||||
TEST_F(SettingsDefaultsTest, Appearance_MaxFontSize_Default)
|
||||
{
|
||||
AppearanceSettings s(settingsPath, nullptr);
|
||||
ASSERT_EQ(s.getMaxFontSize(), 12);
|
||||
}
|
||||
|
||||
TEST_F(SettingsDefaultsTest, Appearance_MaxFontSize_SetAndGet)
|
||||
{
|
||||
AppearanceSettings s(settingsPath, nullptr);
|
||||
s.setMaxFontSize(14);
|
||||
ASSERT_EQ(s.getMaxFontSize(), 14);
|
||||
}
|
||||
|
||||
TEST_F(SettingsDefaultsTest, Appearance_HomeTabBackgroundSource_Default)
|
||||
{
|
||||
AppearanceSettings s(settingsPath, nullptr);
|
||||
|
|
|
|||
|
|
@ -202,7 +202,6 @@ TEST_F(SettingsMigrationTest, MigratesAllSettingsGroups)
|
|||
|
||||
// theme
|
||||
g.setValue("theme/name", "custom_theme");
|
||||
g.setValue("game/maxfontsize", 14);
|
||||
|
||||
// appearance
|
||||
g.setValue("appearance/styleUserList", false);
|
||||
|
|
@ -376,7 +375,6 @@ TEST_F(SettingsMigrationTest, MigratesAllSettingsGroups)
|
|||
|
||||
ASSERT_TRUE(fileExists("appearance.ini"));
|
||||
ASSERT_EQ(readFromIni("appearance.ini", "appearance/themeName"), QVariant("custom_theme"));
|
||||
ASSERT_EQ(readFromIni("appearance.ini", "appearance/maxFontSize"), QVariant(14));
|
||||
ASSERT_EQ(readFromIni("appearance.ini", "appearance/styleUserList"), QVariant(false));
|
||||
ASSERT_EQ(readFromIni("appearance.ini", "appearance/homeTabBackgroundSource"), QVariant("custom_bg"));
|
||||
ASSERT_EQ(readFromIni("appearance.ini", "appearance/homeTabBackgroundShuffleFrequency"), QVariant(30));
|
||||
|
|
@ -984,6 +982,134 @@ TEST_F(SettingsMigrationTest, IsNotMigrationPendingWithoutLegacyData)
|
|||
ASSERT_FALSE(SettingsMigration::isMigrationPending(settingsPath));
|
||||
}
|
||||
|
||||
TEST_F(SettingsMigrationTest, AppearanceMaxFontSize_NonDefaultSeedsThemeAndDeletesKey)
|
||||
{
|
||||
const QString themesPath = tempDir.path() + "/themes";
|
||||
ASSERT_TRUE(QDir().mkpath(themesPath + "/MyTheme"));
|
||||
{
|
||||
QSettings paths(settingsPath + "paths.ini", QSettings::IniFormat);
|
||||
paths.setValue("paths/themes", themesPath);
|
||||
paths.sync();
|
||||
}
|
||||
{
|
||||
QSettings appearance(settingsPath + "appearance.ini", QSettings::IniFormat);
|
||||
appearance.setValue("appearance/maxFontSize", 18);
|
||||
appearance.sync();
|
||||
}
|
||||
|
||||
ASSERT_TRUE(SettingsMigration::migrateAppearanceMaxFontSizeToTheme(settingsPath));
|
||||
|
||||
ASSERT_FALSE(readFromIni("appearance.ini", "appearance/maxFontSize").isValid());
|
||||
|
||||
const QString fontsPath = themesPath + "/MyTheme/fonts.toml";
|
||||
ASSERT_TRUE(QFile::exists(fontsPath));
|
||||
QFile f(fontsPath);
|
||||
ASSERT_TRUE(f.open(QIODevice::ReadOnly | QIODevice::Text));
|
||||
const QString content = QString::fromUtf8(f.readAll());
|
||||
EXPECT_TRUE(content.contains("CardText"));
|
||||
EXPECT_TRUE(content.contains("18"));
|
||||
EXPECT_TRUE(content.contains("Serif"));
|
||||
|
||||
ASSERT_FALSE(SettingsMigration::migrateAppearanceMaxFontSizeToTheme(settingsPath));
|
||||
}
|
||||
|
||||
TEST_F(SettingsMigrationTest, AppearanceMaxFontSize_DefaultDeletesKeyWithoutFiles)
|
||||
{
|
||||
const QString themesPath = tempDir.path() + "/themes";
|
||||
ASSERT_TRUE(QDir().mkpath(themesPath + "/MyTheme"));
|
||||
{
|
||||
QSettings paths(settingsPath + "paths.ini", QSettings::IniFormat);
|
||||
paths.setValue("paths/themes", themesPath);
|
||||
paths.sync();
|
||||
}
|
||||
{
|
||||
QSettings appearance(settingsPath + "appearance.ini", QSettings::IniFormat);
|
||||
appearance.setValue("appearance/maxFontSize", 12);
|
||||
appearance.sync();
|
||||
}
|
||||
|
||||
ASSERT_TRUE(SettingsMigration::migrateAppearanceMaxFontSizeToTheme(settingsPath));
|
||||
ASSERT_FALSE(readFromIni("appearance.ini", "appearance/maxFontSize").isValid());
|
||||
ASSERT_FALSE(QFile::exists(themesPath + "/MyTheme/fonts.toml"));
|
||||
}
|
||||
|
||||
TEST_F(SettingsMigrationTest, AppearanceMaxFontSize_DoesNotOverwriteExplicitMax)
|
||||
{
|
||||
const QString themesPath = tempDir.path() + "/themes";
|
||||
ASSERT_TRUE(QDir().mkpath(themesPath + "/MyTheme"));
|
||||
{
|
||||
QFile f(themesPath + "/MyTheme/fonts.toml");
|
||||
ASSERT_TRUE(f.open(QIODevice::WriteOnly | QIODevice::Text));
|
||||
QTextStream out(&f);
|
||||
out << "[Fonts]\nCardText = \"Inter, 10\"\n";
|
||||
}
|
||||
{
|
||||
QSettings paths(settingsPath + "paths.ini", QSettings::IniFormat);
|
||||
paths.setValue("paths/themes", themesPath);
|
||||
paths.sync();
|
||||
}
|
||||
{
|
||||
QSettings appearance(settingsPath + "appearance.ini", QSettings::IniFormat);
|
||||
appearance.setValue("appearance/maxFontSize", 18);
|
||||
appearance.sync();
|
||||
}
|
||||
|
||||
ASSERT_TRUE(SettingsMigration::migrateAppearanceMaxFontSizeToTheme(settingsPath));
|
||||
|
||||
QFile f(themesPath + "/MyTheme/fonts.toml");
|
||||
ASSERT_TRUE(f.open(QIODevice::ReadOnly | QIODevice::Text));
|
||||
const QString content = QString::fromUtf8(f.readAll());
|
||||
EXPECT_TRUE(content.contains("10"));
|
||||
EXPECT_FALSE(content.contains("18"));
|
||||
}
|
||||
|
||||
TEST_F(SettingsMigrationTest, AppearanceMaxFontSize_MergesWithOtherRoles)
|
||||
{
|
||||
const QString themesPath = tempDir.path() + "/themes";
|
||||
ASSERT_TRUE(QDir().mkpath(themesPath + "/MyTheme"));
|
||||
{
|
||||
QFile f(themesPath + "/MyTheme/fonts.toml");
|
||||
ASSERT_TRUE(f.open(QIODevice::WriteOnly | QIODevice::Text));
|
||||
QTextStream out(&f);
|
||||
out << "[Fonts]\nInterfaceDefault = \"Inter, 10\"\n";
|
||||
}
|
||||
{
|
||||
QSettings paths(settingsPath + "paths.ini", QSettings::IniFormat);
|
||||
paths.setValue("paths/themes", themesPath);
|
||||
paths.sync();
|
||||
}
|
||||
{
|
||||
QSettings appearance(settingsPath + "appearance.ini", QSettings::IniFormat);
|
||||
appearance.setValue("appearance/maxFontSize", 20);
|
||||
appearance.sync();
|
||||
}
|
||||
|
||||
ASSERT_TRUE(SettingsMigration::migrateAppearanceMaxFontSizeToTheme(settingsPath));
|
||||
|
||||
QFile f(themesPath + "/MyTheme/fonts.toml");
|
||||
ASSERT_TRUE(f.open(QIODevice::ReadOnly | QIODevice::Text));
|
||||
const QString content = QString::fromUtf8(f.readAll());
|
||||
EXPECT_TRUE(content.contains("InterfaceDefault"));
|
||||
EXPECT_TRUE(content.contains("CardText"));
|
||||
EXPECT_TRUE(content.contains("20"));
|
||||
}
|
||||
|
||||
TEST_F(SettingsMigrationTest, AppearanceMaxFontSize_AbsentKeyDoesNothing)
|
||||
{
|
||||
ASSERT_FALSE(SettingsMigration::migrateAppearanceMaxFontSizeToTheme(settingsPath));
|
||||
}
|
||||
|
||||
TEST_F(SettingsMigrationTest, IsMigrationPendingWhenMaxFontSizePresent)
|
||||
{
|
||||
{
|
||||
QSettings appearance(settingsPath + "appearance.ini", QSettings::IniFormat);
|
||||
appearance.setValue("appearance/maxFontSize", 18);
|
||||
appearance.sync();
|
||||
}
|
||||
|
||||
ASSERT_TRUE(SettingsMigration::isMigrationPending(settingsPath));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue