37
|
1 |
/*!
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <QtGui>
|
|
19 |
#include <QtTest/QtTest>
|
|
20 |
|
|
21 |
#include <hbapplication.h>
|
|
22 |
#include <hbmainwindow.h>
|
|
23 |
#include <hbaction.h>
|
|
24 |
|
|
25 |
#include "bubbletest.h"
|
|
26 |
#include "bubbleheader.h"
|
|
27 |
|
|
28 |
class ut_BubbleHeader : public QObject
|
|
29 |
{
|
|
30 |
Q_OBJECT
|
|
31 |
|
|
32 |
private slots:
|
|
33 |
void initTestCase();
|
|
34 |
void cleanupTestCase();
|
|
35 |
|
|
36 |
void testIsUsed();
|
|
37 |
void testBubbleId();
|
|
38 |
void testCallState();
|
|
39 |
void testCallFlags();
|
|
40 |
void testNumberType();
|
|
41 |
void testText();
|
|
42 |
void testCli();
|
|
43 |
void testSecondaryCli();
|
|
44 |
void testTimerCost();
|
|
45 |
void testCallImage();
|
|
46 |
void testShowDefaultAvatar();
|
|
47 |
void testAddActions();
|
|
48 |
void testIsConference();
|
|
49 |
void testIsInConference();
|
|
50 |
void testSetExpandAction();
|
|
51 |
void testReset(); // this should run last
|
|
52 |
|
|
53 |
private:
|
|
54 |
BubbleHeader* bubbleHeader; // class under test
|
|
55 |
};
|
|
56 |
|
|
57 |
void ut_BubbleHeader::initTestCase()
|
|
58 |
{
|
|
59 |
bubbleHeader = new BubbleHeader();
|
|
60 |
}
|
|
61 |
|
|
62 |
void ut_BubbleHeader::cleanupTestCase()
|
|
63 |
{
|
|
64 |
delete bubbleHeader;
|
|
65 |
}
|
|
66 |
|
|
67 |
void ut_BubbleHeader::testIsUsed()
|
|
68 |
{
|
|
69 |
bubbleHeader->setIsUsed( true );
|
|
70 |
QVERIFY( bubbleHeader->isUsed() == true );
|
|
71 |
}
|
|
72 |
|
|
73 |
void ut_BubbleHeader::testBubbleId()
|
|
74 |
{
|
|
75 |
bubbleHeader->setBubbleId( 1 );
|
|
76 |
QVERIFY( bubbleHeader->bubbleId() == 1 );
|
|
77 |
}
|
|
78 |
|
|
79 |
void ut_BubbleHeader::testCallState()
|
|
80 |
{
|
|
81 |
bubbleHeader->setCallState( BubbleManager::Active );
|
|
82 |
QVERIFY( bubbleHeader->callState() == BubbleManager::Active );
|
|
83 |
|
|
84 |
bubbleHeader->setCallState( BubbleManager::Disconnected );
|
|
85 |
QVERIFY( bubbleHeader->callState() == BubbleManager::Disconnected );
|
|
86 |
|
|
87 |
bubbleHeader->setCallState( BubbleManager::Incoming );
|
|
88 |
bubbleHeader->setCallState( BubbleManager::Disconnected );
|
|
89 |
QVERIFY( bubbleHeader->callState() == BubbleManager::AlertToDisconnected );
|
|
90 |
}
|
|
91 |
|
|
92 |
void ut_BubbleHeader::testCallFlags()
|
|
93 |
{
|
|
94 |
// set all bits
|
|
95 |
bubbleHeader->setCallFlags( BubbleManager::Diverted );
|
|
96 |
bubbleHeader->setCallFlags( BubbleManager::Video );
|
|
97 |
QVERIFY( bubbleHeader->callFlags() == BubbleManager::Video );
|
|
98 |
|
|
99 |
// set normal (reset all bits)
|
|
100 |
bubbleHeader->setCallFlag( BubbleManager::Normal );
|
|
101 |
QVERIFY( bubbleHeader->callFlags() == 0 );
|
|
102 |
|
|
103 |
// set invidual bit
|
|
104 |
bubbleHeader->setCallFlag( BubbleManager::Diverted );
|
|
105 |
bubbleHeader->setCallFlag( BubbleManager::Video );
|
|
106 |
QVERIFY( bubbleHeader->callFlags() & BubbleManager::Diverted );
|
|
107 |
QVERIFY( bubbleHeader->callFlags() & BubbleManager::Video );
|
|
108 |
QVERIFY( !(bubbleHeader->callFlags() & BubbleManager::NoCiphering) );
|
|
109 |
|
|
110 |
// reset invidual bit
|
|
111 |
bubbleHeader->removeCallFlag( BubbleManager::Video );
|
|
112 |
bubbleHeader->removeCallFlag( BubbleManager::Normal ); // does nothing
|
|
113 |
QVERIFY( bubbleHeader->callFlags() & BubbleManager::Diverted );
|
|
114 |
QVERIFY( !(bubbleHeader->callFlags() & BubbleManager::Video) );
|
|
115 |
QVERIFY( !(bubbleHeader->callFlags() & BubbleManager::NoCiphering) );
|
|
116 |
}
|
|
117 |
|
|
118 |
void ut_BubbleHeader::testNumberType()
|
|
119 |
{
|
|
120 |
bubbleHeader->setNumberType( BubbleManager::Mobile );
|
|
121 |
QVERIFY( bubbleHeader->numberType() == BubbleManager::Mobile );
|
|
122 |
}
|
|
123 |
|
|
124 |
void ut_BubbleHeader::testText()
|
|
125 |
{
|
|
126 |
bubbleHeader->setText( "Calling", Qt::ElideRight );
|
|
127 |
QVERIFY( bubbleHeader->text() == "Calling" );
|
|
128 |
QVERIFY( bubbleHeader->textClipDirection() == Qt::ElideRight );
|
|
129 |
|
|
130 |
bubbleHeader->setText( "", Qt::ElideLeft );
|
|
131 |
QVERIFY( bubbleHeader->text() == "" );
|
|
132 |
QVERIFY( bubbleHeader->textClipDirection() == Qt::ElideLeft );
|
|
133 |
}
|
|
134 |
|
|
135 |
void ut_BubbleHeader::testCli()
|
|
136 |
{
|
|
137 |
bubbleHeader->setCli( "John Doe", Qt::ElideRight );
|
|
138 |
QVERIFY( bubbleHeader->cli() == "John Doe" );
|
|
139 |
QVERIFY( bubbleHeader->cliClipDirection() == Qt::ElideRight );
|
|
140 |
|
|
141 |
bubbleHeader->setCli( "+358501234567", Qt::ElideLeft );
|
|
142 |
QVERIFY( bubbleHeader->cli() == "+358501234567" );
|
|
143 |
QVERIFY( bubbleHeader->cliClipDirection() == Qt::ElideLeft );
|
|
144 |
}
|
|
145 |
|
|
146 |
void ut_BubbleHeader::testSecondaryCli()
|
|
147 |
{
|
|
148 |
bubbleHeader->setSecondaryCli( "John Doe", Qt::ElideRight );
|
|
149 |
QVERIFY( bubbleHeader->secondaryCli() == "John Doe" );
|
|
150 |
QVERIFY( bubbleHeader->secondaryCliClipDirection() == Qt::ElideRight );
|
|
151 |
|
|
152 |
bubbleHeader->setSecondaryCli( "+358501234567", Qt::ElideLeft );
|
|
153 |
QVERIFY( bubbleHeader->secondaryCli() == "+358501234567" );
|
|
154 |
QVERIFY( bubbleHeader->secondaryCliClipDirection() == Qt::ElideLeft );
|
|
155 |
}
|
|
156 |
|
|
157 |
void ut_BubbleHeader::testTimerCost()
|
|
158 |
{
|
|
159 |
bubbleHeader->setTimerCost( "10:01" );
|
|
160 |
QVERIFY( bubbleHeader->timerCost() == "10:01" );
|
|
161 |
}
|
|
162 |
|
|
163 |
void ut_BubbleHeader::testCallImage()
|
|
164 |
{
|
|
165 |
bubbleHeader->setCallImage( "image.png" );
|
|
166 |
QVERIFY( bubbleHeader->callImage() == "image.png" );
|
|
167 |
}
|
|
168 |
|
|
169 |
void ut_BubbleHeader::testShowDefaultAvatar()
|
|
170 |
{
|
|
171 |
bubbleHeader->setShowDefaultAvatar(true);
|
|
172 |
QVERIFY( bubbleHeader->showDefaultAvatar() == true);
|
|
173 |
bubbleHeader->setShowDefaultAvatar(false);
|
|
174 |
QVERIFY( bubbleHeader->showDefaultAvatar() == false);
|
|
175 |
}
|
|
176 |
|
|
177 |
void ut_BubbleHeader::testAddActions()
|
|
178 |
{
|
|
179 |
for ( int i=0; i < 4; i++ )
|
|
180 |
{
|
|
181 |
HbAction* action = new HbAction( "Test", this);
|
|
182 |
bubbleHeader->addAction( action );
|
|
183 |
}
|
|
184 |
|
|
185 |
QVERIFY( bubbleHeader->actions().count() == 4 );
|
|
186 |
|
|
187 |
bubbleHeader->clearActions();
|
|
188 |
}
|
|
189 |
|
|
190 |
void ut_BubbleHeader::testIsConference()
|
|
191 |
{
|
|
192 |
QVERIFY( bubbleHeader->isConference() == false );
|
|
193 |
}
|
|
194 |
|
|
195 |
void ut_BubbleHeader::testIsInConference()
|
|
196 |
{
|
|
197 |
bubbleHeader->setInConference(true);
|
|
198 |
QVERIFY( bubbleHeader->isInConference() == true );
|
|
199 |
}
|
|
200 |
|
|
201 |
void ut_BubbleHeader::testSetExpandAction()
|
|
202 |
{
|
|
203 |
HbAction* action = new HbAction( "Test", this);
|
|
204 |
|
|
205 |
bubbleHeader->setExpandAction( action );
|
|
206 |
QVERIFY( bubbleHeader->expandAction() == action );
|
|
207 |
|
|
208 |
bubbleHeader->setExpandAction( 0 );
|
|
209 |
QVERIFY( bubbleHeader->expandAction() == 0 );
|
|
210 |
}
|
|
211 |
|
|
212 |
void ut_BubbleHeader::testReset()
|
|
213 |
{
|
|
214 |
bubbleHeader->reset();
|
|
215 |
QVERIFY( bubbleHeader->isUsed() == false );
|
|
216 |
QVERIFY( bubbleHeader->bubbleId() == 1 );
|
|
217 |
QVERIFY( bubbleHeader->callState() == BubbleManager::None );
|
|
218 |
QVERIFY( bubbleHeader->callFlags() == 0 );
|
|
219 |
QVERIFY( bubbleHeader->numberType() == BubbleManager::NotSet );
|
|
220 |
QVERIFY( bubbleHeader->cli() == "" );
|
|
221 |
QVERIFY( bubbleHeader->secondaryCli() == "" );
|
|
222 |
QVERIFY( bubbleHeader->timerCost() == "" );
|
|
223 |
QVERIFY( bubbleHeader->callImage() == "" );
|
|
224 |
QVERIFY( bubbleHeader->isInConference() == false );
|
|
225 |
}
|
|
226 |
|
|
227 |
BUBBLE_TEST_MAIN(ut_BubbleHeader)
|
|
228 |
#include "ut_bubbleheader.moc"
|