Fix taskQTBUG_34717_collapseAtBottom test
The test is moved from tst_qtreeview to tst_qtreewidget as it tests qtreewidget class. C++ usage is fixed, there was an illegal C cast that was causing crashes Change-Id: I80e90a9b531e87f9b133186b6f48be42f54901b5 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
This commit is contained in:
parent
4f3379655c
commit
f17837fbf9
@ -253,7 +253,6 @@ private slots:
|
||||
void taskQTBUG_25333_adjustViewOptionsForIndex();
|
||||
void taskQTBUG_18539_emitLayoutChanged();
|
||||
void taskQTBUG_8176_emitOnExpandAll();
|
||||
void taskQTBUG_34717_collapseAtBottom();
|
||||
void taskQTBUG_37813_crash();
|
||||
void taskQTBUG_45697_crash();
|
||||
void testInitialFocus();
|
||||
@ -4283,35 +4282,6 @@ void tst_QTreeView::taskQTBUG_8176_emitOnExpandAll()
|
||||
QCOMPARE(spy2.size(), 1); // item2 is collapsed
|
||||
}
|
||||
|
||||
// From QTBUG_34717 (QTreeWidget crashes when scrolling to the end
|
||||
// of an expanded tree, then collapse all)
|
||||
// The test passes simply if it doesn't crash.
|
||||
void tst_QTreeView::taskQTBUG_34717_collapseAtBottom()
|
||||
{
|
||||
QTreeWidget treeWidget;
|
||||
treeWidget.header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
treeWidget.setColumnCount(2);
|
||||
QTreeWidgetItem *mainItem = new QTreeWidgetItem(&treeWidget, QStringList() << "Root");
|
||||
for (int i = 0; i < 200; ++i) {
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(mainItem, QStringList(QString("Item")));
|
||||
new QTreeWidgetItem(item, QStringList() << "Child" << "1");
|
||||
new QTreeWidgetItem(item, QStringList() << "Child" << "2");
|
||||
new QTreeWidgetItem(item, QStringList() << "Child" << "3");
|
||||
}
|
||||
treeWidget.show();
|
||||
treeWidget.expandAll();
|
||||
treeWidget.scrollToBottom();
|
||||
treeWidget.collapseAll();
|
||||
|
||||
treeWidget.setAnimated(true);
|
||||
treeWidget.expandAll();
|
||||
treeWidget.scrollToBottom();
|
||||
mainItem->setExpanded(false);
|
||||
|
||||
PublicView *pview = (PublicView*) &treeWidget;
|
||||
QVERIFY(pview->sizeHintForColumn(1) >= 0);
|
||||
}
|
||||
|
||||
void tst_QTreeView::testInitialFocus()
|
||||
{
|
||||
QTreeWidget treeWidget;
|
||||
|
@ -161,6 +161,7 @@ private slots:
|
||||
void taskQTBUG2844_visualItemRect();
|
||||
void setChildIndicatorPolicy();
|
||||
|
||||
void taskQTBUG_34717_collapseAtBottom();
|
||||
void task20345_sortChildren();
|
||||
void getMimeDataWithInvalidItem();
|
||||
|
||||
@ -3378,6 +3379,38 @@ void tst_QTreeWidget::setChildIndicatorPolicy()
|
||||
QTRY_COMPARE(delegate.numPaints, 1);
|
||||
}
|
||||
|
||||
// From QTBUG_34717 (QTreeWidget crashes when scrolling to the end
|
||||
// of an expanded tree, then collapse all)
|
||||
// The test passes simply if it doesn't crash.
|
||||
void tst_QTreeWidget::taskQTBUG_34717_collapseAtBottom()
|
||||
{
|
||||
struct PublicTreeWidget: public QTreeWidget
|
||||
{
|
||||
inline int sizeHintForColumn(int column) const { return QTreeWidget::sizeHintForColumn(column); }
|
||||
};
|
||||
PublicTreeWidget treeWidget;
|
||||
treeWidget.header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
treeWidget.setColumnCount(2);
|
||||
QTreeWidgetItem *mainItem = new QTreeWidgetItem(&treeWidget, QStringList() << "Root");
|
||||
for (int i = 0; i < 200; ++i) {
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(mainItem, QStringList(QString("Item")));
|
||||
new QTreeWidgetItem(item, QStringList() << "Child" << "1");
|
||||
new QTreeWidgetItem(item, QStringList() << "Child" << "2");
|
||||
new QTreeWidgetItem(item, QStringList() << "Child" << "3");
|
||||
}
|
||||
treeWidget.show();
|
||||
treeWidget.expandAll();
|
||||
treeWidget.scrollToBottom();
|
||||
treeWidget.collapseAll();
|
||||
|
||||
treeWidget.setAnimated(true);
|
||||
treeWidget.expandAll();
|
||||
treeWidget.scrollToBottom();
|
||||
mainItem->setExpanded(false);
|
||||
|
||||
QVERIFY(treeWidget.sizeHintForColumn(1) >= 0);
|
||||
}
|
||||
|
||||
void tst_QTreeWidget::task20345_sortChildren()
|
||||
{
|
||||
if (qApp->platformName().toLower() == QLatin1String("wayland"))
|
||||
|
Loading…
Reference in New Issue
Block a user