Remove Q_ASSERT from qitemview autotest

Allow createView() to return a null view on failure (which it already
did in release mode builds), but fail the test gracefully instead of
crashing when a null view is returned.  Also reordered the code slightly
to put all the QFETCH's together.

Task-number: QTBUG-17582
Reviewed-by: Rohan McGovern

Change-Id: I3a41c738cb0e4e860db2342b30817a804b20f30d
(cherry picked from commit 51b1d8dc20a2557d2002550b03e5b9f37f425fb4)
bb10
Jason McDonald 2011-05-03 11:25:17 +10:00 committed by Rohan McGovern
parent 7c8c84d92b
commit b0da433436
2 changed files with 19 additions and 7 deletions

View File

@ -297,9 +297,11 @@ void tst_QItemView::nonDestructiveBasicTest()
#endif
QFETCH(QString, viewType);
view = testViews->createView(viewType);
QFETCH(int, vscroll);
QFETCH(int, hscroll);
view = testViews->createView(viewType);
QVERIFY(view);
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
@ -454,9 +456,11 @@ void tst_QItemView::spider()
QSKIP("This test takes too long to execute on IRIX", SkipAll);
#endif
QFETCH(QString, viewType);
view = testViews->createView(viewType);
QFETCH(int, vscroll);
QFETCH(int, hscroll);
view = testViews->createView(viewType);
QVERIFY(view);
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
view->setModel(treeModel);
@ -489,9 +493,11 @@ void tst_QItemView::resize()
// This test needs to be re-thought out, it takes too long and
// doesn't really catch theproblem.
QFETCH(QString, viewType);
view = testViews->createView(viewType);
QFETCH(int, vscroll);
QFETCH(int, hscroll);
view = testViews->createView(viewType);
QVERIFY(view);
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
view->setModel(treeModel);
@ -517,9 +523,11 @@ void tst_QItemView::visualRect()
QSKIP("This test takes too long to execute on IRIX", SkipAll);
#endif
QFETCH(QString, viewType);
view = testViews->createView(viewType);
QFETCH(int, vscroll);
QFETCH(int, hscroll);
view = testViews->createView(viewType);
QVERIFY(view);
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
QCOMPARE(view->visualRect(QModelIndex()), QRect());
@ -651,9 +659,11 @@ void tst_QItemView::indexAt()
QSKIP("This test takes too long to execute on IRIX", SkipAll);
#endif
QFETCH(QString, viewType);
view = testViews->createView(viewType);
QFETCH(int, vscroll);
QFETCH(int, hscroll);
view = testViews->createView(viewType);
QVERIFY(view);
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
view->show();
@ -685,9 +695,11 @@ void tst_QItemView::scrollTo()
QSKIP("This test takes too long to execute on IRIX", SkipAll);
#endif
QFETCH(QString, viewType);
view = testViews->createView(viewType);
QFETCH(int, vscroll);
QFETCH(int, hscroll);
view = testViews->createView(viewType);
QVERIFY(view);
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
view->setModel(treeModel);
@ -735,6 +747,7 @@ void tst_QItemView::moveCursor()
#endif
QFETCH(QString, viewType);
view = testViews->createView(viewType);
QVERIFY(view);
if (view->objectName() == "QHeaderView")
return;

View File

@ -141,7 +141,6 @@ QAbstractItemView *ViewsToTest::createView(const QString &viewType)
view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
view->setSelectionBehavior(QAbstractItemView::SelectItems);
}
Q_ASSERT(view);
return view;
}