diff options
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r-- | tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp | 96 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qstring/tst_qstring.cpp | 8 |
2 files changed, 96 insertions, 8 deletions
diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp index b05e3968ea..6fbaa28d69 100644 --- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -95,6 +95,9 @@ private slots: void QTBUG58851_data(); void QTBUG58851(); + void QTBUG18001_data(); + void QTBUG18001(); + private: QAbstractItemModel *model; QItemSelectionModel *selection; @@ -2922,5 +2925,98 @@ void tst_QItemSelectionModel::QTBUG58851() } } +void tst_QItemSelectionModel::QTBUG18001_data() +{ + using IntPair = std::pair<int, int>; + using IntPairList = QList<IntPair>; + using IntList = QList<int>; + using BoolList = QList<bool>; + + QTest::addColumn<IntPairList>("indexesToSelect"); + QTest::addColumn<IntList>("selectionCommands"); + QTest::addColumn<BoolList>("expectedSelectedRows"); + QTest::addColumn<BoolList>("expectedSelectedColums"); + + int colSelect = QItemSelectionModel::Select | QItemSelectionModel::Columns; + int rowSelect = QItemSelectionModel::Select | QItemSelectionModel::Rows; + + QTest::newRow("Select column 1") + << IntPairList { {0, 1} } + << IntList{ colSelect } + << BoolList{ false, false, false, false, false } + << BoolList{ false, true, false, false, false }; + + QTest::newRow("Select row 1") + << IntPairList { {1, 0} } + << IntList{ rowSelect } + << BoolList{ false, true, false, false, false } + << BoolList{ false, false, false, false, false }; + + QTest::newRow("Select column 1+2, row 1+2") + << IntPairList { {0, 1}, {0, 2}, {1, 0}, {2, 0} } + << IntList{ colSelect, colSelect, rowSelect, rowSelect } + << BoolList{ false, true, true, false, false } + << BoolList{ false, true, true, false, false }; + + QTest::newRow("Select row 1+2, col 1+2") + << IntPairList { {1, 0}, {2, 0}, {0, 1}, {0, 2} } + << IntList{ rowSelect, rowSelect, colSelect, colSelect } + << BoolList{ false, true, true, false, false } + << BoolList{ false, true, true, false, false }; +} + +void tst_QItemSelectionModel::QTBUG18001() +{ + using IntPair = std::pair<int, int>; + using IntPairList = QList<IntPair>; + using IntList = QList<int>; + using BoolList = QList<bool>; + + QFETCH(IntPairList, indexesToSelect); + QFETCH(IntList, selectionCommands); + QFETCH(BoolList, expectedSelectedRows); + QFETCH(BoolList, expectedSelectedColums); + + QStandardItemModel model(5, 5); + for (int row = 0; row < model.rowCount(); ++row) { + for (int column = 0; column < model.columnCount(); ++column) { + QStandardItem *item = new QStandardItem(QString("%0x%1").arg(row).arg(column)); + model.setItem(row, column, item); + + const bool oddRow = row % 2; + const bool oddCol = column % 2; + + if (oddRow == oddCol) + item->setSelectable(false); + } + } + + QItemSelectionModel selectionModel(&model); + + for (int i = 0; i < indexesToSelect.count(); ++i) { + QModelIndex idx = model.index( indexesToSelect.at(i).first, indexesToSelect.at(i).second ); + selectionModel.select(idx, QItemSelectionModel::SelectionFlag(selectionCommands.at(i))); + } + + for (int i = 0; i < expectedSelectedRows.count(); ++i) { + const bool expected = expectedSelectedRows.at(i); + const bool actual = selectionModel.isRowSelected(i, QModelIndex()); + QByteArray description = QByteArray("Row ") + QByteArray::number(i) + + " Expected " + QByteArray::number(expected) + + " Actual " + QByteArray::number(actual); + QVERIFY2(expected == actual, description.data()); + } + + for (int i = 0; i < expectedSelectedColums.count(); ++i) { + const bool expected = expectedSelectedColums.at(i); + const bool actual = selectionModel.isColumnSelected(i, QModelIndex()); + QByteArray description = QByteArray("Col ") + QByteArray::number(i) + + " Expected " + QByteArray::number(expected) + + " Actual " + QByteArray::number(actual); + QVERIFY2(expected == actual, description.data()); + } + +} + QTEST_MAIN(tst_QItemSelectionModel) #include "tst_qitemselectionmodel.moc" diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 6aa3c498aa..fefb533616 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -324,10 +324,8 @@ public: public slots: void cleanup(); private slots: -#ifndef Q_CC_HPACC void fromStdString(); void toStdString(); -#endif void check_QTextIOStream(); void check_QTextStream(); void check_QDataStream(); @@ -4098,8 +4096,6 @@ void tst_QString::setRawData() QVERIFY(cstr.data_ptr() != csd); } -#ifndef Q_CC_HPACC -// This test crashes on HP-UX with aCC (not supported) void tst_QString::fromStdString() { std::string stroustrup = "foo"; @@ -4110,10 +4106,7 @@ void tst_QString::fromStdString() QString qtnull = QString::fromStdString( stdnull ); QCOMPARE( qtnull.size(), int(stdnull.size()) ); } -#endif -#ifndef Q_CC_HPACC -// This test crashes on HP-UX with aCC (not supported) void tst_QString::toStdString() { QString nord = "foo"; @@ -4130,7 +4123,6 @@ void tst_QString::toStdString() std::string stdnull = qtnull.toStdString(); QCOMPARE( int(stdnull.size()), qtnull.size() ); } -#endif void tst_QString::utf8() { |