diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2018-07-27 11:22:57 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2018-07-31 13:33:14 +0200 |
commit | 23c9d4c98f3c6729b56700edc1d7144b444b16db (patch) | |
tree | 27b20ccbf3c101dbc7bcb1e509882b6c7fc75962 /tests/auto/corelib/itemmodels | |
parent | f69a5857d115786f44d053e68c36f74526020e82 (diff) | |
parent | 0ef66e98ccf4946a0e4513ab5fc157df0f0aca4e (diff) |
Merge branch '5.11' into dev
Conflicts:
qmake/library/qmakebuiltins.cpp
src/plugins/platforms/windows/qwindowstabletsupport.h
src/plugins/platforms/xcb/qxcbconnection.cpp
src/plugins/platforms/xcb/qxcbconnection.h
src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
src/plugins/platforms/xcb/qxcbwindow.cpp
src/widgets/styles/qstylesheetstyle.cpp
tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
Done-With: Gatis Paeglis <gatis.paeglis@qt.io>
Change-Id: I000b0eb3cea2a5c7a99b95732bfdd41507cf916e
Diffstat (limited to 'tests/auto/corelib/itemmodels')
-rw-r--r-- | tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index a9138a6505..b3431bcc7a 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -1904,6 +1904,8 @@ void tst_QSortFilterProxyModel::changeSourceData_data() QTest::addColumn<QString>("newValue"); QTest::addColumn<IntPairList>("removeIntervals"); QTest::addColumn<IntPairList>("insertIntervals"); + QTest::addColumn<int>("expectedDataChangedRow"); // -1 if no dataChanged signal expected + QTest::addColumn<bool>("expectedLayoutChanged"); QTest::addColumn<QStringList>("proxyItems"); QTest::newRow("move_to_end_ascending") @@ -1916,6 +1918,8 @@ void tst_QSortFilterProxyModel::changeSourceData_data() << "z" // newValue << IntPairList() // removeIntervals << IntPairList() // insertIntervals + << 2 // dataChanged(row 2) is emitted, see comment "Make sure we also emit dataChanged for the rows" in the source code (unclear why, though) + << true // layoutChanged << (QStringList() << "b" << "c" << "z") // proxyItems ; @@ -1929,6 +1933,8 @@ void tst_QSortFilterProxyModel::changeSourceData_data() << "a" // newValue << IntPairList() // removeIntervals << IntPairList() // insertIntervals + << 2 // dataChanged(row 2) is emitted, see comment "Make sure we also emit dataChanged for the rows" in the source code (unclear why, though) + << true // layoutChanged << (QStringList() << "z" << "b" << "a") // proxyItems ; @@ -1942,9 +1948,26 @@ void tst_QSortFilterProxyModel::changeSourceData_data() << "a" // newValue << IntPairList() // removeIntervals << IntPairList() // insertIntervals + << -1 // no dataChanged signal + << false // layoutChanged << (QStringList() << "b" << "a") // proxyItems ; + QTest::newRow("no_effect_on_filtering") + << (QStringList() << "a" << "b") // sourceItems + << static_cast<int>(Qt::AscendingOrder) // sortOrder + << "" // filter + << (QStringList() << "a" << "b") // expectedInitialProxyItems + << true // dynamic + << 1 // row + << "z" // newValue + << IntPairList() // removeIntervals + << IntPairList() // insertIntervals + << 1 // expectedDataChangedRow + << false // layoutChanged + << (QStringList() << "a" << "z") // proxyItems + ; + QTest::newRow("filtered_out_value_stays_out") << (QStringList() << "a" << "b" << "c" << "d") // sourceItems << static_cast<int>(Qt::AscendingOrder) // sortOrder @@ -1955,6 +1978,8 @@ void tst_QSortFilterProxyModel::changeSourceData_data() << "x" // newValue << IntPairList() // removeIntervals << IntPairList() // insertIntervals + << -1 // no dataChanged signal + << false // layoutChanged << (QStringList() << "a" << "c") // proxyItems ; @@ -1968,6 +1993,8 @@ void tst_QSortFilterProxyModel::changeSourceData_data() << "x" // newValue << IntPairList() // removeIntervals << (IntPairList() << IntPair(2, 2)) // insertIntervals + << -1 // no dataChanged signal + << false // layoutChanged << (QStringList() << "a" << "c" << "x") // proxyItems ; @@ -1981,6 +2008,8 @@ void tst_QSortFilterProxyModel::changeSourceData_data() << "x" // newValue << (IntPairList() << IntPair(1, 1)) // removeIntervals << IntPairList() // insertIntervals + << -1 // no dataChanged signal + << false // layoutChanged << (QStringList() << "a") // proxyItems ; @@ -1994,6 +2023,8 @@ void tst_QSortFilterProxyModel::changeSourceData_data() << "x" // newValue << IntPairList() // removeIntervals << IntPairList() // insertIntervals + << 0 // expectedDataChangedRow + << false // layoutChanged << (QStringList() << "x" << "b" << "c") // proxyItems ; } @@ -2009,6 +2040,8 @@ void tst_QSortFilterProxyModel::changeSourceData() QFETCH(QString, newValue); QFETCH(IntPairList, removeIntervals); QFETCH(IntPairList, insertIntervals); + QFETCH(int, expectedDataChangedRow); + QFETCH(bool, expectedLayoutChanged); QFETCH(QStringList, proxyItems); QStandardItemModel model; @@ -2037,9 +2070,13 @@ void tst_QSortFilterProxyModel::changeSourceData() QSignalSpy removeSpy(&proxy, &QSortFilterProxyModel::rowsRemoved); QSignalSpy insertSpy(&proxy, &QSortFilterProxyModel::rowsInserted); + QSignalSpy dataChangedSpy(&proxy, &QSortFilterProxyModel::dataChanged); + QSignalSpy layoutChangedSpy(&proxy, &QSortFilterProxyModel::layoutChanged); QVERIFY(removeSpy.isValid()); QVERIFY(insertSpy.isValid()); + QVERIFY(dataChangedSpy.isValid()); + QVERIFY(layoutChangedSpy.isValid()); { QModelIndex index = model.index(row, 0, QModelIndex()); @@ -2069,6 +2106,17 @@ void tst_QSortFilterProxyModel::changeSourceData() QModelIndex index = proxy.index(i, 0, QModelIndex()); QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), proxyItems.at(i)); } + + if (expectedDataChangedRow == -1) { + QCOMPARE(dataChangedSpy.count(), 0); + } else { + QCOMPARE(dataChangedSpy.count(), 1); + const QModelIndex idx = dataChangedSpy.at(0).at(0).value<QModelIndex>(); + QCOMPARE(idx.row(), expectedDataChangedRow); + QCOMPARE(idx.column(), 0); + } + + QCOMPARE(layoutChangedSpy.count(), expectedLayoutChanged ? 1 : 0); } // Checks that the model is a table, and that each and every row is like this: |