1 /***************************************************************************
2 * Copyright (C) 2012 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 ***************************************************************************/
20 #include <qtest_kde.h>
21 #include <qtestmouse.h>
22 #include <qtestkeyboard.h>
24 #include "kitemviews/kitemlistcontainer.h"
25 #include "kitemviews/kfileitemlistview.h"
26 #include "kitemviews/kfileitemmodel.h"
27 #include "kitemviews/kitemlistcontroller.h"
28 #include "kitemviews/kitemlistselectionmanager.h"
29 #include "kitemviews/private/kitemlistviewlayouter.h"
33 const int DefaultTimeout
= 2000;
36 Q_DECLARE_METATYPE(KFileItemListView::ItemLayout
);
37 Q_DECLARE_METATYPE(Qt::Orientation
);
38 Q_DECLARE_METATYPE(KItemListController::SelectionBehavior
);
39 Q_DECLARE_METATYPE(QSet
<int>);
41 class KItemListControllerTest
: public QObject
47 void cleanupTestCase();
52 void testKeyboardNavigation_data();
53 void testKeyboardNavigation();
57 * Make sure that the number of columns in the view is equal to \a count
58 * by changing the geometry of the container.
60 void adjustGeometryForColumnCount(int count
);
63 KFileItemListView
* m_view
;
64 KItemListController
* m_controller
;
65 KItemListSelectionManager
* m_selectionManager
;
66 KFileItemModel
* m_model
;
68 KItemListContainer
* m_container
;
72 * This function initializes the member objects, creates the temporary files, and
73 * shows the view on the screen on startup. This could also be done before every
74 * single test, but this would make the time needed to run the test much larger.
76 void KItemListControllerTest::initTestCase()
78 qRegisterMetaType
<QSet
<int> >("QSet<int>");
80 m_testDir
= new TestDir();
81 m_model
= new KFileItemModel();
82 m_view
= new KFileItemListView();
83 m_controller
= new KItemListController(m_model
, m_view
, this);
84 m_container
= new KItemListContainer(m_controller
);
85 m_controller
= m_container
->controller();
86 m_controller
->setSelectionBehavior(KItemListController::MultiSelection
);
87 m_selectionManager
= m_controller
->selectionManager();
91 << "a1" << "a2" << "a3"
93 << "c1" << "c2" << "c3" << "c4" << "c5"
94 << "d1" << "d2" << "d3" << "d4"
95 << "e1" << "e2" << "e3" << "e4" << "e5" << "e6" << "e7";
97 m_testDir
->createFiles(files
);
98 m_model
->loadDirectory(m_testDir
->url());
99 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(directoryLoadingCompleted()), DefaultTimeout
));
102 QTest::qWaitForWindowShown(m_container
);
105 void KItemListControllerTest::cleanupTestCase()
114 /** Before each test, the current item, selection, and item size are reset to the defaults. */
115 void KItemListControllerTest::init()
117 m_selectionManager
->setCurrentItem(0);
118 QCOMPARE(m_selectionManager
->currentItem(), 0);
120 m_selectionManager
->clearSelection();
121 QVERIFY(!m_selectionManager
->hasSelection());
123 const QSizeF
itemSize(50, 50);
124 m_view
->setItemSize(itemSize
);
125 QCOMPARE(m_view
->itemSize(), itemSize
);
128 void KItemListControllerTest::cleanup()
133 * \class KeyPress is a small helper struct that represents a key press event,
134 * including the key and the keyboard modifiers.
138 KeyPress(Qt::Key key
, Qt::KeyboardModifiers modifier
= Qt::NoModifier
) :
144 Qt::KeyboardModifiers m_modifier
;
148 * \class ViewState is a small helper struct that represents a certain state
149 * of the view, including the current item, the selected items in MultiSelection
150 * mode (in the other modes, the selection is either empty or equal to the
151 * current item), and the information whether items were activated by the last
156 ViewState(int current
, const QSet
<int> selection
, bool activated
= false) :
158 m_selection(selection
),
159 m_activated(activated
)
163 QSet
<int> m_selection
;
167 // We have to define a typedef for the pair in order to make the test compile.
168 typedef QPair
<KeyPress
, ViewState
> keyPressViewStatePair
;
169 Q_DECLARE_METATYPE(QList
<keyPressViewStatePair
>);
172 * This function provides the data for the actual test function
173 * KItemListControllerTest::testKeyboardNavigation().
174 * It tests all possible combinations of view layouts, selection behaviors,
175 * and enabled/disabled groupings for different column counts, and
176 * provides a list of key presses and the states that the view should be in
177 * after the key press event.
179 void KItemListControllerTest::testKeyboardNavigation_data()
181 QTest::addColumn
<KFileItemListView::ItemLayout
>("layout");
182 QTest::addColumn
<Qt::Orientation
>("scrollOrientation");
183 QTest::addColumn
<int>("columnCount");
184 QTest::addColumn
<KItemListController::SelectionBehavior
>("selectionBehavior");
185 QTest::addColumn
<bool>("groupingEnabled");
186 QTest::addColumn
<QList
<QPair
<KeyPress
, ViewState
> > >("testList");
188 QList
<KFileItemListView::ItemLayout
> layoutList
;
189 QHash
<KFileItemListView::ItemLayout
, QString
> layoutNames
;
190 layoutList
.append(KFileItemListView::IconsLayout
);
191 layoutNames
[KFileItemListView::IconsLayout
] = "Icons";
192 layoutList
.append(KFileItemListView::CompactLayout
);
193 layoutNames
[KFileItemListView::CompactLayout
] = "Compact";
194 layoutList
.append(KFileItemListView::DetailsLayout
);
195 layoutNames
[KFileItemListView::DetailsLayout
] = "Details";
197 QList
<KItemListController::SelectionBehavior
> selectionBehaviorList
;
198 QHash
<KItemListController::SelectionBehavior
, QString
> selectionBehaviorNames
;
199 selectionBehaviorList
.append(KItemListController::NoSelection
);
200 selectionBehaviorNames
[KItemListController::NoSelection
] = "NoSelection";
201 selectionBehaviorList
.append(KItemListController::SingleSelection
);
202 selectionBehaviorNames
[KItemListController::SingleSelection
] = "SingleSelection";
203 selectionBehaviorList
.append(KItemListController::MultiSelection
);
204 selectionBehaviorNames
[KItemListController::MultiSelection
] = "MultiSelection";
206 QList
<bool> groupingEnabledList
;
207 QHash
<bool, QString
> groupingEnabledNames
;
208 groupingEnabledList
.append(false);
209 groupingEnabledNames
[false] = "ungrouped";
210 groupingEnabledList
.append(true);
211 groupingEnabledNames
[true] = "grouping enabled";
213 foreach (KFileItemListView::ItemLayout layout
, layoutList
) {
214 // The following settings depend on the layout.
215 // Note that 'columns' are actually 'rows' in
217 Qt::Orientation scrollOrientation
;
218 QList
<int> columnCountList
;
220 Qt::Key previousItemKey
;
222 Qt::Key previousRowKey
;
225 case KFileItemListView::IconsLayout
:
226 scrollOrientation
= Qt::Vertical
;
227 columnCountList
<< 1 << 3 << 5;
228 nextItemKey
= Qt::Key_Right
;
229 previousItemKey
= Qt::Key_Left
;
230 nextRowKey
= Qt::Key_Down
;
231 previousRowKey
= Qt::Key_Up
;
233 case KFileItemListView::CompactLayout
:
234 scrollOrientation
= Qt::Horizontal
;
235 columnCountList
<< 1 << 3 << 5;
236 nextItemKey
= Qt::Key_Down
;
237 previousItemKey
= Qt::Key_Up
;
238 nextRowKey
= Qt::Key_Right
;
239 previousRowKey
= Qt::Key_Left
;
241 case KFileItemListView::DetailsLayout
:
242 scrollOrientation
= Qt::Vertical
;
243 columnCountList
<< 1;
244 nextItemKey
= Qt::Key_Down
;
245 previousItemKey
= Qt::Key_Up
;
246 nextRowKey
= Qt::Key_Down
;
247 previousRowKey
= Qt::Key_Up
;
251 foreach (int columnCount
, columnCountList
) {
252 foreach (KItemListController::SelectionBehavior selectionBehavior
, selectionBehaviorList
) {
253 foreach (bool groupingEnabled
, groupingEnabledList
) {
254 QList
<QPair
<KeyPress
, ViewState
> > testList
;
256 // First, key presses which should have the same effect
257 // for any layout and any number of columns.
259 << qMakePair(KeyPress(nextItemKey
), ViewState(1, QSet
<int>() << 1))
260 << qMakePair(KeyPress(Qt::Key_Return
), ViewState(1, QSet
<int>() << 1, true))
261 << qMakePair(KeyPress(Qt::Key_Enter
), ViewState(1, QSet
<int>() << 1, true))
262 << qMakePair(KeyPress(nextItemKey
), ViewState(2, QSet
<int>() << 2))
263 << qMakePair(KeyPress(nextItemKey
, Qt::ShiftModifier
), ViewState(3, QSet
<int>() << 2 << 3))
264 << qMakePair(KeyPress(Qt::Key_Return
), ViewState(3, QSet
<int>() << 2 << 3, true))
265 << qMakePair(KeyPress(previousItemKey
, Qt::ShiftModifier
), ViewState(2, QSet
<int>() << 2))
266 << qMakePair(KeyPress(nextItemKey
, Qt::ShiftModifier
), ViewState(3, QSet
<int>() << 2 << 3))
267 << qMakePair(KeyPress(nextItemKey
, Qt::ControlModifier
), ViewState(4, QSet
<int>() << 2 << 3))
268 << qMakePair(KeyPress(Qt::Key_Return
), ViewState(4, QSet
<int>() << 2 << 3, true))
269 << qMakePair(KeyPress(previousItemKey
), ViewState(3, QSet
<int>() << 3))
270 << qMakePair(KeyPress(Qt::Key_Home
, Qt::ShiftModifier
), ViewState(0, QSet
<int>() << 0 << 1 << 2 << 3))
271 << qMakePair(KeyPress(nextItemKey
, Qt::ControlModifier
), ViewState(1, QSet
<int>() << 0 << 1 << 2 << 3))
272 << qMakePair(KeyPress(Qt::Key_Space
, Qt::ControlModifier
), ViewState(1, QSet
<int>() << 0 << 2 << 3))
273 << qMakePair(KeyPress(Qt::Key_Space
, Qt::ControlModifier
), ViewState(1, QSet
<int>() << 0 << 1 << 2 << 3))
274 << qMakePair(KeyPress(Qt::Key_End
), ViewState(19, QSet
<int>() << 19))
275 << qMakePair(KeyPress(previousItemKey
, Qt::ShiftModifier
), ViewState(18, QSet
<int>() << 18 << 19))
276 << qMakePair(KeyPress(Qt::Key_Home
), ViewState(0, QSet
<int>() << 0))
277 << qMakePair(KeyPress(Qt::Key_Space
, Qt::ControlModifier
), ViewState(0, QSet
<int>()))
278 << qMakePair(KeyPress(Qt::Key_Enter
), ViewState(0, QSet
<int>(), true))
279 << qMakePair(KeyPress(Qt::Key_Space
, Qt::ControlModifier
), ViewState(0, QSet
<int>() << 0));
281 // Next, we test combinations of key presses which only work for a
282 // particular number of columns and either enabled or disabled grouping.
285 if (columnCount
== 1) {
287 << qMakePair(KeyPress(nextRowKey
), ViewState(1, QSet
<int>() << 1))
288 << qMakePair(KeyPress(nextRowKey
, Qt::ShiftModifier
), ViewState(2, QSet
<int>() << 1 << 2))
289 << qMakePair(KeyPress(nextRowKey
, Qt::ControlModifier
), ViewState(3, QSet
<int>() << 1 << 2))
290 << qMakePair(KeyPress(previousRowKey
), ViewState(2, QSet
<int>() << 2))
291 << qMakePair(KeyPress(previousItemKey
), ViewState(1, QSet
<int>() << 1))
292 << qMakePair(KeyPress(Qt::Key_Home
), ViewState(0, QSet
<int>() << 0));
295 // Multiple columns: we test both 3 and 5 columns with grouping
296 // enabled or disabled. For each case, the layout of the items
297 // in the view is shown (both using file names and indices) to
298 // make it easier to understand what the tests do.
300 if (columnCount
== 3 && !groupingEnabled
) {
301 // 3 columns, no grouping:
306 // d1 d2 d3 | 9 10 11
307 // d4 e1 e2 | 12 13 14
308 // e3 e4 e5 | 15 16 17
311 << qMakePair(KeyPress(nextRowKey
), ViewState(3, QSet
<int>() << 3))
312 << qMakePair(KeyPress(nextItemKey
, Qt::ControlModifier
), ViewState(4, QSet
<int>() << 3))
313 << qMakePair(KeyPress(nextRowKey
), ViewState(7, QSet
<int>() << 7))
314 << qMakePair(KeyPress(nextItemKey
, Qt::ShiftModifier
), ViewState(8, QSet
<int>() << 7 << 8))
315 << qMakePair(KeyPress(nextItemKey
, Qt::ShiftModifier
), ViewState(9, QSet
<int>() << 7 << 8 << 9))
316 << qMakePair(KeyPress(previousItemKey
, Qt::ShiftModifier
), ViewState(8, QSet
<int>() << 7 << 8))
317 << qMakePair(KeyPress(previousItemKey
, Qt::ShiftModifier
), ViewState(7, QSet
<int>() << 7))
318 << qMakePair(KeyPress(previousItemKey
, Qt::ShiftModifier
), ViewState(6, QSet
<int>() << 6 << 7))
319 << qMakePair(KeyPress(previousItemKey
, Qt::ShiftModifier
), ViewState(5, QSet
<int>() << 5 << 6 << 7))
320 << qMakePair(KeyPress(nextItemKey
, Qt::ShiftModifier
), ViewState(6, QSet
<int>() << 6 << 7))
321 << qMakePair(KeyPress(nextItemKey
, Qt::ShiftModifier
), ViewState(7, QSet
<int>() << 7))
322 << qMakePair(KeyPress(nextRowKey
), ViewState(10, QSet
<int>() << 10))
323 << qMakePair(KeyPress(nextItemKey
), ViewState(11, QSet
<int>() << 11))
324 << qMakePair(KeyPress(nextRowKey
), ViewState(14, QSet
<int>() << 14))
325 << qMakePair(KeyPress(nextRowKey
), ViewState(17, QSet
<int>() << 17))
326 << qMakePair(KeyPress(nextRowKey
), ViewState(19, QSet
<int>() << 19))
327 << qMakePair(KeyPress(previousRowKey
), ViewState(17, QSet
<int>() << 17))
328 << qMakePair(KeyPress(Qt::Key_End
), ViewState(19, QSet
<int>() << 19))
329 << qMakePair(KeyPress(previousRowKey
), ViewState(16, QSet
<int>() << 16))
330 << qMakePair(KeyPress(Qt::Key_Home
), ViewState(0, QSet
<int>() << 0));
333 if (columnCount
== 5 && !groupingEnabled
) {
334 // 5 columns, no grouping:
336 // a1 a2 a3 b1 c1 | 0 1 2 3 4
337 // c2 c3 c4 c5 d1 | 5 6 7 8 9
338 // d2 d3 d4 e1 e2 | 10 11 12 13 14
339 // e3 e4 e5 e6 e7 | 15 16 17 18 19
341 << qMakePair(KeyPress(nextRowKey
), ViewState(5, QSet
<int>() << 5))
342 << qMakePair(KeyPress(nextItemKey
, Qt::ControlModifier
), ViewState(6, QSet
<int>() << 5))
343 << qMakePair(KeyPress(nextRowKey
), ViewState(11, QSet
<int>() << 11))
344 << qMakePair(KeyPress(nextItemKey
), ViewState(12, QSet
<int>() << 12))
345 << qMakePair(KeyPress(nextRowKey
, Qt::ShiftModifier
), ViewState(17, QSet
<int>() << 12 << 13 << 14 << 15 << 16 << 17))
346 << qMakePair(KeyPress(previousRowKey
, Qt::ShiftModifier
), ViewState(12, QSet
<int>() << 12))
347 << qMakePair(KeyPress(previousRowKey
, Qt::ShiftModifier
), ViewState(7, QSet
<int>() << 7 << 8 << 9 << 10 << 11 << 12))
348 << qMakePair(KeyPress(nextRowKey
, Qt::ShiftModifier
), ViewState(12, QSet
<int>() << 12))
349 << qMakePair(KeyPress(Qt::Key_End
, Qt::ControlModifier
), ViewState(19, QSet
<int>() << 12))
350 << qMakePair(KeyPress(previousRowKey
), ViewState(14, QSet
<int>() << 14))
351 << qMakePair(KeyPress(Qt::Key_Home
), ViewState(0, QSet
<int>() << 0));
354 if (columnCount
== 3 && groupingEnabled
) {
355 // 3 columns, with grouping:
361 // d1 d2 d3 | 9 10 11
363 // e1 e2 e3 | 13 14 15
364 // e4 e5 e6 | 16 17 18
367 << qMakePair(KeyPress(nextItemKey
), ViewState(1, QSet
<int>() << 1))
368 << qMakePair(KeyPress(nextItemKey
), ViewState(2, QSet
<int>() << 2))
369 << qMakePair(KeyPress(nextRowKey
, Qt::ShiftModifier
), ViewState(3, QSet
<int>() << 2 << 3))
370 << qMakePair(KeyPress(nextRowKey
, Qt::ShiftModifier
), ViewState(6, QSet
<int>() << 2 << 3 << 4 << 5 << 6))
371 << qMakePair(KeyPress(nextRowKey
), ViewState(8, QSet
<int>() << 8))
372 << qMakePair(KeyPress(nextRowKey
), ViewState(11, QSet
<int>() << 11))
373 << qMakePair(KeyPress(nextItemKey
, Qt::ControlModifier
), ViewState(12, QSet
<int>() << 11))
374 << qMakePair(KeyPress(nextRowKey
), ViewState(13, QSet
<int>() << 13))
375 << qMakePair(KeyPress(nextRowKey
), ViewState(16, QSet
<int>() << 16))
376 << qMakePair(KeyPress(nextItemKey
), ViewState(17, QSet
<int>() << 17))
377 << qMakePair(KeyPress(nextRowKey
), ViewState(19, QSet
<int>() << 19))
378 << qMakePair(KeyPress(previousRowKey
), ViewState(17, QSet
<int>() << 17))
379 << qMakePair(KeyPress(Qt::Key_Home
), ViewState(0, QSet
<int>() << 0));
382 if (columnCount
== 5 && groupingEnabled
) {
383 // 5 columns, with grouping:
387 // c1 c2 c3 c4 c5 | 4 5 6 7 8
388 // d1 d2 d3 d4 | 9 10 11 12
389 // e1 e2 e3 e4 e5 | 13 14 15 16 17
392 << qMakePair(KeyPress(nextItemKey
), ViewState(1, QSet
<int>() << 1))
393 << qMakePair(KeyPress(nextRowKey
, Qt::ShiftModifier
), ViewState(3, QSet
<int>() << 1 << 2 << 3))
394 << qMakePair(KeyPress(nextRowKey
, Qt::ShiftModifier
), ViewState(5, QSet
<int>() << 1 << 2 << 3 << 4 << 5))
395 << qMakePair(KeyPress(nextItemKey
), ViewState(6, QSet
<int>() << 6))
396 << qMakePair(KeyPress(nextItemKey
, Qt::ControlModifier
), ViewState(7, QSet
<int>() << 6))
397 << qMakePair(KeyPress(nextItemKey
, Qt::ControlModifier
), ViewState(8, QSet
<int>() << 6))
398 << qMakePair(KeyPress(nextRowKey
), ViewState(12, QSet
<int>() << 12))
399 << qMakePair(KeyPress(nextRowKey
), ViewState(17, QSet
<int>() << 17))
400 << qMakePair(KeyPress(nextRowKey
), ViewState(19, QSet
<int>() << 19))
401 << qMakePair(KeyPress(previousRowKey
), ViewState(17, QSet
<int>() << 17))
402 << qMakePair(KeyPress(Qt::Key_End
, Qt::ShiftModifier
), ViewState(19, QSet
<int>() << 17 << 18 << 19))
403 << qMakePair(KeyPress(previousRowKey
, Qt::ShiftModifier
), ViewState(14, QSet
<int>() << 14 << 15 << 16 << 17))
404 << qMakePair(KeyPress(Qt::Key_Home
), ViewState(0, QSet
<int>() << 0));
407 const QString testName
=
408 layoutNames
[layout
] + ", " +
409 QString("%1 columns, ").arg(columnCount
) +
410 selectionBehaviorNames
[selectionBehavior
] + ", " +
411 groupingEnabledNames
[groupingEnabled
];
413 const QByteArray testNameAscii
= testName
.toAscii();
415 QTest::newRow(testNameAscii
.data())
429 * This function sets the view's properties according to the data provided by
430 * KItemListControllerTest::testKeyboardNavigation_data().
432 * The list \a testList contains pairs of key presses, which are sent to the
433 * container, and expected view states, which are verified then.
435 void KItemListControllerTest::testKeyboardNavigation()
437 QFETCH(KFileItemListView::ItemLayout
, layout
);
438 QFETCH(Qt::Orientation
, scrollOrientation
);
439 QFETCH(int, columnCount
);
440 QFETCH(KItemListController::SelectionBehavior
, selectionBehavior
);
441 QFETCH(bool, groupingEnabled
);
442 QFETCH(QList
<keyPressViewStatePair
>, testList
);
444 m_view
->setItemLayout(layout
);
445 QCOMPARE(m_view
->itemLayout(), layout
);
447 m_view
->setScrollOrientation(scrollOrientation
);
448 QCOMPARE(m_view
->scrollOrientation(), scrollOrientation
);
450 m_controller
->setSelectionBehavior(selectionBehavior
);
451 QCOMPARE(m_controller
->selectionBehavior(), selectionBehavior
);
453 m_model
->setGroupedSorting(groupingEnabled
);
454 QCOMPARE(m_model
->groupedSorting(), groupingEnabled
);
456 adjustGeometryForColumnCount(columnCount
);
457 QCOMPARE(m_view
->m_layouter
->m_columnCount
, columnCount
);
459 QSignalSpy
spySingleItemActivated(m_controller
, SIGNAL(itemActivated(int)));
460 QSignalSpy
spyMultipleItemsActivated(m_controller
, SIGNAL(itemsActivated(QSet
<int>)));
462 while (!testList
.isEmpty()) {
463 const QPair
<KeyPress
, ViewState
> test
= testList
.takeFirst();
464 const Qt::Key key
= test
.first
.m_key
;
465 const Qt::KeyboardModifiers modifier
= test
.first
.m_modifier
;
466 const int current
= test
.second
.m_current
;
467 const QSet
<int> selection
= test
.second
.m_selection
;
468 const bool activated
= test
.second
.m_activated
;
470 QTest::keyClick(m_container
, key
, modifier
);
472 QCOMPARE(m_selectionManager
->currentItem(), current
);
473 switch (selectionBehavior
) {
474 case KItemListController::NoSelection
: QVERIFY(m_selectionManager
->selectedItems().isEmpty()); break;
475 case KItemListController::SingleSelection
: QCOMPARE(m_selectionManager
->selectedItems(), QSet
<int>() << current
); break;
476 case KItemListController::MultiSelection
: QCOMPARE(m_selectionManager
->selectedItems(), selection
); break;
480 switch (selectionBehavior
) {
481 case KItemListController::MultiSelection
:
482 if (!selection
.isEmpty()) {
483 // The selected items should be activated.
484 if (selection
.count() == 1) {
485 QVERIFY(!spySingleItemActivated
.isEmpty());
486 QCOMPARE(qvariant_cast
<int>(spySingleItemActivated
.takeFirst().at(0)), selection
.toList().at(0));
487 QVERIFY(spyMultipleItemsActivated
.isEmpty());
489 QVERIFY(spySingleItemActivated
.isEmpty());
490 QVERIFY(!spyMultipleItemsActivated
.isEmpty());
491 QCOMPARE(qvariant_cast
<QSet
<int> >(spyMultipleItemsActivated
.takeFirst().at(0)), selection
);
495 // No items are selected. Therefore, the current item should be activated.
496 // This is handled by falling through to the NoSelection/SingleSelection case.
497 case KItemListController::NoSelection
:
498 case KItemListController::SingleSelection
:
499 // In NoSelection and SingleSelection mode, the current item should be activated.
500 QVERIFY(!spySingleItemActivated
.isEmpty());
501 QCOMPARE(qvariant_cast
<int>(spySingleItemActivated
.takeFirst().at(0)), current
);
502 QVERIFY(spyMultipleItemsActivated
.isEmpty());
509 void KItemListControllerTest::adjustGeometryForColumnCount(int count
)
511 const QSize size
= m_view
->itemSize().toSize();
513 QRect rect
= m_container
->geometry();
514 rect
.setSize(size
* count
);
515 m_container
->setGeometry(rect
);
517 // Increase the size of the container until the correct column count is reached.
518 while (m_view
->m_layouter
->m_columnCount
< count
) {
519 rect
= m_container
->geometry();
520 rect
.setSize(rect
.size() + size
);
521 m_container
->setGeometry(rect
);
525 QTEST_KDEMAIN(KItemListControllerTest
, GUI
)
527 #include "kitemlistcontrollertest.moc"