diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-26 16:03:49 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-26 16:03:49 +0200 |
| commit | bd90331cba3633754482fc13b99ae39a3b5f79a2 (patch) | |
| tree | d850c76f382aa94db5139edceb72c18bc08851ec /tests/test_carddelegate.cpp | |
| parent | ef4d48c56c39f19efc751488cc2df6ee5af24a7f (diff) | |
| download | qtmaildir-bd90331cba3633754482fc13b99ae39a3b5f79a2.tar.gz qtmaildir-bd90331cba3633754482fc13b99ae39a3b5f79a2.zip | |
feat: draw a sender's avatar on every card
Diffstat (limited to 'tests/test_carddelegate.cpp')
| -rw-r--r-- | tests/test_carddelegate.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/test_carddelegate.cpp b/tests/test_carddelegate.cpp index 6ec43b8..8b53309 100644 --- a/tests/test_carddelegate.cpp +++ b/tests/test_carddelegate.cpp @@ -38,6 +38,8 @@ private slots: void aSiblingChipsPaddingShrinksWithItsFont(); void theFadeEndsAtSixtyPercentOfTheCard(); void aReplyFadeStartsAtItsOwnSpine(); + void theDelegateAsksForAScaledSquircle(); + void aRowWithNoSenderFallsBackToTheAccount(); }; namespace { @@ -284,5 +286,44 @@ void TestCardDelegate::aReplyFadeStartsAtItsOwnSpine() QVERIFY(reply.width() < CardDelegate::fadeRectFor(card, QRect()).width()); } +void TestCardDelegate::theDelegateAsksForAScaledSquircle() +{ + // Asserted through the function the PRODUCTION path calls, not through + // Avatar::pixmapFor() directly: a test pointed at the function being + // called into proves what that function does and nothing about whether the + // delegate asks it for the right thing. CLAUDE.md records a mutation that + // survived exactly that mistake. + const QRect card(0, 0, 500, 60); + const QFont font; + const CardLayout layout = + CardLayout::compute(CardLayout::Input(), card, font); + + const QPixmap pixmap = CardDelegate::avatarFor( + QStringLiteral("john@example.org"), QStringLiteral("John Doe"), + QStringLiteral("me@example.org"), QStringLiteral("Work"), false, + layout.avatarRect.width(), font); + + QCOMPARE(pixmap.size(), + QSize(layout.avatarRect.width(), layout.avatarRect.width())); +} + +void TestCardDelegate::aRowWithNoSenderFallsBackToTheAccount() +{ + const QFont font; + // No sender address at all: the squircle is still drawn, seeded from the + // account, so a card never shows a hole. + const QPixmap fallback = CardDelegate::avatarFor( + QString(), QString(), QStringLiteral("me@example.org"), + QStringLiteral("Work"), false, 44, font); + QVERIFY(!fallback.isNull()); + + // And it is the ACCOUNT's identity, not an arbitrary one: seeding from the + // same account twice agrees. + const QPixmap again = CardDelegate::avatarFor( + QString(), QString(), QStringLiteral("me@example.org"), + QStringLiteral("Work"), false, 44, font); + QCOMPARE(fallback.toImage(), again.toImage()); +} + QTEST_MAIN(TestCardDelegate) #include "test_carddelegate.moc" |
