|
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 #include <hbmainwindow.h> |
|
25 #include <hbinstance.h> |
|
26 #include <hbstyle.h> |
|
27 #include <hbtextitem.h> |
|
28 #include <hbiconitem.h> |
|
29 |
|
30 #include "bubbletest.h" |
|
31 #include "bubbleheadingwidget.h" |
|
32 #include "bubbleheader.h" |
|
33 #include "bubblemanagerif.h" |
|
34 |
|
35 class ut_BubbleHeadingWidget : public QObject |
|
36 { |
|
37 Q_OBJECT |
|
38 |
|
39 private slots: |
|
40 void initTestCase(); |
|
41 void cleanupTestCase(); |
|
42 void cleanupTest(); |
|
43 |
|
44 void testThreeLinedHeading(); |
|
45 void testTwoLinedHeading(); |
|
46 void testOneLinedHeading(); |
|
47 |
|
48 private: |
|
49 BubbleHeadingWidget* mHeading; |
|
50 HbMainWindow* mMainWindow; |
|
51 |
|
52 HbTextItem* mText1; |
|
53 HbTextItem* mText2; |
|
54 HbTextItem* mText3; |
|
55 |
|
56 HbIconItem* mIndi1; |
|
57 HbIconItem* mIndi2; |
|
58 |
|
59 }; |
|
60 |
|
61 void ut_BubbleHeadingWidget::initTestCase() |
|
62 { |
|
63 mMainWindow = new HbMainWindow(); |
|
64 mHeading = new BubbleHeadingWidget(); |
|
65 mMainWindow->addView(mHeading); |
|
66 mMainWindow->show(); |
|
67 |
|
68 mText1 = qgraphicsitem_cast<HbTextItem*>( |
|
69 static_cast<HbWidget*>(mHeading)->primitive("text_line_1")); |
|
70 QVERIFY(mText1); |
|
71 mText2 = qgraphicsitem_cast<HbTextItem*>( |
|
72 static_cast<HbWidget*>(mHeading)->primitive("text_line_2")); |
|
73 QVERIFY(mText2); |
|
74 mText3 = qgraphicsitem_cast<HbTextItem*>( |
|
75 static_cast<HbWidget*>(mHeading)->primitive("text_line_3")); |
|
76 QVERIFY(mText3); |
|
77 |
|
78 mIndi1 = qgraphicsitem_cast<HbIconItem*>( |
|
79 static_cast<HbWidget*>(mHeading)->primitive("indicator_icon_1")); |
|
80 QVERIFY(mIndi1); |
|
81 mIndi2 = qgraphicsitem_cast<HbIconItem*>( |
|
82 static_cast<HbWidget*>(mHeading)->primitive("indicator_icon_2")); |
|
83 QVERIFY(mIndi2); |
|
84 } |
|
85 |
|
86 void ut_BubbleHeadingWidget::cleanupTestCase() |
|
87 { |
|
88 delete mMainWindow; |
|
89 } |
|
90 |
|
91 void ut_BubbleHeadingWidget::cleanupTest() |
|
92 { |
|
93 mHeading->hide(); |
|
94 mHeading->reset(); |
|
95 } |
|
96 |
|
97 void ut_BubbleHeadingWidget::testThreeLinedHeading() |
|
98 { |
|
99 mHeading->setLineCount(3); |
|
100 |
|
101 BubbleHeader header; |
|
102 header.setCli("John Doe",Qt::ElideRight); |
|
103 header.setSecondaryCli("12345",Qt::ElideLeft); |
|
104 header.setText("",Qt::ElideRight); |
|
105 header.setTimerCost("0:00"); |
|
106 header.setCallState(BubbleManagerIF::Active); |
|
107 header.setCallFlag(BubbleManagerIF::NoCiphering); |
|
108 QVERIFY(mHeading->lineCount()==3); |
|
109 mHeading->readBubbleHeader(header); |
|
110 mHeading->show(); |
|
111 QTest::qWait(200); |
|
112 QVERIFY(mHeading->layout()=="three_lines_1"); |
|
113 |
|
114 QVERIFY(mText1->text()=="John Doe"); |
|
115 QVERIFY(mText2->text()=="12345"); |
|
116 QVERIFY(mText2->alignment()&Qt::AlignLeft); |
|
117 QVERIFY(mText3->text()=="0:00"); |
|
118 |
|
119 header.setTimerCost("0:01"); |
|
120 mHeading->updateTimerDisplayNow(); |
|
121 QVERIFY(mText3->text()=="0:01"); |
|
122 |
|
123 header.setCallState(BubbleManagerIF::Incoming); |
|
124 header.setCallFlag(BubbleManagerIF::NoCiphering); |
|
125 header.setCallFlag(BubbleManagerIF::Diverted); |
|
126 mHeading->readBubbleHeader(header); |
|
127 mHeading->show(); |
|
128 QTest::qWait(200); |
|
129 QVERIFY(mHeading->layout()=="three_lines_2"); |
|
130 |
|
131 header.setCallFlags(BubbleManagerIF::Normal); |
|
132 mHeading->readBubbleHeader(header); |
|
133 mHeading->show(); |
|
134 QTest::qWait(200); |
|
135 QVERIFY(mHeading->layout()=="three_lines"); |
|
136 } |
|
137 |
|
138 void ut_BubbleHeadingWidget::testTwoLinedHeading() |
|
139 { |
|
140 mHeading->setLineCount(2); |
|
141 |
|
142 BubbleHeader header; |
|
143 header.setCli("John Doe",Qt::ElideRight); |
|
144 header.setSecondaryCli("12345",Qt::ElideLeft); |
|
145 header.setText("",Qt::ElideRight); |
|
146 header.setTimerCost("0:00"); |
|
147 header.setCallState(BubbleManagerIF::Active); |
|
148 header.setCallFlag(BubbleManagerIF::NoCiphering); |
|
149 QVERIFY(mHeading->lineCount()==2); |
|
150 mHeading->readBubbleHeader(header); |
|
151 mHeading->show(); |
|
152 QTest::qWait(200); |
|
153 QVERIFY(mHeading->layout()=="two_lines_1"); |
|
154 |
|
155 QVERIFY(mText1->text()=="John Doe"); |
|
156 QVERIFY(mText2->text()=="0:00"); |
|
157 QVERIFY(mText2->alignment()&Qt::AlignLeft); |
|
158 QVERIFY(!mText3->isVisible()); |
|
159 |
|
160 header.setTimerCost("0:01"); |
|
161 mHeading->updateTimerDisplayNow(); |
|
162 QVERIFY(mText2->text()=="0:01"); |
|
163 |
|
164 header.setCallState(BubbleManagerIF::Incoming); |
|
165 header.setCallFlag(BubbleManagerIF::NoCiphering); |
|
166 header.setCallFlag(BubbleManagerIF::Diverted); |
|
167 mHeading->readBubbleHeader(header); |
|
168 mHeading->show(); |
|
169 QTest::qWait(200); |
|
170 QVERIFY(mHeading->layout()=="two_lines_2"); |
|
171 |
|
172 header.setCallFlags(BubbleManagerIF::Normal); |
|
173 mHeading->readBubbleHeader(header); |
|
174 mHeading->show(); |
|
175 QTest::qWait(200); |
|
176 QVERIFY(mHeading->layout()=="two_lines"); |
|
177 |
|
178 } |
|
179 |
|
180 void ut_BubbleHeadingWidget::testOneLinedHeading() |
|
181 { |
|
182 mHeading->setLineCount(1); |
|
183 |
|
184 BubbleHeader header; |
|
185 header.setCli("John Doe",Qt::ElideRight); |
|
186 header.setSecondaryCli("12345",Qt::ElideLeft); |
|
187 header.setText("",Qt::ElideRight); |
|
188 header.setTimerCost("0:00"); |
|
189 header.setCallState(BubbleManagerIF::Active); |
|
190 header.setCallFlag(BubbleManagerIF::NoCiphering); |
|
191 QVERIFY(mHeading->lineCount()==1); |
|
192 mHeading->readBubbleHeader(header); |
|
193 mHeading->show(); |
|
194 QTest::qWait(200); |
|
195 QVERIFY(mHeading->layout()=="one_line_1"); |
|
196 QVERIFY(mText1->text()=="John Doe"); |
|
197 QVERIFY(mText2->text()=="0:00"); |
|
198 QVERIFY(mText2->alignment()&Qt::AlignRight); |
|
199 QVERIFY(!mText3->isVisible()); |
|
200 |
|
201 header.setTimerCost("0:01"); |
|
202 mHeading->updateTimerDisplayNow(); |
|
203 QVERIFY(mText2->text()=="0:01"); |
|
204 |
|
205 header.setCallState(BubbleManagerIF::Incoming); |
|
206 header.setCallFlag(BubbleManagerIF::NoCiphering); |
|
207 header.setCallFlag(BubbleManagerIF::Diverted); |
|
208 mHeading->hide(); |
|
209 mHeading->readBubbleHeader(header); |
|
210 mHeading->show(); |
|
211 QTest::qWait(200); |
|
212 QVERIFY(mHeading->layout()=="one_line_2"); |
|
213 QVERIFY(mText2->alignment()&Qt::AlignRight); |
|
214 |
|
215 header.setCallFlags(BubbleManagerIF::Normal); |
|
216 mHeading->hide(); |
|
217 mHeading->readBubbleHeader(header); |
|
218 mHeading->show(); |
|
219 QTest::qWait(200); |
|
220 QVERIFY(mHeading->layout()=="one_line"); |
|
221 QVERIFY(mText2->alignment()&Qt::AlignRight); |
|
222 } |
|
223 |
|
224 BUBBLE_TEST_MAIN(ut_BubbleHeadingWidget) |
|
225 #include "ut_bubbleheadingwidget.moc" |