|
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: Unit test for MpTrackListWidget |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * there are no valuable test cases for following functions |
|
20 * resizeEvent() |
|
21 * gestureEvent() |
|
22 * mousePressEvent() |
|
23 * |
|
24 */ |
|
25 |
|
26 #include "unittest_mptracklistwidget.h" |
|
27 #include "hbinstancestub.h" |
|
28 #include <hblistview.h> |
|
29 |
|
30 // Do this so we can access all member variables. |
|
31 #define private public |
|
32 #include "mptracklistwidget.h" |
|
33 #undef private |
|
34 |
|
35 //This so we can test private functions |
|
36 #include "../../src/mptracklistwidget.cpp" |
|
37 |
|
38 /*! |
|
39 Make our test case a stand-alone executable that runs all the test functions. |
|
40 */ |
|
41 int main(int argc, char *argv[]) |
|
42 { |
|
43 QApplication app(argc, argv); |
|
44 TestMpTrackListWidget tv; |
|
45 |
|
46 if ( argc > 1 ) { |
|
47 return QTest::qExec( &tv, argc, argv); |
|
48 } |
|
49 else { |
|
50 char *pass[3]; |
|
51 pass[0] = argv[0]; |
|
52 pass[1] = "-o"; |
|
53 pass[2] = "c:\\data\\unittest_mptracklistwidget.txt"; |
|
54 |
|
55 return QTest::qExec(&tv, 3, pass); |
|
56 } |
|
57 } |
|
58 |
|
59 TestMpTrackListWidget::TestMpTrackListWidget() |
|
60 : mTest(0) |
|
61 { |
|
62 } |
|
63 |
|
64 TestMpTrackListWidget::~TestMpTrackListWidget() |
|
65 { |
|
66 delete mTest; |
|
67 } |
|
68 |
|
69 /*! |
|
70 Called before the first testfunction is executed. |
|
71 */ |
|
72 void TestMpTrackListWidget::initTestCase() |
|
73 { |
|
74 } |
|
75 |
|
76 /*! |
|
77 Called after the last testfunction was executed. |
|
78 */ |
|
79 void TestMpTrackListWidget::cleanupTestCase() |
|
80 { |
|
81 } |
|
82 |
|
83 /*! |
|
84 Called before each testfunction is executed. |
|
85 */ |
|
86 void TestMpTrackListWidget::init() |
|
87 { |
|
88 mTest = new MpTrackListWidget(); |
|
89 } |
|
90 |
|
91 /*! |
|
92 Called after every testfunction. |
|
93 */ |
|
94 void TestMpTrackListWidget::cleanup() |
|
95 { |
|
96 delete mTest; |
|
97 mTest = 0; |
|
98 } |
|
99 |
|
100 /*! |
|
101 test constructor. |
|
102 */ |
|
103 void TestMpTrackListWidget::testConstructor() |
|
104 { |
|
105 QVERIFY( mTest->mList->layoutName() == "mpmwtracklist" ); |
|
106 } |
|
107 |
|
108 /*! |
|
109 test swipeAngleToDirection |
|
110 */ |
|
111 void TestMpTrackListWidget::testSwipeAngleToDirection() |
|
112 { |
|
113 hbInstance->allMainWindows()[0]->mOrientation = Qt::Vertical; |
|
114 QSwipeGesture::SwipeDirection direction; |
|
115 |
|
116 direction = mTest->swipeAngleToDirection( 70 ); |
|
117 QVERIFY( direction == QSwipeGesture::Up ); |
|
118 |
|
119 direction = mTest->swipeAngleToDirection( 250 ); |
|
120 QVERIFY( direction == QSwipeGesture::Down ); |
|
121 |
|
122 direction = mTest->swipeAngleToDirection( 20 ); |
|
123 QVERIFY( direction == QSwipeGesture::Right ); |
|
124 |
|
125 direction = mTest->swipeAngleToDirection( 340 ); |
|
126 QVERIFY( direction == QSwipeGesture::Right ); |
|
127 |
|
128 direction = mTest->swipeAngleToDirection( 160 ); |
|
129 QVERIFY( direction == QSwipeGesture::Left ); |
|
130 |
|
131 hbInstance->allMainWindows()[0]->mOrientation = Qt::Horizontal; |
|
132 #ifdef __WINS__ |
|
133 direction = mTest->swipeAngleToDirection( 70 ); |
|
134 QVERIFY( direction == QSwipeGesture::Right ); |
|
135 |
|
136 direction = mTest->swipeAngleToDirection( 100 ); |
|
137 QVERIFY( direction == QSwipeGesture::Right ); |
|
138 #else |
|
139 direction = mTest->swipeAngleToDirection( 70 ); |
|
140 QVERIFY( direction == QSwipeGesture::Left ); |
|
141 |
|
142 direction = mTest->swipeAngleToDirection( 340 ); |
|
143 QVERIFY( direction == QSwipeGesture::Up ); |
|
144 #endif |
|
145 } |
|
146 |
|
147 // End of file |