|
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 |
|
28 #include "bubbletest.h" |
|
29 #include "bubbleheadingwidget.h" |
|
30 #include "bubbleheader.h" |
|
31 #include "bubblemanagerif.h" |
|
32 |
|
33 class ut_BubbleHeadingWidget : public QObject |
|
34 { |
|
35 Q_OBJECT |
|
36 |
|
37 private slots: |
|
38 void initTestCase(); |
|
39 void cleanupTestCase(); |
|
40 void cleanupTest(); |
|
41 |
|
42 void testThreeLinedHeading(); |
|
43 void testTwoLinedHeading(); |
|
44 void testOneLinedHeading(); |
|
45 |
|
46 //void testInvalidStylePlugin(); |
|
47 |
|
48 private: |
|
49 BubbleHeadingWidget* mHeading; |
|
50 HbMainWindow* mMainWindow; |
|
51 int mStyleBaseId; |
|
52 }; |
|
53 |
|
54 void ut_BubbleHeadingWidget::initTestCase() |
|
55 { |
|
56 mMainWindow = new HbMainWindow(); |
|
57 mHeading = new BubbleHeadingWidget(BUBBLE_STYLE_PLUGIN); |
|
58 mMainWindow->addView(mHeading); |
|
59 mMainWindow->show(); |
|
60 } |
|
61 |
|
62 void ut_BubbleHeadingWidget::cleanupTestCase() |
|
63 { |
|
64 delete mMainWindow; |
|
65 } |
|
66 |
|
67 void ut_BubbleHeadingWidget::cleanupTest() |
|
68 { |
|
69 mHeading->hide(); |
|
70 mHeading->reset(); |
|
71 } |
|
72 |
|
73 void ut_BubbleHeadingWidget::testThreeLinedHeading() |
|
74 { |
|
75 BubbleHeader header; |
|
76 header.setCli("John Doe",Qt::ElideRight); |
|
77 header.setSecondaryCli("12345",Qt::ElideLeft); |
|
78 header.setText("",Qt::ElideRight); |
|
79 header.setTimerCost("0:00"); |
|
80 header.setCallState(BubbleManagerIF::Active); |
|
81 mHeading->setLineCount(3); |
|
82 Q_ASSERT(mHeading->lineCount()==3); |
|
83 mHeading->readBubbleHeader(header); |
|
84 mHeading->show(); |
|
85 QTest::qWait(100); |
|
86 mHeading->updateTimerDisplayNow(); |
|
87 } |
|
88 |
|
89 void ut_BubbleHeadingWidget::testTwoLinedHeading() |
|
90 { |
|
91 BubbleHeader header; |
|
92 header.setCli("John Doe",Qt::ElideRight); |
|
93 header.setSecondaryCli("12345",Qt::ElideLeft); |
|
94 header.setText("",Qt::ElideRight); |
|
95 header.setTimerCost("0:00"); |
|
96 header.setCallState(BubbleManagerIF::Active); |
|
97 |
|
98 mHeading->setLineCount(2); |
|
99 Q_ASSERT(mHeading->lineCount()==2); |
|
100 mHeading->readBubbleHeader(header); |
|
101 mHeading->show(); |
|
102 QTest::qWait(100); |
|
103 mHeading->updateTimerDisplayNow(); |
|
104 } |
|
105 |
|
106 void ut_BubbleHeadingWidget::testOneLinedHeading() |
|
107 { |
|
108 BubbleHeader header; |
|
109 header.setCli("John Doe",Qt::ElideRight); |
|
110 header.setSecondaryCli("12345",Qt::ElideLeft); |
|
111 header.setText("",Qt::ElideRight); |
|
112 header.setTimerCost("0:00"); |
|
113 header.setCallState(BubbleManagerIF::Active); |
|
114 |
|
115 mHeading->setLineCount(1); |
|
116 Q_ASSERT(mHeading->lineCount()==1); |
|
117 header.setCallState(BubbleManagerIF::OnHold); |
|
118 mHeading->readBubbleHeader(header); |
|
119 mHeading->show(); |
|
120 QTest::qWait(100); |
|
121 mHeading->updateTimerDisplayNow(); |
|
122 } |
|
123 |
|
124 /*void ut_BubbleHeadingWidget::testInvalidStylePlugin() |
|
125 { |
|
126 // this just shouldn't crash |
|
127 BubbleHeadingWidget *heading = |
|
128 new BubbleHeadingWidget("c:\foobar.dll"); |
|
129 HbView* view = mMainWindow->addView(heading); |
|
130 mMainWindow->setCurrentView(view); |
|
131 BubbleHeader header; |
|
132 header.setCli("John Doe",Qt::ElideRight); |
|
133 header.setSecondaryCli("12345",Qt::ElideLeft); |
|
134 header.setText("",Qt::ElideRight); |
|
135 header.setTimerCost("0:00"); |
|
136 header.setCallState(BubbleManagerIF::Active); |
|
137 heading->readBubbleHeader(header); |
|
138 heading->show(); |
|
139 }*/ |
|
140 |
|
141 BUBBLE_TEST_MAIN(ut_BubbleHeadingWidget) |
|
142 #include "ut_bubbleheadingwidget.moc" |