diff options
author | Marius Bugge Monsen <mmonsen@trolltech.com> | 2009-05-11 13:59:00 +0200 |
---|---|---|
committer | Marius Bugge Monsen <mmonsen@trolltech.com> | 2009-05-11 13:59:00 +0200 |
commit | e5fa88b08d9ce2c0cf83c7b2f45c141465708560 (patch) | |
tree | 9c9b86699234183ef3380a0b27e9942127dfdbeb /tests | |
parent | f2692e22c44a80774082b7b1d1b2d16f7f4f740a (diff) |
Updates to the QtListSelectionManager test to reflect the API updates.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/qlistselectionmanager/tst_qlistselectionmanager.cpp | 114 |
1 files changed, 69 insertions, 45 deletions
diff --git a/tests/qlistselectionmanager/tst_qlistselectionmanager.cpp b/tests/qlistselectionmanager/tst_qlistselectionmanager.cpp index 998a5cb..1d68692 100644 --- a/tests/qlistselectionmanager/tst_qlistselectionmanager.cpp +++ b/tests/qlistselectionmanager/tst_qlistselectionmanager.cpp @@ -40,6 +40,12 @@ class tst_QtListSelectionManager : public QObject Q_OBJECT public: + enum SelectionMode { + Select = QtListSelectionManager::Select, + Deselect = QtListSelectionManager::Deselect, + Toggle = QtListSelectionManager::Toggle + }; + tst_QtListSelectionManager(); virtual ~tst_QtListSelectionManager(); @@ -126,7 +132,7 @@ void tst_QtListSelectionManager::currentItem_data() QTest::addColumn<int>("changedCurrent"); QTest::addColumn<int>("signalCount"); - QTest::newRow("no data") + QTest::newRow("no model") << false << 0 // model << -1 << 0 // initial << 0 << -1 // set/get @@ -135,6 +141,15 @@ void tst_QtListSelectionManager::currentItem_data() << 0 << 0 << 0 // move << -1 << 0; // changed/signals + QTest::newRow("no data") + << true << 0 + << -1 << 0 + << 0 << -1 + << 0 << 0 + << 0 << 0 + << 0 << 0 << 0 + << -1 << 0; + QTest::newRow("before first") << true << 10 << 0 << 0 @@ -244,7 +259,7 @@ void tst_QtListSelectionManager::anchorItem_data() QTest::addColumn<int>("changedAnchor"); QTest::addColumn<int>("signalCount"); - QTest::newRow("no data") + QTest::newRow("no model") << false << 0 // model << -1 << 0 // initial << 0 << -1 // set/get @@ -253,6 +268,15 @@ void tst_QtListSelectionManager::anchorItem_data() << 0 << 0 << 0 // move << -1 << 0; // changed/signals + QTest::newRow("no data") + << true << 0 + << -1 << 0 + << 0 << -1 + << 0 << 0 + << 0 << 0 + << 0 << 0 << 0 + << -1 << 0; + QTest::newRow("before first") << true << 10 << 0 << 0 @@ -348,7 +372,7 @@ void tst_QtListSelectionManager::selections_data() QTest::addColumn<bool>("useModel"); QTest::addColumn<int>("itemCount"); QTest::addColumn<QList<int> >("newSelectionIndexes"); - QTest::addColumn<QList<bool> >("newSelectionStates"); + QTest::addColumn<QList<int> >("newSelectionModes"); QTest::addColumn<QList<int> >("expectedSelectionIndexes"); QTest::addColumn<int>("insertAt"); QTest::addColumn<int>("insertCount"); @@ -362,7 +386,7 @@ void tst_QtListSelectionManager::selections_data() QTest::newRow("no data") << false << 0 // model - << QList<int>() << QList<bool>() << QList<int>() // initial + << QList<int>() << QList<int>() << QList<int>() // initial << 0 << 0 // insert << 0 << 0 // remove << 0 << 0 << 0 // move @@ -371,7 +395,7 @@ void tst_QtListSelectionManager::selections_data() QTest::newRow("no data, one selection") << false << 0 - << (QList<int>() << 3) << (QList<bool>() << true) << QList<int>() + << (QList<int>() << 3) << (QList<int>() << int(Select)) << QList<int>() << 0 << 0 << 0 << 0 << 0 << 0 << 0 @@ -380,7 +404,7 @@ void tst_QtListSelectionManager::selections_data() QTest::newRow("no selections") << true << 10 - << QList<int>() << QList<bool>() << QList<int>() + << QList<int>() << QList<int>() << QList<int>() << 0 << 0 << 0 << 0 << 0 << 0 << 0 @@ -389,7 +413,7 @@ void tst_QtListSelectionManager::selections_data() QTest::newRow("one selection") << true << 10 - << (QList<int>() << 3) << (QList<bool>() << true) << (QList<int>() << 3) + << (QList<int>() << 3) << (QList<int>() << int(Select)) << (QList<int>() << 3) << 0 << 0 << 0 << 0 << 0 << 0 << 0 @@ -398,7 +422,7 @@ void tst_QtListSelectionManager::selections_data() QTest::newRow("two selections") << true << 10 - << (QList<int>() << 3 << 5) << (QList<bool>() << true << true) << (QList<int>() << 3 << 5) + << (QList<int>() << 3 << 5) << (QList<int>() << int(Select) << int(Select)) << (QList<int>() << 3 << 5) << 0 << 0 << 0 << 0 << 0 << 0 << 0 @@ -407,7 +431,7 @@ void tst_QtListSelectionManager::selections_data() QTest::newRow("one selection, one de-selection") << true << 10 - << (QList<int>() << 3 << 3) << (QList<bool>() << true << false) << QList<int>() + << (QList<int>() << 3 << 3) << (QList<int>() << int(Select) << int(Deselect)) << QList<int>() << 0 << 0 << 0 << 0 << 0 << 0 << 0 @@ -416,7 +440,7 @@ void tst_QtListSelectionManager::selections_data() QTest::newRow("two selections, one de-selection") << true << 10 - << (QList<int>() << 3 << 5 << 3) << (QList<bool>() << true << true << false) << (QList<int>() << 5) + << (QList<int>() << 3 << 5 << 3) << (QList<int>() << int(Select) << int(Select) << int(Deselect)) << (QList<int>() << 5) << 0 << 0 << 0 << 0 << 0 << 0 << 0 @@ -425,7 +449,7 @@ void tst_QtListSelectionManager::selections_data() QTest::newRow("two out of range selections") << true << 10 - << (QList<int>() << -1 << INT_MAX) << (QList<bool>() << true << true) << QList<int>() + << (QList<int>() << -1 << INT_MAX) << (QList<int>() << int(Select) << int(Select)) << QList<int>() << 0 << 0 << 0 << 0 << 0 << 0 << 0 @@ -434,43 +458,43 @@ void tst_QtListSelectionManager::selections_data() QTest::newRow("no selections, one insertion") << true << 10 - << QList<int>() << QList<bool>() << QList<int>() + << QList<int>() << QList<int>() << QList<int>() << 4 << 1 << 0 << 0 << 0 << 0 << 0 << QList<int>() << 0; - QTest::newRow("one selections, one insertion before") + QTest::newRow("one selection, one insertion before") << true << 10 - << (QList<int>() << 3) << (QList<bool>() << true) << (QList<int>() << 3) + << (QList<int>() << 3) << (QList<int>() << int(Select)) << (QList<int>() << 3) << 2 << 1 << 0 << 0 << 0 << 0 << 0 << (QList<int>() << 4) << 2; // selection and insertion - QTest::newRow("one selections, one insertion after") + QTest::newRow("one selection, one insertion after") << true << 10 - << (QList<int>() << 3) << (QList<bool>() << true) << (QList<int>() << 3) + << (QList<int>() << 3) << (QList<int>() << int(Select)) << (QList<int>() << 3) << 4 << 1 << 0 << 0 << 0 << 0 << 0 << (QList<int>() << 3) << 1; // selection - QTest::newRow("one selections, one removal before") + QTest::newRow("one selection, one removal before") << true << 10 - << (QList<int>() << 3) << (QList<bool>() << true) << (QList<int>() << 3) + << (QList<int>() << 3) << (QList<int>() << int(Select)) << (QList<int>() << 3) << 0 << 0 << 2 << 1 << 0 << 0 << 0 << (QList<int>() << 2) << 2; // selection and removal - QTest::newRow("one selections, one removal after") + QTest::newRow("one selection, one removal after") << true << 10 - << (QList<int>() << 3) << (QList<bool>() << true) << (QList<int>() << 3) + << (QList<int>() << 3) << (QList<int>() << int(Select)) << (QList<int>() << 3) << 0 << 0 << 4 << 1 << 0 << 0 << 0 @@ -483,7 +507,7 @@ void tst_QtListSelectionManager::selections() QFETCH(bool, useModel); QFETCH(int, itemCount); QFETCH(QList<int>, newSelectionIndexes); - QFETCH(QList<bool>, newSelectionStates); + QFETCH(QList<int>, newSelectionModes); QFETCH(QList<int>, expectedSelectionIndexes); QFETCH(int, insertAt); QFETCH(int, insertCount); @@ -510,7 +534,7 @@ void tst_QtListSelectionManager::selections() // set and check selection for (int a = 0; a < newSelectionIndexes.count(); ++a) - manager->setSelected(newSelectionIndexes.at(a), newSelectionStates.at(a)); + manager->setSelected(newSelectionIndexes.at(a), 1, QtListSelectionManager::SelectionMode(newSelectionModes.at(a))); QList<int> selectedItems = manager->selectedItems(); QCOMPARE(selectedItems.count(), expectedSelectionIndexes.count()); for (int b = 0; b < expectedSelectionIndexes.count(); ++b) @@ -543,7 +567,7 @@ void tst_QtListSelectionManager::anchoredSelections_data() QTest::addColumn<bool>("useModel"); QTest::addColumn<int>("itemCount"); QTest::addColumn<QList<int> >("initialSelectionIndexes"); - QTest::addColumn<bool>("toggle"); + QTest::addColumn<int>("mode"); QTest::addColumn<int>("anchorIndex"); QTest::addColumn<int>("currentIndex"); QTest::addColumn<QList<int> >("expectedSelectionIndexes"); @@ -559,21 +583,21 @@ void tst_QtListSelectionManager::anchoredSelections_data() QTest::addColumn<int>("signalCount"); QTest::newRow("no data") - << false << 0 // model - << QList<int>() // initial - << false << 0 << 0 // range - << QList<int>() // expected - << 0 << 0 // insert - << 0 << 0 // remove - << 0 << 0 << 0 // move - << QList<int>() // changed - << QList<int>() // commited - << 0; // signals + << false << 0 // model + << QList<int>() // initial + << int(Select) << 0 << 0 // range + << QList<int>() // expected + << 0 << 0 // insert + << 0 << 0 // remove + << 0 << 0 << 0 // move + << QList<int>() // changed + << QList<int>() // commited + << 0; // signals QTest::newRow("valid range") << true << 10 << QList<int>() - << false << 4 << 7 + << int(Select) << 4 << 7 << (QList<int>() << 4 << 5 << 6 << 7) << 0 << 0 << 0 << 0 @@ -585,7 +609,7 @@ void tst_QtListSelectionManager::anchoredSelections_data() QTest::newRow("reversed valid range") << true << 10 << QList<int>() - << false << 7 << 4 + << int(Select) << 7 << 4 << (QList<int>() << 4 << 5 << 6 << 7) << 0 << 0 << 0 << 0 @@ -597,7 +621,7 @@ void tst_QtListSelectionManager::anchoredSelections_data() QTest::newRow("invalid anchor") << true << 10 << QList<int>() - << false << -1 << 3 + << int(Select) << -1 << 3 << (QList<int>() << 0 << 1 << 2 << 3) << 0 << 0 << 0 << 0 @@ -609,7 +633,7 @@ void tst_QtListSelectionManager::anchoredSelections_data() QTest::newRow("invalid current") << true << 10 << QList<int>() - << false << 6 << INT_MAX + << int(Select) << 6 << INT_MAX << (QList<int>() << 6 << 7 << 8 << 9) << 0 << 0 << 0 << 0 @@ -621,7 +645,7 @@ void tst_QtListSelectionManager::anchoredSelections_data() QTest::newRow("same anchor and current") << true << 10 << QList<int>() - << false << 4 << 4 + << int(Select) << 4 << 4 << (QList<int>() << 4) << 0 << 0 << 0 << 0 @@ -633,7 +657,7 @@ void tst_QtListSelectionManager::anchoredSelections_data() QTest::newRow("valid range, one insert above") << true << 10 << QList<int>() - << false << 4 << 7 + << int(Select) << 4 << 7 << (QList<int>() << 4 << 5 << 6 << 7) << 1 << 1 << 0 << 0 @@ -645,7 +669,7 @@ void tst_QtListSelectionManager::anchoredSelections_data() QTest::newRow("valid range, one insert below") << true << 10 << QList<int>() - << false << 4 << 7 + << int(Select) << 4 << 7 << (QList<int>() << 4 << 5 << 6 << 7) << 8 << 1 << 0 << 0 @@ -657,7 +681,7 @@ void tst_QtListSelectionManager::anchoredSelections_data() QTest::newRow("valid range, one removal above") << true << 10 << QList<int>() - << false << 4 << 7 + << int(Select) << 4 << 7 << (QList<int>() << 4 << 5 << 6 << 7) << 0 << 0 << 1 << 1 @@ -669,7 +693,7 @@ void tst_QtListSelectionManager::anchoredSelections_data() QTest::newRow("valid range, one removal below") << true << 10 << QList<int>() - << false << 4 << 7 + << int(Select) << 4 << 7 << (QList<int>() << 4 << 5 << 6 << 7) << 0 << 0 << 8 << 1 @@ -684,7 +708,7 @@ void tst_QtListSelectionManager::anchoredSelections() QFETCH(bool, useModel); QFETCH(int, itemCount); QFETCH(QList<int>, initialSelectionIndexes); - QFETCH(bool, toggle); + QFETCH(int, mode); QFETCH(int, anchorIndex); QFETCH(int, currentIndex); QFETCH(QList<int>, expectedSelectionIndexes); @@ -714,10 +738,10 @@ void tst_QtListSelectionManager::anchoredSelections() // set initial selection for (int a = 0; a < initialSelectionIndexes.count(); ++a) - manager->setSelected(initialSelectionIndexes.at(a), true); + manager->setSelected(initialSelectionIndexes.at(a), 1, QtListSelectionManager::Select); // set anchor and mode - manager->beginAnchoredSelection(anchorIndex, toggle ? QtListSelectionManager::Toggle : QtListSelectionManager::Select); + manager->beginAnchoredSelection(anchorIndex, QtListSelectionManager::SelectionMode(mode)); // set current to make a selected range manager->setCurrentItem(currentIndex); |