/* * Copyright 2010-2011 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 Q_SLOTS: void initTestCase(); void cleanupTestCase(); private Q_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"; QTest::newRow("ciao") << "ciao" << "ciao" << "ciao"; QTest::newRow("http://ciao") << "http://ciao" << "ciao" << "http://ciao"; } 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"