aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_mainwindow.cpp')
-rw-r--r--tests/test_mainwindow.cpp34
1 files changed, 23 insertions, 11 deletions
diff --git a/tests/test_mainwindow.cpp b/tests/test_mainwindow.cpp
index a572fd0..08589b2 100644
--- a/tests/test_mainwindow.cpp
+++ b/tests/test_mainwindow.cpp
@@ -12955,15 +12955,23 @@ void TestMainWindow::theComposerSplitsItsToolbarByScope()
auto *column = qobject_cast<QVBoxLayout *>(central->layout());
QVERIFY2(column, "the composer is not laid out in a vertical column");
- int barIndex = -1;
- int bodyIndex = -1;
- for (int i = 0; i < column->count(); ++i) {
- QLayoutItem *item = column->itemAt(i);
- if (item->widget() == editorBar)
- barIndex = i;
- else if (item->widget() == body)
- bodyIndex = i;
- }
+ // The editor sits inside a QSplitter since item 171, so its position in
+ // the column is the SPLITTER's: a forward puts the forwarded message
+ // beside the editor, and the toolbar must stay above both. Walking up to
+ // whichever child of the column contains the body keeps this test about
+ // the toolbar's position rather than about the editor's parentage.
+ const auto columnChildOf = [column](QWidget *widget) {
+ for (QWidget *w = widget; w; w = w->parentWidget()) {
+ for (int i = 0; i < column->count(); ++i) {
+ if (column->itemAt(i)->widget() == w)
+ return i;
+ }
+ }
+ return -1;
+ };
+
+ const int barIndex = columnChildOf(editorBar);
+ const int bodyIndex = columnChildOf(body);
QVERIFY2(barIndex >= 0 && bodyIndex >= 0,
"the editor bar or the body is not in the composer's column");
QVERIFY2(barIndex < bodyIndex, "the editor bar is not above the editor");
@@ -13753,8 +13761,12 @@ void TestMainWindow::anAutosaveWritesADraftAndClearsTheDirtyFlag()
QVERIFY(written.open(QIODevice::ReadOnly));
const QByteArray bytes = written.readAll();
QVERIFY2(bytes.contains("Draft body."), "the draft does not carry the body");
- // Written with the Maildir draft flag, not left bare.
- QVERIFY2(files.first().endsWith(QStringLiteral(":2,D")),
+ // Written with the Maildir draft flag, not left bare. The flag SET is not
+ // pinned here: a draft also carries S, asserted by
+ // TestComposeWindow::aSavedDraftIsFlaggedSeen(), and an endsWith(":2,D")
+ // here would fail against that correct behaviour.
+ QVERIFY2(files.first().section(QStringLiteral(":2,"), 1)
+ .contains(QLatin1Char('D')),
qPrintable(QStringLiteral("wrong maildir flags: ") + files.first()));
}