diff --git a/tests/unittests/previewengine_unittest.cpp b/tests/unittests/previewengine_unittest.cpp index 70808dfd285d8feed76fdafdd7a0d119e8632748..1f87aaa7ad972f4c655aa32762fcad04db9ae5a8 100644 --- a/tests/unittests/previewengine_unittest.cpp +++ b/tests/unittests/previewengine_unittest.cpp @@ -24,15 +24,17 @@ class PreviewEngineFixture : public ::testing::Test public: // Prepare unit test context. Called at // prior each unit test execution - void SetUp() override { + void SetUp() override + { server = new QHttpServer(); // Setup a server that can return an HTML body. server->listen(QHostAddress::LocalHost, 8000); } - // Close unit test context. Called - // after each unit test ending - void TearDown() override { + // Close unit test context. Called + // after each unit test ending + void TearDown() override + { delete server; } @@ -47,9 +49,8 @@ public: TEST_F(PreviewEngineFixture, ParsingALinkEmitsInfoReadySignal) { auto link = QString("http://localhost:8000/test"); - server->route("/test", [] () { - return QString("<meta property=\"og:title\" content=\"Test title\">"); - }); + server->route("/test", + []() { return QString("<meta property=\"og:title\" content=\"Test title\">"); }); QSignalSpy infoReadySpy(globalEnv.previewEngine.data(), &PreviewEngine::infoReady); @@ -70,14 +71,14 @@ TEST_F(PreviewEngineFixture, ParsingALinkEmitsInfoReadySignal) */ TEST_F(PreviewEngineFixture, UTF8CharactersAreParsedCorrectly) { - auto link = QString("http://localhost:8000/test"); - server->route("/test", [] () { - return QString("<meta property=\"og:description\" content=\"Test de caractères Utf-8"); + const auto testString = QString("liberté 自由 自由 свобода Szabadság ŐőŰű 자유 😊 € è ñ"); + server->route("/test", [&]() { + return QString("<meta property=\"og:description\" content=\"%1\">").arg(testString); }); QSignalSpy infoReadySpy(globalEnv.previewEngine.data(), &PreviewEngine::infoReady); - Q_EMIT globalEnv.previewEngine->parseLink("msgId_01", link); + Q_EMIT globalEnv.previewEngine->parseLink("msgId_01", "http://localhost:8000/test"); // Wait for the infoReady signal which should be emitted once. infoReadySpy.wait(); @@ -89,5 +90,5 @@ TEST_F(PreviewEngineFixture, UTF8CharactersAreParsedCorrectly) // Check that the description is parsed correctly. QVariantMap info = infoReadyArguments.at(1).toMap(); EXPECT_TRUE(info.contains("description")); - EXPECT_EQ(info["description"].toString(), "Test de caractères Utf-8"); + EXPECT_EQ(info["description"].toString(), testString); }