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>
25 #include "kitemviews/kitemlistcontainer.h"
26 #include "kitemviews/kfileitemlistview.h"
27 #include "kitemviews/kfileitemmodel.h"
28 #include "kitemviews/kitemlistcontroller.h"
29 #include "kitemviews/kitemlistselectionmanager.h"
30 #include "kitemviews/kitemlistviewlayouter_p.h"
34 const int DefaultTimeout
= 2000;
37 Q_DECLARE_METATYPE(KFileItemListView::Layout
);
38 Q_DECLARE_METATYPE(Qt::Orientation
);
39 Q_DECLARE_METATYPE(KItemListController::SelectionBehavior
);
40 Q_DECLARE_METATYPE(QSet
<int>);
42 class KItemListControllerTest
: public QObject
48 void cleanupTestCase();
53 void testKeyboardNavigation_data();
54 void testKeyboardNavigation();
58 * Make sure that the number of columns in the view is equal to \a count
59 * by changing the geometry of the container.
61 void adjustGeometryForColumnCount(int count
);
64 KFileItemListView
* m_view
;
65 KItemListController
* m_controller
;
66 KItemListSelectionManager
* m_selectionManager
;
67 KFileItemModel
* m_model
;
68 KDirLister
* m_dirLister
;
70 KItemListContainer
* m_container
;
74 * This function initializes the member objects, creates the temporary files, and
75 * shows the view on the screen on startup. This could also be done before every
76 * single test, but this would make the time needed to run the test much larger.
78 void KItemListControllerTest::initTestCase()
80 qRegisterMetaType
<QSet
<int> >("QSet<int>");
82 m_testDir
= new TestDir();
83 m_dirLister
= new KDirLister();
84 m_model
= new KFileItemModel(m_dirLister
);
85 m_container
= new KItemListContainer();
86 m_controller
= m_container
->controller();
87 m_controller
->setSelectionBehavior(KItemListController::MultiSelection
);
88 m_selectionManager
= m_controller
->selectionManager();
90 m_view
= new KFileItemListView();
91 m_controller
->setView(m_view
);
92 m_controller
->setModel(m_model
);
96 << "a1" << "a2" << "a3"
98 << "c1" << "c2" << "c3" << "c4" << "c5"
99 << "d1" << "d2" << "d3" << "d4"
100 << "e1" << "e2" << "e3" << "e4" << "e5" << "e6" << "e7";
102 m_testDir
->createFiles(files
);
103 m_dirLister
->openUrl(m_testDir
->url());
104 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(loadingCompleted()), DefaultTimeout
));
107 QTest::qWaitForWindowShown(m_container
);
110 void KItemListControllerTest::cleanupTestCase()
129 /** Before each test, the current item, selection, and item size are reset to the defaults. */
130 void KItemListControllerTest::init()
132 m_selectionManager
->setCurrentItem(0);
133 QCOMPARE(m_selectionManager
->currentItem(), 0);
135 m_selectionManager
->clearSelection();
136 QVERIFY(!m_selectionManager
->hasSelection());
138 const QSizeF
itemSize(50, 50);
139 m_view
->setItemSize(itemSize
);
140 QCOMPARE(m_view
->itemSize(), itemSize
);
143 void KItemListControllerTest::cleanup()
148 * \class KeyPress is a small helper struct that represents a key press event,
149 * including the key and the keyboard modifiers.
153 KeyPress(Qt::Key key
, Qt::KeyboardModifiers modifier
= Qt::NoModifier
) :
159 Qt::KeyboardModifiers m_modifier
;
163 * \class ViewState is a small helper struct that represents a certain state
164 * of the view, including the current item, the selected items in MultiSelection
165 * mode (in the other modes, the selection is either empty or equal to the
166 * current item), and the information whether items were activated by the last
171 ViewState(int current
, const QSet
<int> selection
, bool activated
= false) :
173 m_selection(selection
),
174 m_activated(activated
)
178 QSet
<int> m_selection
;
182 // We have to define a typedef for the pair in order to make the test compile.
183 typedef QPair
<KeyPress
, ViewState
> keyPressViewStatePair
;
184 Q_DECLARE_METATYPE(QList
<keyPressViewStatePair
>);
187 * This function provides the data for the actual test function
188 * KItemListControllerTest::testKeyboardNavigation().
189 * It tests all possible combinations of view layouts, selection behaviors,
190 * and enabled/disabled groupings for different column counts, and
191 * provides a list of key presses and the states that the view should be in
192 * after the key press event.
194 void KItemListControllerTest::testKeyboardNavigation_data()
196 QTest::addColumn
<KFileItemListView::Layout
>("layout");
197 QTest::addColumn
<Qt::Orientation
>("scrollOrientation");
198 QTest::addColumn
<int>("columnCount");
199 QTest::addColumn
<KItemListController::SelectionBehavior
>("selectionBehavior");
200 QTest::addColumn
<bool>("groupingEnabled");
201 QTest::addColumn
<QList
<QPair
<KeyPress
, ViewState
> > >("testList");
203 QList
<KFileItemListView::Layout
> layoutList
;
204 QHash
<KFileItemListView::Layout
, QString
> layoutNames
;
205 layoutList
.append(KFileItemListView::IconsLayout
);
206 layoutNames
[KFileItemListView::IconsLayout
] = "Icons";
207 layoutList
.append(KFileItemListView::CompactLayout
);
208 layoutNames
[KFileItemListView::CompactLayout
] = "Compact";
209 layoutList
.append(KFileItemListView::DetailsLayout
);
210 layoutNames
[KFileItemListView::DetailsLayout
] = "Details";
212 QList
<KItemListController::SelectionBehavior
> selectionBehaviorList
;
213 QHash
<KItemListController::SelectionBehavior
, QString
> selectionBehaviorNames
;
214 selectionBehaviorList
.append(KItemListController::NoSelection
);
215 selectionBehaviorNames
[KItemListController::NoSelection
] = "NoSelection";
216 selectionBehaviorList
.append(KItemListController::SingleSelection
);
217 selectionBehaviorNames
[KItemListController::SingleSelection
] = "SingleSelection";
218 selectionBehaviorList
.append(KItemListController::MultiSelection
);
219 selectionBehaviorNames
[KItemListController::MultiSelection
] = "MultiSelection";
221 QList
<bool> groupingEnabledList
;
222 QHash
<bool, QString
> groupingEnabledNames
;
223 groupingEnabledList
.append(false);
224 groupingEnabledNames
[false] = "ungrouped";
225 groupingEnabledList
.append(true);
226 groupingEnabledNames
[true] = "grouping enabled";
228 foreach (KFileItemListView::Layout layout
, layoutList
) {
229 // The following settings depend on the layout.
230 // Note that 'columns' are actually 'rows' in
232 Qt::Orientation scrollOrientation
;
233 QList
<int> columnCountList
;
235 Qt::Key previousItemKey
;
237 Qt::Key previousRowKey
;
240 case KFileItemListView::IconsLayout
:
241 scrollOrientation
= Qt::Vertical
;
242 columnCountList
<< 1 << 3 << 5;
243 nextItemKey
= Qt::Key_Right
;
244 previousItemKey
= Qt::Key_Left
;
245 nextRowKey
= Qt::Key_Down
;
246 previousRowKey
= Qt::Key_Up
;
248 case KFileItemListView::CompactLayout
:
249 scrollOrientation
= Qt::Horizontal
;
250 columnCountList
<< 1 << 3 << 5;
251 nextItemKey
= Qt::Key_Down
;
252 previousItemKey
= Qt::Key_Up
;
253 nextRowKey
= Qt::Key_Right
;
254 previousRowKey
= Qt::Key_Left
;
256 case KFileItemListView::DetailsLayout
:
257 scrollOrientation
= Qt::Vertical
;
258 columnCountList
<< 1;
259 nextItemKey
= Qt::Key_Down
;
260 previousItemKey
= Qt::Key_Up
;
261 nextRowKey
= Qt::Key_Down
;
262 previousRowKey
= Qt::Key_Up
;
266 foreach (int columnCount
, columnCountList
) {
267 foreach (KItemListController::SelectionBehavior selectionBehavior
, selectionBehaviorList
) {
268 foreach (bool groupingEnabled
, groupingEnabledList
) {
269 QList
<QPair
<KeyPress
, ViewState
> > testList
;
271 // First, key presses which should have the same effect
272 // for any layout and any number of columns.
274 << qMakePair(KeyPress(nextItemKey
), ViewState(1, QSet
<int>() << 1))
275 << qMakePair(KeyPress(Qt::Key_Return
), ViewState(1, QSet
<int>() << 1, true))
276 << qMakePair(KeyPress(Qt::Key_Enter
), ViewState(1, QSet
<int>() << 1, true))
277 << qMakePair(KeyPress(nextItemKey
), ViewState(2, QSet
<int>() << 2))
278 << qMakePair(KeyPress(nextItemKey
, Qt::ShiftModifier
), ViewState(3, QSet
<int>() << 2 << 3))
279 << qMakePair(KeyPress(Qt::Key_Return
), ViewState(3, QSet
<int>() << 2 << 3, true))
280 << qMakePair(KeyPress(previousItemKey
, Qt::ShiftModifier
), ViewState(2, QSet
<int>() << 2))
281 << qMakePair(KeyPress(nextItemKey
, Qt::ShiftModifier
), ViewState(3, QSet
<int>() << 2 << 3))
282 << qMakePair(KeyPress(nextItemKey
, Qt::ControlModifier
), ViewState(4, QSet
<int>() << 2 << 3))
283 << qMakePair(KeyPress(Qt::Key_Return
), ViewState(4, QSet
<int>() << 2 << 3, true))
284 << qMakePair(KeyPress(previousItemKey
), ViewState(3, QSet
<int>() << 3))
285 << qMakePair(KeyPress(Qt::Key_Home
, Qt::ShiftModifier
), ViewState(0, QSet
<int>() << 0 << 1 << 2 << 3))
286 << qMakePair(KeyPress(nextItemKey
, Qt::ControlModifier
), ViewState(1, QSet
<int>() << 0 << 1 << 2 << 3))
287 << qMakePair(KeyPress(Qt::Key_Space
, Qt::ControlModifier
), ViewState(1, QSet
<int>() << 0 << 2 << 3))
288 << qMakePair(KeyPress(Qt::Key_Space
, Qt::ControlModifier
), ViewState(1, QSet
<int>() << 0 << 1 << 2 << 3))
289 << qMakePair(KeyPress(Qt::Key_End
), ViewState(19, QSet
<int>() << 19))
290 << qMakePair(KeyPress(previousItemKey
, Qt::ShiftModifier
), ViewState(18, QSet
<int>() << 18 << 19))
291 << qMakePair(KeyPress(Qt::Key_Home
), ViewState(0, QSet
<int>() << 0))
292 << qMakePair(KeyPress(Qt::Key_Space
, Qt::ControlModifier
), ViewState(0, QSet
<int>()))
293 << qMakePair(KeyPress(Qt::Key_Enter
), ViewState(0, QSet
<int>(), true))
294 << qMakePair(KeyPress(Qt::Key_Space
, Qt::ControlModifier
), ViewState(0, QSet
<int>() << 0));
296 // Next, we test combinations of key presses which only work for a
297 // particular number of columns and either enabled or disabled grouping.
300 if (columnCount
== 1) {
302 << qMakePair(KeyPress(nextRowKey
), ViewState(1, QSet
<int>() << 1))
303 << qMakePair(KeyPress(nextRowKey
, Qt::ShiftModifier
), ViewState(2, QSet
<int>() << 1 << 2))
304 << qMakePair(KeyPress(nextRowKey
, Qt::ControlModifier
), ViewState(3, QSet
<int>() << 1 << 2))
305 << qMakePair(KeyPress(previousRowKey
), ViewState(2, QSet
<int>() << 2))
306 << qMakePair(KeyPress(previousItemKey
), ViewState(1, QSet
<int>() << 1))
307 << qMakePair(KeyPress(Qt::Key_Home
), ViewState(0, QSet
<int>() << 0));
310 // Multiple columns: we test both 3 and 5 columns with grouping
311 // enabled or disabled. For each case, the layout of the items
312 // in the view is shown (both using file names and indices) to
313 // make it easier to understand what the tests do.
315 if (columnCount
== 3 && !groupingEnabled
) {
316 // 3 columns, no grouping:
321 // d1 d2 d3 | 9 10 11
322 // d4 e1 e2 | 12 13 14
323 // e3 e4 e5 | 15 16 17
326 << qMakePair(KeyPress(nextRowKey
), ViewState(3, QSet
<int>() << 3))
327 << qMakePair(KeyPress(nextItemKey
, Qt::ControlModifier
), ViewState(4, QSet
<int>() << 3))
328 << qMakePair(KeyPress(nextRowKey
), ViewState(7, QSet
<int>() << 7))
329 << qMakePair(KeyPress(nextItemKey
, Qt::ShiftModifier
), ViewState(8, QSet
<int>() << 7 << 8))
330 << qMakePair(KeyPress(nextItemKey
, Qt::ShiftModifier
), ViewState(9, QSet
<int>() << 7 << 8 << 9))
331 << qMakePair(KeyPress(previousItemKey
, Qt::ShiftModifier
), ViewState(8, QSet
<int>() << 7 << 8))
332 << qMakePair(KeyPress(previousItemKey
, Qt::ShiftModifier
), ViewState(7, QSet
<int>() << 7))
333 << qMakePair(KeyPress(previousItemKey
, Qt::ShiftModifier
), ViewState(6, QSet
<int>() << 6 << 7))
334 << qMakePair(KeyPress(previousItemKey
, Qt::ShiftModifier
), ViewState(5, QSet
<int>() << 5 << 6 << 7))
335 << qMakePair(KeyPress(nextItemKey
, Qt::ShiftModifier
), ViewState(6, QSet
<int>() << 6 << 7))
336 << qMakePair(KeyPress(nextItemKey
, Qt::ShiftModifier
), ViewState(7, QSet
<int>() << 7))
337 << qMakePair(KeyPress(nextRowKey
), ViewState(10, QSet
<int>() << 10))
338 << qMakePair(KeyPress(nextItemKey
), ViewState(11, QSet
<int>() << 11))
339 << qMakePair(KeyPress(nextRowKey
), ViewState(14, QSet
<int>() << 14))
340 << qMakePair(KeyPress(nextRowKey
), ViewState(17, QSet
<int>() << 17))
341 << qMakePair(KeyPress(nextRowKey
), ViewState(19, QSet
<int>() << 19))
342 << qMakePair(KeyPress(previousRowKey
), ViewState(17, QSet
<int>() << 17))
343 << qMakePair(KeyPress(Qt::Key_End
), ViewState(19, QSet
<int>() << 19))
344 << qMakePair(KeyPress(previousRowKey
), ViewState(16, QSet
<int>() << 16))
345 << qMakePair(KeyPress(Qt::Key_Home
), ViewState(0, QSet
<int>() << 0));
348 if (columnCount
== 5 && !groupingEnabled
) {
349 // 5 columns, no grouping:
351 // a1 a2 a3 b1 c1 | 0 1 2 3 4
352 // c2 c3 c4 c5 d1 | 5 6 7 8 9
353 // d2 d3 d4 e1 e2 | 10 11 12 13 14
354 // e3 e4 e5 e6 e7 | 15 16 17 18 19
356 << qMakePair(KeyPress(nextRowKey
), ViewState(5, QSet
<int>() << 5))
357 << qMakePair(KeyPress(nextItemKey
, Qt::ControlModifier
), ViewState(6, QSet
<int>() << 5))
358 << qMakePair(KeyPress(nextRowKey
), ViewState(11, QSet
<int>() << 11))
359 << qMakePair(KeyPress(nextItemKey
), ViewState(12, QSet
<int>() << 12))
360 << qMakePair(KeyPress(nextRowKey
, Qt::ShiftModifier
), ViewState(17, QSet
<int>() << 12 << 13 << 14 << 15 << 16 << 17))
361 << qMakePair(KeyPress(previousRowKey
, Qt::ShiftModifier
), ViewState(12, QSet
<int>() << 12))
362 << qMakePair(KeyPress(previousRowKey
, Qt::ShiftModifier
), ViewState(7, QSet
<int>() << 7 << 8 << 9 << 10 << 11 << 12))
363 << qMakePair(KeyPress(nextRowKey
, Qt::ShiftModifier
), ViewState(12, QSet
<int>() << 12))
364 << qMakePair(KeyPress(Qt::Key_End
, Qt::ControlModifier
), ViewState(19, QSet
<int>() << 12))
365 << qMakePair(KeyPress(previousRowKey
), ViewState(14, QSet
<int>() << 14))
366 << qMakePair(KeyPress(Qt::Key_Home
), ViewState(0, QSet
<int>() << 0));
369 if (columnCount
== 3 && groupingEnabled
) {
370 // 3 columns, with grouping:
376 // d1 d2 d3 | 9 10 11
378 // e1 e2 e3 | 13 14 15
379 // e4 e5 e6 | 16 17 18
382 << qMakePair(KeyPress(nextItemKey
), ViewState(1, QSet
<int>() << 1))
383 << qMakePair(KeyPress(nextItemKey
), ViewState(2, QSet
<int>() << 2))
384 << qMakePair(KeyPress(nextRowKey
, Qt::ShiftModifier
), ViewState(3, QSet
<int>() << 2 << 3))
385 << qMakePair(KeyPress(nextRowKey
, Qt::ShiftModifier
), ViewState(6, QSet
<int>() << 2 << 3 << 4 << 5 << 6))
386 << qMakePair(KeyPress(nextRowKey
), ViewState(8, QSet
<int>() << 8))
387 << qMakePair(KeyPress(nextRowKey
), ViewState(11, QSet
<int>() << 11))
388 << qMakePair(KeyPress(nextItemKey
, Qt::ControlModifier
), ViewState(12, QSet
<int>() << 11))
389 << qMakePair(KeyPress(nextRowKey
), ViewState(13, QSet
<int>() << 13))
390 << qMakePair(KeyPress(nextRowKey
), ViewState(16, QSet
<int>() << 16))
391 << qMakePair(KeyPress(nextItemKey
), ViewState(17, QSet
<int>() << 17))
392 << qMakePair(KeyPress(nextRowKey
), ViewState(19, QSet
<int>() << 19))
393 << qMakePair(KeyPress(previousRowKey
), ViewState(17, QSet
<int>() << 17))
394 << qMakePair(KeyPress(Qt::Key_Home
), ViewState(0, QSet
<int>() << 0));
397 if (columnCount
== 5 && groupingEnabled
) {
398 // 5 columns, with grouping:
402 // c1 c2 c3 c4 c5 | 4 5 6 7 8
403 // d1 d2 d3 d4 | 9 10 11 12
404 // e1 e2 e3 e4 e5 | 13 14 15 16 17
407 << qMakePair(KeyPress(nextItemKey
), ViewState(1, QSet
<int>() << 1))
408 << qMakePair(KeyPress(nextRowKey
, Qt::ShiftModifier
), ViewState(3, QSet
<int>() << 1 << 2 << 3))
409 << qMakePair(KeyPress(nextRowKey
, Qt::ShiftModifier
), ViewState(5, QSet
<int>() << 1 << 2 << 3 << 4 << 5))
410 << qMakePair(KeyPress(nextItemKey
), ViewState(6, QSet
<int>() << 6))
411 << qMakePair(KeyPress(nextItemKey
, Qt::ControlModifier
), ViewState(7, QSet
<int>() << 6))
412 << qMakePair(KeyPress(nextItemKey
, Qt::ControlModifier
), ViewState(8, QSet
<int>() << 6))
413 << qMakePair(KeyPress(nextRowKey
), ViewState(12, QSet
<int>() << 12))
414 << qMakePair(KeyPress(nextRowKey
), ViewState(17, QSet
<int>() << 17))
415 << qMakePair(KeyPress(nextRowKey
), ViewState(19, QSet
<int>() << 19))
416 << qMakePair(KeyPress(previousRowKey
), ViewState(17, QSet
<int>() << 17))
417 << qMakePair(KeyPress(Qt::Key_End
, Qt::ShiftModifier
), ViewState(19, QSet
<int>() << 17 << 18 << 19))
418 << qMakePair(KeyPress(previousRowKey
, Qt::ShiftModifier
), ViewState(14, QSet
<int>() << 14 << 15 << 16 << 17))
419 << qMakePair(KeyPress(Qt::Key_Home
), ViewState(0, QSet
<int>() << 0));
422 const QString testName
=
423 layoutNames
[layout
] + ", " +
424 QString("%1 columns, ").arg(columnCount
) +
425 selectionBehaviorNames
[selectionBehavior
] + ", " +
426 groupingEnabledNames
[groupingEnabled
];
428 const QByteArray testNameAscii
= testName
.toAscii();
430 QTest::newRow(testNameAscii
.data())
444 * This function sets the view's properties according to the data provided by
445 * KItemListControllerTest::testKeyboardNavigation_data().
447 * The list \a testList contains pairs of key presses, which are sent to the
448 * container, and expected view states, which are verified then.
450 void KItemListControllerTest::testKeyboardNavigation()
452 QFETCH(KFileItemListView::Layout
, layout
);
453 QFETCH(Qt::Orientation
, scrollOrientation
);
454 QFETCH(int, columnCount
);
455 QFETCH(KItemListController::SelectionBehavior
, selectionBehavior
);
456 QFETCH(bool, groupingEnabled
);
457 QFETCH(QList
<keyPressViewStatePair
>, testList
);
459 m_view
->setItemLayout(layout
);
460 QCOMPARE(m_view
->itemLayout(), layout
);
462 m_view
->setScrollOrientation(scrollOrientation
);
463 QCOMPARE(m_view
->scrollOrientation(), scrollOrientation
);
465 m_controller
->setSelectionBehavior(selectionBehavior
);
466 QCOMPARE(m_controller
->selectionBehavior(), selectionBehavior
);
468 m_model
->setGroupedSorting(groupingEnabled
);
469 QCOMPARE(m_model
->groupedSorting(), groupingEnabled
);
471 adjustGeometryForColumnCount(columnCount
);
472 QCOMPARE(m_view
->m_layouter
->m_columnCount
, columnCount
);
474 QSignalSpy
spySingleItemActivated(m_controller
, SIGNAL(itemActivated(int)));
475 QSignalSpy
spyMultipleItemsActivated(m_controller
, SIGNAL(itemsActivated(QSet
<int>)));
477 while (!testList
.isEmpty()) {
478 const QPair
<KeyPress
, ViewState
> test
= testList
.takeFirst();
479 const Qt::Key key
= test
.first
.m_key
;
480 const Qt::KeyboardModifiers modifier
= test
.first
.m_modifier
;
481 const int current
= test
.second
.m_current
;
482 const QSet
<int> selection
= test
.second
.m_selection
;
483 const bool activated
= test
.second
.m_activated
;
485 QTest::keyClick(m_container
, key
, modifier
);
487 QCOMPARE(m_selectionManager
->currentItem(), current
);
488 switch (selectionBehavior
) {
489 case KItemListController::NoSelection
: QVERIFY(m_selectionManager
->selectedItems().isEmpty()); break;
490 case KItemListController::SingleSelection
: QCOMPARE(m_selectionManager
->selectedItems(), QSet
<int>() << current
); break;
491 case KItemListController::MultiSelection
: QCOMPARE(m_selectionManager
->selectedItems(), selection
); break;
495 switch (selectionBehavior
) {
496 case KItemListController::MultiSelection
:
497 if (!selection
.isEmpty()) {
498 // The selected items should be activated.
499 if (selection
.count() == 1) {
500 QVERIFY(!spySingleItemActivated
.isEmpty());
501 QCOMPARE(qvariant_cast
<int>(spySingleItemActivated
.takeFirst().at(0)), selection
.toList().at(0));
502 QVERIFY(spyMultipleItemsActivated
.isEmpty());
504 QVERIFY(spySingleItemActivated
.isEmpty());
505 QVERIFY(!spyMultipleItemsActivated
.isEmpty());
506 QCOMPARE(qvariant_cast
<QSet
<int> >(spyMultipleItemsActivated
.takeFirst().at(0)), selection
);
510 // No items are selected. Therefore, the current item should be activated.
511 // This is handled by falling through to the NoSelection/SingleSelection case.
512 case KItemListController::NoSelection
:
513 case KItemListController::SingleSelection
:
514 // In NoSelection and SingleSelection mode, the current item should be activated.
515 QVERIFY(!spySingleItemActivated
.isEmpty());
516 QCOMPARE(qvariant_cast
<int>(spySingleItemActivated
.takeFirst().at(0)), current
);
517 QVERIFY(spyMultipleItemsActivated
.isEmpty());
524 void KItemListControllerTest::adjustGeometryForColumnCount(int count
)
526 const QSize size
= m_view
->itemSize().toSize();
528 QRect rect
= m_container
->geometry();
529 rect
.setSize(size
* count
);
530 m_container
->setGeometry(rect
);
532 // Increase the size of the container until the correct column count is reached.
533 while (m_view
->m_layouter
->m_columnCount
< count
) {
534 rect
= m_container
->geometry();
535 rect
.setSize(rect
.size() + size
);
536 m_container
->setGeometry(rect
);
540 QTEST_KDEMAIN(KItemListControllerTest
, GUI
)
542 #include "kitemlistcontrollertest.moc"