|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the examples of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 |
|
43 #include "mainwindow.h" |
|
44 #include "autotest.h" |
|
45 |
|
46 |
|
47 void autoTest::initTestCase() |
|
48 { |
|
49 } |
|
50 |
|
51 void autoTest::testDefaults() |
|
52 { |
|
53 QFile *albumDetails = new QFile("albumdetails.xml"); |
|
54 |
|
55 MainWindow mw("artists", "albums", albumDetails); |
|
56 |
|
57 mw.show(); |
|
58 |
|
59 // Test default values for widget properties |
|
60 QCOMPARE( mw.acceptDrops(), false ); |
|
61 QCOMPARE( mw.hasEditFocus(), false ); |
|
62 QCOMPARE( mw.hasFocus(), false ); |
|
63 QCOMPARE( mw.hasMouseTracking(), false ); |
|
64 QCOMPARE( mw.isActiveWindow(), true ); |
|
65 QCOMPARE( mw.isEnabled(), true ); |
|
66 QCOMPARE( mw.isFullScreen(), false ); |
|
67 QCOMPARE( mw.isHidden(), false ); |
|
68 QCOMPARE( mw.isMaximized(), false ); |
|
69 QCOMPARE( mw.isMinimized(), false ); |
|
70 QCOMPARE( mw.isModal(), false ); |
|
71 QCOMPARE( mw.isVisible(), true ); |
|
72 QCOMPARE( mw.isWindow(), true ); |
|
73 QCOMPARE( mw.isWindowModified(), false ); |
|
74 QCOMPARE( mw.underMouse(), false ); |
|
75 QCOMPARE( mw.updatesEnabled(), true ); |
|
76 |
|
77 mw.hide(); |
|
78 } |
|
79 void autoTest::testMainView() |
|
80 { |
|
81 QFile *albumDetails = new QFile("albumdetails.xml"); |
|
82 MainWindow mw("artists", "albums", albumDetails); |
|
83 |
|
84 mw.show(); |
|
85 QComboBox *artv = mw.getArtistView(); |
|
86 QTableView *albv = mw.getAlbumView(); |
|
87 |
|
88 // sanity checks for items in view |
|
89 QVERIFY( artv ); |
|
90 QVERIFY( albv ); |
|
91 |
|
92 // verify that combobox is in default state |
|
93 QCOMPARE( artv->count(), 0 ); |
|
94 QCOMPARE( artv->currentIndex(), -1 ); |
|
95 |
|
96 // verify that albumview shows correct items |
|
97 QTest::mouseClick ( (QWidget *)artv, Qt::LeftButton ); |
|
98 QTest::qWait(100); |
|
99 artv->setCurrentIndex(0); |
|
100 QTest::mouseClick ( (QWidget *)albv, Qt::LeftButton ); |
|
101 QTest::qWait(100); |
|
102 QCOMPARE( artv->currentIndex(), 0 ); |
|
103 |
|
104 // select one item from the combobox item list |
|
105 // verify that albumview shows correct items |
|
106 QTest::mouseClick ( (QWidget *)artv, Qt::LeftButton ); |
|
107 QTest::qWait(100); |
|
108 artv->setCurrentIndex(2); |
|
109 QTest::mouseClick ( (QWidget *)albv, Qt::LeftButton ); |
|
110 QTest::qWait(100); |
|
111 QCOMPARE( artv->currentIndex(), 2 ); |
|
112 |
|
113 // select another item from the combobox item list |
|
114 // verify that albumview shows correct items |
|
115 QTest::mouseClick ( (QWidget *)artv, Qt::LeftButton ); |
|
116 QTest::qWait(100); |
|
117 artv->setCurrentIndex(1); |
|
118 QTest::mouseClick ( (QWidget *)albv, Qt::LeftButton ); |
|
119 QTest::qWait(100); |
|
120 QCOMPARE( artv->currentIndex(), 1 ); |
|
121 |
|
122 mw.hide(); |
|
123 } |
|
124 |
|
125 void autoTest::testAlbumView() |
|
126 { |
|
127 QFile *albumDetails = new QFile("albumdetails.xml"); |
|
128 MainWindow mw("artists", "albums", albumDetails); |
|
129 |
|
130 //mw.show(); |
|
131 QTableView *albv = mw.getAlbumView(); |
|
132 |
|
133 // what is tested here? |
|
134 QVERIFY( albv ); |
|
135 |
|
136 mw.hide(); |
|
137 } |
|
138 |
|
139 void autoTest::testArtistView() |
|
140 { |
|
141 QFile *albumDetails = new QFile("albumdetails.xml"); |
|
142 MainWindow mw("artists", "albums", albumDetails); |
|
143 |
|
144 //mw.show(); |
|
145 QComboBox *artv = mw.getArtistView(); |
|
146 |
|
147 // what is tested here? |
|
148 QVERIFY( artv ); |
|
149 |
|
150 mw.hide(); |
|
151 } |
|
152 |
|
153 void autoTest::testTrackList() |
|
154 { |
|
155 QFile *albumDetails = new QFile("albumdetails.xml"); |
|
156 MainWindow mw("artists", "albums", albumDetails); |
|
157 |
|
158 //mw.show(); |
|
159 QListWidget *tl = mw.getTrackList(); |
|
160 |
|
161 // what is tested here? |
|
162 QVERIFY( tl ); |
|
163 |
|
164 mw.hide(); |
|
165 } |
|
166 |
|
167 void autoTest::testModel() |
|
168 { |
|
169 QFile *albumDetails = new QFile("albumdetails.xml"); |
|
170 MainWindow mw("artists", "albums", albumDetails); |
|
171 |
|
172 mw.show(); |
|
173 QSqlRelationalTableModel *mdl = mw.getModel(); |
|
174 |
|
175 // what is tested here? |
|
176 // adding more items into model? |
|
177 // saving whole model? |
|
178 // deleting items from model? |
|
179 // reloading whole model? |
|
180 |
|
181 QVERIFY( mdl ); |
|
182 |
|
183 // check the default values |
|
184 /* |
|
185 QCOMPARE( mdl->columnCount(), 2 ); |
|
186 QCOMPARE( mdl->rowCount(), 2 ); |
|
187 */ |
|
188 |
|
189 mw.hide(); |
|
190 } |
|
191 |