author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 0 | 1918ee327afb |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the test suite 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 <QtTest/QtTest> |
|
44 |
#include <QtCore/QtCore> |
|
45 |
#include "viewstotest.cpp" |
|
46 |
#include <stdlib.h> |
|
47 |
||
48 |
#if defined(Q_OS_UNIX) |
|
49 |
#include <time.h> |
|
50 |
#endif |
|
51 |
#if defined(Q_OS_WIN) |
|
52 |
#include <time.h> |
|
53 |
#if defined(Q_OS_WINCE) |
|
54 |
#include <aygshell.h> |
|
55 |
#endif |
|
56 |
#define random rand |
|
57 |
#define srandom srand |
|
58 |
||
59 |
#if defined(Q_OS_WINCE) |
|
60 |
bool qt_wince_is_platform(const QString &platformString) { |
|
61 |
wchar_t tszPlatform[64]; |
|
62 |
if (SystemParametersInfo(SPI_GETPLATFORMTYPE, |
|
63 |
sizeof(tszPlatform)/sizeof(*tszPlatform),tszPlatform,0)) |
|
64 |
if (0 == _tcsicmp(reinterpret_cast<const wchar_t *> (platformString.utf16()), tszPlatform)) |
|
65 |
return true; |
|
66 |
return false; |
|
67 |
} |
|
68 |
||
69 |
bool qt_wince_is_pocket_pc() { |
|
70 |
return qt_wince_is_platform(QString::fromLatin1("PocketPC")); |
|
71 |
} |
|
72 |
||
73 |
bool qt_wince_is_smartphone() { |
|
74 |
return qt_wince_is_platform(QString::fromLatin1("Smartphone")); |
|
75 |
} |
|
76 |
bool qt_wince_is_mobile() { |
|
77 |
return (qt_wince_is_smartphone() || qt_wince_is_pocket_pc()); |
|
78 |
} |
|
79 |
#endif |
|
80 |
#endif |
|
81 |
||
82 |
//TESTED_CLASS= |
|
83 |
//TESTED_FILES=gui/itemviews/qtreeview.h gui/itemviews/qtreeview.cpp |
|
84 |
||
85 |
/*! |
|
86 |
See viewstotest.cpp for instructions on how to have your view tested with these tests. |
|
87 |
||
88 |
Each test such as visualRect have a _data() function which populate the QTest data with |
|
89 |
tests specified by viewstotest.cpp and any extra data needed for that perticular test. |
|
90 |
||
91 |
setupWithNoTestData() fills QTest data with only the tests it is used by most tests. |
|
92 |
||
93 |
There are some basic qDebug statements sprikled about that might be helpfull for |
|
94 |
fixing your issues. |
|
95 |
*/ |
|
96 |
class tst_QItemView : public QObject |
|
97 |
{ |
|
98 |
Q_OBJECT |
|
99 |
||
100 |
public: |
|
101 |
tst_QItemView() {}; |
|
102 |
virtual ~tst_QItemView() {}; |
|
103 |
||
104 |
public slots: |
|
105 |
void init(); |
|
106 |
void cleanup(); |
|
107 |
||
108 |
private slots: |
|
109 |
void nonDestructiveBasicTest_data(); |
|
110 |
void nonDestructiveBasicTest(); |
|
111 |
||
112 |
void spider_data(); |
|
113 |
void spider(); |
|
114 |
||
115 |
void resize_data(); |
|
116 |
void resize(); |
|
117 |
||
118 |
void visualRect_data(); |
|
119 |
void visualRect(); |
|
120 |
||
121 |
void indexAt_data(); |
|
122 |
void indexAt(); |
|
123 |
||
124 |
void scrollTo_data(); |
|
125 |
void scrollTo(); |
|
126 |
||
127 |
void moveCursor_data(); |
|
128 |
void moveCursor(); |
|
129 |
||
130 |
private: |
|
131 |
void setupWithNoTestData(); |
|
132 |
void populate(); |
|
133 |
void walkScreen(QAbstractItemView *view); |
|
134 |
||
135 |
QAbstractItemView *view; |
|
136 |
QAbstractItemModel *treeModel; |
|
137 |
ViewsToTest *testViews; |
|
138 |
}; |
|
139 |
||
140 |
/*! |
|
141 |
* Views should not make invalid requests, sense a model might not check all the bad cases. |
|
142 |
*/ |
|
143 |
class CheckerModel : public QStandardItemModel |
|
144 |
{ |
|
145 |
Q_OBJECT |
|
146 |
||
147 |
public: |
|
148 |
CheckerModel() : QStandardItemModel() {}; |
|
149 |
||
150 |
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole ) const { |
|
151 |
Q_ASSERT(index.isValid()); |
|
152 |
return QStandardItemModel::data(index, role); |
|
153 |
}; |
|
154 |
||
155 |
Qt::ItemFlags flags(const QModelIndex & index) const { |
|
156 |
Q_ASSERT(index.isValid()); |
|
157 |
if (index.row() == 2 || index.row() == rowCount() - 3 |
|
158 |
|| index.column() == 2 || index.column() == columnCount() - 3) { |
|
159 |
Qt::ItemFlags f = QStandardItemModel::flags(index); |
|
160 |
f &= ~Qt::ItemIsEnabled; |
|
161 |
return f; |
|
162 |
} |
|
163 |
return QStandardItemModel::flags(index); |
|
164 |
}; |
|
165 |
||
166 |
QModelIndex parent ( const QModelIndex & child ) const { |
|
167 |
Q_ASSERT(child.isValid()); |
|
168 |
return QStandardItemModel::parent(child); |
|
169 |
}; |
|
170 |
||
171 |
QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const { |
|
172 |
Q_ASSERT(section >= 0); |
|
173 |
if (orientation == Qt::Horizontal) { Q_ASSERT(section <= columnCount());}; |
|
174 |
if (orientation == Qt::Vertical) { Q_ASSERT(section <= rowCount());}; |
|
175 |
return QStandardItemModel::headerData(section, orientation, role); |
|
176 |
} |
|
177 |
||
178 |
QModelIndex index( int row, int column, const QModelIndex & parent = QModelIndex() ) const { |
|
179 |
return QStandardItemModel::index(row, column, parent); |
|
180 |
}; |
|
181 |
||
182 |
bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ) { |
|
183 |
Q_ASSERT(index.isValid()); |
|
184 |
return QStandardItemModel::setData(index, value, role); |
|
185 |
} |
|
186 |
||
187 |
void sort( int column, Qt::SortOrder order = Qt::AscendingOrder ) { |
|
188 |
Q_ASSERT(column >= 0 && column <= columnCount()); |
|
189 |
QStandardItemModel::sort(column, order); |
|
190 |
}; |
|
191 |
||
192 |
QModelIndexList match ( const QModelIndex & start, int role, const QVariant & value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap ) ) const { |
|
193 |
Q_ASSERT(hits > 0); |
|
194 |
Q_ASSERT(value.isValid()); |
|
195 |
return QAbstractItemModel::match(start, role, value, hits, flags); |
|
196 |
}; |
|
197 |
||
198 |
bool setHeaderData ( int section, Qt::Orientation orientation, const QVariant & value, int role = Qt::EditRole ) { |
|
199 |
Q_ASSERT(section >= 0); |
|
200 |
return QAbstractItemModel::setHeaderData(section, orientation, value, role); |
|
201 |
}; |
|
202 |
}; |
|
203 |
||
204 |
void tst_QItemView::init() |
|
205 |
{ |
|
206 |
#ifdef Q_OS_IRIX |
|
207 |
return; |
|
208 |
#endif |
|
209 |
||
210 |
testViews = new ViewsToTest(); |
|
211 |
populate(); |
|
212 |
} |
|
213 |
||
214 |
void tst_QItemView::cleanup() |
|
215 |
{ |
|
216 |
delete testViews; |
|
217 |
delete view; |
|
218 |
delete treeModel; |
|
219 |
view = 0; |
|
220 |
testViews = 0; |
|
221 |
treeModel = 0; |
|
222 |
} |
|
223 |
||
224 |
void tst_QItemView::setupWithNoTestData() |
|
225 |
{ |
|
226 |
#ifdef Q_OS_IRIX |
|
227 |
//QSKIP("This test takes too long to execute on IRIX", SkipAll); |
|
228 |
return; |
|
229 |
#endif |
|
230 |
||
231 |
ViewsToTest testViews; |
|
232 |
QTest::addColumn<QString>("viewType"); |
|
233 |
QTest::addColumn<bool>("displays"); |
|
234 |
QTest::addColumn<int>("vscroll"); |
|
235 |
QTest::addColumn<int>("hscroll"); |
|
236 |
for (int i = 0; i < testViews.tests.size(); ++i) { |
|
237 |
QString view = testViews.tests.at(i).viewType; |
|
238 |
QString test = view + " ScrollPerPixel"; |
|
239 |
bool displayIndexes = (testViews.tests.at(i).display == ViewsToTest::DisplayRoot); |
|
240 |
QTest::newRow(test.toLatin1().data()) << view << displayIndexes |
|
241 |
<< (int)QAbstractItemView::ScrollPerPixel |
|
242 |
<< (int)QAbstractItemView::ScrollPerPixel |
|
243 |
; |
|
244 |
} |
|
245 |
for (int i = 0; i < testViews.tests.size(); ++i) { |
|
246 |
QString view = testViews.tests.at(i).viewType; |
|
247 |
QString test = view + " ScrollPerItem"; |
|
248 |
bool displayIndexes = (testViews.tests.at(i).display == ViewsToTest::DisplayRoot); |
|
249 |
QTest::newRow(test.toLatin1().data()) << view << displayIndexes |
|
250 |
<< (int)QAbstractItemView::ScrollPerItem |
|
251 |
<< (int)QAbstractItemView::ScrollPerItem |
|
252 |
; |
|
253 |
} |
|
254 |
} |
|
255 |
||
256 |
void tst_QItemView::populate() |
|
257 |
{ |
|
258 |
treeModel = new CheckerModel; |
|
259 |
QModelIndex parent; |
|
260 |
#if defined(QT_ARCH_ARM) || defined(Q_OS_SYMBIAN) |
|
261 |
const int baseInsert = 4; |
|
262 |
#else |
|
263 |
const int baseInsert = 26; |
|
264 |
#endif |
|
265 |
for (int i = 0; i < 40; ++i) { |
|
266 |
parent = treeModel->index(0, 0, parent); |
|
267 |
treeModel->insertRows(0, baseInsert + i, parent); |
|
268 |
treeModel->insertColumns(0, baseInsert + i, parent); |
|
269 |
// Fill in some values to make it easier to debug |
|
270 |
for (int x = 0; x < treeModel->rowCount(); ++x) { |
|
271 |
for (int y = 0; y < treeModel->columnCount(); ++y) { |
|
272 |
QModelIndex index = treeModel->index(x, y, parent); |
|
273 |
treeModel->setData(index, QString("%1_%2_%3").arg(x).arg(y).arg(i)); |
|
274 |
treeModel->setData(index, QVariant(QColor(Qt::blue)), Qt::TextColorRole); |
|
275 |
} |
|
276 |
} |
|
277 |
} |
|
278 |
} |
|
279 |
||
280 |
void tst_QItemView::nonDestructiveBasicTest_data() |
|
281 |
{ |
|
282 |
setupWithNoTestData(); |
|
283 |
} |
|
284 |
||
285 |
/*! |
|
286 |
nonDestructiveBasicTest trys to call a number of the basic functions (not all) |
|
287 |
to make sure the view doesn't segfault, testing the functions that makes sense. |
|
288 |
*/ |
|
289 |
void tst_QItemView::nonDestructiveBasicTest() |
|
290 |
{ |
|
291 |
#ifdef Q_OS_IRIX |
|
292 |
QSKIP("This test takes too long to execute on IRIX", SkipAll); |
|
293 |
#endif |
|
294 |
||
295 |
#ifdef Q_OS_WINCE |
|
296 |
QTest::qWait(400); |
|
297 |
#endif |
|
298 |
||
299 |
QFETCH(QString, viewType); |
|
300 |
view = testViews->createView(viewType); |
|
301 |
QFETCH(int, vscroll); |
|
302 |
QFETCH(int, hscroll); |
|
303 |
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll); |
|
304 |
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll); |
|
305 |
||
306 |
// setSelectionModel() will assert |
|
307 |
//view->setSelectionModel(0); |
|
308 |
// setItemDelegate() will assert |
|
309 |
//view->setItemDelegate(0); |
|
310 |
||
311 |
// setSelectionMode |
|
312 |
view->setSelectionMode(QAbstractItemView::SingleSelection); |
|
313 |
QCOMPARE(view->selectionMode(), QAbstractItemView::SingleSelection); |
|
314 |
view->setSelectionMode(QAbstractItemView::ContiguousSelection); |
|
315 |
QCOMPARE(view->selectionMode(), QAbstractItemView::ContiguousSelection); |
|
316 |
view->setSelectionMode(QAbstractItemView::ExtendedSelection); |
|
317 |
QCOMPARE(view->selectionMode(), QAbstractItemView::ExtendedSelection); |
|
318 |
view->setSelectionMode(QAbstractItemView::MultiSelection); |
|
319 |
QCOMPARE(view->selectionMode(), QAbstractItemView::MultiSelection); |
|
320 |
view->setSelectionMode(QAbstractItemView::NoSelection); |
|
321 |
QCOMPARE(view->selectionMode(), QAbstractItemView::NoSelection); |
|
322 |
||
323 |
// setSelectionBehavior |
|
324 |
view->setSelectionBehavior(QAbstractItemView::SelectItems); |
|
325 |
QCOMPARE(view->selectionBehavior(), QAbstractItemView::SelectItems); |
|
326 |
view->setSelectionBehavior(QAbstractItemView::SelectRows); |
|
327 |
QCOMPARE(view->selectionBehavior(), QAbstractItemView::SelectRows); |
|
328 |
view->setSelectionBehavior(QAbstractItemView::SelectColumns); |
|
329 |
QCOMPARE(view->selectionBehavior(), QAbstractItemView::SelectColumns); |
|
330 |
||
331 |
// setEditTriggers |
|
332 |
view->setEditTriggers(QAbstractItemView::EditKeyPressed); |
|
333 |
QCOMPARE(view->editTriggers(), QAbstractItemView::EditKeyPressed); |
|
334 |
view->setEditTriggers(QAbstractItemView::NoEditTriggers); |
|
335 |
QCOMPARE(view->editTriggers(), QAbstractItemView::NoEditTriggers); |
|
336 |
view->setEditTriggers(QAbstractItemView::CurrentChanged); |
|
337 |
QCOMPARE(view->editTriggers(), QAbstractItemView::CurrentChanged); |
|
338 |
view->setEditTriggers(QAbstractItemView::DoubleClicked); |
|
339 |
QCOMPARE(view->editTriggers(), QAbstractItemView::DoubleClicked); |
|
340 |
view->setEditTriggers(QAbstractItemView::SelectedClicked); |
|
341 |
QCOMPARE(view->editTriggers(), QAbstractItemView::SelectedClicked); |
|
342 |
view->setEditTriggers(QAbstractItemView::AnyKeyPressed); |
|
343 |
QCOMPARE(view->editTriggers(), QAbstractItemView::AnyKeyPressed); |
|
344 |
view->setEditTriggers(QAbstractItemView::AllEditTriggers); |
|
345 |
QCOMPARE(view->editTriggers(), QAbstractItemView::AllEditTriggers); |
|
346 |
||
347 |
// setAutoScroll |
|
348 |
view->setAutoScroll(false); |
|
349 |
QCOMPARE(view->hasAutoScroll(), false); |
|
350 |
view->setAutoScroll(true); |
|
351 |
QCOMPARE(view->hasAutoScroll(), true); |
|
352 |
||
353 |
// setTabKeyNavigation |
|
354 |
view->setTabKeyNavigation(false); |
|
355 |
QCOMPARE(view->tabKeyNavigation(), false); |
|
356 |
view->setTabKeyNavigation(true); |
|
357 |
QCOMPARE(view->tabKeyNavigation(), true); |
|
358 |
#ifndef QT_NO_DRAGANDDROP |
|
359 |
// setDropIndicatorShown |
|
360 |
view->setDropIndicatorShown(false); |
|
361 |
QCOMPARE(view->showDropIndicator(), false); |
|
362 |
view->setDropIndicatorShown(true); |
|
363 |
QCOMPARE(view->showDropIndicator(), true); |
|
364 |
||
365 |
// setDragEnabled |
|
366 |
view->setDragEnabled(false); |
|
367 |
QCOMPARE(view->dragEnabled(), false); |
|
368 |
view->setDragEnabled(true); |
|
369 |
QCOMPARE(view->dragEnabled(), true); |
|
370 |
#endif |
|
371 |
||
372 |
// setAlternatingRowColors |
|
373 |
view->setAlternatingRowColors(false); |
|
374 |
QCOMPARE(view->alternatingRowColors(), false); |
|
375 |
view->setAlternatingRowColors(true); |
|
376 |
QCOMPARE(view->alternatingRowColors(), true); |
|
377 |
||
378 |
// setIconSize |
|
379 |
view->setIconSize(QSize(16, 16)); |
|
380 |
QCOMPARE(view->iconSize(), QSize(16, 16)); |
|
381 |
view->setIconSize(QSize(32, 32)); |
|
382 |
QCOMPARE(view->iconSize(), QSize(32, 32)); |
|
383 |
// Should this happen? |
|
384 |
view->setIconSize(QSize(-1, -1)); |
|
385 |
QCOMPARE(view->iconSize(), QSize(-1, -1)); |
|
386 |
||
387 |
QCOMPARE(view->currentIndex(), QModelIndex()); |
|
388 |
QCOMPARE(view->rootIndex(), QModelIndex()); |
|
389 |
||
390 |
view->keyboardSearch(""); |
|
391 |
view->keyboardSearch("foo"); |
|
392 |
view->keyboardSearch("1"); |
|
393 |
||
394 |
QCOMPARE(view->visualRect(QModelIndex()), QRect()); |
|
395 |
||
396 |
view->scrollTo(QModelIndex()); |
|
397 |
||
398 |
QCOMPARE(view->sizeHintForIndex(QModelIndex()), QSize()); |
|
399 |
QCOMPARE(view->indexAt(QPoint(-1, -1)), QModelIndex()); |
|
400 |
||
401 |
if (!view->model()){ |
|
402 |
QCOMPARE(view->indexAt(QPoint(10, 10)), QModelIndex()); |
|
403 |
QCOMPARE(view->sizeHintForRow(0), -1); |
|
404 |
QCOMPARE(view->sizeHintForColumn(0), -1); |
|
405 |
} else if (view->itemDelegate()){ |
|
406 |
view->sizeHintForRow(0); |
|
407 |
view->sizeHintForColumn(0); |
|
408 |
} |
|
409 |
view->openPersistentEditor(QModelIndex()); |
|
410 |
view->closePersistentEditor(QModelIndex()); |
|
411 |
||
412 |
view->reset(); |
|
413 |
view->setRootIndex(QModelIndex()); |
|
414 |
view->doItemsLayout(); |
|
415 |
view->selectAll(); |
|
416 |
// edit() causes warning by default |
|
417 |
//view->edit(QModelIndex()); |
|
418 |
view->clearSelection(); |
|
419 |
view->setCurrentIndex(QModelIndex()); |
|
420 |
} |
|
421 |
||
422 |
void tst_QItemView::spider_data() |
|
423 |
{ |
|
424 |
setupWithNoTestData(); |
|
425 |
} |
|
426 |
||
427 |
void touch(QWidget *widget, Qt::KeyboardModifier modifier, Qt::Key keyPress){ |
|
428 |
int width = widget->width(); |
|
429 |
int height = widget->height(); |
|
430 |
for (int i = 0; i < 5; ++i) { |
|
431 |
QTest::mouseClick(widget, Qt::LeftButton, modifier, QPoint(random() % width, random() % height)); |
|
432 |
QTest::mouseDClick(widget, Qt::LeftButton, modifier, QPoint(random() % width, random() % height)); |
|
433 |
QPoint press(random() % width, random() % height); |
|
434 |
QPoint releasePoint(random() % width, random() % height); |
|
435 |
QTest::mousePress(widget, Qt::LeftButton, modifier, press); |
|
436 |
QTest::mouseMove(widget, releasePoint); |
|
437 |
if (random() % 1 == 0) |
|
438 |
QTest::mouseRelease(widget, Qt::LeftButton, 0, releasePoint); |
|
439 |
else |
|
440 |
QTest::mouseRelease(widget, Qt::LeftButton, modifier, releasePoint); |
|
441 |
QTest::keyClick(widget, keyPress); |
|
442 |
} |
|
443 |
} |
|
444 |
||
445 |
/*! |
|
446 |
This is a basic stress testing application that tries a few basics such as clicking around |
|
447 |
the screen, and key presses. |
|
448 |
||
449 |
The main goal is to catch any easy segfaults, not to test every case. |
|
450 |
*/ |
|
451 |
void tst_QItemView::spider() |
|
452 |
{ |
|
453 |
#ifdef Q_OS_IRIX |
|
454 |
QSKIP("This test takes too long to execute on IRIX", SkipAll); |
|
455 |
#endif |
|
456 |
QFETCH(QString, viewType); |
|
457 |
view = testViews->createView(viewType); |
|
458 |
QFETCH(int, vscroll); |
|
459 |
QFETCH(int, hscroll); |
|
460 |
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll); |
|
461 |
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll); |
|
462 |
view->setModel(treeModel); |
|
463 |
view->show(); |
|
464 |
#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) |
|
465 |
srandom(0); |
|
466 |
#else |
|
467 |
srandom(time(0)); |
|
468 |
#endif |
|
469 |
touch(view->viewport(), Qt::NoModifier, Qt::Key_Left); |
|
470 |
touch(view->viewport(), Qt::ShiftModifier, Qt::Key_Enter); |
|
471 |
touch(view->viewport(), Qt::ControlModifier, Qt::Key_Backspace); |
|
472 |
touch(view->viewport(), Qt::AltModifier, Qt::Key_Up); |
|
473 |
} |
|
474 |
||
475 |
void tst_QItemView::resize_data() |
|
476 |
{ |
|
477 |
setupWithNoTestData(); |
|
478 |
} |
|
479 |
||
480 |
/*! |
|
481 |
The main goal is to catch any infinite loops from layouting |
|
482 |
*/ |
|
483 |
void tst_QItemView::resize() |
|
484 |
{ |
|
485 |
#ifdef Q_OS_IRIX |
|
486 |
QSKIP("This test takes too long to execute on IRIX", SkipAll); |
|
487 |
#endif |
|
488 |
return; |
|
489 |
// This test needs to be re-thought out, it takes too long and |
|
490 |
// doesn't really catch theproblem. |
|
491 |
QFETCH(QString, viewType); |
|
492 |
view = testViews->createView(viewType); |
|
493 |
QFETCH(int, vscroll); |
|
494 |
QFETCH(int, hscroll); |
|
495 |
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll); |
|
496 |
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll); |
|
497 |
view->setModel(treeModel); |
|
498 |
view->show(); |
|
499 |
||
500 |
for (int w = 100; w < 400; w+=10) { |
|
501 |
for (int h = 100; h < 400; h+=10) { |
|
502 |
view->resize(w, h); |
|
503 |
QTest::qWait(1); |
|
504 |
qApp->processEvents(); |
|
505 |
} |
|
506 |
} |
|
507 |
} |
|
508 |
||
509 |
void tst_QItemView::visualRect_data() |
|
510 |
{ |
|
511 |
setupWithNoTestData(); |
|
512 |
} |
|
513 |
||
514 |
void tst_QItemView::visualRect() |
|
515 |
{ |
|
516 |
#ifdef Q_OS_IRIX |
|
517 |
QSKIP("This test takes too long to execute on IRIX", SkipAll); |
|
518 |
#endif |
|
519 |
QFETCH(QString, viewType); |
|
520 |
view = testViews->createView(viewType); |
|
521 |
QFETCH(int, vscroll); |
|
522 |
QFETCH(int, hscroll); |
|
523 |
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll); |
|
524 |
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll); |
|
525 |
QCOMPARE(view->visualRect(QModelIndex()), QRect()); |
|
526 |
||
527 |
// Add model |
|
528 |
view->setModel(treeModel); |
|
529 |
QCOMPARE(view->visualRect(QModelIndex()), QRect()); |
|
530 |
||
531 |
QModelIndex topIndex = treeModel->index(0,0); |
|
532 |
||
533 |
QFETCH(bool, displays); |
|
534 |
if (!displays){ |
|
535 |
QVERIFY(view->visualRect(topIndex) == QRect()); |
|
536 |
return; |
|
537 |
} |
|
538 |
||
539 |
QVERIFY(view->visualRect(topIndex) != QRect()); |
|
540 |
view->show(); |
|
541 |
QVERIFY(view->visualRect(topIndex) != QRect()); |
|
542 |
||
543 |
QVERIFY(topIndex == view->indexAt(view->visualRect(topIndex).center())); |
|
544 |
QVERIFY(topIndex == view->indexAt(view->visualRect(topIndex).bottomLeft())); |
|
545 |
QVERIFY(topIndex == view->indexAt(view->visualRect(topIndex).bottomRight())); |
|
546 |
QVERIFY(topIndex == view->indexAt(view->visualRect(topIndex).topLeft())); |
|
547 |
QVERIFY(topIndex == view->indexAt(view->visualRect(topIndex).topRight())); |
|
548 |
||
549 |
testViews->hideIndexes(view); |
|
550 |
QModelIndex hiddenIndex = treeModel->index(1, 0); |
|
551 |
QVERIFY(view->visualRect(hiddenIndex) == QRect()); |
|
552 |
} |
|
553 |
||
554 |
void tst_QItemView::walkScreen(QAbstractItemView *view) |
|
555 |
{ |
|
556 |
QModelIndex hiddenIndex = view->model() ? view->model()->index(1, 0) : QModelIndex(); |
|
557 |
int width = view->width(); |
|
558 |
int height = view->height(); |
|
559 |
for (int w = 0; w < width; ++w) |
|
560 |
{ |
|
561 |
for (int h = 0; h < height; ++h) |
|
562 |
{ |
|
563 |
QPoint point(w, h); |
|
564 |
QModelIndex index = view->indexAt(point); |
|
565 |
||
566 |
// If we have no model then we should *never* get a valid index |
|
567 |
if (!view->model() || !view->isVisible()) |
|
568 |
QVERIFY(!index.isValid()); |
|
569 |
// index should not be the hidden one |
|
570 |
if (hiddenIndex.isValid()) |
|
571 |
QVERIFY(hiddenIndex != index); |
|
572 |
// If we are valid then check the visualRect for that index |
|
573 |
if (index.isValid()){ |
|
574 |
QRect visualRect = view->visualRect(index); |
|
575 |
if (!visualRect.contains(point)) |
|
576 |
qDebug() << point << visualRect; |
|
577 |
QVERIFY(visualRect.contains(point)); |
|
578 |
} |
|
579 |
} |
|
580 |
} |
|
581 |
} |
|
582 |
||
583 |
void walkIndex(QModelIndex index, QAbstractItemView *view) |
|
584 |
{ |
|
585 |
QRect visualRect = view->visualRect(index); |
|
586 |
//if (index.column() == 0) |
|
587 |
//qDebug() << index << visualRect; |
|
588 |
int width = visualRect.width(); |
|
589 |
int height = visualRect.height(); |
|
590 |
||
591 |
for (int w = 0; w < width; ++w) |
|
592 |
{ |
|
593 |
for (int h = 0; h < height; ++h) |
|
594 |
{ |
|
595 |
QPoint point(visualRect.x()+w, visualRect.y()+h); |
|
596 |
if (view->indexAt(point) != index) { |
|
597 |
qDebug() << "index" << index << "visualRect" << visualRect << point << view->indexAt(point); |
|
598 |
} |
|
599 |
QVERIFY(view->indexAt(point) == index); |
|
600 |
} |
|
601 |
} |
|
602 |
||
603 |
} |
|
604 |
||
605 |
/*! |
|
606 |
A model that returns an index of parent X should also return X when asking |
|
607 |
for the parent of the index. |
|
608 |
||
609 |
This recursive function does pretty extensive testing on the whole model in an |
|
610 |
effort to catch edge cases. |
|
611 |
||
612 |
This function assumes that rowCount(), columnCount() and index() work. If they have |
|
613 |
a bug it will point it out, but the above tests should have already found the basic bugs |
|
614 |
because it is easier to figure out the problem in those tests then this one. |
|
615 |
*/ |
|
616 |
void checkChildren(QAbstractItemView *currentView, const QModelIndex &parent = QModelIndex(), int currentDepth=0) |
|
617 |
{ |
|
618 |
QAbstractItemModel *currentModel = currentView->model(); |
|
619 |
||
620 |
int rows = currentModel->rowCount(parent); |
|
621 |
int columns = currentModel->columnCount(parent); |
|
622 |
||
623 |
for (int r = 0; r < rows; ++r) { |
|
624 |
for (int c = 0; c < columns; ++c) { |
|
625 |
QModelIndex index = currentModel->index(r, c, parent); |
|
626 |
walkIndex(index, currentView); |
|
627 |
if (QTest::currentTestFailed()) |
|
628 |
return; |
|
629 |
||
630 |
// recursivly go down |
|
631 |
if (currentModel->hasChildren(index) && currentDepth < 2) { |
|
632 |
checkChildren(currentView, index, ++currentDepth); |
|
633 |
// Because this is recursive we will return at the first failure rather then |
|
634 |
// reporting it over and over |
|
635 |
if (QTest::currentTestFailed()) |
|
636 |
return; |
|
637 |
} |
|
638 |
} |
|
639 |
} |
|
640 |
} |
|
641 |
||
642 |
||
643 |
void tst_QItemView::indexAt_data() |
|
644 |
{ |
|
645 |
setupWithNoTestData(); |
|
646 |
} |
|
647 |
||
648 |
void tst_QItemView::indexAt() |
|
649 |
{ |
|
650 |
#ifdef Q_OS_IRIX |
|
651 |
QSKIP("This test takes too long to execute on IRIX", SkipAll); |
|
652 |
#endif |
|
653 |
QFETCH(QString, viewType); |
|
654 |
view = testViews->createView(viewType); |
|
655 |
QFETCH(int, vscroll); |
|
656 |
QFETCH(int, hscroll); |
|
657 |
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll); |
|
658 |
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll); |
|
659 |
view->show(); |
|
660 |
view->setModel(treeModel); |
|
661 |
#if 0 |
|
662 |
checkChildren(view); |
|
663 |
||
664 |
QModelIndex index = view->model()->index(0, 0); |
|
665 |
while (view->model()->hasChildren(index)) |
|
666 |
index = view->model()->index(0, 0, index); |
|
667 |
QCOMPARE(view->model()->hasChildren(index), false); |
|
668 |
QVERIFY(index.isValid()); |
|
669 |
view->setRootIndex(index); |
|
670 |
//qDebug() << view->indexAt(QPoint(view->width()/2, view->height()/2)) << view->rootIndex(); |
|
671 |
QPoint p(1, view->height()/2); |
|
672 |
QModelIndex idx = view->indexAt(p); |
|
673 |
QCOMPARE(idx, QModelIndex()); |
|
674 |
#endif |
|
675 |
} |
|
676 |
||
677 |
void tst_QItemView::scrollTo_data() |
|
678 |
{ |
|
679 |
setupWithNoTestData(); |
|
680 |
} |
|
681 |
||
682 |
void tst_QItemView::scrollTo() |
|
683 |
{ |
|
684 |
#ifdef Q_OS_IRIX |
|
685 |
QSKIP("This test takes too long to execute on IRIX", SkipAll); |
|
686 |
#endif |
|
687 |
QFETCH(QString, viewType); |
|
688 |
view = testViews->createView(viewType); |
|
689 |
QFETCH(int, vscroll); |
|
690 |
QFETCH(int, hscroll); |
|
691 |
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll); |
|
692 |
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll); |
|
693 |
view->setModel(treeModel); |
|
694 |
view->show(); |
|
695 |
||
696 |
QModelIndex parent; |
|
697 |
for (int row = 0; row < treeModel->rowCount(parent); ++row) { |
|
698 |
for (int column = 0; column < treeModel->columnCount(parent); ++column) { |
|
699 |
QModelIndex idx = treeModel->index(row, column, parent); |
|
700 |
view->scrollTo(idx); |
|
701 |
QRect rect = view->visualRect(idx); |
|
702 |
view->scrollTo(idx); |
|
703 |
QCOMPARE(rect, view->visualRect(idx)); |
|
704 |
} |
|
705 |
} |
|
706 |
||
707 |
QModelIndex idx = treeModel->index(0, 0, parent); |
|
708 |
view->scrollTo(idx); |
|
709 |
QRect rect = view->visualRect(idx); |
|
710 |
view->scrollToBottom(); |
|
711 |
view->scrollTo(idx); |
|
712 |
QCOMPARE(rect, view->visualRect(idx)); |
|
713 |
} |
|
714 |
||
715 |
void tst_QItemView::moveCursor_data() |
|
716 |
{ |
|
717 |
setupWithNoTestData(); |
|
718 |
} |
|
719 |
||
720 |
class Event { |
|
721 |
public: |
|
722 |
Event(){} |
|
723 |
Event(Qt::Key k, QModelIndex s, QModelIndex e, QString n) : key(k), start(s), end(e), name(n){} |
|
724 |
Qt::Key key; |
|
725 |
QModelIndex start; |
|
726 |
QModelIndex end; |
|
727 |
QString name; |
|
728 |
}; |
|
729 |
||
730 |
||
731 |
void tst_QItemView::moveCursor() |
|
732 |
{ |
|
733 |
#ifdef Q_OS_IRIX |
|
734 |
QSKIP("This test takes too long to execute on IRIX", SkipAll); |
|
735 |
#endif |
|
736 |
QFETCH(QString, viewType); |
|
737 |
view = testViews->createView(viewType); |
|
738 |
if (view->objectName() == "QHeaderView") |
|
739 |
return; |
|
740 |
||
741 |
view->setModel(treeModel); |
|
742 |
testViews->hideIndexes(view); |
|
743 |
view->resize(100, 100); |
|
744 |
||
745 |
QModelIndex invalidIndex = QModelIndex(); |
|
746 |
QModelIndex firstRow = treeModel->index(0, 0); |
|
747 |
QModelIndex hiddenRowT = treeModel->index(1, 0); |
|
748 |
QModelIndex disabledRowT = treeModel->index(2, 0); |
|
749 |
QModelIndex secondRow = treeModel->index(3, 0); |
|
750 |
||
751 |
QModelIndex secondToLastRow = treeModel->index(treeModel->rowCount() - 4, 0); |
|
752 |
QModelIndex disabledRowB = treeModel->index(treeModel->rowCount() - 3, 0); |
|
753 |
QModelIndex hiddenRowB = treeModel->index(treeModel->rowCount() - 2, 0); |
|
754 |
QModelIndex lastRow = treeModel->index(treeModel->rowCount() - 1, 0); |
|
755 |
||
756 |
QStack<Event> events; |
|
757 |
||
758 |
events.push(Event(Qt::Key_Up, invalidIndex, firstRow, "inv, first")); |
|
759 |
events.push(Event(Qt::Key_Up, hiddenRowT, firstRow, "hid, first")); |
|
760 |
events.push(Event(Qt::Key_Up, disabledRowT, firstRow, "dis, first")); |
|
761 |
events.push(Event(Qt::Key_Up, firstRow, firstRow, "first, first")); |
|
762 |
events.push(Event(Qt::Key_Up, secondRow, firstRow, "sec, first")); |
|
763 |
events.push(Event(Qt::Key_Up, hiddenRowB, firstRow, "hidB, first")); |
|
764 |
events.push(Event(Qt::Key_Up, disabledRowB, secondToLastRow, "disB, secLast")); |
|
765 |
events.push(Event(Qt::Key_Up, lastRow, secondToLastRow, "last, secLast")); |
|
766 |
||
767 |
events.push(Event(Qt::Key_Down, invalidIndex, firstRow, "inv, first")); |
|
768 |
events.push(Event(Qt::Key_Down, hiddenRowT, firstRow, "hid, first")); |
|
769 |
events.push(Event(Qt::Key_Down, disabledRowT, secondRow, "dis, sec")); |
|
770 |
events.push(Event(Qt::Key_Down, firstRow, secondRow, "first, sec")); |
|
771 |
events.push(Event(Qt::Key_Down, secondToLastRow, lastRow, "secLast, last" )); |
|
772 |
events.push(Event(Qt::Key_Down, disabledRowB, lastRow, "disB, last")); |
|
773 |
events.push(Event(Qt::Key_Down, hiddenRowB, firstRow, "hidB, first")); |
|
774 |
events.push(Event(Qt::Key_Down, lastRow, lastRow, "last, last")); |
|
775 |
||
776 |
events.push(Event(Qt::Key_Home, invalidIndex, firstRow, "inv, first")); |
|
777 |
events.push(Event(Qt::Key_End, invalidIndex, firstRow, "inv, first")); |
|
778 |
||
779 |
if (view->objectName() == "QTableView") { |
|
780 |
// In a table we move to the first/last column |
|
781 |
events.push(Event(Qt::Key_Home, hiddenRowT, firstRow, "hid, first")); |
|
782 |
events.push(Event(Qt::Key_Home, disabledRowT, disabledRowT, "dis, dis")); |
|
783 |
events.push(Event(Qt::Key_Home, firstRow, firstRow, "first, first")); |
|
784 |
events.push(Event(Qt::Key_Home, secondRow, secondRow, "sec, sec")); |
|
785 |
events.push(Event(Qt::Key_Home, disabledRowB, disabledRowB, "disB, disB")); |
|
786 |
events.push(Event(Qt::Key_Home, hiddenRowB, firstRow, "hidB, first")); |
|
787 |
events.push(Event(Qt::Key_Home, secondToLastRow, secondToLastRow, "secLast, secLast")); |
|
788 |
events.push(Event(Qt::Key_Home, lastRow, lastRow, "last, last")); |
|
789 |
||
790 |
int col = treeModel->columnCount() - 1; |
|
791 |
events.push(Event(Qt::Key_End, hiddenRowT, firstRow, "hidT, hidT")); |
|
792 |
events.push(Event(Qt::Key_End, disabledRowT, disabledRowT, "disT, disT")); |
|
793 |
events.push(Event(Qt::Key_End, firstRow, firstRow.sibling(firstRow.row(), col), "first, first_C")); |
|
794 |
events.push(Event(Qt::Key_End, secondRow, secondRow.sibling(secondRow.row(), col), "sec, sec_C")); |
|
795 |
events.push(Event(Qt::Key_End, disabledRowB, disabledRowB, "disB, disB")); |
|
796 |
events.push(Event(Qt::Key_End, hiddenRowB, firstRow, "hidB, hidB")); |
|
797 |
events.push(Event(Qt::Key_End, secondToLastRow, secondToLastRow.sibling(secondToLastRow.row(), col), "secLast, secLast_C")); |
|
798 |
events.push(Event(Qt::Key_End, lastRow, lastRow.sibling(lastRow.row(), col), "last, last_C")); |
|
799 |
} else { |
|
800 |
events.push(Event(Qt::Key_Home, hiddenRowT, firstRow, "hid, first")); |
|
801 |
events.push(Event(Qt::Key_Home, disabledRowT, firstRow, "dis, first")); |
|
802 |
events.push(Event(Qt::Key_Home, firstRow, firstRow, "first, first")); |
|
803 |
events.push(Event(Qt::Key_Home, secondRow, firstRow, "sec, first")); |
|
804 |
events.push(Event(Qt::Key_Home, disabledRowB, firstRow, "disB, first")); |
|
805 |
events.push(Event(Qt::Key_Home, hiddenRowB, firstRow, "hidB, first")); |
|
806 |
events.push(Event(Qt::Key_Home, secondToLastRow, firstRow, "sec, first")); |
|
807 |
events.push(Event(Qt::Key_Home, lastRow, firstRow, "last, first")); |
|
808 |
||
809 |
events.push(Event(Qt::Key_End, hiddenRowT, firstRow, "hid, last")); |
|
810 |
events.push(Event(Qt::Key_End, disabledRowT, lastRow, "dis, last")); |
|
811 |
events.push(Event(Qt::Key_End, firstRow, lastRow, "first, last")); |
|
812 |
events.push(Event(Qt::Key_End, secondRow, lastRow, "sec, last")); |
|
813 |
events.push(Event(Qt::Key_End, disabledRowB, lastRow, "disB, last")); |
|
814 |
events.push(Event(Qt::Key_End, hiddenRowB, firstRow, "hidB, last")); |
|
815 |
events.push(Event(Qt::Key_End, secondToLastRow, lastRow, "sec, last")); |
|
816 |
events.push(Event(Qt::Key_End, lastRow, lastRow, "last, last")); |
|
817 |
} |
|
818 |
||
819 |
events.push(Event(Qt::Key_PageDown, invalidIndex, firstRow, "inv, first")); |
|
820 |
events.push(Event(Qt::Key_PageDown, firstRow, QModelIndex(), "first, x")); |
|
821 |
events.push(Event(Qt::Key_PageDown, secondRow, QModelIndex(), "sec, x")); |
|
822 |
events.push(Event(Qt::Key_PageDown, hiddenRowT, QModelIndex(), "hid, x")); |
|
823 |
events.push(Event(Qt::Key_PageDown, disabledRowT, QModelIndex(), "dis, x")); |
|
824 |
events.push(Event(Qt::Key_PageDown, disabledRowB, lastRow, "disB, last")); |
|
825 |
events.push(Event(Qt::Key_PageDown, hiddenRowB, lastRow, "hidB, last")); |
|
826 |
events.push(Event(Qt::Key_PageDown, secondToLastRow, lastRow, "secLast, last")); |
|
827 |
events.push(Event(Qt::Key_PageDown, lastRow, lastRow, "last, last")); |
|
828 |
||
829 |
events.push(Event(Qt::Key_PageUp, invalidIndex, firstRow, "inv, first")); |
|
830 |
events.push(Event(Qt::Key_PageUp, firstRow, firstRow, "first, first")); |
|
831 |
events.push(Event(Qt::Key_PageUp, secondRow, firstRow, "sec, first")); |
|
832 |
events.push(Event(Qt::Key_PageUp, secondToLastRow, QModelIndex(), "secLast, x")); |
|
833 |
events.push(Event(Qt::Key_PageUp, lastRow, QModelIndex(), "last, x")); |
|
834 |
||
835 |
if (view->objectName() == "QTableView") { |
|
836 |
events.push(Event(Qt::Key_Left, firstRow, firstRow, "first_0, first")); |
|
837 |
events.push(Event(Qt::Key_Left, firstRow.sibling(0, 1), firstRow, "first_1, first")); |
|
838 |
events.push(Event(Qt::Key_Left, firstRow.sibling(0, 2), firstRow, "first_2, first")); |
|
839 |
events.push(Event(Qt::Key_Left, firstRow.sibling(0, 3), firstRow, "first_3, first")); |
|
840 |
events.push(Event(Qt::Key_Left, secondRow, secondRow, "sec, sec")); |
|
841 |
||
842 |
events.push(Event(Qt::Key_Right, firstRow, firstRow.sibling(0, 3), "first, first_3")); |
|
843 |
events.push(Event(Qt::Key_Right, firstRow.sibling(0, 1), firstRow, "first_1, first")); |
|
844 |
events.push(Event(Qt::Key_Right, firstRow.sibling(0, 2), firstRow.sibling(0, 3), "first_2, first_3")); |
|
845 |
events.push(Event(Qt::Key_Right, firstRow.sibling(0, treeModel->columnCount()-1), firstRow.sibling(0, treeModel->columnCount()-1), "first_3, sec")); |
|
846 |
} |
|
847 |
||
848 |
#if 0 // ### disable this part for now |
|
849 |
||
850 |
// ### hide the first/last row,column and re-run all of these tests |
|
851 |
// ### Not 100% sure, but I think the next to are tableview specific only and everyone else just does up/down |
|
852 |
// QAbstractItemView::MoveNext, AbstractItemView::MovePrevious |
|
853 |
||
854 |
while (!events.isEmpty()) { |
|
855 |
Event event = events.pop(); |
|
856 |
view->setCurrentIndex(event.start); |
|
857 |
QCOMPARE(view->currentIndex(), event.start); |
|
858 |
||
859 |
if (event.key == Qt::Key_PageUp && event.end == QModelIndex()) { |
|
860 |
QModelIndex x = view->indexAt(QPoint(1,1)); |
|
861 |
if (x.row() == 0) |
|
862 |
event.end = x; |
|
863 |
else |
|
864 |
event.end = x.sibling(x.row() - 1, x.column()); |
|
865 |
} |
|
866 |
if (event.key == Qt::Key_PageDown && event.end == QModelIndex()) { |
|
867 |
QModelIndex x = view->indexAt(QPoint(1, view->viewport()->height() - 10)); |
|
868 |
if (x.row() == view->model()->rowCount() - 1) |
|
869 |
event.end = x; |
|
870 |
else |
|
871 |
event.end = x.sibling(x.row() + 1, x.column()); |
|
872 |
} |
|
873 |
||
874 |
QTest::keyPress(view, event.key); |
|
875 |
QTest::keyRelease(view, event.key); |
|
876 |
QModelIndex current = view->currentIndex(); |
|
877 |
if (event.key == Qt::Key_PageUp) { |
|
878 |
int diff = event.end.row() - current.row(); |
|
879 |
QVERIFY(diff <= 2); |
|
880 |
continue; |
|
881 |
} |
|
882 |
if (event.key == Qt::Key_PageDown) { |
|
883 |
int diff = current.row() - event.end.row(); |
|
884 |
QVERIFY(diff <= 2); |
|
885 |
continue; |
|
886 |
} |
|
887 |
||
888 |
if (current != event.end) { |
|
889 |
QString k; |
|
890 |
if (event.key == Qt::Key_Up) k = "up"; |
|
891 |
if (event.key == Qt::Key_Right) k = "right"; |
|
892 |
if (event.key == Qt::Key_Left) k = "left"; |
|
893 |
if (event.key == Qt::Key_PageUp) k = "page up"; |
|
894 |
if (event.key == Qt::Key_PageDown) k = "page down"; |
|
895 |
if (event.key == Qt::Key_Down) k = "down"; |
|
896 |
if (event.key == Qt::Key_Home) k = "home"; |
|
897 |
if (event.key == Qt::Key_End) k = "end"; |
|
898 |
qDebug() << k << event.name << event.start << event.end << current; |
|
899 |
} |
|
900 |
QCOMPARE(current, event.end); |
|
901 |
} |
|
902 |
#endif |
|
903 |
} |
|
904 |
||
905 |
QTEST_MAIN(tst_QItemView) |
|
906 |
#include "tst_qitemview.moc" |