aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_avatar.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_avatar.cpp b/tests/test_avatar.cpp
index 225b4f1..b53dfc1 100644
--- a/tests/test_avatar.cpp
+++ b/tests/test_avatar.cpp
@@ -30,6 +30,9 @@ private slots:
void bareAddressTakesLocalAndDomain();
void nothingUsableFallsBackToTheAccountLabel();
void initialsAreAlwaysTwoLetters();
+ void aDisplayNameMeansAPerson();
+ void theListOverridesADisplayName();
+ void aColourIsStablePerAddress();
};
void TestAvatar::twoWordNameTakesOneLetterFromEach()
@@ -91,5 +94,30 @@ void TestAvatar::initialsAreAlwaysTwoLetters()
}
}
+void TestAvatar::aDisplayNameMeansAPerson()
+{
+ // The case the user asked for by name: a corporate address that presents
+ // itself as a person reads as a person.
+ QCOMPARE(Avatar::fillFor(QStringLiteral("Ian Farrell"), false),
+ Avatar::Fill::Identicon);
+ QCOMPARE(Avatar::fillFor(QString(), false), Avatar::Fill::TwoTone);
+}
+
+void TestAvatar::theListOverridesADisplayName()
+{
+ // A listed address stays a business even when it sets a friendly name.
+ QCOMPARE(Avatar::fillFor(QStringLiteral("Cofidis"), true),
+ Avatar::Fill::TwoTone);
+}
+
+void TestAvatar::aColourIsStablePerAddress()
+{
+ const QColor first = Avatar::colourFor(QStringLiteral("a@example.org"));
+ const QColor again = Avatar::colourFor(QStringLiteral("a@example.org"));
+ QCOMPARE(first, again);
+ QVERIFY(first.isValid());
+ QVERIFY(Avatar::colourFor(QStringLiteral("b@example.org")) != first);
+}
+
QTEST_MAIN(TestAvatar)
#include "test_avatar.moc"