aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_config.cpp83
-rw-r--r--tests/test_mainwindow.cpp29
2 files changed, 112 insertions, 0 deletions
diff --git a/tests/test_config.cpp b/tests/test_config.cpp
index 079ba3b..ec630d4 100644
--- a/tests/test_config.cpp
+++ b/tests/test_config.cpp
@@ -31,6 +31,10 @@ private slots:
void missingSyncCommandIsEmpty();
void syncLogDefaultsToTheScriptsOwnPath();
void syncLogCanBeOverridden();
+ void toolbarIconSizeDefaultsTo24();
+ void toolbarIconSizeIsActuallyRead();
+ void toolbarIconSizeIsClampedAndReported();
+ void toolbarIconSizeRejectsGarbage();
void accountWithoutMaildirIsRejected();
void scopedQueryWrapsCorrectly();
void absentSyncCommandIsNoticeNotProblem();
@@ -170,6 +174,85 @@ void TestConfig::syncLogCanBeOverridden()
QCOMPARE(config.syncLog(), QStringLiteral("/var/log/mail/sync.log"));
}
+void TestConfig::toolbarIconSizeDefaultsTo24()
+{
+ // The desktop's own metric is the obvious default and was rejected: this
+ // style reports PM_ToolBarIconSize as 16, which is a small click target for
+ // a toolbar that now shows icons with no text beside them. 24 is a normal
+ // toolbar size, and setting the key back to 16 restores the theme's value.
+ QTemporaryDir dir;
+ const QString path = writeIni(dir, QStringLiteral("[general]\n"));
+
+ Config config;
+ config.load(path);
+
+ QCOMPARE(config.toolbarIconSize(), 24);
+ QVERIFY(config.problems().isEmpty());
+}
+
+void TestConfig::toolbarIconSizeIsActuallyRead()
+{
+ // [general] keys are read WITHOUT the general/ prefix, per the note at the
+ // top of Config::load(). A key that silently matched nothing would leave
+ // the default in place and look exactly like a working default.
+ QTemporaryDir dir;
+ const QString path = writeIni(dir, QStringLiteral(
+ "[general]\n"
+ "toolbar_icon_size = 32\n"
+ ));
+
+ Config config;
+ config.load(path);
+
+ QCOMPARE(config.toolbarIconSize(), 32);
+}
+
+void TestConfig::toolbarIconSizeIsClampedAndReported()
+{
+ // Out of range is clamped rather than honoured: a 4px icon is invisible and
+ // a 4000px one makes the toolbar taller than the window, and neither is
+ // recoverable from the UI the value just broke. Reported, because silently
+ // ignoring what the user asked for is how message_zoom's documented 0.5-3.0
+ // range came to be unenforced without anyone noticing.
+ QTemporaryDir dir;
+ const QString tooBig = writeIni(dir, QStringLiteral(
+ "[general]\n"
+ "toolbar_icon_size = 4000\n"
+ ));
+
+ Config big;
+ big.load(tooBig);
+ QCOMPARE(big.toolbarIconSize(), 64);
+ QVERIFY(!big.warnings().isEmpty() || !big.problems().isEmpty());
+
+ QTemporaryDir dir2;
+ const QString tooSmall = writeIni(dir2, QStringLiteral(
+ "[general]\n"
+ "toolbar_icon_size = 2\n"
+ ));
+
+ Config small;
+ small.load(tooSmall);
+ QCOMPARE(small.toolbarIconSize(), 16);
+}
+
+void TestConfig::toolbarIconSizeRejectsGarbage()
+{
+ // Unparseable falls back to the default and says so, matching how
+ // mark_read_delay_ms treats the same mistake.
+ QTemporaryDir dir;
+ const QString path = writeIni(dir, QStringLiteral(
+ "[general]\n"
+ "toolbar_icon_size = enormous\n"
+ ));
+
+ Config config;
+ config.load(path);
+
+ QCOMPARE(config.toolbarIconSize(), 24);
+ QVERIFY(!config.problems().isEmpty());
+}
+
void TestConfig::accountWithoutMaildirIsRejected()
{
QTemporaryDir dir;
diff --git a/tests/test_mainwindow.cpp b/tests/test_mainwindow.cpp
index 4a911c9..84a3a7d 100644
--- a/tests/test_mainwindow.cpp
+++ b/tests/test_mainwindow.cpp
@@ -120,6 +120,7 @@ private slots:
void theToolbarDoesNotOverrideTheDesktopButtonStyle();
void theImportantActionIsLabelledImportant();
void theImportantActionStillWritesTheFlaggedTag();
+ void theToolbarUsesTheConfiguredIconSize();
};
void TestMainWindow::everyKnownActionIsRegistered()
@@ -2513,6 +2514,34 @@ void TestMainWindow::theImportantActionStillWritesTheFlaggedTag()
"written, which no other tool reading this Maildir knows");
}
+void TestMainWindow::theToolbarUsesTheConfiguredIconSize()
+{
+ // With the toolbar following the desktop's "Icon only" style, the icons are
+ // the whole control, and this style reports 16px, which is a small target.
+ // The size is configurable with a 24px default; this proves the config
+ // value actually reaches the widget rather than sitting in Config unread.
+ QTemporaryDir dir;
+ QVERIFY(dir.isValid());
+ const QString path = dir.filePath(QStringLiteral("qtmaildir.conf"));
+ QFile file(path);
+ QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text));
+ file.write("[general]\ntoolbar_icon_size = 40\n");
+ file.close();
+
+ Config config;
+ config.load(path);
+ QCOMPARE(config.toolbarIconSize(), 40);
+
+ MainWindow window(config);
+ auto *toolBar = window.findChild<QToolBar *>(QStringLiteral("main_toolbar"));
+ QVERIFY(toolBar);
+
+ // 40 is deliberately not any of this style's own metrics (16 small, 32
+ // large), so the assertion cannot pass by the widget happening to agree
+ // with the theme.
+ QCOMPARE(toolBar->iconSize(), QSize(40, 40));
+}
+
// Constructing a MainWindow needs a QApplication and a platform plugin. The
// test has no display under ctest, so it runs offscreen unless the caller
// asked for something else.