]>
cloud.milkyroute.net Git - dolphin.git/blob - src/tests/dolphinviewtest_allviewmodes.cpp
1 /****************************************************************************
2 * Copyright (C) 2010-2011 by Frank Reininghaus (frank78ac@googlemail.com) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 *****************************************************************************/
22 #include "dolphinviewtest_allviewmodes.h"
24 #include <qtest_kde.h>
28 #include "views/dolphinview.h"
29 #include "views/dolphinmodel.h"
30 #include "views/dolphindirlister.h"
31 #include "views/dolphinsortfilterproxymodel.h"
32 #include "views/zoomlevelinfo.h"
36 #include <qtestmouse.h>
37 #include <qtestkeyboard.h>
39 DolphinViewTest_AllViewModes::DolphinViewTest_AllViewModes() {
40 // Need to register KFileItemList for use with QSignalSpy
41 qRegisterMetaType
<KFileItemList
>("KFileItemList");
45 * testSelection() checks the basic selection functionality of DolphinView, including:
48 * selectedItemsCount()
54 * and the signal selectionChanged(const KFileItemList& selection)
57 Q_DECLARE_METATYPE(KFileItemList
)
59 void DolphinViewTest_AllViewModes::testSelection() {
61 const int totalItems
= 50;
62 for (int i
= 0; i
< totalItems
; i
++) {
63 dir
.createFile(QString("%1").arg(i
));
66 DolphinView
view(dir
.url(), 0);
67 QAbstractItemView
* itemView
= initView(&view
);
69 // Start with an empty selection
70 view
.clearSelection();
72 QCOMPARE(view
.selectedItems().count(), 0);
73 QCOMPARE(view
.selectedItemsCount(), 0);
74 QVERIFY(!view
.hasSelection());
76 // First some simple tests where either all or no items are selected
78 verifySelectedItemsCount(&view
, totalItems
);
80 view
.invertSelection();
81 verifySelectedItemsCount(&view
, 0);
83 view
.invertSelection();
84 verifySelectedItemsCount(&view
, totalItems
);
86 view
.clearSelection();
87 verifySelectedItemsCount(&view
, 0);
89 // Now we select individual items using mouse clicks
90 QModelIndex index
= itemView
->model()->index(2, 0);
91 itemView
->scrollTo(index
);
92 QTest::mouseClick(itemView
->viewport(), Qt::LeftButton
, Qt::ControlModifier
, itemView
->visualRect(index
).center());
93 verifySelectedItemsCount(&view
, 1);
95 index
= itemView
->model()->index(totalItems
- 5, 0);
96 itemView
->scrollTo(index
);
97 QTest::mouseClick(itemView
->viewport(), Qt::LeftButton
, Qt::ControlModifier
, itemView
->visualRect(index
).center());
98 verifySelectedItemsCount(&view
, 2);
100 index
= itemView
->model()->index(totalItems
- 2, 0);
101 itemView
->scrollTo(index
);
102 QTest::mouseClick(itemView
->viewport(), Qt::LeftButton
, Qt::ShiftModifier
, itemView
->visualRect(index
).center());
103 verifySelectedItemsCount(&view
, 5);
105 view
.invertSelection();
106 verifySelectedItemsCount(&view
, totalItems
- 5);
108 // Pressing Esc should clear the selection
109 QTest::keyClick(itemView
->viewport(), Qt::Key_Escape
);
110 verifySelectedItemsCount(&view
, 0);
114 * Check that setting the directory view properties works.
117 void DolphinViewTest_AllViewModes::testViewPropertySettings()
119 // Create some files with different sizes and modification times to check the different sorting options
120 QDateTime now
= QDateTime::currentDateTime();
123 dir
.createFile("a", "A file", now
.addDays(-3));
124 dir
.createFile("b", "A larger file", now
.addDays(0));
125 dir
.createDir("c", now
.addDays(-2));
126 dir
.createFile("d", "The largest file in this directory", now
.addDays(-1));
127 dir
.createFile("e", "An even larger file", now
.addDays(-4));
128 dir
.createFile(".f");
130 DolphinView
view(dir
.url(), 0);
133 // First set all settings to the default.
134 view
.setSorting(DolphinView::SortByName
);
135 QCOMPARE(view
.sorting(), DolphinView::SortByName
);
137 view
.setSortOrder(Qt::AscendingOrder
);
138 QCOMPARE(view
.sortOrder(), Qt::AscendingOrder
);
140 view
.setSortFoldersFirst(true);
141 QVERIFY(view
.sortFoldersFirst());
143 view
.setShowPreview(false);
144 QVERIFY(!view
.showPreview());
146 view
.setShowHiddenFiles(false);
147 QVERIFY(!view
.showHiddenFiles());
149 /** Check that the sort order is correct for different kinds of settings */
151 // Sort by Name, ascending
152 QCOMPARE(view
.sorting(), DolphinView::SortByName
);
153 QCOMPARE(view
.sortOrder(), Qt::AscendingOrder
);
154 QCOMPARE(viewItems(&view
), QStringList() << "c" << "a" << "b" << "d" << "e");
156 // Sort by Name, descending
157 view
.setSortOrder(Qt::DescendingOrder
);
158 QCOMPARE(view
.sorting(), DolphinView::SortByName
);
159 QCOMPARE(view
.sortOrder(), Qt::DescendingOrder
);
160 QCOMPARE(viewItems(&view
), QStringList() << "c" << "e" << "d" << "b" << "a");
162 // Sort by Size, descending
163 view
.setSorting(DolphinView::SortBySize
);
164 QCOMPARE(view
.sorting(), DolphinView::SortBySize
);
165 QCOMPARE(view
.sortOrder(), Qt::DescendingOrder
);
166 QCOMPARE(viewItems(&view
), QStringList() << "c" << "d" << "e" << "b" << "a");
168 // Sort by Size, ascending
169 view
.setSortOrder(Qt::AscendingOrder
);
170 QCOMPARE(view
.sorting(), DolphinView::SortBySize
);
171 QCOMPARE(view
.sortOrder(), Qt::AscendingOrder
);
172 QCOMPARE(viewItems(&view
), QStringList() << "c" << "a" << "b" << "e" << "d");
174 // Sort by Date, ascending
175 view
.setSorting(DolphinView::SortByDate
);
176 QCOMPARE(view
.sorting(), DolphinView::SortByDate
);
177 QCOMPARE(view
.sortOrder(), Qt::AscendingOrder
);
178 QCOMPARE(viewItems(&view
), QStringList() << "c" << "e" << "a" << "d" << "b");
180 // Sort by Date, descending
181 view
.setSortOrder(Qt::DescendingOrder
);
182 QCOMPARE(view
.sorting(), DolphinView::SortByDate
);
183 QCOMPARE(view
.sortOrder(), Qt::DescendingOrder
);
184 QCOMPARE(viewItems(&view
), QStringList() << "c" << "b" << "d" << "a" << "e");
186 // Disable "Sort Folders First"
187 view
.setSortFoldersFirst(false);
188 QVERIFY(!view
.sortFoldersFirst());
189 QCOMPARE(viewItems(&view
), QStringList()<< "b" << "d" << "c" << "a" << "e");
191 // Try again with Sort by Name, ascending
192 view
.setSorting(DolphinView::SortByName
);
193 view
.setSortOrder(Qt::AscendingOrder
);
194 QCOMPARE(view
.sorting(), DolphinView::SortByName
);
195 QCOMPARE(view
.sortOrder(), Qt::AscendingOrder
);
196 QCOMPARE(viewItems(&view
), QStringList() << "a" << "b" << "c" << "d" << "e");
198 // Show hidden files. This triggers the dir lister
199 // -> we have to wait until loading the hidden files is finished
200 view
.setShowHiddenFiles(true);
201 waitForFinishedPathLoading(&view
);
202 QVERIFY(view
.showHiddenFiles());
203 QCOMPARE(viewItems(&view
), QStringList() << ".f" << "a" << "b" << "c" << "d" << "e");
206 view
.setShowPreview(true);
207 QVERIFY(view
.showPreview());
209 // TODO: Check that the view properties are restored correctly when changing the folder and then going back.
213 * testZoomLevel() checks that setting the zoom level works, both using DolphinView's API and using Ctrl+mouse wheel.
216 void DolphinViewTest_AllViewModes::testZoomLevel()
219 dir
.createFiles(QStringList() << "a" << "b");
220 DolphinView
view(dir
.url(), 0);
221 QAbstractItemView
* itemView
= initView(&view
);
223 view
.setShowPreview(false);
224 QVERIFY(!view
.showPreview());
226 int zoomLevelBackup
= view
.zoomLevel();
228 int zoomLevel
= ZoomLevelInfo::minimumLevel();
229 view
.setZoomLevel(zoomLevel
);
230 QCOMPARE(view
.zoomLevel(), zoomLevel
);
232 // Increase the zoom level successively to the maximum.
233 while(zoomLevel
< ZoomLevelInfo::maximumLevel()) {
235 view
.setZoomLevel(zoomLevel
);
236 QCOMPARE(view
.zoomLevel(), zoomLevel
);
239 // Try setting a zoom level larger than the maximum
240 view
.setZoomLevel(ZoomLevelInfo::maximumLevel() + 1);
241 QCOMPARE(view
.zoomLevel(), ZoomLevelInfo::maximumLevel());
243 // Turn previews on and try setting a zoom level smaller than the minimum
244 view
.setShowPreview(true);
245 QVERIFY(view
.showPreview());
246 view
.setZoomLevel(ZoomLevelInfo::minimumLevel() - 1);
247 QCOMPARE(view
.zoomLevel(), ZoomLevelInfo::minimumLevel());
249 // Turn previews off again and check that the zoom level is restored
250 view
.setShowPreview(false);
251 QVERIFY(!view
.showPreview());
252 QCOMPARE(view
.zoomLevel(), ZoomLevelInfo::maximumLevel());
254 // Change the zoom level using Ctrl+mouse wheel
255 QModelIndex index
= itemView
->model()->index(0, 0);
256 itemView
->scrollTo(index
);
258 while (view
.zoomLevel() > ZoomLevelInfo::minimumLevel()) {
259 int oldZoomLevel
= view
.zoomLevel();
260 QWheelEvent
wheelEvent(itemView
->visualRect(index
).center(), -1, Qt::NoButton
, Qt::ControlModifier
);
261 bool wheelEventReceived
= qApp
->notify(itemView
->viewport(), &wheelEvent
);
262 QVERIFY(wheelEventReceived
);
263 QVERIFY(view
.zoomLevel() < oldZoomLevel
);
265 QCOMPARE(view
.zoomLevel(), ZoomLevelInfo::minimumLevel());
267 while (view
.zoomLevel() < ZoomLevelInfo::maximumLevel()) {
268 int oldZoomLevel
= view
.zoomLevel();
269 QWheelEvent
wheelEvent(itemView
->visualRect(index
).center(), 1, Qt::NoButton
, Qt::ControlModifier
);
270 bool wheelEventReceived
= qApp
->notify(itemView
->viewport(), &wheelEvent
);
271 QVERIFY(wheelEventReceived
);
272 QVERIFY(view
.zoomLevel() > oldZoomLevel
);
274 QCOMPARE(view
.zoomLevel(), ZoomLevelInfo::maximumLevel());
276 // Turn previews on again and check that the zoom level is restored
277 view
.setShowPreview(true);
278 QVERIFY(view
.showPreview());
279 QCOMPARE(view
.zoomLevel(), ZoomLevelInfo::minimumLevel());
281 // Restore the initial state
282 view
.setZoomLevel(zoomLevelBackup
);
283 view
.setShowPreview(false);
284 view
.setZoomLevel(zoomLevelBackup
);
288 * testSaveAndRestoreState() checks if saving and restoring the view state (current item, scroll position).
290 * Note that we call qApp->sendPostedEvents() every time the view's finishedPathLoading(const KUrl&) signal
291 * is received. The reason is that the scroll position is restored in the slot restoreContentsPosition(),
292 * which is been invoked using a queued connection in DolphinView::slotLoadingCompleted(). To make sure
293 * that this slot is really executed before we proceed, we have to empty the event queue using qApp->sendPostedEvents().
296 void DolphinViewTest_AllViewModes::testSaveAndRestoreState()
298 const int totalItems
= 50;
300 for (int i
= 0; i
< totalItems
; i
++) {
301 dir
.createFile(QString("%1").arg(i
));
304 DolphinView
view(dir
.url(), 0);
307 // Set sorting settings to the default to make sure that the item positions are reproducible.
308 view
.setSorting(DolphinView::SortByName
);
309 QCOMPARE(view
.sorting(), DolphinView::SortByName
);
310 view
.setSortOrder(Qt::AscendingOrder
);
311 QCOMPARE(view
.sortOrder(), Qt::AscendingOrder
);
313 // Make sure that previews are off and that the icon size does not depend on the preview setting.
314 // This is needed for the test for bug 270437, see below.
315 view
.setShowPreview(false);
316 int zoomLevel
= view
.zoomLevel();
317 view
.setShowPreview(true);
318 view
.setZoomLevel(zoomLevel
);
319 view
.setShowPreview(false);
322 const QModelIndex index45
= itemView(&view
)->model()->index(45, 0);
323 itemView(&view
)->scrollTo(index45
);
324 itemView(&view
)->setCurrentIndex(index45
);
325 const int scrollPosX
= itemView(&view
)->horizontalScrollBar()->value();
326 const int scrollPosY
= itemView(&view
)->verticalScrollBar()->value();
328 // Save the view state
329 QByteArray viewState
;
330 QDataStream
saveStream(&viewState
, QIODevice::WriteOnly
);
331 view
.saveState(saveStream
);
334 view
.setUrl(KUrl(dir
.name() + "51"));
335 waitForFinishedPathLoading(&view
);
336 qApp
->sendPostedEvents();
338 // Go back, but do not call DolphinView::restoreState()
339 view
.setUrl(dir
.url());
340 waitForFinishedPathLoading(&view
);
341 qApp
->sendPostedEvents();
343 // Verify that the view is scrolled to top-left corner and that item 45 is not the current item.
344 // Note that the vertical position of the columns view might not be zero -> skip that part
345 // of the check in this case.
346 QVERIFY(itemView(&view
)->currentIndex() != index45
);
347 QCOMPARE(itemView(&view
)->horizontalScrollBar()->value(), 0);
348 if (mode() != DolphinView::ColumnView
) {
349 QCOMPARE(itemView(&view
)->verticalScrollBar()->value(), 0);
352 // Change the URL again
353 view
.setUrl(KUrl(dir
.name() + "51"));
354 waitForFinishedPathLoading(&view
);
355 qApp
->sendPostedEvents();
357 // Check that the current item and scroll position are correct if DolphinView::restoreState()
358 // is called after the URL change
359 view
.setUrl(dir
.url());
360 QDataStream
restoreStream(viewState
);
361 view
.restoreState(restoreStream
);
362 waitForFinishedPathLoading(&view
);
363 qApp
->sendPostedEvents();
365 QCOMPARE(itemView(&view
)->currentIndex(), index45
);
366 QCOMPARE(itemView(&view
)->horizontalScrollBar()->value(), scrollPosX
);
367 QCOMPARE(itemView(&view
)->verticalScrollBar()->value(), scrollPosY
);
370 * Additionally, we verify the fix for the bug https://bugs.kde.org/show_bug.cgi?id=270437
371 * Actually, it's a bug in KFilePreviewGenerator, but it is easier to test it here.
375 view
.setShowPreview(true);
376 QVERIFY(view
.showPreview());
378 // We have to process all events in the queue to make sure that previews are really on.
379 qApp
->sendPostedEvents();
381 // Current item and scroll position should not change.
382 QCOMPARE(itemView(&view
)->currentIndex(), index45
);
383 QCOMPARE(itemView(&view
)->horizontalScrollBar()->value(), scrollPosX
);
384 QCOMPARE(itemView(&view
)->verticalScrollBar()->value(), scrollPosY
);
386 // Turn previews off again. Before bug 270437, this triggered the dir lister's openUrl() method
387 // -> we check that by listening to the view's startedPathLoading() signal and wait until the loading is finished in that case.
388 QSignalSpy
spy(&view
, SIGNAL(startedPathLoading(const KUrl
&)));
389 view
.setShowPreview(false);
390 QVERIFY(!view
.showPreview());
391 qApp
->sendPostedEvents();
392 if (!spy
.isEmpty()) {
393 // The dir lister reloads the directory. We wait until the loading is finished.
394 waitForFinishedPathLoading(&view
);
397 // Current item and scroll position should not change.
398 QCOMPARE(itemView(&view
)->currentIndex(), index45
);
399 QCOMPARE(itemView(&view
)->horizontalScrollBar()->value(), scrollPosX
);
400 QCOMPARE(itemView(&view
)->verticalScrollBar()->value(), scrollPosY
);
404 * testKeyboardFocus() checks whether a view grabs the keyboard focus.
406 * A view may never grab the keyboard focus itself and must respect the focus-state
407 * when switching the view mode, see
409 * https://bugs.kde.org/show_bug.cgi?id=261147
412 void DolphinViewTest_AllViewModes::testKeyboardFocus()
415 dir
.createFiles(QStringList() << "a" << "b");
416 DolphinView
view(dir
.url(), 0);
419 // Move the keyboard focus to another widget.
422 QTest::qWaitForWindowShown(&widget
);
425 QVERIFY(!view
.hasFocus());
427 // Switch view modes and verify that the view does not get the focus back
428 for (int i
= 0; i
<= DolphinView::MaxModeEnum
; ++i
) {
429 view
.setMode(static_cast<DolphinView::Mode
>(i
));
430 QVERIFY(!view
.hasFocus());
435 * testCutCopyPaste() checks if cutting or copying items in one view and pasting
436 * them in another one works.
439 void DolphinViewTest_AllViewModes::testCutCopyPaste()
442 dir1
.createFiles(QStringList() << "a" << "b" << "c" << "d");
443 DolphinView
view1(dir1
.url(), 0);
444 QAbstractItemView
* itemView1
= initView(&view1
);
447 dir2
.createFiles(QStringList() << "1" << "2" << "3" << "4");
448 dir2
.createDir("subfolder");
449 DolphinView
view2(dir2
.url(), 0);
450 QAbstractItemView
* itemView2
= initView(&view2
);
452 // Make sure that both views are sorted by name in ascending order
453 // TODO: Maybe that should be done in initView(), such all tests can rely on it...?
454 view1
.setSorting(DolphinView::SortByName
);
455 view1
.setSortOrder(Qt::AscendingOrder
);
456 view2
.setSorting(DolphinView::SortByName
);
457 view2
.setSortOrder(Qt::AscendingOrder
);
458 view2
.setSortFoldersFirst(true);
460 QCOMPARE(viewItems(&view1
), QStringList() << "a" << "b" << "c" << "d");
461 QCOMPARE(viewItems(&view2
), QStringList() << "subfolder" << "1" << "2" << "3" << "4");
463 /** Copy and paste */
464 // Select an item ("d") n view1, copy it and paste it in view2.
465 // Note that we have to wait for view2's finishedPathLoading() signal because the pasting is done in the background.
466 QModelIndex index
= itemView1
->model()->index(3, 0);
467 itemView1
->scrollTo(index
);
468 QTest::mouseClick(itemView1
->viewport(), Qt::LeftButton
, Qt::ControlModifier
, itemView1
->visualRect(index
).center());
469 verifySelectedItemsCount(&view1
, 1);
470 QCOMPARE(selectedItems(&view1
), QStringList() << "d");
471 view1
.copySelectedItems();
473 waitForFinishedPathLoading(&view2
);
474 QCOMPARE(viewItems(&view1
), QStringList() << "a" << "b" << "c" << "d");
475 QCOMPARE(viewItems(&view2
), QStringList() << "subfolder" << "1" << "2" << "3" << "4" << "d");
476 // The pasted item should be selected
477 QCOMPARE(selectedItems(&view2
), QStringList() << "d");
480 // Select two items ("3", "4") in view2, cut and paste in view1.
481 view2
.clearSelection();
482 index
= itemView2
->model()->index(3, 0);
483 itemView2
->scrollTo(index
);
484 QTest::mouseClick(itemView2
->viewport(), Qt::LeftButton
, Qt::ControlModifier
, itemView2
->visualRect(index
).center());
485 verifySelectedItemsCount(&view2
, 1);
486 index
= itemView2
->model()->index(4, 0);
487 itemView2
->scrollTo(index
);
488 QTest::mouseClick(itemView2
->viewport(), Qt::LeftButton
, Qt::ShiftModifier
, itemView2
->visualRect(index
).center());
489 verifySelectedItemsCount(&view2
, 2);
490 QCOMPARE(selectedItems(&view2
), QStringList() << "3" << "4");
491 view2
.cutSelectedItems();
492 // In view1, "d" is still selected
493 QCOMPARE(selectedItems(&view1
), QStringList() << "d");
496 waitForFinishedPathLoading(&view1
);
497 // In principle, KIO could implement copy&paste such that the pasted items are already there, but the cut items
498 // have not been removed yet. Therefore, we check the number of items in view2 and also wait for that view's
499 // finishedPathLoading() signal if the cut items are still there.
500 if (viewItems(&view2
).count() > 4) {
501 waitForFinishedPathLoading(&view2
);
503 QCOMPARE(viewItems(&view1
), QStringList() << "3" << "4" << "a" << "b" << "c" << "d");
504 QCOMPARE(viewItems(&view2
), QStringList() << "subfolder" << "1" << "2" << "d");
505 // The pasted items ("3", "4") should be selected now, and the previous selection ("d") should be cleared.
506 QCOMPARE(selectedItems(&view1
), QStringList() << "3" << "4");
508 /** Copy and paste into subfolder */
509 view1
.clearSelection();
510 index
= itemView1
->model()->index(3, 0);
511 itemView1
->scrollTo(index
);
512 QTest::mouseClick(itemView1
->viewport(), Qt::LeftButton
, Qt::ControlModifier
, itemView1
->visualRect(index
).center());
513 verifySelectedItemsCount(&view1
, 1);
514 QCOMPARE(selectedItems(&view1
), QStringList() << "b");
515 view1
.copySelectedItems();
516 // Now we use view1 to display the subfolder, which is still empty.
517 view1
.setUrl(KUrl(dir2
.name() + "subfolder"));
518 waitForFinishedPathLoading(&view1
);
519 QCOMPARE(viewItems(&view1
), QStringList());
520 // Select the subfolder.in view2
521 view2
.clearSelection();
522 index
= itemView2
->model()->index(0, 0);
523 itemView2
->scrollTo(index
);
524 QTest::mouseClick(itemView2
->viewport(), Qt::LeftButton
, Qt::ControlModifier
, itemView2
->visualRect(index
).center());
525 verifySelectedItemsCount(&view2
, 1);
526 // Paste into the subfolder
527 view2
.pasteIntoFolder();
528 waitForFinishedPathLoading(&view1
);
529 QCOMPARE(viewItems(&view1
), QStringList() << "b");
530 // The pasted items in view1 are *not* selected now (because the pasting was done indirectly using view2.pasteIntoFolder()).
533 // Private member functions which are used by the tests
536 * initView(DolphinView*) sets the correct view mode, shows the view on the screen, and waits until loading the
537 * folder in the view is finished.
539 * Many unit tests need access to DolphinView's internal item view (icons, details, or columns).
540 * Therefore, a pointer to the item view is returned by initView(DolphinView*).
543 QAbstractItemView
* DolphinViewTest_AllViewModes::initView(DolphinView
* view
) const
545 QSignalSpy
spyFinishedPathLoading(view
, SIGNAL(finishedPathLoading(const KUrl
&)));
546 view
->setMode(mode());
547 Q_ASSERT(verifyCorrectViewMode(view
));
548 view
->resize(200, 300);
550 QTest::qWaitForWindowShown(view
);
552 // If the DolphinView's finishedPathLoading(const KUrl&) signal has not been received yet,
553 // we have to wait a bit more.
554 // The reason why the if-statement is needed here is that the signal might have been emitted
555 // while we were waiting in QTest::qWaitForWindowShown(view)
556 // -> waitForFinishedPathLoading(view) would fail in that case.
557 if (spyFinishedPathLoading
.isEmpty()) {
558 waitForFinishedPathLoading(view
);
561 return itemView(view
);
565 * verifySelectedItemsCount(int) waits until the DolphinView's selectionChanged(const KFileItemList&)
566 * signal is received and checks that the selection state of the view is as expected.
569 void DolphinViewTest_AllViewModes::verifySelectedItemsCount(DolphinView
* view
, int itemsCount
) const
571 QSignalSpy
spySelectionChanged(view
, SIGNAL(selectionChanged(const KFileItemList
&)));
572 QVERIFY(QTest::kWaitForSignal(view
, SIGNAL(selectionChanged(const KFileItemList
&)), 500));
574 QCOMPARE(view
->selectedItems().count(), itemsCount
);
575 QCOMPARE(view
->selectedItemsCount(), itemsCount
);
576 QCOMPARE(spySelectionChanged
.count(), 1);
577 QCOMPARE(qvariant_cast
<KFileItemList
>(spySelectionChanged
.at(0).at(0)).count(), itemsCount
);
579 QVERIFY(view
->hasSelection());
582 QVERIFY(!view
->hasSelection());
586 #include "dolphinviewtest_allviewmodes.moc"