summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtableview
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qtableview')
-rw-r--r--tests/auto/qtableview/qtableview.pro2
-rw-r--r--tests/auto/qtableview/tst_qtableview.cpp94
2 files changed, 90 insertions, 6 deletions
diff --git a/tests/auto/qtableview/qtableview.pro b/tests/auto/qtableview/qtableview.pro
index 2368a56..72099d4 100644
--- a/tests/auto/qtableview/qtableview.pro
+++ b/tests/auto/qtableview/qtableview.pro
@@ -1,4 +1,4 @@
load(qttest_p4)
+TARGET.EPOCHEAPSIZE = 0x200000 0x800000
SOURCES += tst_qtableview.cpp
-
diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp
index f71d97c..39ab4c6 100644
--- a/tests/auto/qtableview/tst_qtableview.cpp
+++ b/tests/auto/qtableview/tst_qtableview.cpp
@@ -42,6 +42,7 @@
#include <QtGui/QtGui>
#include <QtTest/QtTest>
+#include "../../shared/util.h"
//TESTED_CLASS=
//TESTED_FILES=
@@ -175,6 +176,9 @@ private slots:
// task-specific tests:
void task173773_updateVerticalHeader();
void task227953_setRootIndex();
+ void task240266_veryBigColumn();
+ void task248688_autoScrollNavigation();
+ void task259308_scrollVerticalHeaderSwappedSections();
void mouseWheel_data();
void mouseWheel();
@@ -586,7 +590,7 @@ void tst_QTableView::keyboardNavigation()
QModelIndex index = model.index(rowCount - 1, columnCount - 1);
view.setCurrentIndex(index);
- QApplication::instance()->processEvents();
+ QApplication::processEvents();
int row = rowCount - 1;
int column = columnCount - 1;
@@ -618,7 +622,7 @@ void tst_QTableView::keyboardNavigation()
}
QTest::keyClick(&view, key);
- QApplication::instance()->processEvents();
+ QApplication::processEvents();
QModelIndex index = model.index(row, column);
QCOMPARE(view.currentIndex(), index);
@@ -2540,6 +2544,7 @@ void tst_QTableView::span_data()
<< 2 << 1
<< false;
+ /* This makes no sens.
QTest::newRow("top left 2x0")
<< 10 << 10
<< -1 << -1
@@ -2554,7 +2559,7 @@ void tst_QTableView::span_data()
<< 0 << 0
<< 0 << 2
<< 0 << 2
- << false;
+ << false;*/
QTest::newRow("invalid 2x2")
<< 10 << 10
@@ -3107,14 +3112,14 @@ void tst_QTableView::task227953_setRootIndex()
}
tableView.setModel(&model);
-
+
//show the first 10 rows of the first table
QModelIndex root = model.indexFromItem(&item1);
tableView.setRootIndex(root);
for (int i = 10; i != 40; ++i) {
tableView.setRowHidden(i, true);
}
-
+
QCOMPARE(tableView.verticalHeader()->count(), 40);
QCOMPARE(tableView.verticalHeader()->hiddenSectionCount(), 30);
@@ -3126,6 +3131,53 @@ void tst_QTableView::task227953_setRootIndex()
QVERIFY(!tableView.verticalHeader()->isHidden());
}
+void tst_QTableView::task240266_veryBigColumn()
+{
+ QTableView table;
+ table.setFixedSize(500, 300); //just to make sure we have the 2 first columns visible
+ QStandardItemModel model(1, 3);
+ table.setModel(&model);
+ table.setColumnWidth(0, 100); //normal column
+ table.setColumnWidth(1, 100); //normal column
+ table.setColumnWidth(2, 9000); //very big column
+ table.show();
+ QTest::qWait(100);
+
+ QScrollBar *scroll = table.horizontalScrollBar();
+ QCOMPARE(scroll->minimum(), 0);
+ QCOMPARE(scroll->maximum(), model.columnCount() - 1);
+ QCOMPARE(scroll->singleStep(), 1);
+
+ //1 is not always a very correct value for pageStep. Ideally this should be dynamic.
+ //Maybe something for Qt 5 ;-)
+ QCOMPARE(scroll->pageStep(), 1);
+
+}
+
+void tst_QTableView::task248688_autoScrollNavigation()
+{
+ //we make sure that when navigating with the keyboard the view is correctly scrolled
+ //to the current item
+ QStandardItemModel model(16, 16);
+ QTableView view;
+ view.setModel(&model);
+
+ view.hideColumn(8);
+ view.hideRow(8);
+ view.show();
+ for (int r = 0; r < model.rowCount(); ++r) {
+ if (view.isRowHidden(r))
+ continue;
+ for (int c = 0; c < model.columnCount(); ++c) {
+ if (view.isColumnHidden(c))
+ continue;
+ QModelIndex index = model.index(r, c);
+ view.setCurrentIndex(index);
+ QVERIFY(view.viewport()->rect().contains(view.visualRect(index)));
+ }
+ }
+}
+
void tst_QTableView::mouseWheel_data()
{
@@ -3203,6 +3255,38 @@ void tst_QTableView::addColumnWhileEditing()
QCOMPARE(editor->geometry(), view.visualRect(last));
}
+void tst_QTableView::task259308_scrollVerticalHeaderSwappedSections()
+{
+ QStandardItemModel model;
+ model.setRowCount(50);
+ model.setColumnCount(2);
+ for (int row = 0; row < model.rowCount(); ++row)
+ for (int col = 0; col < model.columnCount(); ++col) {
+ const QModelIndex &idx = model.index(row, col);
+ model.setData(idx, QVariant(row), Qt::EditRole);
+ }
+
+ QTableView tv;
+ tv.setModel(&model);
+ tv.show();
+ tv.verticalHeader()->swapSections(0, model.rowCount() - 1);
+ tv.setCurrentIndex(model.index(model.rowCount() - 1, 0));
+
+ QTest::qWait(60);
+ QTest::keyClick(&tv, Qt::Key_PageUp); // PageUp won't scroll when at top
+ QTRY_COMPARE(tv.rowAt(0), tv.verticalHeader()->logicalIndex(0));
+
+ int newRow = tv.rowAt(tv.viewport()->height());
+ if (newRow == tv.rowAt(tv.viewport()->height() - 1)) // Overlapping row
+ newRow++;
+ QTest::keyClick(&tv, Qt::Key_PageDown); // Scroll down and check current
+ QTRY_COMPARE(tv.currentIndex().row(), newRow);
+
+ tv.setCurrentIndex(model.index(0, 0));
+ QTest::qWait(60);
+ 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));
+}
QTEST_MAIN(tst_QTableView)
#include "tst_qtableview.moc"