tests/auto/widgets/itemviews: Avoid unconditional qWait()s
Task-number: QTBUG-63992 Change-Id: Id4fcb0c2e4f83edd9508565468e16f57e100c780 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
This commit is contained in:
parent
a2df0ef57a
commit
e110ab6c28
@ -1168,8 +1168,7 @@ void tst_QAbstractItemView::task221955_selectedEditor()
|
|||||||
|
|
||||||
//We set the focus to the button, the index need to be selected
|
//We set the focus to the button, the index need to be selected
|
||||||
button->setFocus();
|
button->setFocus();
|
||||||
QTest::qWait(100);
|
QTRY_VERIFY(tree.selectionModel()->selectedIndexes().contains(tree.model()->index(3,0)));
|
||||||
QVERIFY(tree.selectionModel()->selectedIndexes().contains(tree.model()->index(3,0)));
|
|
||||||
|
|
||||||
tree.setCurrentIndex(tree.model()->index(1,0));
|
tree.setCurrentIndex(tree.model()->index(1,0));
|
||||||
QVERIFY(! tree.selectionModel()->selectedIndexes().contains(tree.model()->index(3,0)));
|
QVERIFY(! tree.selectionModel()->selectedIndexes().contains(tree.model()->index(3,0)));
|
||||||
@ -1179,7 +1178,6 @@ void tst_QAbstractItemView::task221955_selectedEditor()
|
|||||||
tree.setSelectionMode(QAbstractItemView::NoSelection);
|
tree.setSelectionMode(QAbstractItemView::NoSelection);
|
||||||
tree.clearSelection();
|
tree.clearSelection();
|
||||||
QVERIFY(tree.selectionModel()->selectedIndexes().isEmpty());
|
QVERIFY(tree.selectionModel()->selectedIndexes().isEmpty());
|
||||||
QTest::qWait(10);
|
|
||||||
button->setFocus();
|
button->setFocus();
|
||||||
QTest::qWait(50);
|
QTest::qWait(50);
|
||||||
QVERIFY(tree.selectionModel()->selectedIndexes().isEmpty());
|
QVERIFY(tree.selectionModel()->selectedIndexes().isEmpty());
|
||||||
@ -1267,15 +1265,11 @@ void tst_QAbstractItemView::task257481_emptyEditor()
|
|||||||
QCOMPARE(lineEditors.count(), 1);
|
QCOMPARE(lineEditors.count(), 1);
|
||||||
QVERIFY(!lineEditors.first()->size().isEmpty());
|
QVERIFY(!lineEditors.first()->size().isEmpty());
|
||||||
|
|
||||||
QTest::qWait(30);
|
|
||||||
|
|
||||||
treeView.edit(model.index(1,0));
|
treeView.edit(model.index(1,0));
|
||||||
lineEditors = treeView.viewport()->findChildren<QLineEdit *>();
|
lineEditors = treeView.viewport()->findChildren<QLineEdit *>();
|
||||||
QCOMPARE(lineEditors.count(), 1);
|
QCOMPARE(lineEditors.count(), 1);
|
||||||
QVERIFY(!lineEditors.first()->size().isEmpty());
|
QVERIFY(!lineEditors.first()->size().isEmpty());
|
||||||
|
|
||||||
QTest::qWait(30);
|
|
||||||
|
|
||||||
treeView.edit(model.index(2,0));
|
treeView.edit(model.index(2,0));
|
||||||
lineEditors = treeView.viewport()->findChildren<QLineEdit *>();
|
lineEditors = treeView.viewport()->findChildren<QLineEdit *>();
|
||||||
QCOMPARE(lineEditors.count(), 1);
|
QCOMPARE(lineEditors.count(), 1);
|
||||||
@ -1462,7 +1456,6 @@ void tst_QAbstractItemView::QTBUG6407_extendedSelection()
|
|||||||
QCOMPARE(static_cast<QWidget *>(&view), QApplication::activeWindow());
|
QCOMPARE(static_cast<QWidget *>(&view), QApplication::activeWindow());
|
||||||
|
|
||||||
view.verticalScrollBar()->setValue(view.verticalScrollBar()->maximum());
|
view.verticalScrollBar()->setValue(view.verticalScrollBar()->maximum());
|
||||||
QTest::qWait(20);
|
|
||||||
|
|
||||||
QModelIndex index49 = view.model()->index(49,0);
|
QModelIndex index49 = view.model()->index(49,0);
|
||||||
QPoint p = view.visualRect(index49).center();
|
QPoint p = view.visualRect(index49).center();
|
||||||
@ -1506,7 +1499,6 @@ void tst_QAbstractItemView::QTBUG6753_selectOnSelection()
|
|||||||
QRect itemRect = table.visualRect(item);
|
QRect itemRect = table.visualRect(item);
|
||||||
QTest::mouseMove(table.viewport(), itemRect.center());
|
QTest::mouseMove(table.viewport(), itemRect.center());
|
||||||
QTest::mouseClick(table.viewport(), Qt::LeftButton, Qt::NoModifier, itemRect.center());
|
QTest::mouseClick(table.viewport(), Qt::LeftButton, Qt::NoModifier, itemRect.center());
|
||||||
QTest::qWait(20);
|
|
||||||
|
|
||||||
QCOMPARE(table.selectedItems().count(), 1);
|
QCOMPARE(table.selectedItems().count(), 1);
|
||||||
QCOMPARE(table.selectedItems().first(), table.item(item.row(), item.column()));
|
QCOMPARE(table.selectedItems().first(), table.item(item.row(), item.column()));
|
||||||
|
@ -703,7 +703,7 @@ void tst_QColumnView::moveGrip()
|
|||||||
view.setCurrentIndex(home);
|
view.setCurrentIndex(home);
|
||||||
view.resize(640, 200);
|
view.resize(640, 200);
|
||||||
topLevel.show();
|
topLevel.show();
|
||||||
QTest::qWait(ANIMATION_DELAY);
|
QVERIFY(QTest::qWaitForWindowActive(&topLevel));
|
||||||
|
|
||||||
int columnNum = view.createdColumns.count() - 2;
|
int columnNum = view.createdColumns.count() - 2;
|
||||||
QVERIFY(columnNum >= 0);
|
QVERIFY(columnNum >= 0);
|
||||||
@ -934,7 +934,6 @@ void tst_QColumnView::parentCurrentIndex()
|
|||||||
QVERIFY(second.isValid());
|
QVERIFY(second.isValid());
|
||||||
QVERIFY(third.isValid());
|
QVERIFY(third.isValid());
|
||||||
view.setCurrentIndex(third);
|
view.setCurrentIndex(third);
|
||||||
QTest::qWait(ANIMATION_DELAY);
|
|
||||||
QTRY_COMPARE(view.createdColumns[0]->currentIndex(), first);
|
QTRY_COMPARE(view.createdColumns[0]->currentIndex(), first);
|
||||||
QTRY_COMPARE(view.createdColumns[1]->currentIndex(), second);
|
QTRY_COMPARE(view.createdColumns[1]->currentIndex(), second);
|
||||||
QTRY_COMPARE(view.createdColumns[2]->currentIndex(), third);
|
QTRY_COMPARE(view.createdColumns[2]->currentIndex(), third);
|
||||||
@ -946,7 +945,6 @@ void tst_QColumnView::parentCurrentIndex()
|
|||||||
QVERIFY(second.isValid());
|
QVERIFY(second.isValid());
|
||||||
QVERIFY(third.isValid());
|
QVERIFY(third.isValid());
|
||||||
view.setCurrentIndex(third);
|
view.setCurrentIndex(third);
|
||||||
QTest::qWait(ANIMATION_DELAY);
|
|
||||||
QTRY_COMPARE(view.createdColumns[0]->currentIndex(), first);
|
QTRY_COMPARE(view.createdColumns[0]->currentIndex(), first);
|
||||||
QTRY_COMPARE(view.createdColumns[1]->currentIndex(), second);
|
QTRY_COMPARE(view.createdColumns[1]->currentIndex(), second);
|
||||||
|
|
||||||
|
@ -240,8 +240,8 @@ private slots:
|
|||||||
void testStreamWithHide();
|
void testStreamWithHide();
|
||||||
void testStylePosition();
|
void testStylePosition();
|
||||||
void stretchAndRestoreLastSection();
|
void stretchAndRestoreLastSection();
|
||||||
void testMinMaxSectionSizeStretched();
|
void testMinMaxSectionSize_data();
|
||||||
void testMinMaxSectionSizeNotStretched();
|
void testMinMaxSectionSize();
|
||||||
void sizeHintCrash();
|
void sizeHintCrash();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -2268,22 +2268,21 @@ void tst_QHeaderView::QTBUG6058_reset()
|
|||||||
QHeaderView view(Qt::Vertical);
|
QHeaderView view(Qt::Vertical);
|
||||||
view.setModel(&proxy);
|
view.setModel(&proxy);
|
||||||
view.show();
|
view.show();
|
||||||
QTest::qWait(20);
|
QVERIFY(QTest::qWaitForWindowActive(&view));
|
||||||
|
|
||||||
proxy.setSourceModel(&model1);
|
proxy.setSourceModel(&model1);
|
||||||
QApplication::processEvents();
|
|
||||||
view.swapSections(0,2);
|
view.swapSections(0,2);
|
||||||
view.swapSections(1,4);
|
view.swapSections(1,4);
|
||||||
QApplication::processEvents();
|
QVector<int> expectedOrder{2, 4, 0, 3, 1, 5};
|
||||||
QCOMPARE(checkHeaderViewOrder(&view, QVector<int>() << 2 << 4 << 0 << 3 << 1 << 5) , 0);
|
QTRY_COMPARE(checkHeaderViewOrder(&view, expectedOrder) , 0);
|
||||||
|
|
||||||
proxy.setSourceModel(&model2);
|
proxy.setSourceModel(&model2);
|
||||||
QApplication::processEvents();
|
expectedOrder = {2, 0, 1};
|
||||||
QCOMPARE(checkHeaderViewOrder(&view, QVector<int>() << 2 << 0 << 1 ) , 0);
|
QTRY_COMPARE(checkHeaderViewOrder(&view, expectedOrder) , 0);
|
||||||
|
|
||||||
proxy.setSourceModel(&model1);
|
proxy.setSourceModel(&model1);
|
||||||
QApplication::processEvents();
|
expectedOrder = {2, 0, 1, 3, 4, 5};
|
||||||
QCOMPARE(checkHeaderViewOrder(&view, QVector<int>() << 2 << 0 << 1 << 3 << 4 << 5 ) , 0);
|
QTRY_COMPARE(checkHeaderViewOrder(&view, expectedOrder) , 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QHeaderView::QTBUG7833_sectionClicked()
|
void tst_QHeaderView::QTBUG7833_sectionClicked()
|
||||||
@ -3269,28 +3268,17 @@ void tst_QHeaderView::stretchAndRestoreLastSection()
|
|||||||
QCOMPARE(header.sectionSize(9), someOtherSectionSize);
|
QCOMPARE(header.sectionSize(9), someOtherSectionSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QHeaderView::testMinMaxSectionSizeStretched()
|
void tst_QHeaderView::testMinMaxSectionSize_data()
|
||||||
{
|
{
|
||||||
testMinMaxSectionSize(true);
|
QTest::addColumn<bool>("stretchLastSection");
|
||||||
|
QTest::addRow("stretched") << true;
|
||||||
|
QTest::addRow("not stretched") << false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QHeaderView::testMinMaxSectionSizeNotStretched()
|
void tst_QHeaderView::testMinMaxSectionSize()
|
||||||
{
|
{
|
||||||
testMinMaxSectionSize(false);
|
QFETCH(bool, stretchLastSection);
|
||||||
}
|
|
||||||
|
|
||||||
static void waitFor(const std::function<bool()> &func)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 100; i++)
|
|
||||||
{
|
|
||||||
if (func())
|
|
||||||
return;
|
|
||||||
QTest::qWait(10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QHeaderView::testMinMaxSectionSize(bool stretchLastSection)
|
|
||||||
{
|
|
||||||
QStandardItemModel m(5, 5);
|
QStandardItemModel m(5, 5);
|
||||||
QTableView tv;
|
QTableView tv;
|
||||||
tv.setModel(&m);
|
tv.setModel(&m);
|
||||||
@ -3326,8 +3314,7 @@ void tst_QHeaderView::testMinMaxSectionSize(bool stretchLastSection)
|
|||||||
header.resizeSection(0, sectionSizeMax);
|
header.resizeSection(0, sectionSizeMax);
|
||||||
QCOMPARE(header.sectionSize(0), sectionSizeMax);
|
QCOMPARE(header.sectionSize(0), sectionSizeMax);
|
||||||
header.setMaximumSectionSize(defaultSectionSize);
|
header.setMaximumSectionSize(defaultSectionSize);
|
||||||
waitFor([&header, defaultSectionSize]() { return header.sectionSize(0) == defaultSectionSize; });
|
QTRY_COMPARE(header.sectionSize(0), defaultSectionSize);
|
||||||
QCOMPARE(header.sectionSize(0), defaultSectionSize);
|
|
||||||
|
|
||||||
// change section size on min change
|
// change section size on min change
|
||||||
header.setMinimumSectionSize(sectionSizeMin);
|
header.setMinimumSectionSize(sectionSizeMin);
|
||||||
@ -3335,8 +3322,7 @@ void tst_QHeaderView::testMinMaxSectionSize(bool stretchLastSection)
|
|||||||
header.resizeSection(0, sectionSizeMin);
|
header.resizeSection(0, sectionSizeMin);
|
||||||
QCOMPARE(header.sectionSize(0), sectionSizeMin);
|
QCOMPARE(header.sectionSize(0), sectionSizeMin);
|
||||||
header.setMinimumSectionSize(defaultSectionSize);
|
header.setMinimumSectionSize(defaultSectionSize);
|
||||||
waitFor([&header, defaultSectionSize]() { return header.sectionSize(0) == defaultSectionSize; });
|
QTRY_COMPARE(header.sectionSize(0), defaultSectionSize);
|
||||||
QCOMPARE(header.sectionSize(0), defaultSectionSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1276,7 +1276,7 @@ void tst_QItemDelegate::enterKey()
|
|||||||
view.show();
|
view.show();
|
||||||
QApplication::setActiveWindow(&view);
|
QApplication::setActiveWindow(&view);
|
||||||
view.setFocus();
|
view.setFocus();
|
||||||
QTest::qWait(30);
|
QVERIFY(QTest::qWaitForWindowActive(&view));
|
||||||
|
|
||||||
struct TestDelegate : public QItemDelegate
|
struct TestDelegate : public QItemDelegate
|
||||||
{
|
{
|
||||||
@ -1306,7 +1306,6 @@ void tst_QItemDelegate::enterKey()
|
|||||||
QModelIndex index = model.index(0, 0);
|
QModelIndex index = model.index(0, 0);
|
||||||
view.setCurrentIndex(index); // the editor will only selectAll on the current index
|
view.setCurrentIndex(index); // the editor will only selectAll on the current index
|
||||||
view.edit(index);
|
view.edit(index);
|
||||||
QTest::qWait(30);
|
|
||||||
|
|
||||||
QList<QWidget*> lineEditors = view.viewport()->findChildren<QWidget *>(QString::fromLatin1("TheEditor"));
|
QList<QWidget*> lineEditors = view.viewport()->findChildren<QWidget *>(QString::fromLatin1("TheEditor"));
|
||||||
QCOMPARE(lineEditors.count(), 1);
|
QCOMPARE(lineEditors.count(), 1);
|
||||||
@ -1315,7 +1314,6 @@ void tst_QItemDelegate::enterKey()
|
|||||||
QCOMPARE(editor->hasFocus(), true);
|
QCOMPARE(editor->hasFocus(), true);
|
||||||
|
|
||||||
QTest::keyClick(editor, Qt::Key(key));
|
QTest::keyClick(editor, Qt::Key(key));
|
||||||
QApplication::processEvents();
|
|
||||||
|
|
||||||
if (expectedFocus) {
|
if (expectedFocus) {
|
||||||
QVERIFY(!editor.isNull());
|
QVERIFY(!editor.isNull());
|
||||||
@ -1335,11 +1333,10 @@ void tst_QItemDelegate::task257859_finalizeEdit()
|
|||||||
view.show();
|
view.show();
|
||||||
QApplication::setActiveWindow(&view);
|
QApplication::setActiveWindow(&view);
|
||||||
view.setFocus();
|
view.setFocus();
|
||||||
QTest::qWait(30);
|
QVERIFY(QTest::qWaitForWindowActive(&view));
|
||||||
|
|
||||||
QModelIndex index = model.index(0, 0);
|
QModelIndex index = model.index(0, 0);
|
||||||
view.edit(index);
|
view.edit(index);
|
||||||
QTest::qWait(30);
|
|
||||||
|
|
||||||
QList<QLineEdit *> lineEditors = view.viewport()->findChildren<QLineEdit *>();
|
QList<QLineEdit *> lineEditors = view.viewport()->findChildren<QLineEdit *>();
|
||||||
QCOMPARE(lineEditors.count(), 1);
|
QCOMPARE(lineEditors.count(), 1);
|
||||||
@ -1454,28 +1451,26 @@ void tst_QItemDelegate::testLineEditValidation()
|
|||||||
QApplication::setActiveWindow(&view);
|
QApplication::setActiveWindow(&view);
|
||||||
QVERIFY(QTest::qWaitForWindowActive(&view));
|
QVERIFY(QTest::qWaitForWindowActive(&view));
|
||||||
|
|
||||||
QList<QLineEdit *> lineEditors;
|
|
||||||
QPointer<QLineEdit> editor;
|
QPointer<QLineEdit> editor;
|
||||||
QPersistentModelIndex index = model.indexFromItem(item);
|
QPersistentModelIndex index = model.indexFromItem(item);
|
||||||
|
|
||||||
view.setCurrentIndex(index);
|
view.setCurrentIndex(index);
|
||||||
view.edit(index);
|
view.edit(index);
|
||||||
QTest::qWait(30);
|
|
||||||
|
|
||||||
lineEditors = view.findChildren<QLineEdit *>(QStringLiteral("TheEditor"));
|
const auto findEditors = [&]() {
|
||||||
QCOMPARE(lineEditors.count(), 1);
|
return view.findChildren<QLineEdit *>(QStringLiteral("TheEditor"));
|
||||||
editor = lineEditors.at(0);
|
};
|
||||||
|
QCOMPARE(findEditors().count(), 1);
|
||||||
|
editor = findEditors().at(0);
|
||||||
editor->clear();
|
editor->clear();
|
||||||
|
|
||||||
// first try to set a valid text
|
// first try to set a valid text
|
||||||
QTest::keyClicks(editor, QStringLiteral("foo,bar"));
|
QTest::keyClicks(editor, QStringLiteral("foo,bar"));
|
||||||
QTest::qWait(30);
|
|
||||||
|
|
||||||
// close the editor
|
// close the editor
|
||||||
QTest::keyClick(editor, Qt::Key(key));
|
QTest::keyClick(editor, Qt::Key(key));
|
||||||
QTest::qWait(30);
|
|
||||||
|
|
||||||
QVERIFY(editor.isNull());
|
QTRY_VERIFY(editor.isNull());
|
||||||
if (key != Qt::Key_Escape)
|
if (key != Qt::Key_Escape)
|
||||||
QCOMPARE(item->data(Qt::DisplayRole).toString(), QStringLiteral("foo,bar"));
|
QCOMPARE(item->data(Qt::DisplayRole).toString(), QStringLiteral("foo,bar"));
|
||||||
else
|
else
|
||||||
@ -1484,20 +1479,16 @@ void tst_QItemDelegate::testLineEditValidation()
|
|||||||
// now an invalid (but partially matching) text
|
// now an invalid (but partially matching) text
|
||||||
view.setCurrentIndex(index);
|
view.setCurrentIndex(index);
|
||||||
view.edit(index);
|
view.edit(index);
|
||||||
QTest::qWait(30);
|
|
||||||
|
|
||||||
lineEditors = view.findChildren<QLineEdit *>(QStringLiteral("TheEditor"));
|
QTRY_COMPARE(findEditors().count(), 1);
|
||||||
QCOMPARE(lineEditors.count(), 1);
|
editor = findEditors().at(0);
|
||||||
editor = lineEditors.at(0);
|
|
||||||
editor->clear();
|
editor->clear();
|
||||||
|
|
||||||
// edit
|
// edit
|
||||||
QTest::keyClicks(editor, QStringLiteral("foobar"));
|
QTest::keyClicks(editor, QStringLiteral("foobar"));
|
||||||
QTest::qWait(30);
|
|
||||||
|
|
||||||
// try to close the editor
|
// try to close the editor
|
||||||
QTest::keyClick(editor, Qt::Key(key));
|
QTest::keyClick(editor, Qt::Key(key));
|
||||||
QTest::qWait(30);
|
|
||||||
|
|
||||||
if (key != Qt::Key_Escape) {
|
if (key != Qt::Key_Escape) {
|
||||||
QVERIFY(!editor.isNull());
|
QVERIFY(!editor.isNull());
|
||||||
@ -1505,33 +1496,29 @@ void tst_QItemDelegate::testLineEditValidation()
|
|||||||
QCOMPARE(editor->text(), QStringLiteral("foobar"));
|
QCOMPARE(editor->text(), QStringLiteral("foobar"));
|
||||||
QCOMPARE(item->data(Qt::DisplayRole).toString(), QStringLiteral("foo,bar"));
|
QCOMPARE(item->data(Qt::DisplayRole).toString(), QStringLiteral("foo,bar"));
|
||||||
} else {
|
} else {
|
||||||
QVERIFY(editor.isNull());
|
QTRY_VERIFY(editor.isNull());
|
||||||
QCOMPARE(item->data(Qt::DisplayRole).toString(), QStringLiteral("abc,def"));
|
QCOMPARE(item->data(Qt::DisplayRole).toString(), QStringLiteral("abc,def"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset the view to forcibly close the editor
|
// reset the view to forcibly close the editor
|
||||||
view.reset();
|
view.reset();
|
||||||
QTest::qWait(30);
|
QTRY_COMPARE(findEditors().count(), 0);
|
||||||
|
|
||||||
// set a valid text again
|
// set a valid text again
|
||||||
view.setCurrentIndex(index);
|
view.setCurrentIndex(index);
|
||||||
view.edit(index);
|
view.edit(index);
|
||||||
QTest::qWait(30);
|
|
||||||
|
|
||||||
lineEditors = view.findChildren<QLineEdit *>(QStringLiteral("TheEditor"));
|
QTRY_COMPARE(findEditors().count(), 1);
|
||||||
QCOMPARE(lineEditors.count(), 1);
|
editor = findEditors().at(0);
|
||||||
editor = lineEditors.at(0);
|
|
||||||
editor->clear();
|
editor->clear();
|
||||||
|
|
||||||
// set a valid text
|
// set a valid text
|
||||||
QTest::keyClicks(editor, QStringLiteral("gender,bender"));
|
QTest::keyClicks(editor, QStringLiteral("gender,bender"));
|
||||||
QTest::qWait(30);
|
|
||||||
|
|
||||||
// close the editor
|
// close the editor
|
||||||
QTest::keyClick(editor, Qt::Key(key));
|
QTest::keyClick(editor, Qt::Key(key));
|
||||||
QTest::qWait(30);
|
|
||||||
|
|
||||||
QVERIFY(editor.isNull());
|
QTRY_VERIFY(editor.isNull());
|
||||||
if (key != Qt::Key_Escape)
|
if (key != Qt::Key_Escape)
|
||||||
QCOMPARE(item->data(Qt::DisplayRole).toString(), QStringLiteral("gender,bender"));
|
QCOMPARE(item->data(Qt::DisplayRole).toString(), QStringLiteral("gender,bender"));
|
||||||
else
|
else
|
||||||
|
@ -293,7 +293,7 @@ public:
|
|||||||
|
|
||||||
void tst_QListView::cleanup()
|
void tst_QListView::cleanup()
|
||||||
{
|
{
|
||||||
QVERIFY(QApplication::topLevelWidgets().isEmpty());
|
QTRY_VERIFY(QApplication::topLevelWidgets().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QListView::noDelegate()
|
void tst_QListView::noDelegate()
|
||||||
@ -779,7 +779,6 @@ void tst_QListView::hideFirstRow()
|
|||||||
view.setRowHidden(0,true);
|
view.setRowHidden(0,true);
|
||||||
view.show();
|
view.show();
|
||||||
QVERIFY(QTest::qWaitForWindowExposed(&view));
|
QVERIFY(QTest::qWaitForWindowExposed(&view));
|
||||||
QTest::qWait(10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int modelIndexCount(const QAbstractItemView *view)
|
static int modelIndexCount(const QAbstractItemView *view)
|
||||||
@ -857,7 +856,6 @@ void tst_QListView::setCurrentIndex()
|
|||||||
QCOMPARE(sb->value(), offset + 1);
|
QCOMPARE(sb->value(), offset + 1);
|
||||||
++offset;
|
++offset;
|
||||||
}
|
}
|
||||||
//QTest::qWait(50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
--i; // item 20 does not exist
|
--i; // item 20 does not exist
|
||||||
@ -870,7 +868,6 @@ void tst_QListView::setCurrentIndex()
|
|||||||
QCOMPARE(sb->value(), offset - 1);
|
QCOMPARE(sb->value(), offset - 1);
|
||||||
--offset;
|
--offset;
|
||||||
}
|
}
|
||||||
//QTest::qWait(50);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1397,21 +1394,17 @@ void tst_QListView::scrollBarAsNeeded()
|
|||||||
lv.setModel(&model);
|
lv.setModel(&model);
|
||||||
lv.resize(size);
|
lv.resize(size);
|
||||||
topLevel.show();
|
topLevel.show();
|
||||||
|
QVERIFY(QTest::qWaitForWindowActive(&topLevel));
|
||||||
|
|
||||||
for (uint r = 0; r < sizeof(rowCounts)/sizeof(int); ++r) {
|
for (uint r = 0; r < sizeof(rowCounts)/sizeof(int); ++r) {
|
||||||
QStringList list;
|
QStringList list;
|
||||||
int i;
|
for (int i = 0; i < rowCounts[r]; ++i)
|
||||||
for (i = 0; i < rowCounts[r]; ++i)
|
|
||||||
list << QLatin1String("Item ") + QString::number(i);
|
list << QLatin1String("Item ") + QString::number(i);
|
||||||
|
|
||||||
model.setStringList(list);
|
model.setStringList(list);
|
||||||
QApplication::processEvents();
|
|
||||||
QTest::qWait(50);
|
|
||||||
|
|
||||||
model.setStringList(generateList(QLatin1String("Item "), itemCount));
|
model.setStringList(generateList(QLatin1String("Item "), itemCount));
|
||||||
|
|
||||||
QApplication::processEvents();
|
|
||||||
|
|
||||||
QTRY_COMPARE(lv.horizontalScrollBar()->isVisible(), horizontalScrollBarVisible);
|
QTRY_COMPARE(lv.horizontalScrollBar()->isVisible(), horizontalScrollBarVisible);
|
||||||
QTRY_COMPARE(lv.verticalScrollBar()->isVisible(), verticalScrollBarVisible);
|
QTRY_COMPARE(lv.verticalScrollBar()->isVisible(), verticalScrollBarVisible);
|
||||||
}
|
}
|
||||||
@ -1577,14 +1570,14 @@ void tst_QListView::task228566_infiniteRelayout()
|
|||||||
|
|
||||||
view.setFixedHeight(itemHeight * 12);
|
view.setFixedHeight(itemHeight * 12);
|
||||||
view.show();
|
view.show();
|
||||||
|
QVERIFY(QTest::qWaitForWindowActive(&view));
|
||||||
QTest::qWait(100); //make sure the layout is done once
|
QTest::qWait(100); //make sure the layout is done once
|
||||||
|
|
||||||
QSignalSpy spy(view.horizontalScrollBar(), SIGNAL(rangeChanged(int,int)));
|
QSignalSpy spy(view.horizontalScrollBar(), SIGNAL(rangeChanged(int,int)));
|
||||||
|
|
||||||
QTest::qWait(200);
|
|
||||||
//the layout should already have been done
|
//the layout should already have been done
|
||||||
//so there should be no change made to the scrollbar
|
//so there should be no change made to the scrollbar
|
||||||
QCOMPARE(spy.count(), 0);
|
QVERIFY(!spy.wait(200));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QListView::task248430_crashWith0SizedItem()
|
void tst_QListView::task248430_crashWith0SizedItem()
|
||||||
@ -1619,7 +1612,7 @@ void tst_QListView::task250446_scrollChanged()
|
|||||||
QTRY_COMPARE(view.currentIndex(), index);
|
QTRY_COMPARE(view.currentIndex(), index);
|
||||||
|
|
||||||
view.showNormal();
|
view.showNormal();
|
||||||
QTest::qWait(50);
|
QVERIFY(QTest::qWaitForWindowExposed(&view));
|
||||||
QTRY_COMPARE(view.verticalScrollBar()->value(), scrollValue);
|
QTRY_COMPARE(view.verticalScrollBar()->value(), scrollValue);
|
||||||
QTRY_COMPARE(view.currentIndex(), index);
|
QTRY_COMPARE(view.currentIndex(), index);
|
||||||
}
|
}
|
||||||
@ -1709,19 +1702,14 @@ void tst_QListView::keyboardSearch()
|
|||||||
qApp->setActiveWindow(&view);
|
qApp->setActiveWindow(&view);
|
||||||
QVERIFY(QTest::qWaitForWindowActive(&view));
|
QVERIFY(QTest::qWaitForWindowActive(&view));
|
||||||
|
|
||||||
// QCOMPARE(view.currentIndex() , model.index(0,0));
|
|
||||||
|
|
||||||
QTest::keyClick(&view, Qt::Key_K);
|
QTest::keyClick(&view, Qt::Key_K);
|
||||||
QTest::qWait(10);
|
QTRY_COMPARE(view.currentIndex() , model.index(5,0)); //KAFEINE
|
||||||
QCOMPARE(view.currentIndex() , model.index(5,0)); //KAFEINE
|
|
||||||
|
|
||||||
QTest::keyClick(&view, Qt::Key_O);
|
QTest::keyClick(&view, Qt::Key_O);
|
||||||
QTest::qWait(10);
|
QTRY_COMPARE(view.currentIndex() , model.index(6,0)); //KONQUEROR
|
||||||
QCOMPARE(view.currentIndex() , model.index(6,0)); //KONQUEROR
|
|
||||||
|
|
||||||
QTest::keyClick(&view, Qt::Key_N);
|
QTest::keyClick(&view, Qt::Key_N);
|
||||||
QTest::qWait(10);
|
QTRY_COMPARE(view.currentIndex() , model.index(6,0)); //KONQUEROR
|
||||||
QCOMPARE(view.currentIndex() , model.index(6,0)); //KONQUEROR
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QListView::shiftSelectionWithNonUniformItemSizes()
|
void tst_QListView::shiftSelectionWithNonUniformItemSizes()
|
||||||
@ -1751,8 +1739,7 @@ void tst_QListView::shiftSelectionWithNonUniformItemSizes()
|
|||||||
QCOMPARE(view.currentIndex(), index);
|
QCOMPARE(view.currentIndex(), index);
|
||||||
|
|
||||||
QTest::keyClick(&view, Qt::Key_Up, Qt::ShiftModifier);
|
QTest::keyClick(&view, Qt::Key_Up, Qt::ShiftModifier);
|
||||||
QTest::qWait(10);
|
QTRY_COMPARE(view.currentIndex(), model.index(1, 0));
|
||||||
QCOMPARE(view.currentIndex(), model.index(1, 0));
|
|
||||||
|
|
||||||
QModelIndexList selected = view.selectionModel()->selectedIndexes();
|
QModelIndexList selected = view.selectionModel()->selectedIndexes();
|
||||||
QCOMPARE(selected.count(), 3);
|
QCOMPARE(selected.count(), 3);
|
||||||
@ -1781,8 +1768,7 @@ void tst_QListView::shiftSelectionWithNonUniformItemSizes()
|
|||||||
QCOMPARE(view.currentIndex(), index);
|
QCOMPARE(view.currentIndex(), index);
|
||||||
|
|
||||||
QTest::keyClick(&view, Qt::Key_Left, Qt::ShiftModifier);
|
QTest::keyClick(&view, Qt::Key_Left, Qt::ShiftModifier);
|
||||||
QTest::qWait(10);
|
QTRY_COMPARE(view.currentIndex(), model.index(1, 0));
|
||||||
QCOMPARE(view.currentIndex(), model.index(1, 0));
|
|
||||||
|
|
||||||
QModelIndexList selected = view.selectionModel()->selectedIndexes();
|
QModelIndexList selected = view.selectionModel()->selectedIndexes();
|
||||||
QCOMPARE(selected.count(), 3);
|
QCOMPARE(selected.count(), 3);
|
||||||
@ -1833,10 +1819,8 @@ void tst_QListView::task262152_setModelColumnNavigate()
|
|||||||
QVERIFY(QTest::qWaitForWindowActive(&view));
|
QVERIFY(QTest::qWaitForWindowActive(&view));
|
||||||
QCOMPARE(static_cast<QWidget *>(&view), QApplication::activeWindow());
|
QCOMPARE(static_cast<QWidget *>(&view), QApplication::activeWindow());
|
||||||
QTest::keyClick(&view, Qt::Key_Down);
|
QTest::keyClick(&view, Qt::Key_Down);
|
||||||
QTest::qWait(30);
|
|
||||||
QTRY_COMPARE(view.currentIndex(), model.index(1,1));
|
QTRY_COMPARE(view.currentIndex(), model.index(1,1));
|
||||||
QTest::keyClick(&view, Qt::Key_Down);
|
QTest::keyClick(&view, Qt::Key_Down);
|
||||||
QTest::qWait(30);
|
|
||||||
QTRY_COMPARE(view.currentIndex(), model.index(2,1));
|
QTRY_COMPARE(view.currentIndex(), model.index(2,1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1888,14 +1872,11 @@ void tst_QListView::taskQTBUG_2233_scrollHiddenItems()
|
|||||||
int nbVisibleItem = rowCount / 2 - bar->maximum();
|
int nbVisibleItem = rowCount / 2 - bar->maximum();
|
||||||
|
|
||||||
bar->setValue(bar->maximum());
|
bar->setValue(bar->maximum());
|
||||||
QApplication::processEvents();
|
|
||||||
for (int i = rowCount; i > rowCount / 2; i--) {
|
for (int i = rowCount; i > rowCount / 2; i--) {
|
||||||
view.setRowHidden(i, true);
|
view.setRowHidden(i, true);
|
||||||
}
|
}
|
||||||
QApplication::processEvents();
|
QTRY_COMPARE(bar->maximum(), rowCount/4 - nbVisibleItem);
|
||||||
QTest::qWait(50);
|
|
||||||
QCOMPARE(bar->value(), bar->maximum());
|
QCOMPARE(bar->value(), bar->maximum());
|
||||||
QCOMPARE(bar->maximum(), rowCount/4 - nbVisibleItem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QListView::taskQTBUG_633_changeModelData()
|
void tst_QListView::taskQTBUG_633_changeModelData()
|
||||||
@ -1911,10 +1892,12 @@ void tst_QListView::taskQTBUG_633_changeModelData()
|
|||||||
view.show();
|
view.show();
|
||||||
QVERIFY(QTest::qWaitForWindowExposed(&view));
|
QVERIFY(QTest::qWaitForWindowExposed(&view));
|
||||||
model.setData( model.index(1, 0), QLatin1String("long long text"));
|
model.setData( model.index(1, 0), QLatin1String("long long text"));
|
||||||
QTest::qWait(100); //leave time for relayouting the items
|
const auto longTextDoesNotIntersectNextItem = [&]() {
|
||||||
QRect rectLongText = view.visualRect(model.index(1,0));
|
QRect rectLongText = view.visualRect(model.index(1,0));
|
||||||
QRect rect2 = view.visualRect(model.index(2,0));
|
QRect rect2 = view.visualRect(model.index(2,0));
|
||||||
QVERIFY( ! rectLongText.intersects(rect2) );
|
return !rectLongText.intersects(rect2);
|
||||||
|
};
|
||||||
|
QTRY_VERIFY(longTextDoesNotIntersectNextItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QListView::taskQTBUG_435_deselectOnViewportClick()
|
void tst_QListView::taskQTBUG_435_deselectOnViewportClick()
|
||||||
|
@ -1565,7 +1565,7 @@ void tst_QListWidget::task217070_scrollbarsAdjusted()
|
|||||||
v.setResizeMode(QListView::Adjust);
|
v.setResizeMode(QListView::Adjust);
|
||||||
v.setUniformItemSizes(true);
|
v.setUniformItemSizes(true);
|
||||||
v.resize(160,100);
|
v.resize(160,100);
|
||||||
QTest::qWait(50);
|
QVERIFY(QTest::qWaitForWindowActive(&v));
|
||||||
QScrollBar *hbar = v.horizontalScrollBar();
|
QScrollBar *hbar = v.horizontalScrollBar();
|
||||||
QScrollBar *vbar = v.verticalScrollBar();
|
QScrollBar *vbar = v.verticalScrollBar();
|
||||||
QVERIFY(hbar && vbar);
|
QVERIFY(hbar && vbar);
|
||||||
|
@ -2781,15 +2781,14 @@ void tst_QTableView::scrollTo()
|
|||||||
for (int c = 0; c < columnCount; ++c)
|
for (int c = 0; c < columnCount; ++c)
|
||||||
view.setColumnWidth(c, columnWidth);
|
view.setColumnWidth(c, columnWidth);
|
||||||
|
|
||||||
QTest::qWait(150); // ### needed to pass the test
|
|
||||||
view.horizontalScrollBar()->setValue(horizontalScroll);
|
view.horizontalScrollBar()->setValue(horizontalScroll);
|
||||||
view.verticalScrollBar()->setValue(verticalScroll);
|
view.verticalScrollBar()->setValue(verticalScroll);
|
||||||
|
|
||||||
QModelIndex index = model.index(row, column);
|
QModelIndex index = model.index(row, column);
|
||||||
QVERIFY(index.isValid());
|
QVERIFY(index.isValid());
|
||||||
view.scrollTo(index, (QAbstractItemView::ScrollHint)scrollHint);
|
view.scrollTo(index, (QAbstractItemView::ScrollHint)scrollHint);
|
||||||
QCOMPARE(view.verticalScrollBar()->value(), expectedVerticalScroll);
|
QTRY_COMPARE(view.verticalScrollBar()->value(), expectedVerticalScroll);
|
||||||
QCOMPARE(view.horizontalScrollBar()->value(), expectedHorizontalScroll);
|
QTRY_COMPARE(view.horizontalScrollBar()->value(), expectedHorizontalScroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QTableView::indexAt_data()
|
void tst_QTableView::indexAt_data()
|
||||||
@ -2936,14 +2935,12 @@ void tst_QTableView::indexAt()
|
|||||||
for (int c = 0; c < columnCount; ++c)
|
for (int c = 0; c < columnCount; ++c)
|
||||||
view.setColumnWidth(c, columnWidth);
|
view.setColumnWidth(c, columnWidth);
|
||||||
|
|
||||||
QTest::qWait(20);
|
|
||||||
view.horizontalScrollBar()->setValue(horizontalScroll);
|
view.horizontalScrollBar()->setValue(horizontalScroll);
|
||||||
view.verticalScrollBar()->setValue(verticalScroll);
|
view.verticalScrollBar()->setValue(verticalScroll);
|
||||||
QTest::qWait(20);
|
|
||||||
|
|
||||||
QModelIndex index = view.indexAt(QPoint(x, y));
|
QModelIndex index = view.indexAt(QPoint(x, y));
|
||||||
QCOMPARE(index.row(), expectedRow);
|
QTRY_COMPARE(index.row(), expectedRow);
|
||||||
QCOMPARE(index.column(), expectedColumn);
|
QTRY_COMPARE(index.column(), expectedColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QTableView::span_data()
|
void tst_QTableView::span_data()
|
||||||
@ -3261,7 +3258,7 @@ void tst_QTableView::spansAfterRowInsertion()
|
|||||||
view.setModel(&model);
|
view.setModel(&model);
|
||||||
view.setSpan(3, 3, 3, 3);
|
view.setSpan(3, 3, 3, 3);
|
||||||
view.show();
|
view.show();
|
||||||
QTest::qWait(50);
|
QVERIFY(QTest::qWaitForWindowActive(&view));
|
||||||
|
|
||||||
// Insertion before the span only shifts the span.
|
// Insertion before the span only shifts the span.
|
||||||
view.model()->insertRows(0, 2);
|
view.model()->insertRows(0, 2);
|
||||||
@ -3297,7 +3294,7 @@ void tst_QTableView::spansAfterColumnInsertion()
|
|||||||
view.setModel(&model);
|
view.setModel(&model);
|
||||||
view.setSpan(3, 3, 3, 3);
|
view.setSpan(3, 3, 3, 3);
|
||||||
view.show();
|
view.show();
|
||||||
QTest::qWait(50);
|
QVERIFY(QTest::qWaitForWindowActive(&view));
|
||||||
|
|
||||||
// Insertion before the span only shifts the span.
|
// Insertion before the span only shifts the span.
|
||||||
view.model()->insertColumns(0, 2);
|
view.model()->insertColumns(0, 2);
|
||||||
@ -3345,7 +3342,7 @@ void tst_QTableView::spansAfterRowRemoval()
|
|||||||
view.setSpan(span.top(), span.left(), span.height(), span.width());
|
view.setSpan(span.top(), span.left(), span.height(), span.width());
|
||||||
|
|
||||||
view.show();
|
view.show();
|
||||||
QTest::qWait(100);
|
QVERIFY(QTest::qWaitForWindowActive(&view));
|
||||||
view.model()->removeRows(3, 3);
|
view.model()->removeRows(3, 3);
|
||||||
|
|
||||||
QList<QRect> expectedSpans;
|
QList<QRect> expectedSpans;
|
||||||
@ -3385,7 +3382,7 @@ void tst_QTableView::spansAfterColumnRemoval()
|
|||||||
view.setSpan(span.left(), span.top(), span.width(), span.height());
|
view.setSpan(span.left(), span.top(), span.width(), span.height());
|
||||||
|
|
||||||
view.show();
|
view.show();
|
||||||
QTest::qWait(100);
|
QVERIFY(QTest::qWaitForWindowActive(&view));
|
||||||
view.model()->removeColumns(3, 3);
|
view.model()->removeColumns(3, 3);
|
||||||
|
|
||||||
QList<QRect> expectedSpans;
|
QList<QRect> expectedSpans;
|
||||||
@ -4083,7 +4080,6 @@ void tst_QTableView::task259308_scrollVerticalHeaderSwappedSections()
|
|||||||
QTRY_COMPARE(tv.currentIndex().row(), newRow);
|
QTRY_COMPARE(tv.currentIndex().row(), newRow);
|
||||||
|
|
||||||
tv.setCurrentIndex(model.index(0, 0));
|
tv.setCurrentIndex(model.index(0, 0));
|
||||||
QTest::qWait(60);
|
|
||||||
QTest::keyClick(&tv, Qt::Key_PageDown); // PageDown won't scroll when at the bottom
|
QTest::keyClick(&tv, Qt::Key_PageDown); // PageDown won't scroll when at the bottom
|
||||||
QTRY_COMPARE(tv.rowAt(tv.viewport()->height() - 1), tv.verticalHeader()->logicalIndex(model.rowCount() - 1));
|
QTRY_COMPARE(tv.rowAt(tv.viewport()->height() - 1), tv.verticalHeader()->logicalIndex(model.rowCount() - 1));
|
||||||
}
|
}
|
||||||
@ -4104,7 +4100,7 @@ void tst_QTableView::task191545_dragSelectRows()
|
|||||||
table.setSelectionMode(QAbstractItemView::ExtendedSelection);
|
table.setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
table.setMinimumSize(1000, 400);
|
table.setMinimumSize(1000, 400);
|
||||||
table.show();
|
table.show();
|
||||||
QTest::qWait(200);
|
QVERIFY(QTest::qWaitForWindowActive(&table));
|
||||||
|
|
||||||
ValueSaver<Qt::KeyboardModifiers> saver(QApplicationPrivate::modifier_buttons);
|
ValueSaver<Qt::KeyboardModifiers> saver(QApplicationPrivate::modifier_buttons);
|
||||||
QApplicationPrivate::modifier_buttons = Qt::ControlModifier;
|
QApplicationPrivate::modifier_buttons = Qt::ControlModifier;
|
||||||
@ -4214,27 +4210,22 @@ void tst_QTableView::task234926_setHeaderSorting()
|
|||||||
QTableView view;
|
QTableView view;
|
||||||
view.setModel(&model);
|
view.setModel(&model);
|
||||||
// view.show();
|
// view.show();
|
||||||
QTest::qWait(20);
|
QTRY_COMPARE(model.stringList(), data);
|
||||||
QCOMPARE(model.stringList(), data);
|
|
||||||
view.setSortingEnabled(true);
|
view.setSortingEnabled(true);
|
||||||
view.sortByColumn(0, Qt::AscendingOrder);
|
view.sortByColumn(0, Qt::AscendingOrder);
|
||||||
QApplication::processEvents();
|
QTRY_COMPARE(model.stringList() , sortedDataA);
|
||||||
QCOMPARE(model.stringList() , sortedDataA);
|
|
||||||
|
|
||||||
view.horizontalHeader()->setSortIndicator(0, Qt::DescendingOrder);
|
view.horizontalHeader()->setSortIndicator(0, Qt::DescendingOrder);
|
||||||
QApplication::processEvents();
|
QTRY_COMPARE(model.stringList() , sortedDataD);
|
||||||
QCOMPARE(model.stringList() , sortedDataD);
|
|
||||||
|
|
||||||
QHeaderView *h = new QHeaderView(Qt::Horizontal);
|
QHeaderView *h = new QHeaderView(Qt::Horizontal);
|
||||||
h->setModel(&model);
|
h->setModel(&model);
|
||||||
view.setHorizontalHeader(h);
|
view.setHorizontalHeader(h);
|
||||||
h->setSortIndicator(0, Qt::AscendingOrder);
|
h->setSortIndicator(0, Qt::AscendingOrder);
|
||||||
QApplication::processEvents();
|
QTRY_COMPARE(model.stringList() , sortedDataA);
|
||||||
QCOMPARE(model.stringList() , sortedDataA);
|
|
||||||
|
|
||||||
h->setSortIndicator(0, Qt::DescendingOrder);
|
h->setSortIndicator(0, Qt::DescendingOrder);
|
||||||
QApplication::processEvents();
|
QTRY_COMPARE(model.stringList() , sortedDataD);
|
||||||
QCOMPARE(model.stringList() , sortedDataD);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QTableView::taskQTBUG_5062_spansInconsistency()
|
void tst_QTableView::taskQTBUG_5062_spansInconsistency()
|
||||||
@ -4288,9 +4279,8 @@ void tst_QTableView::changeHeaderData()
|
|||||||
QVERIFY(view.verticalHeader()->width() < textWidth);
|
QVERIFY(view.verticalHeader()->width() < textWidth);
|
||||||
|
|
||||||
model.setHeaderData(2, Qt::Vertical, text);
|
model.setHeaderData(2, Qt::Vertical, text);
|
||||||
QTest::qWait(100); //leave time for layout
|
|
||||||
|
|
||||||
QVERIFY(view.verticalHeader()->width() > textWidth);
|
QTRY_VERIFY(view.verticalHeader()->width() > textWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_CONFIG(wheelevent)
|
#if QT_CONFIG(wheelevent)
|
||||||
|
@ -3464,6 +3464,7 @@ void tst_QTreeView::addRowsWhileSectionsAreHidden()
|
|||||||
QStandardItemModel *model = new QStandardItemModel(6, pass, &view);
|
QStandardItemModel *model = new QStandardItemModel(6, pass, &view);
|
||||||
view.setModel(model);
|
view.setModel(model);
|
||||||
view.show();
|
view.show();
|
||||||
|
QVERIFY(QTest::qWaitForWindowActive(&view));
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < 3; ++i)
|
for (i = 0; i < 3; ++i)
|
||||||
@ -3487,12 +3488,15 @@ void tst_QTreeView::addRowsWhileSectionsAreHidden()
|
|||||||
}
|
}
|
||||||
for (col = 0; col < pass; ++col)
|
for (col = 0; col < pass; ++col)
|
||||||
view.setColumnHidden(col, false);
|
view.setColumnHidden(col, false);
|
||||||
QTest::qWait(250);
|
|
||||||
|
|
||||||
for (i = 0; i < 6; ++i) {
|
auto allVisualRectsValid = [](QTreeView *view, QStandardItemModel *model) {
|
||||||
QRect rect = view.visualRect(model->index(i, 0));
|
for (int i = 0; i < 6; ++i) {
|
||||||
QCOMPARE(rect.isValid(), true);
|
if (!view->visualRect(model->index(i, 0)).isValid())
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
QTRY_VERIFY(allVisualRectsValid(&view, model));
|
||||||
|
|
||||||
delete model;
|
delete model;
|
||||||
}
|
}
|
||||||
@ -3515,11 +3519,9 @@ void tst_QTreeView::task216717_updateChildren()
|
|||||||
tree.refreshed = false;
|
tree.refreshed = false;
|
||||||
QTreeWidgetItem *parent = new QTreeWidgetItem(QStringList() << "parent");
|
QTreeWidgetItem *parent = new QTreeWidgetItem(QStringList() << "parent");
|
||||||
tree.addTopLevelItem(parent);
|
tree.addTopLevelItem(parent);
|
||||||
QTest::qWait(10);
|
|
||||||
QTRY_VERIFY(tree.refreshed);
|
QTRY_VERIFY(tree.refreshed);
|
||||||
tree.refreshed = false;
|
tree.refreshed = false;
|
||||||
parent->addChild(new QTreeWidgetItem(QStringList() << "child"));
|
parent->addChild(new QTreeWidgetItem(QStringList() << "child"));
|
||||||
QTest::qWait(10);
|
|
||||||
QTRY_VERIFY(tree.refreshed);
|
QTRY_VERIFY(tree.refreshed);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -3553,11 +3555,10 @@ void tst_QTreeView::task220298_selectColumns()
|
|||||||
Model model;
|
Model model;
|
||||||
view.setModel(&model);
|
view.setModel(&model);
|
||||||
view.show();
|
view.show();
|
||||||
QTest::qWait(50);
|
QVERIFY(QTest::qWaitForWindowActive(&view));
|
||||||
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0,
|
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0,
|
||||||
view.visualRect(view.model()->index(1, 1)).center());
|
view.visualRect(view.model()->index(1, 1)).center());
|
||||||
QTest::qWait(50);
|
QTRY_VERIFY(view.selectedIndexes().contains(view.model()->index(1, 2)));
|
||||||
QVERIFY(view.selectedIndexes().contains(view.model()->index(1, 2)));
|
|
||||||
QVERIFY(view.selectedIndexes().contains(view.model()->index(1, 1)));
|
QVERIFY(view.selectedIndexes().contains(view.model()->index(1, 1)));
|
||||||
QVERIFY(view.selectedIndexes().contains(view.model()->index(1, 0)));
|
QVERIFY(view.selectedIndexes().contains(view.model()->index(1, 0)));
|
||||||
}
|
}
|
||||||
@ -3575,15 +3576,14 @@ void tst_QTreeView::task224091_appendColumns()
|
|||||||
qApp->setActiveWindow(topLevel);
|
qApp->setActiveWindow(topLevel);
|
||||||
QVERIFY(QTest::qWaitForWindowActive(topLevel));
|
QVERIFY(QTest::qWaitForWindowActive(topLevel));
|
||||||
|
|
||||||
|
QVERIFY(!treeView->verticalScrollBar()->isVisible());
|
||||||
|
|
||||||
QList<QStandardItem *> projlist;
|
QList<QStandardItem *> projlist;
|
||||||
for (int k = 0; k < 10; ++k)
|
for (int k = 0; k < 10; ++k)
|
||||||
projlist.append(new QStandardItem(QLatin1String("Top Level ") + QString::number(k)));
|
projlist.append(new QStandardItem(QLatin1String("Top Level ") + QString::number(k)));
|
||||||
model->appendColumn(projlist);
|
model->appendColumn(projlist);
|
||||||
model->invisibleRootItem()->appendRow(new QStandardItem("end"));
|
model->invisibleRootItem()->appendRow(new QStandardItem("end"));
|
||||||
|
|
||||||
QTest::qWait(50);
|
|
||||||
qApp->processEvents();
|
|
||||||
|
|
||||||
QTRY_VERIFY(treeView->verticalScrollBar()->isVisible());
|
QTRY_VERIFY(treeView->verticalScrollBar()->isVisible());
|
||||||
|
|
||||||
delete topLevel;
|
delete topLevel;
|
||||||
@ -3741,11 +3741,10 @@ void tst_QTreeView::task238873_avoidAutoReopening()
|
|||||||
view.setModel(&model);
|
view.setModel(&model);
|
||||||
view.show();
|
view.show();
|
||||||
view.expandAll();
|
view.expandAll();
|
||||||
QTest::qWait(100);
|
QVERIFY(QTest::qWaitForWindowActive(&view));
|
||||||
|
|
||||||
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.visualRect(child.index()).center());
|
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.visualRect(child.index()).center());
|
||||||
QTest::qWait(20);
|
QTRY_COMPARE(view.currentIndex(), child.index());
|
||||||
QCOMPARE(view.currentIndex(), child.index());
|
|
||||||
|
|
||||||
view.setExpanded(item1.index(), false);
|
view.setExpanded(item1.index(), false);
|
||||||
|
|
||||||
@ -3810,7 +3809,6 @@ void tst_QTreeView::task246536_scrollbarsNotWorking()
|
|||||||
QTest::qWait(100);
|
QTest::qWait(100);
|
||||||
o.count = 0;
|
o.count = 0;
|
||||||
tree.verticalScrollBar()->setValue(50);
|
tree.verticalScrollBar()->setValue(50);
|
||||||
QTest::qWait(100);
|
|
||||||
QTRY_VERIFY(o.count > 0);
|
QTRY_VERIFY(o.count > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3826,7 +3824,7 @@ void tst_QTreeView::task250683_wrongSectionSize()
|
|||||||
treeView.setColumnHidden(3, true);
|
treeView.setColumnHidden(3, true);
|
||||||
|
|
||||||
treeView.show();
|
treeView.show();
|
||||||
QTest::qWait(100);
|
QVERIFY(QTest::qWaitForWindowActive(&treeView));
|
||||||
|
|
||||||
QCOMPARE(treeView.header()->sectionSize(0) + treeView.header()->sectionSize(1), treeView.viewport()->width());
|
QCOMPARE(treeView.header()->sectionSize(0) + treeView.header()->sectionSize(1), treeView.viewport()->width());
|
||||||
}
|
}
|
||||||
@ -3863,7 +3861,6 @@ void tst_QTreeView::task239271_addRowsWithFirstColumnHidden()
|
|||||||
QStandardItem sub1("sub1"), sub11("sub11");
|
QStandardItem sub1("sub1"), sub11("sub11");
|
||||||
root0.appendRow(QList<QStandardItem*>() << &sub1 << &sub11);
|
root0.appendRow(QList<QStandardItem*>() << &sub1 << &sub11);
|
||||||
|
|
||||||
QTest::qWait(20);
|
|
||||||
//items in the 2nd column should have been painted
|
//items in the 2nd column should have been painted
|
||||||
QTRY_VERIFY(!delegate.paintedIndexes.isEmpty());
|
QTRY_VERIFY(!delegate.paintedIndexes.isEmpty());
|
||||||
QVERIFY(delegate.paintedIndexes.contains(sub00.index()));
|
QVERIFY(delegate.paintedIndexes.contains(sub00.index()));
|
||||||
@ -3976,7 +3973,6 @@ void tst_QTreeView::doubleClickedWithSpans()
|
|||||||
|
|
||||||
//end the previous edition
|
//end the previous edition
|
||||||
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p);
|
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p);
|
||||||
QTest::qWait(150);
|
|
||||||
QTest::mousePress(view.viewport(), Qt::LeftButton, 0, p);
|
QTest::mousePress(view.viewport(), Qt::LeftButton, 0, p);
|
||||||
QTest::mouseDClick(view.viewport(), Qt::LeftButton, 0, p);
|
QTest::mouseDClick(view.viewport(), Qt::LeftButton, 0, p);
|
||||||
QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, p);
|
QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, p);
|
||||||
@ -4041,7 +4037,6 @@ void tst_QTreeView::taskQTBUG_9216_setSizeAndUniformRowHeightsWrongRepaint()
|
|||||||
view.painted = 0;
|
view.painted = 0;
|
||||||
view.doCompare = true;
|
view.doCompare = true;
|
||||||
model.setData(model.index(0, 0), QVariant(QSize(50, 50)), Qt::SizeHintRole);
|
model.setData(model.index(0, 0), QVariant(QSize(50, 50)), Qt::SizeHintRole);
|
||||||
QTest::qWait(100);
|
|
||||||
QTRY_VERIFY(view.painted > 0);
|
QTRY_VERIFY(view.painted > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4249,7 +4244,6 @@ void tst_QTreeView::taskQTBUG_11466_keyboardNavigationRegression()
|
|||||||
QVERIFY(QTest::qWaitForWindowExposed(&treeView));
|
QVERIFY(QTest::qWaitForWindowExposed(&treeView));
|
||||||
|
|
||||||
QTest::keyPress(treeView.viewport(), Qt::Key_Down);
|
QTest::keyPress(treeView.viewport(), Qt::Key_Down);
|
||||||
QTest::qWait(10);
|
|
||||||
QTRY_COMPARE(treeView.currentIndex(), treeView.selectionModel()->selection().indexes().first());
|
QTRY_COMPARE(treeView.currentIndex(), treeView.selectionModel()->selection().indexes().first());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4269,8 +4263,7 @@ void tst_QTreeView::taskQTBUG_13567_removeLastItemRegression()
|
|||||||
|
|
||||||
view.setCurrentIndex(model.index(199, 0));
|
view.setCurrentIndex(model.index(199, 0));
|
||||||
model.removeLastRow();
|
model.removeLastRow();
|
||||||
QTest::qWait(10);
|
QTRY_COMPARE(view.currentIndex(), model.index(198, 0));
|
||||||
QCOMPARE(view.currentIndex(), model.index(198, 0));
|
|
||||||
CHECK_VISIBLE(198, 0);
|
CHECK_VISIBLE(198, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2026,7 +2026,6 @@ void tst_QTreeWidget::setHeaderItem()
|
|||||||
headerItem->setText(0, "0");
|
headerItem->setText(0, "0");
|
||||||
headerItem->setText(1, "1");
|
headerItem->setText(1, "1");
|
||||||
testWidget->setHeaderItem(headerItem);
|
testWidget->setHeaderItem(headerItem);
|
||||||
QTest::qWait(100);
|
|
||||||
QCOMPARE(testWidget->headerItem(), headerItem);
|
QCOMPARE(testWidget->headerItem(), headerItem);
|
||||||
QCOMPARE(headerItem->treeWidget(), static_cast<QTreeWidget *>(testWidget));
|
QCOMPARE(headerItem->treeWidget(), static_cast<QTreeWidget *>(testWidget));
|
||||||
|
|
||||||
@ -2981,7 +2980,7 @@ void tst_QTreeWidget::task191552_rtl()
|
|||||||
item->setCheckState(0, Qt::Checked);
|
item->setCheckState(0, Qt::Checked);
|
||||||
QCOMPARE(item->checkState(0), Qt::Checked);
|
QCOMPARE(item->checkState(0), Qt::Checked);
|
||||||
tw.show();
|
tw.show();
|
||||||
QTest::qWait(50);
|
QVERIFY(QTest::qWaitForWindowActive(&tw));
|
||||||
QStyleOptionViewItem opt;
|
QStyleOptionViewItem opt;
|
||||||
opt.initFrom(&tw);
|
opt.initFrom(&tw);
|
||||||
opt.rect = tw.visualItemRect(item);
|
opt.rect = tw.visualItemRect(item);
|
||||||
@ -2991,7 +2990,6 @@ void tst_QTreeWidget::task191552_rtl()
|
|||||||
opt.widget = &tw;
|
opt.widget = &tw;
|
||||||
const QRect checkRect = tw.style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, &tw);
|
const QRect checkRect = tw.style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, &tw);
|
||||||
QTest::mouseClick(tw.viewport(), Qt::LeftButton, Qt::NoModifier, checkRect.center());
|
QTest::mouseClick(tw.viewport(), Qt::LeftButton, Qt::NoModifier, checkRect.center());
|
||||||
QTest::qWait(200);
|
|
||||||
QCOMPARE(item->checkState(0), Qt::Unchecked);
|
QCOMPARE(item->checkState(0), Qt::Unchecked);
|
||||||
|
|
||||||
qApp->setLayoutDirection(oldDir);
|
qApp->setLayoutDirection(oldDir);
|
||||||
@ -3088,7 +3086,7 @@ void tst_QTreeWidget::task253109_itemHeight()
|
|||||||
QTreeWidget treeWidget;
|
QTreeWidget treeWidget;
|
||||||
treeWidget.setColumnCount(1);
|
treeWidget.setColumnCount(1);
|
||||||
treeWidget.show();
|
treeWidget.show();
|
||||||
QTest::qWait(200);
|
QVERIFY(QTest::qWaitForWindowActive(&treeWidget));
|
||||||
|
|
||||||
QTreeWidgetItem item(&treeWidget);
|
QTreeWidgetItem item(&treeWidget);
|
||||||
class MyWidget : public QWidget
|
class MyWidget : public QWidget
|
||||||
@ -3097,9 +3095,7 @@ void tst_QTreeWidget::task253109_itemHeight()
|
|||||||
} w;
|
} w;
|
||||||
treeWidget.setItemWidget(&item, 0, &w);
|
treeWidget.setItemWidget(&item, 0, &w);
|
||||||
|
|
||||||
QTest::qWait(200);
|
QTRY_COMPARE(w.geometry(), treeWidget.visualItemRect(&item));
|
||||||
QCOMPARE(w.geometry(), treeWidget.visualItemRect(&item));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QTreeWidget::task206367_duplication()
|
void tst_QTreeWidget::task206367_duplication()
|
||||||
@ -3306,16 +3302,15 @@ void tst_QTreeWidget::setTextUpdate()
|
|||||||
|
|
||||||
treeWidget.setItemDelegate(&delegate);
|
treeWidget.setItemDelegate(&delegate);
|
||||||
treeWidget.show();
|
treeWidget.show();
|
||||||
|
QVERIFY(QTest::qWaitForWindowExposed(&treeWidget));
|
||||||
QStringList strList;
|
QStringList strList;
|
||||||
strList << "variable1" << "0";
|
strList << "variable1" << "0";
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem(strList);
|
QTreeWidgetItem *item = new QTreeWidgetItem(strList);
|
||||||
treeWidget.insertTopLevelItem(0, item);
|
treeWidget.insertTopLevelItem(0, item);
|
||||||
QTest::qWait(50);
|
|
||||||
QTRY_VERIFY(delegate.numPaints > 0);
|
QTRY_VERIFY(delegate.numPaints > 0);
|
||||||
delegate.numPaints = 0;
|
delegate.numPaints = 0;
|
||||||
|
|
||||||
item->setText(1, "42");
|
item->setText(1, "42");
|
||||||
QApplication::processEvents();
|
|
||||||
QTRY_VERIFY(delegate.numPaints > 0);
|
QTRY_VERIFY(delegate.numPaints > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3356,34 +3351,30 @@ void tst_QTreeWidget::setChildIndicatorPolicy()
|
|||||||
|
|
||||||
treeWidget.setItemDelegate(&delegate);
|
treeWidget.setItemDelegate(&delegate);
|
||||||
treeWidget.show();
|
treeWidget.show();
|
||||||
|
QVERIFY(QTest::qWaitForWindowExposed(&treeWidget));
|
||||||
|
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList("Hello"));
|
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList("Hello"));
|
||||||
treeWidget.insertTopLevelItem(0, item);
|
treeWidget.insertTopLevelItem(0, item);
|
||||||
QTest::qWait(50);
|
|
||||||
QTRY_VERIFY(delegate.numPaints > 0);
|
QTRY_VERIFY(delegate.numPaints > 0);
|
||||||
|
|
||||||
delegate.numPaints = 0;
|
delegate.numPaints = 0;
|
||||||
delegate.expectChildren = true;
|
delegate.expectChildren = true;
|
||||||
item->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);
|
item->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);
|
||||||
QApplication::processEvents();
|
|
||||||
QTRY_COMPARE(delegate.numPaints, 1);
|
QTRY_COMPARE(delegate.numPaints, 1);
|
||||||
|
|
||||||
delegate.numPaints = 0;
|
delegate.numPaints = 0;
|
||||||
delegate.expectChildren = false;
|
delegate.expectChildren = false;
|
||||||
item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
||||||
QApplication::processEvents();
|
|
||||||
QTRY_COMPARE(delegate.numPaints, 1);
|
QTRY_COMPARE(delegate.numPaints, 1);
|
||||||
|
|
||||||
delegate.numPaints = 0;
|
delegate.numPaints = 0;
|
||||||
delegate.expectChildren = true;
|
delegate.expectChildren = true;
|
||||||
new QTreeWidgetItem(item);
|
new QTreeWidgetItem(item);
|
||||||
QApplication::processEvents();
|
|
||||||
QTRY_COMPARE(delegate.numPaints, 1);
|
QTRY_COMPARE(delegate.numPaints, 1);
|
||||||
|
|
||||||
delegate.numPaints = 0;
|
delegate.numPaints = 0;
|
||||||
delegate.expectChildren = false;
|
delegate.expectChildren = false;
|
||||||
item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicator);
|
item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicator);
|
||||||
QApplication::processEvents();
|
|
||||||
QTRY_COMPARE(delegate.numPaints, 1);
|
QTRY_COMPARE(delegate.numPaints, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user