From 6a36700848b54b977eb6723a6ff68b36c1f0937d Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Fri, 17 Sep 2010 20:31:15 +0200 Subject: ListItem: add auto test for multiple word highlighting. --- src/tests/CMakeLists.txt | 12 ++++++ src/tests/listitem_test.cpp | 94 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 src/tests/listitem_test.cpp (limited to 'src') diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 3bc9a27f..9769aec1 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -165,4 +165,16 @@ target_link_libraries( urlbar_test ${QT_QTTEST_LIBRARY} ) +##### ------------- listitem test + +kde4_add_unit_test( listitem_test listitem_test.cpp ) + +target_link_libraries( listitem_test + kdeinit_rekonq + ${KDE4_KDECORE_LIBS} + ${KDE4_KDEUI_LIBS} + ${KDE4_KDEWEBKIT_LIBS} + ${QT_QTTEST_LIBRARY} +) + ############################################################ diff --git a/src/tests/listitem_test.cpp b/src/tests/listitem_test.cpp new file mode 100644 index 00000000..961f4b6a --- /dev/null +++ b/src/tests/listitem_test.cpp @@ -0,0 +1,94 @@ +/* + * Copyright 2010 Pierre Rossi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + + + +#include + +#include "listitem.h" + + +class ListItemTest : public QObject +{ + Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + +private slots: + + void wordHighLighting_data(); + void wordHighLighting(); + +}; + + +// ------------------------------------------- + +void ListItemTest::initTestCase() +{ +} + + +void ListItemTest::cleanupTestCase() +{ +} + + +// ------------------------------------------- + +void ListItemTest::wordHighLighting_data() +{ + QTest::addColumn("string"); + QTest::addColumn("wordsToHighlight"); + QTest::addColumn("expected"); + + QTest::newRow("plan b") << "http://www.google.com/search?q=plan b&ie=UTF-8&oe=UTF-8" + << "plan b" << "http://www.google.com/search?q=plan b&ie=UTF-8&oe=UTF-8"; + QTest::newRow("plan b #2") << "http://en.wikipedia.org/wiki/Plan_B_(British_musician)" + << "plan b" << "http://en.wikipedia.org/wiki/Plan_B_(British_musician)"; + QTest::newRow("i") << "http://i.imgur.com/jacoj.jpg" << "i" + << "http://i.imgur.com/jacoj.jpg"; + QTest::newRow("i#2") << "KDE - Experience Freedom!" << "i" << "KDE - Experience Freedom!"; + QTest::newRow("i#3") << "The WebKit Open Source Project" << "i" << "The WebKit Open Source Project"; + QTest::newRow("i#4") << "http://webkit.org/" << "i" << "http://webkit.org/"; + QTest::newRow("b") << "http://mail.google.com/mail/#inbox" << "b" << "http://mail.google.com/mail/#inbox"; + QTest::newRow("b#2") << "rekonq, WebKit KDE browser" << "b" << "rekonq, WebKit KDE browser"; + QTest::newRow("<") << "Subject < Section < Wiki" << "<" << "Subject < Section < Wiki"; + QTest::newRow("&") << "http://www.google.com/search?q=qt test&ie=UTF-8&oe=UTF-8" << "&" + << "http://www.google.com/search?q=qt test&ie=UTF-8&oe=UTF-8"; + +} + +void ListItemTest::wordHighLighting() +{ + QFETCH(QString, string); + QFETCH(QString, wordsToHighlight); + QFETCH(QString, expected); + + TextLabel test(string, wordsToHighlight); + QCOMPARE(test.text(), expected); +} + + +// ------------------------------------------- + +QTEST_KDEMAIN(ListItemTest, GUI) +#include "listitem_test.moc" -- cgit v1.2.1