1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
/*
ChatWindowStyle test suite
Copyright (c) 2005 by Michaƫl Larouche <michael.larouche@kdemail.net>
Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
* *
* 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 <kunittest/module.h>
#include "chatwindowstyle_test.h"
#include <stdlib.h>
#include <tqdir.h>
#include <tqfile.h>
#include <kopetechatwindowstyle.h>
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( "KDEHOME", 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(
"<div>%chatName%</div>\n"
"<div>%sourceName%</div>\n"
"<div>%destinationName%</div>\n"
"<div>%incomingIconPath%</div>\n"
"<div>%outgoingIconPath%</div>\n"
"<div>%timeOpened%</div>\n"
"<div>%timeOpened{%H:%M}%</div>");
// Footer is empty on purpose, this is to test if the file doesn't exist.
TQString exceptedFooter;
TQString exceptedIncoming = TQString::fromUtf8(
"Incoming:\n"
"<div>%userIconPath%</div>\n"
"<div>%senderScreenName%</div>\n"
"<div>%sender%</div>\n"
"<div>%service%</div>\n"
"<div>%message%</div>\n"
"<div>%time%</div>\n"
"<div>%time{%H:%M}%</div>\n"
"<div id=\"insert\">");
TQString exceptedNextIncoming = TQString::fromUtf8(
"Incoming:\n"
"<div>%message%</div>\n"
"<div id=\"insert\">"
);
TQString exceptedOutgoing = TQString::fromUtf8(
"Outgoing:\n"
"<div>%userIconPath%</div>\n"
"<div>%senderScreenName%</div>\n"
"<div>%sender%</div>\n"
"<div>%service%</div>\n"
"<div>%message%</div>\n"
"<div>%time%</div>\n"
"<div>%time{%H:%M}%</div>\n"
"<div id=\"insert\">");
TQString exceptedNextOutgoing = TQString::fromUtf8(
"Outgoing:\n"
"<div>%message%</div>\n"
"<div id=\"insert\">"
);
TQString exceptedtqStatus = TQString::fromUtf8(
"<div>%message%</div>\n"
"<div>%time%</div>\n"
"<div>%time{%H:%M}%</div>");
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);
}
|