|
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 <QGraphicsWidget> |
|
19 #include <QSqlDatabase> |
|
20 #include <HbInstance> |
|
21 #include <HbPanGesture> |
|
22 |
|
23 #include "t_hsdomainmodel.h" |
|
24 #include "hsdomainmodeldatastructures.h" |
|
25 #include "hswidgethost.h" |
|
26 #include "hswidgethostvisual.h" |
|
27 #include "hspage.h" |
|
28 #include "hsscene.h" |
|
29 #include "hswidgettoucharea.h" |
|
30 #include "hshostedwidgetfactory.h" |
|
31 #include "hsconfiguration.h" |
|
32 |
|
33 void TestHsDomainModel::testHsWidgetHostVisualConstruction() |
|
34 { |
|
35 HsWidgetHostVisual *visual = new HsWidgetHostVisual(); |
|
36 |
|
37 QVERIFY(visual); |
|
38 QVERIFY(!visual->mWidget); |
|
39 delete visual; |
|
40 } |
|
41 |
|
42 |
|
43 void TestHsDomainModel::testHsWidgetHostVisualShape() |
|
44 { |
|
45 HsWidgetData data; |
|
46 data.pageId = 0; |
|
47 data.uri = "mockwidgetplugin"; |
|
48 HsWidgetHost *host = HsWidgetHost::createInstance(data); |
|
49 |
|
50 host->startWidget(); |
|
51 QPainterPath path = host->visual()->shape(); |
|
52 QCOMPARE(path.boundingRect(),QRectF(QPointF(0,0), HsConfiguration::instance()->minimumWidgetSizeInPixels())); |
|
53 |
|
54 host->visual()->mWidget->resize(QSizeF(100,100)); |
|
55 path = host->visual()->shape(); |
|
56 QCOMPARE(path.boundingRect(),QRectF(0,0,100,100)); |
|
57 |
|
58 |
|
59 host->remove(); |
|
60 |
|
61 data.pageId = 0; |
|
62 data.uri = "mockwidgetplugintoobig"; |
|
63 host = HsWidgetHost::createInstance(data); |
|
64 host->startWidget(); |
|
65 path = host->visual()->shape(); |
|
66 QCOMPARE(path.boundingRect(),QRectF(QPointF(0,0), HsConfiguration::instance()->maximumWidgetSizeInPixels())); |
|
67 host->remove(); |
|
68 } |
|
69 |
|
70 void TestHsDomainModel::testHsWidgetHostVisualSetWidget() |
|
71 { |
|
72 QObject *widget = HsHostedWidgetFactory::instance()->createWidget("mockwidgetplugin"); |
|
73 HsWidgetHostVisual *visual = new HsWidgetHostVisual(); |
|
74 visual->setWidget(widget); |
|
75 QVERIFY(visual->mWidget == widget); |
|
76 delete visual; |
|
77 } |
|
78 |
|
79 void TestHsDomainModel::testHsWidgetHostVisualSetVisualModel() |
|
80 { |
|
81 HsWidgetHost *host = new HsWidgetHost(-1); |
|
82 HsWidgetHostVisual *visual = new HsWidgetHostVisual(); |
|
83 visual->setVisualModel(host); |
|
84 QVERIFY(visual->mVisualModel == host); |
|
85 delete visual; |
|
86 host->remove(); |
|
87 } |
|
88 |
|
89 void TestHsDomainModel::testHsWidgetHostVisualEffects() |
|
90 { |
|
91 HsWidgetData data; |
|
92 data.pageId = 0; |
|
93 data.uri = "mockwidgetplugin"; |
|
94 HsWidgetHost *host = HsWidgetHost::createInstance(data); |
|
95 |
|
96 host->startWidget(); |
|
97 host->visual()->startDragEffect(); |
|
98 host->visual()->startDropEffect(); |
|
99 host->remove(); |
|
100 } |
|
101 |
|
102 |
|
103 void TestHsDomainModel::testHsWidgetHostVisualEventFilter() |
|
104 { |
|
105 HsWidgetHostVisual *visual = new HsWidgetHostVisual(); |
|
106 QSignalSpy resizedSpy(visual, SIGNAL(resized())); |
|
107 QEvent *someEvent = new QEvent(QEvent::ApplicationActivated); |
|
108 visual->eventFilter(0, someEvent); |
|
109 QCOMPARE(resizedSpy.count(), 0); |
|
110 delete visual; |
|
111 delete someEvent; |
|
112 } |
|
113 |
|
114 |
|
115 void TestHsDomainModel::testHsWidgetHostVisualGestureEvent() |
|
116 { |
|
117 HsWidgetHostVisual *visual = new HsWidgetHostVisual(); |
|
118 QList<QGesture*> gestureList; |
|
119 |
|
120 // test empty gesture list |
|
121 visual->gestureEvent(new QGestureEvent(gestureList)); |
|
122 |
|
123 // test pan |
|
124 HbPanGesture *panGesture = new HbPanGesture(); |
|
125 gestureList << panGesture; |
|
126 QGestureEvent *gestureEvent = new QGestureEvent(gestureList); |
|
127 visual->gestureEvent(gestureEvent); |
|
128 |
|
129 delete panGesture; |
|
130 delete visual; |
|
131 } |
|
132 |
|
133 void TestHsDomainModel::testHsWidgetHostVisualSetupTouchArea() |
|
134 { |
|
135 HsWidgetHostVisual *visual = new HsWidgetHostVisual(); |
|
136 visual->setupTouchArea(); |
|
137 delete visual; |
|
138 } |
|
139 |
|
140 void TestHsDomainModel::testHsWidgetHostVisualSetupEffects() |
|
141 { |
|
142 HsWidgetHostVisual *visual = new HsWidgetHostVisual(); |
|
143 visual->setupEffects(); |
|
144 delete visual; |
|
145 } |
|
146 |
|
147 void TestHsDomainModel::testHsWidgetHostVisualSetNewSize() |
|
148 { |
|
149 HsWidgetHostVisual *visual = new HsWidgetHostVisual(); |
|
150 visual->setNewSize(QSizeF(100,100)); |
|
151 QVERIFY(visual->size() == QSizeF(100,100)); |
|
152 delete visual; |
|
153 } |
|
154 |
|
155 |