|
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 testAddActions(); |
|
47 void testIsConference(); |
|
48 void testIsInConference(); |
|
49 void testSetExpandAction(); |
|
50 void testReset(); // this should run last |
|
51 |
|
52 private: |
|
53 BubbleHeader* bubbleHeader; // class under test |
|
54 }; |
|
55 |
|
56 void ut_BubbleHeader::initTestCase() |
|
57 { |
|
58 bubbleHeader = new BubbleHeader(); |
|
59 } |
|
60 |
|
61 void ut_BubbleHeader::cleanupTestCase() |
|
62 { |
|
63 delete bubbleHeader; |
|
64 } |
|
65 |
|
66 void ut_BubbleHeader::testIsUsed() |
|
67 { |
|
68 bubbleHeader->setIsUsed( true ); |
|
69 QVERIFY( bubbleHeader->isUsed() == true ); |
|
70 } |
|
71 |
|
72 void ut_BubbleHeader::testBubbleId() |
|
73 { |
|
74 bubbleHeader->setBubbleId( 1 ); |
|
75 QVERIFY( bubbleHeader->bubbleId() == 1 ); |
|
76 } |
|
77 |
|
78 void ut_BubbleHeader::testCallState() |
|
79 { |
|
80 bubbleHeader->setCallState( BubbleManager::Active ); |
|
81 QVERIFY( bubbleHeader->callState() == BubbleManager::Active ); |
|
82 |
|
83 bubbleHeader->setCallState( BubbleManager::Disconnected ); |
|
84 QVERIFY( bubbleHeader->callState() == BubbleManager::Disconnected ); |
|
85 |
|
86 bubbleHeader->setCallState( BubbleManager::Incoming ); |
|
87 bubbleHeader->setCallState( BubbleManager::Disconnected ); |
|
88 QVERIFY( bubbleHeader->callState() == BubbleManager::AlertToDisconnected ); |
|
89 } |
|
90 |
|
91 void ut_BubbleHeader::testCallFlags() |
|
92 { |
|
93 // set all bits |
|
94 bubbleHeader->setCallFlags( BubbleManager::Diverted ); |
|
95 bubbleHeader->setCallFlags( BubbleManager::Video ); |
|
96 QVERIFY( bubbleHeader->callFlags() == BubbleManager::Video ); |
|
97 |
|
98 // set normal (reset all bits) |
|
99 bubbleHeader->setCallFlag( BubbleManager::Normal ); |
|
100 QVERIFY( bubbleHeader->callFlags() == 0 ); |
|
101 |
|
102 // set invidual bit |
|
103 bubbleHeader->setCallFlag( BubbleManager::Diverted ); |
|
104 bubbleHeader->setCallFlag( BubbleManager::Video ); |
|
105 QVERIFY( bubbleHeader->callFlags() & BubbleManager::Diverted ); |
|
106 QVERIFY( bubbleHeader->callFlags() & BubbleManager::Video ); |
|
107 QVERIFY( !(bubbleHeader->callFlags() & BubbleManager::NoCiphering) ); |
|
108 |
|
109 // reset invidual bit |
|
110 bubbleHeader->removeCallFlag( BubbleManager::Video ); |
|
111 bubbleHeader->removeCallFlag( BubbleManager::Normal ); // does nothing |
|
112 QVERIFY( bubbleHeader->callFlags() & BubbleManager::Diverted ); |
|
113 QVERIFY( !(bubbleHeader->callFlags() & BubbleManager::Video) ); |
|
114 QVERIFY( !(bubbleHeader->callFlags() & BubbleManager::NoCiphering) ); |
|
115 } |
|
116 |
|
117 void ut_BubbleHeader::testNumberType() |
|
118 { |
|
119 bubbleHeader->setNumberType( BubbleManager::Mobile ); |
|
120 QVERIFY( bubbleHeader->numberType() == BubbleManager::Mobile ); |
|
121 } |
|
122 |
|
123 void ut_BubbleHeader::testText() |
|
124 { |
|
125 bubbleHeader->setText( "Calling", Qt::ElideRight ); |
|
126 QVERIFY( bubbleHeader->text() == "Calling" ); |
|
127 QVERIFY( bubbleHeader->textClipDirection() == Qt::ElideRight ); |
|
128 |
|
129 bubbleHeader->setText( "", Qt::ElideLeft ); |
|
130 QVERIFY( bubbleHeader->text() == "" ); |
|
131 QVERIFY( bubbleHeader->textClipDirection() == Qt::ElideLeft ); |
|
132 } |
|
133 |
|
134 void ut_BubbleHeader::testCli() |
|
135 { |
|
136 bubbleHeader->setCli( "John Doe", Qt::ElideRight ); |
|
137 QVERIFY( bubbleHeader->cli() == "John Doe" ); |
|
138 QVERIFY( bubbleHeader->cliClipDirection() == Qt::ElideRight ); |
|
139 |
|
140 bubbleHeader->setCli( "+358501234567", Qt::ElideLeft ); |
|
141 QVERIFY( bubbleHeader->cli() == "+358501234567" ); |
|
142 QVERIFY( bubbleHeader->cliClipDirection() == Qt::ElideLeft ); |
|
143 } |
|
144 |
|
145 void ut_BubbleHeader::testSecondaryCli() |
|
146 { |
|
147 bubbleHeader->setSecondaryCli( "John Doe", Qt::ElideRight ); |
|
148 QVERIFY( bubbleHeader->secondaryCli() == "John Doe" ); |
|
149 QVERIFY( bubbleHeader->secondaryCliClipDirection() == Qt::ElideRight ); |
|
150 |
|
151 bubbleHeader->setSecondaryCli( "+358501234567", Qt::ElideLeft ); |
|
152 QVERIFY( bubbleHeader->secondaryCli() == "+358501234567" ); |
|
153 QVERIFY( bubbleHeader->secondaryCliClipDirection() == Qt::ElideLeft ); |
|
154 } |
|
155 |
|
156 void ut_BubbleHeader::testTimerCost() |
|
157 { |
|
158 bubbleHeader->setTimerCost( "10:01" ); |
|
159 QVERIFY( bubbleHeader->timerCost() == "10:01" ); |
|
160 } |
|
161 |
|
162 void ut_BubbleHeader::testCallImage() |
|
163 { |
|
164 bubbleHeader->setCallImage( "image.png" ); |
|
165 QVERIFY( bubbleHeader->callImage() == "image.png" ); |
|
166 } |
|
167 |
|
168 void ut_BubbleHeader::testAddActions() |
|
169 { |
|
170 for ( int i=0; i < 4; i++ ) |
|
171 { |
|
172 HbAction* action = new HbAction( "Test", this); |
|
173 bubbleHeader->addAction( action ); |
|
174 } |
|
175 |
|
176 QVERIFY( bubbleHeader->actions().count() == 4 ); |
|
177 |
|
178 bubbleHeader->clearActions(); |
|
179 } |
|
180 |
|
181 void ut_BubbleHeader::testIsConference() |
|
182 { |
|
183 QVERIFY( bubbleHeader->isConference() == false ); |
|
184 } |
|
185 |
|
186 void ut_BubbleHeader::testIsInConference() |
|
187 { |
|
188 bubbleHeader->setInConference(true); |
|
189 QVERIFY( bubbleHeader->isInConference() == true ); |
|
190 } |
|
191 |
|
192 void ut_BubbleHeader::testSetExpandAction() |
|
193 { |
|
194 HbAction* action = new HbAction( "Test", this); |
|
195 |
|
196 bubbleHeader->setExpandAction( action ); |
|
197 QVERIFY( bubbleHeader->expandAction() == action ); |
|
198 |
|
199 bubbleHeader->setExpandAction( 0 ); |
|
200 QVERIFY( bubbleHeader->expandAction() == 0 ); |
|
201 } |
|
202 |
|
203 void ut_BubbleHeader::testReset() |
|
204 { |
|
205 bubbleHeader->reset(); |
|
206 QVERIFY( bubbleHeader->isUsed() == false ); |
|
207 QVERIFY( bubbleHeader->bubbleId() == 1 ); |
|
208 QVERIFY( bubbleHeader->callState() == BubbleManager::None ); |
|
209 QVERIFY( bubbleHeader->callFlags() == 0 ); |
|
210 QVERIFY( bubbleHeader->numberType() == BubbleManager::NotSet ); |
|
211 QVERIFY( bubbleHeader->cli() == "" ); |
|
212 QVERIFY( bubbleHeader->secondaryCli() == "" ); |
|
213 QVERIFY( bubbleHeader->timerCost() == "" ); |
|
214 QVERIFY( bubbleHeader->callImage() == "" ); |
|
215 QVERIFY( bubbleHeader->isInConference() == false ); |
|
216 } |
|
217 |
|
218 BUBBLE_TEST_MAIN(ut_BubbleHeader) |
|
219 #include "ut_bubbleheader.moc" |