/* ChatWindowStyle test suite Copyright (c) 2005 by Michaƫl Larouche Kopete (c) 2002-2005 by the Kopete developers ************************************************************************* * * * 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. * * * ************************************************************************* */ #include #include "chatwindowstyle_test.h" #include #include #include #include KUNITTEST_MODULE( kunittest_chatwindowstyle_test, "KopeteChatWindowTestSuite"); KUNITTEST_MODULE_REGISTER_TESTER( ChatWindowStyle_Test ); void ChatWindowStyle_Test::allTests() { testStyle = new ChatWindowStyle(TQString(SRCDIR)+TQString("/TestStyle")); // change user data dir to avoid messing with user's .kde dir setenv( "TDEHOME", TQFile::encodeName( TQDir::homeDirPath() + "/.kopete-unittest" ), true ); testPaths(); testHtml(); testVariants(); testAction(); } void ChatWindowStyle_Test::testPaths() { TQString expectedStylePath = SRCDIR + TQString::fromUtf8("/TestStyle"); TQString expectedBaseHref = expectedStylePath + TQString::fromUtf8("/Contents/Resources/"); CHECK(testStyle->getStylePath(), expectedStylePath); CHECK(testStyle->getStyleBaseHref(), expectedBaseHref); } void ChatWindowStyle_Test::testHtml() { TQString exceptedHeader = TQString::fromUtf8( "
%chatName%
\n" "
%sourceName%
\n" "
%destinationName%
\n" "
%incomingIconPath%
\n" "
%outgoingIconPath%
\n" "
%timeOpened%
\n" "
%timeOpened{%H:%M}%
"); // Footer is empty on purpose, this is to test if the file doesn't exist. TQString exceptedFooter; TQString exceptedIncoming = TQString::fromUtf8( "Incoming:\n" "
%userIconPath%
\n" "
%senderScreenName%
\n" "
%sender%
\n" "
%service%
\n" "
%message%
\n" "
%time%
\n" "
%time{%H:%M}%
\n" "
"); TQString exceptedNextIncoming = TQString::fromUtf8( "Incoming:\n" "
%message%
\n" "
" ); TQString exceptedOutgoing = TQString::fromUtf8( "Outgoing:\n" "
%userIconPath%
\n" "
%senderScreenName%
\n" "
%sender%
\n" "
%service%
\n" "
%message%
\n" "
%time%
\n" "
%time{%H:%M}%
\n" "
"); TQString exceptedNextOutgoing = TQString::fromUtf8( "Outgoing:\n" "
%message%
\n" "
" ); TQString exceptedtqStatus = TQString::fromUtf8( "
%message%
\n" "
%time%
\n" "
%time{%H:%M}%
"); CHECK(testStyle->getHeaderHtml(), exceptedHeader); CHECK(testStyle->getFooterHtml(), exceptedFooter); CHECK(testStyle->getIncomingHtml(), exceptedIncoming); CHECK(testStyle->getNextIncomingHtml(), exceptedNextIncoming); CHECK(testStyle->getOutgoingHtml(), exceptedOutgoing); CHECK(testStyle->getNextOutgoingHtml(), exceptedNextOutgoing); CHECK(testStyle->getStatusHtml(), exceptedtqStatus); } void ChatWindowStyle_Test::testAction() { CHECK(testStyle->hasActionTemplate(), false); } void ChatWindowStyle_Test::testVariants() { TQString expectedNameResult("Variant1;Variant2"); TQString expectedPathResult("Variants/Variant1.css;Variants/Variant2.css"); TQStringList variantNameList; TQStringList variantPathList; ChatWindowStyle::StyleVariants variantList; ChatWindowStyle::StyleVariants::ConstIterator it; variantList = testStyle->getVariants(); for(it = variantList.constBegin(); it != variantList.constEnd(); ++it) { variantNameList.append(it.key()); variantPathList.append(it.data()); } CHECK(variantNameList.join(";"), expectedNameResult); CHECK(variantPathList.join(";"), expectedPathResult); }