70
|
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: Test class for CalenDayContentScrollArea
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include <QGraphicsItem>
|
|
18 |
#include <QGraphicsScene>
|
|
19 |
#include <QtTest/QtTest>
|
|
20 |
#include <QGesture>
|
|
21 |
|
|
22 |
#include <HbStyleLoader>
|
|
23 |
#include <HbWidget>
|
|
24 |
#include <HbSwipeGesture>
|
|
25 |
|
|
26 |
#define private public
|
|
27 |
#define protected public
|
|
28 |
|
|
29 |
#include "calendaycontentscrollarea.h"
|
|
30 |
|
|
31 |
// Test variables
|
|
32 |
qreal gTestScrollAreaWidth = 300;
|
|
33 |
qreal gTestScrollAreaHeight = 200;
|
|
34 |
QRectF gTestWindowRect = QRectF(0, 0, gTestScrollAreaWidth, gTestScrollAreaHeight);
|
|
35 |
Qt::Orientation gTestOrientation = Qt::Vertical;
|
|
36 |
Qt::GestureState gTestGestureState = Qt::NoGesture;
|
|
37 |
qreal gTestSceneSwipeAngle = 0.0;
|
|
38 |
QSwipeGesture::SwipeDirection gTestSceneHorizontalDirection = QSwipeGesture::NoDirection;
|
|
39 |
|
|
40 |
class TestCalenDayContentScrollArea : public QObject
|
|
41 |
{
|
|
42 |
Q_OBJECT
|
|
43 |
|
|
44 |
public:
|
|
45 |
TestCalenDayContentScrollArea();
|
|
46 |
virtual ~TestCalenDayContentScrollArea();
|
|
47 |
|
|
48 |
private slots:
|
|
49 |
void initTestCase();
|
|
50 |
void cleanupTestCase();
|
|
51 |
void init();
|
|
52 |
void cleanup();
|
|
53 |
|
|
54 |
void testConstructors();
|
|
55 |
void testScrollToMiddleWidget();
|
|
56 |
void testScrollByAmount();
|
|
57 |
void testGestureEvent();
|
|
58 |
void testEventFilter();
|
|
59 |
void testEvent();
|
|
60 |
void testMoveTo();
|
|
61 |
void testHorizontalSwipe();
|
|
62 |
void testMoveFinished();
|
|
63 |
void testOrientationChanged();
|
81
|
64 |
void testCheckPanDirection();
|
|
65 |
void testSetGetDisallowedScrollDirection();
|
70
|
66 |
|
|
67 |
private:
|
|
68 |
CalenDayContentScrollArea *mContentScrollArea;
|
|
69 |
};
|
|
70 |
|
|
71 |
/*!
|
|
72 |
Constructor
|
|
73 |
*/
|
|
74 |
TestCalenDayContentScrollArea::TestCalenDayContentScrollArea() :
|
|
75 |
mContentScrollArea(NULL)
|
|
76 |
{
|
|
77 |
|
|
78 |
}
|
|
79 |
|
|
80 |
/*!
|
|
81 |
Destructor
|
|
82 |
*/
|
|
83 |
TestCalenDayContentScrollArea::~TestCalenDayContentScrollArea()
|
|
84 |
{
|
|
85 |
|
|
86 |
}
|
|
87 |
|
|
88 |
/*!
|
|
89 |
Called before testcase
|
|
90 |
*/
|
|
91 |
void TestCalenDayContentScrollArea::initTestCase()
|
|
92 |
{
|
|
93 |
HbStyleLoader::registerFilePath(":/calendayhourelement.css");
|
|
94 |
HbStyleLoader::registerFilePath(":/calendayhourelement.widgetml");
|
|
95 |
HbStyleLoader::registerFilePath(":/calendayitem.css");
|
|
96 |
HbStyleLoader::registerFilePath(":/calendayitem.widgetml");
|
|
97 |
HbStyleLoader::registerFilePath(":/calendayeventspane.css");
|
|
98 |
}
|
|
99 |
|
|
100 |
/*!
|
|
101 |
Called after testcase
|
|
102 |
*/
|
|
103 |
void TestCalenDayContentScrollArea::cleanupTestCase()
|
|
104 |
{
|
|
105 |
|
|
106 |
}
|
|
107 |
|
|
108 |
/*!
|
|
109 |
Called before every function
|
|
110 |
*/
|
|
111 |
void TestCalenDayContentScrollArea::init()
|
|
112 |
{
|
|
113 |
// Create and configure scroll area
|
|
114 |
mContentScrollArea = new CalenDayContentScrollArea();
|
|
115 |
mContentScrollArea->setScrollDirections(Qt::Horizontal | Qt::Vertical);
|
|
116 |
mContentScrollArea->resize(gTestScrollAreaWidth, gTestScrollAreaHeight);
|
|
117 |
|
|
118 |
// Create and set content widget
|
|
119 |
qreal contentWidth = mContentScrollArea->mContentWidth;
|
|
120 |
HbWidget *contentWidget = new HbWidget();
|
|
121 |
contentWidget->resize(3*contentWidth, 2*gTestScrollAreaHeight);
|
|
122 |
mContentScrollArea->setContentWidget(contentWidget);
|
|
123 |
}
|
|
124 |
|
|
125 |
/*!
|
|
126 |
Called after everyfunction
|
|
127 |
*/
|
|
128 |
void TestCalenDayContentScrollArea::cleanup()
|
|
129 |
{
|
|
130 |
if (mContentScrollArea) {
|
|
131 |
delete mContentScrollArea;
|
|
132 |
mContentScrollArea = NULL;
|
|
133 |
}
|
|
134 |
}
|
|
135 |
|
|
136 |
/*!
|
|
137 |
Test function for constructors
|
|
138 |
1. Test if content scroll area is not initialized
|
|
139 |
2. Test if content scroll area is correcty created
|
|
140 |
*/
|
|
141 |
void TestCalenDayContentScrollArea::testConstructors()
|
|
142 |
{
|
|
143 |
//1)
|
|
144 |
CalenDayContentScrollArea *testContentScrollArea = 0;
|
|
145 |
QVERIFY(!testContentScrollArea);
|
|
146 |
|
|
147 |
testContentScrollArea = new CalenDayContentScrollArea();
|
|
148 |
QVERIFY(testContentScrollArea);
|
|
149 |
|
|
150 |
delete testContentScrollArea;
|
|
151 |
}
|
|
152 |
|
|
153 |
/*!
|
|
154 |
Test function for scrollToMiddleWidget
|
|
155 |
1. Test if content widget is available
|
|
156 |
2. Test initial position of content widget
|
|
157 |
3. Test the position of content widget after scrolling
|
|
158 |
*/
|
|
159 |
void TestCalenDayContentScrollArea::testScrollToMiddleWidget()
|
|
160 |
{
|
|
161 |
//1)
|
|
162 |
QVERIFY(mContentScrollArea->contentWidget());
|
|
163 |
|
|
164 |
//2)
|
|
165 |
QPointF pos = mContentScrollArea->contentWidget()->pos();
|
|
166 |
QCOMPARE(pos.x(), abs(0.0));
|
|
167 |
QCOMPARE(pos.y(), abs(0.0));
|
|
168 |
|
|
169 |
//3)
|
|
170 |
qreal contentWidth = mContentScrollArea->mContentWidth;
|
|
171 |
mContentScrollArea->scrollToMiddleWidget();
|
|
172 |
pos = mContentScrollArea->contentWidget()->pos();
|
|
173 |
QCOMPARE(abs(pos.x()), abs(contentWidth));
|
|
174 |
QCOMPARE(abs(pos.y()), abs(0.0));
|
|
175 |
}
|
|
176 |
|
|
177 |
/*!
|
|
178 |
Test function for scrollToMiddleWidget
|
|
179 |
1. Test if content widget is available
|
|
180 |
2. Test initial position of content widget
|
|
181 |
3. Test the position of content widget after vertical gesture
|
|
182 |
4. Test the position of content widget after horizontal gesture
|
|
183 |
5. Test the position of content widget after non-specified gesture
|
|
184 |
*/
|
|
185 |
void TestCalenDayContentScrollArea::testScrollByAmount()
|
|
186 |
{
|
|
187 |
//1)
|
|
188 |
QVERIFY(mContentScrollArea->contentWidget());
|
|
189 |
|
|
190 |
//2)
|
|
191 |
QPointF pos = mContentScrollArea->contentWidget()->pos();
|
|
192 |
QCOMPARE(abs(pos.x()), abs(0.0));
|
|
193 |
QCOMPARE(abs(pos.y()), abs(0.0));
|
|
194 |
|
|
195 |
//3)
|
|
196 |
QPointF delta(50.0, 25.0);
|
|
197 |
mContentScrollArea->mPanDayDirection
|
|
198 |
= CalenDayContentScrollArea::ECalenPanVertical;
|
|
199 |
mContentScrollArea->scrollByAmount(delta);
|
|
200 |
pos = mContentScrollArea->contentWidget()->pos();
|
|
201 |
QCOMPARE(abs(pos.x()), abs(0.0));
|
|
202 |
QCOMPARE(abs(pos.y()), abs(delta.y()));
|
|
203 |
|
|
204 |
//4)
|
|
205 |
mContentScrollArea->mPanDayDirection
|
|
206 |
= CalenDayContentScrollArea::ECalenPanHorizontal;
|
|
207 |
mContentScrollArea->scrollByAmount(delta);
|
|
208 |
pos = mContentScrollArea->contentWidget()->pos();
|
|
209 |
QCOMPARE(abs(pos.x()), abs(delta.x()));
|
|
210 |
QCOMPARE(abs(pos.y()), abs(delta.y()));
|
|
211 |
|
|
212 |
//5)
|
|
213 |
QPointF newDelta(5.0, 5.0);
|
|
214 |
delta += newDelta;
|
|
215 |
mContentScrollArea->mPanDayDirection
|
|
216 |
= CalenDayContentScrollArea::ECalenPanNotSet;
|
|
217 |
mContentScrollArea->scrollByAmount(newDelta);
|
|
218 |
pos = mContentScrollArea->contentWidget()->pos();
|
|
219 |
QCOMPARE(abs(pos.x()), abs(delta.x()));
|
|
220 |
QCOMPARE(abs(pos.y()), abs(delta.y()));
|
|
221 |
}
|
|
222 |
|
|
223 |
/*!
|
|
224 |
Test function for gestureEvent
|
|
225 |
1. Call gestureEvent with QPanGesture (nothing should happen)
|
|
226 |
2. Call gestureEvent with HbSwipeGesture, vertical movement
|
|
227 |
KCalenSwipeAngle < angle < 180 - KCalenSwipeAngle
|
|
228 |
3. Call gestureEvent with HbSwipeGesture, horizontal movement right
|
|
229 |
angle < KCalenSwipeAngle
|
|
230 |
4. Call gestureEvent with HbSwipeGesture, horizontal movement left
|
|
231 |
180.0 - KCalenSwipeAngle < angle < 180.0
|
|
232 |
*/
|
|
233 |
void TestCalenDayContentScrollArea::testGestureEvent()
|
|
234 |
{
|
|
235 |
QGestureEvent *gestureEvent = NULL;
|
|
236 |
mContentScrollArea->mMoveDirection = ECalenScrollNoDayChange;
|
|
237 |
|
|
238 |
//1)
|
|
239 |
QList<QGesture*> list;
|
|
240 |
QPanGesture *panGesture = new QPanGesture();
|
|
241 |
list.append(panGesture);
|
|
242 |
gestureEvent = new QGestureEvent(list);
|
|
243 |
mContentScrollArea->gestureEvent(gestureEvent);
|
|
244 |
QCOMPARE(mContentScrollArea->mMoveDirection, ECalenScrollNoDayChange);
|
|
245 |
|
|
246 |
delete gestureEvent;
|
|
247 |
gestureEvent = NULL;
|
|
248 |
|
|
249 |
//2)
|
|
250 |
HbSwipeGesture *swipeGesture = new HbSwipeGesture();
|
|
251 |
list.append(swipeGesture);
|
|
252 |
gTestGestureState = Qt::GestureStarted;
|
|
253 |
gTestSceneSwipeAngle = KCalenSwipeAngle + 1.0;
|
|
254 |
gestureEvent = new QGestureEvent(list);
|
|
255 |
mContentScrollArea->gestureEvent(gestureEvent);
|
|
256 |
QCOMPARE(mContentScrollArea->mMoveDirection, ECalenScrollNoDayChange);
|
|
257 |
|
|
258 |
//3)
|
|
259 |
gTestGestureState = Qt::GestureStarted;
|
|
260 |
gTestSceneSwipeAngle = KCalenSwipeAngle - 1.0;
|
|
261 |
gTestSceneHorizontalDirection = QSwipeGesture::Right;
|
|
262 |
mContentScrollArea->gestureEvent(gestureEvent);
|
|
263 |
QCOMPARE(mContentScrollArea->mMoveDirection, ECalenScrollToPrev);
|
|
264 |
|
|
265 |
//4)
|
|
266 |
gTestGestureState = Qt::GestureStarted;
|
|
267 |
gTestSceneSwipeAngle = 180.0 - KCalenSwipeAngle + 1.0;
|
|
268 |
gTestSceneHorizontalDirection = QSwipeGesture::Left;
|
|
269 |
mContentScrollArea->gestureEvent(gestureEvent);
|
|
270 |
QCOMPARE(mContentScrollArea->mMoveDirection, ECalenScrollToNext);
|
|
271 |
|
|
272 |
delete gestureEvent;
|
|
273 |
}
|
|
274 |
|
|
275 |
/*!
|
|
276 |
Test function for eventFilter
|
|
277 |
1. Call eventFilter with event type: None
|
|
278 |
2. Call eventFilter with event type: Gesture, scroll area is moving
|
|
279 |
3. Call eventFilter with event type: Gesture, scroll area area not moving,
|
|
280 |
swipe gesture
|
|
281 |
*/
|
|
282 |
void TestCalenDayContentScrollArea::testEventFilter()
|
|
283 |
{
|
|
284 |
bool result = false;
|
|
285 |
|
|
286 |
//1)
|
|
287 |
QEvent noneEvent(QEvent::None);
|
|
288 |
result = mContentScrollArea->eventFilter(NULL, &noneEvent);
|
|
289 |
QVERIFY(!result); //false
|
|
290 |
|
|
291 |
//2)
|
|
292 |
QEvent gestureEvent(QEvent::Gesture);
|
|
293 |
mContentScrollArea->mIsMoving = true;
|
|
294 |
result = mContentScrollArea->eventFilter(NULL, &gestureEvent);
|
|
295 |
QVERIFY(result); //true
|
|
296 |
|
|
297 |
//3)
|
|
298 |
QSwipeGesture *swipeGesture = new QSwipeGesture();
|
|
299 |
QList<QGesture*> list;
|
|
300 |
list.append(swipeGesture);
|
|
301 |
QGestureEvent *gesture = new QGestureEvent(list);
|
|
302 |
QEvent *swipeGestureEvent = static_cast <QEvent*> (gesture);
|
|
303 |
|
|
304 |
mContentScrollArea->mIsMoving = false;
|
|
305 |
result = mContentScrollArea->eventFilter(NULL, swipeGestureEvent);
|
|
306 |
QVERIFY(result); //true
|
|
307 |
|
|
308 |
delete gesture;
|
|
309 |
}
|
|
310 |
|
|
311 |
/*!
|
|
312 |
Test function for event
|
|
313 |
1. Test event type: Gesture, scroll area not moving
|
|
314 |
2. Test event type: Gesture, scroll area is moving
|
|
315 |
3. Test event type: FocusOut, scroll area not moving
|
|
316 |
4. Test event type: FocusOut, scroll area is moving
|
|
317 |
5. Test event type: FocusIn, scroll area not moving
|
|
318 |
6. Test event type: FocusIn, scroll area is moving
|
|
319 |
7. Test event type: LayoutRequest
|
|
320 |
*/
|
|
321 |
void TestCalenDayContentScrollArea::testEvent()
|
|
322 |
{
|
|
323 |
bool result = false;
|
|
324 |
|
|
325 |
//1)
|
|
326 |
QEvent gestureEvent(QEvent::Gesture);
|
|
327 |
mContentScrollArea->mIsMoving = false;
|
|
328 |
result = mContentScrollArea->event(&gestureEvent);
|
|
329 |
QVERIFY(!result); //false
|
|
330 |
|
|
331 |
//2)
|
|
332 |
mContentScrollArea->mIsMoving = true;
|
|
333 |
result = mContentScrollArea->event(&gestureEvent);
|
|
334 |
QVERIFY(result); //true
|
|
335 |
|
|
336 |
//3)
|
|
337 |
QEvent focusOutEvent(QEvent::FocusOut);
|
|
338 |
mContentScrollArea->mIsMoving = false;
|
|
339 |
result = mContentScrollArea->event(&focusOutEvent);
|
|
340 |
QVERIFY(!result); //false
|
|
341 |
|
|
342 |
//4)
|
|
343 |
mContentScrollArea->mIsMoving = true;
|
|
344 |
result = mContentScrollArea->event(&focusOutEvent);
|
|
345 |
QVERIFY(result); //true
|
|
346 |
|
|
347 |
//5)
|
|
348 |
QEvent focusInEvent(QEvent::FocusIn);
|
|
349 |
mContentScrollArea->mIsMoving = false;
|
|
350 |
result = mContentScrollArea->event(&focusInEvent);
|
|
351 |
QVERIFY(!result); //false
|
|
352 |
|
|
353 |
//6)
|
|
354 |
mContentScrollArea->mIsMoving = true;
|
|
355 |
result = mContentScrollArea->event(&focusInEvent);
|
|
356 |
QVERIFY(result); //true
|
|
357 |
|
|
358 |
//7)
|
|
359 |
QEvent layoutReqEvent(QEvent::LayoutRequest);
|
|
360 |
QPointF oldPos = mContentScrollArea->contentWidget()->pos();
|
|
361 |
mContentScrollArea->event(&layoutReqEvent);
|
|
362 |
QPointF pos = mContentScrollArea->contentWidget()->pos();
|
|
363 |
QCOMPARE(oldPos == pos, false);
|
|
364 |
}
|
|
365 |
|
|
366 |
/*!
|
|
367 |
Test function for moveTo
|
|
368 |
1. Test moveTo, day not changed
|
|
369 |
2. Test moveTo, day changed to next
|
|
370 |
3. Test moveTo, day changed to prev
|
81
|
371 |
4. Test moveTo, disallowed directon
|
70
|
372 |
*/
|
|
373 |
void TestCalenDayContentScrollArea::testMoveTo()
|
|
374 |
{
|
|
375 |
#ifndef __WINSCW__
|
|
376 |
//1)
|
|
377 |
mContentScrollArea->mMoveDirection = ECalenScrollNoDayChange;
|
|
378 |
QPointF newPos(10,0);
|
|
379 |
mContentScrollArea->moveTo(newPos);
|
|
380 |
QPointF pos = mContentScrollArea->contentWidget()->pos();
|
|
381 |
QCOMPARE(abs(pos.x()), abs(mContentScrollArea->contentWidget()->pos().x()));
|
|
382 |
QCOMPARE(abs(pos.y()), abs(mContentScrollArea->contentWidget()->pos().y()));
|
|
383 |
|
|
384 |
//2)
|
|
385 |
newPos = QPointF(20,0);
|
|
386 |
mContentScrollArea->mMoveDirection = ECalenScrollToNext;
|
|
387 |
mContentScrollArea->moveTo(newPos);
|
|
388 |
pos = mContentScrollArea->contentWidget()->pos();
|
|
389 |
QCOMPARE(abs(pos.x()), abs(mContentScrollArea->contentWidget()->pos().x()));
|
|
390 |
QCOMPARE(abs(pos.y()), abs(mContentScrollArea->contentWidget()->pos().y()));
|
|
391 |
QCOMPARE(mContentScrollArea->mMoveDirection, ECalenScrollNoDayChange);
|
|
392 |
|
81
|
393 |
//3)
|
70
|
394 |
newPos = QPointF(-20,0);
|
|
395 |
mContentScrollArea->mMoveDirection = ECalenScrollToNext;
|
|
396 |
mContentScrollArea->moveTo(newPos);
|
|
397 |
pos = mContentScrollArea->contentWidget()->pos();
|
|
398 |
QCOMPARE(abs(mContentScrollArea->contentWidget()->pos().x()), abs(pos.x()));
|
|
399 |
QCOMPARE(abs(mContentScrollArea->contentWidget()->pos().y()), abs(pos.y()));
|
|
400 |
QCOMPARE(mContentScrollArea->mMoveDirection, ECalenScrollNoDayChange);
|
81
|
401 |
|
|
402 |
//4)
|
|
403 |
newPos = QPointF(20,0);
|
|
404 |
pos = mContentScrollArea->contentWidget()->pos();
|
|
405 |
mContentScrollArea->mDisallowedDirection = ECalenScrollToNext;
|
|
406 |
mContentScrollArea->mMoveDirection = ECalenScrollToNext;
|
|
407 |
mContentScrollArea->moveTo(newPos);
|
|
408 |
QCOMPARE(abs(mContentScrollArea->contentWidget()->pos().x()), abs(pos.x()));
|
|
409 |
QCOMPARE(abs(mContentScrollArea->contentWidget()->pos().y()), abs(pos.y()));
|
70
|
410 |
#endif /* __WINSCW__ */
|
|
411 |
}
|
|
412 |
|
|
413 |
/*!
|
|
414 |
Test function for checking if swipe is horizontal or not
|
|
415 |
1) test Horizontal swipe
|
|
416 |
2) test no horizontal swipe
|
|
417 |
*/
|
|
418 |
void TestCalenDayContentScrollArea::testHorizontalSwipe()
|
|
419 |
{
|
|
420 |
#ifndef __WINSCW__
|
|
421 |
//1)
|
|
422 |
QCOMPARE(mContentScrollArea->isHorizontalSwipe(KCalenSwipeAngle - 5), true);
|
|
423 |
|
|
424 |
//2)
|
|
425 |
QCOMPARE(mContentScrollArea->isHorizontalSwipe(KCalenSwipeAngle + 5), false);
|
|
426 |
#endif /* __WINSCW__ */
|
|
427 |
}
|
|
428 |
|
|
429 |
/*!
|
|
430 |
Test moveFinished slot
|
|
431 |
1) test moveFinished, no day change
|
|
432 |
2) test moveFinished, day changed to next
|
|
433 |
3) test moveFinished, day changed to prev
|
|
434 |
*/
|
|
435 |
void TestCalenDayContentScrollArea::testMoveFinished()
|
|
436 |
{
|
|
437 |
#ifndef __WINSCW__
|
|
438 |
//1)
|
|
439 |
mContentScrollArea->mMoveDirection = ECalenScrollNoDayChange;
|
|
440 |
mContentScrollArea->moveFinished();
|
|
441 |
QCOMPARE(mContentScrollArea->mMoveDirection, ECalenScrollNoDayChange);
|
|
442 |
|
|
443 |
//2)
|
|
444 |
mContentScrollArea->mMoveDirection = ECalenScrollToNext;
|
|
445 |
mContentScrollArea->moveFinished();
|
|
446 |
QCOMPARE(mContentScrollArea->mMoveDirection, ECalenScrollNoDayChange);
|
|
447 |
|
|
448 |
//3)
|
|
449 |
mContentScrollArea->mMoveDirection = ECalenScrollToPrev;
|
|
450 |
mContentScrollArea->moveFinished();
|
|
451 |
QCOMPARE(mContentScrollArea->mMoveDirection, ECalenScrollNoDayChange);
|
|
452 |
#endif /* __WINSCW__ */
|
|
453 |
}
|
|
454 |
|
|
455 |
/*!
|
|
456 |
Test orientationChanged slot
|
|
457 |
1) test orientation changed to horizontal
|
|
458 |
2) test orientation changed to vertical
|
|
459 |
*/
|
|
460 |
void TestCalenDayContentScrollArea::testOrientationChanged()
|
|
461 |
{
|
|
462 |
#ifndef __WINSCW__
|
|
463 |
//1)
|
|
464 |
mContentScrollArea->orientationChanged(Qt::Horizontal);
|
|
465 |
QCOMPARE(mContentScrollArea->mOrientation, Qt::Horizontal);
|
|
466 |
|
|
467 |
//2)
|
|
468 |
mContentScrollArea->orientationChanged(Qt::Vertical);
|
|
469 |
QCOMPARE(mContentScrollArea->mOrientation, Qt::Vertical);
|
|
470 |
#endif /* __WINSCW__ */
|
|
471 |
}
|
|
472 |
|
81
|
473 |
/*!
|
|
474 |
Test checkPanDirection function
|
|
475 |
1) test pan direction, gesture cancelled, vertical orientation
|
|
476 |
2) test pan direction, gesture started, vertical orientation, vertical movement
|
|
477 |
3) test pan direction, gesture started, vertical orientation, horizontal movement
|
|
478 |
4) test pan direction, gesture started, horizontal orientation, vertical movement
|
|
479 |
5) test pan direction, gesture started, horizontal orientation, horizontal movement
|
|
480 |
*/
|
|
481 |
void TestCalenDayContentScrollArea::testCheckPanDirection()
|
|
482 |
{
|
|
483 |
#ifndef __WINSCW__
|
|
484 |
QPanGesture *gesture = new QPanGesture();
|
|
485 |
|
|
486 |
//1)
|
|
487 |
gesture->setOffset(QPointF(10, 100));
|
|
488 |
gTestGestureState = Qt::GestureCanceled;
|
|
489 |
mContentScrollArea->mPanDayDirection = CalenDayContentScrollArea::ECalenPanNotSet;
|
|
490 |
mContentScrollArea->mOrientation = Qt::Vertical;
|
|
491 |
mContentScrollArea->checkPanDirection(gesture);
|
|
492 |
QCOMPARE(mContentScrollArea->mPanDayDirection, CalenDayContentScrollArea::ECalenPanNotSet);
|
|
493 |
|
|
494 |
// Cases 2-5 temporarily unavailable
|
|
495 |
/*
|
|
496 |
//2)
|
|
497 |
gesture->setOffset(QPointF(10, 100));
|
|
498 |
gTestGestureState = Qt::GestureStarted;
|
|
499 |
mContentScrollArea->mPanDayDirection = CalenDayContentScrollArea::ECalenPanNotSet;
|
|
500 |
mContentScrollArea->mOrientation = Qt::Vertical;
|
|
501 |
mContentScrollArea->checkPanDirection(gesture);
|
|
502 |
QCOMPARE(mContentScrollArea->mPanDayDirection, CalenDayContentScrollArea::ECalenPanVertical);
|
|
503 |
|
|
504 |
//3)
|
|
505 |
gesture->setOffset(QPointF(100, 10));
|
|
506 |
gTestGestureState = Qt::GestureStarted;
|
|
507 |
mContentScrollArea->mPanDayDirection = CalenDayContentScrollArea::ECalenPanNotSet;
|
|
508 |
mContentScrollArea->mOrientation = Qt::Vertical;
|
|
509 |
mContentScrollArea->checkPanDirection(gesture);
|
|
510 |
QCOMPARE(mContentScrollArea->mPanDayDirection, CalenDayContentScrollArea::ECalenPanHorizontal);
|
|
511 |
|
|
512 |
//4)
|
|
513 |
gesture->setOffset(QPointF(10, 100));
|
|
514 |
gTestGestureState = Qt::GestureStarted;
|
|
515 |
mContentScrollArea->mPanDayDirection = CalenDayContentScrollArea::ECalenPanNotSet;
|
|
516 |
mContentScrollArea->mOrientation = Qt::Horizontal;
|
|
517 |
mContentScrollArea->checkPanDirection(gesture);
|
|
518 |
QCOMPARE(mContentScrollArea->mPanDayDirection, CalenDayContentScrollArea::ECalenPanHorizontal);
|
|
519 |
|
|
520 |
//5)
|
|
521 |
gesture->setOffset(QPointF(100, 10));
|
|
522 |
gTestGestureState = Qt::GestureStarted;
|
|
523 |
mContentScrollArea->mPanDayDirection = CalenDayContentScrollArea::ECalenPanNotSet;
|
|
524 |
mContentScrollArea->mOrientation = Qt::Horizontal;
|
|
525 |
mContentScrollArea->checkPanDirection(gesture);
|
|
526 |
QCOMPARE(mContentScrollArea->mPanDayDirection, CalenDayContentScrollArea::ECalenPanVertical);
|
|
527 |
*/
|
|
528 |
#endif /* __WINSCW__ */
|
|
529 |
}
|
|
530 |
|
|
531 |
/*!
|
|
532 |
Test setter and getter for disallowed direction
|
|
533 |
1) test setter
|
|
534 |
2) test getter
|
|
535 |
*/
|
|
536 |
void TestCalenDayContentScrollArea::testSetGetDisallowedScrollDirection()
|
|
537 |
{
|
|
538 |
QCOMPARE(mContentScrollArea->mDisallowedDirection, ECalenScrollNoDayChange);
|
|
539 |
|
|
540 |
//1)
|
|
541 |
mContentScrollArea->setDisallowedScrollDirection(ECalenScrollToNext);
|
|
542 |
QCOMPARE(mContentScrollArea->mDisallowedDirection, ECalenScrollToNext);
|
|
543 |
|
|
544 |
//2)
|
|
545 |
QCOMPARE(mContentScrollArea->disallowedScrollDirection(), ECalenScrollToNext);
|
|
546 |
}
|
|
547 |
|
70
|
548 |
QTEST_MAIN(TestCalenDayContentScrollArea);
|
|
549 |
#include "unittest_calendaycontentscrollarea.moc"
|