summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-06-03 10:23:56 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-06-03 10:23:56 +0200
commite2f66f921594b7be4af4a058c959557489e86879 (patch)
treecc44931708b57bd5a761906797c7dee0360d1d6b /tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
parent933bf178aab88ab5df8a68cbf02611d6d8744b1b (diff)
parent754efa57d89c62d1796e01b407e9222e67450f52 (diff)
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts: src/corelib/global/qnamespace.qdoc src/corelib/io/qwindowspipereader.cpp src/corelib/io/qwindowspipereader_p.h src/corelib/statemachine/qstatemachine.cpp src/corelib/statemachine/qstatemachine_p.h src/plugins/platforms/xcb/qxcbconnection.h tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp tests/auto/tools/qmake/tst_qmake.cpp tests/manual/touch/main.cpp Change-Id: I917d694890e79ee3da7d65134b5b085e23e0dd62
Diffstat (limited to 'tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp')
-rw-r--r--tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index 22245707cc..9b8b306e00 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -48,6 +48,7 @@
#include <QtWidgets/QScrollBar>
#include <QtWidgets/QDialog>
#include <QtWidgets/QStyledItemDelegate>
+#include <QtWidgets/QStyleFactory>
#if defined(Q_OS_WIN) || defined(Q_OS_WINCE)
# include <windows.h>
@@ -2350,11 +2351,34 @@ void tst_QListView::testViewOptions()
QCOMPARE(options.decorationPosition, QStyleOptionViewItem::Top);
}
+// make sure we have no transient scroll bars
+class TempStyleSetter
+{
+public:
+ TempStyleSetter()
+ : m_oldStyle(qApp->style())
+ {
+ m_oldStyle->setParent(0);
+ QListView tempView;
+ if (QApplication::style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, tempView.horizontalScrollBar()))
+ QApplication::setStyle(QStyleFactory::create("Fusion"));
+ }
+
+ ~TempStyleSetter()
+ {
+ QApplication::setStyle(m_oldStyle);
+ }
+private:
+ QStyle* m_oldStyle;
+};
+
void tst_QListView::taskQTBUG_39902_mutualScrollBars()
{
QWidget window;
window.resize(400, 300);
QListView *view = new QListView(&window);
+ // make sure we have no transient scroll bars
+ TempStyleSetter styleSetter;
QStandardItemModel model(200, 1);
const QSize itemSize(100, 20);
for (int i = 0; i < model.rowCount(); ++i)
@@ -2372,6 +2396,44 @@ void tst_QListView::taskQTBUG_39902_mutualScrollBars()
view->resize(itemSize.width() + view->frameWidth() * 2, model.rowCount() * itemSize.height() + view->frameWidth() * 2);
// this will end up in a stack overflow, if QTBUG-39902 is not fixed
QTest::qWait(100);
+
+ // these tests do not apply with transient scroll bars enabled
+ QVERIFY (!view->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, view->horizontalScrollBar()));
+
+ // make it double as large, no scroll bars should be visible
+ view->resize((itemSize.width() + view->frameWidth() * 2) * 2, (model.rowCount() * itemSize.height() + view->frameWidth() * 2) * 2);
+ QTRY_VERIFY(!view->horizontalScrollBar()->isVisible());
+ QTRY_VERIFY(!view->verticalScrollBar()->isVisible());
+
+ // make it half the size, both scroll bars should be visible
+ view->resize((itemSize.width() + view->frameWidth() * 2) / 2, (model.rowCount() * itemSize.height() + view->frameWidth() * 2) / 2);
+ QTRY_VERIFY(view->horizontalScrollBar()->isVisible());
+ QTRY_VERIFY(view->verticalScrollBar()->isVisible());
+
+ // make it double as large, no scroll bars should be visible
+ view->resize((itemSize.width() + view->frameWidth() * 2) * 2, (model.rowCount() * itemSize.height() + view->frameWidth() * 2) * 2);
+ QTRY_VERIFY(!view->horizontalScrollBar()->isVisible());
+ QTRY_VERIFY(!view->verticalScrollBar()->isVisible());
+
+ // now, coming from the double size, resize it to the exactly matching size, still no scroll bars should be visible again
+ view->resize(itemSize.width() + view->frameWidth() * 2, model.rowCount() * itemSize.height() + view->frameWidth() * 2);
+ QTRY_VERIFY(!view->horizontalScrollBar()->isVisible());
+ QTRY_VERIFY(!view->verticalScrollBar()->isVisible());
+
+ // now remove just one single pixel in height -> both scroll bars will show up since they depend on each other
+ view->resize(itemSize.width() + view->frameWidth() * 2, model.rowCount() * itemSize.height() + view->frameWidth() * 2 - 1);
+ QTRY_VERIFY(view->horizontalScrollBar()->isVisible());
+ QTRY_VERIFY(view->verticalScrollBar()->isVisible());
+
+ // now remove just one single pixel in with -> both scroll bars will show up since they depend on each other
+ view->resize(itemSize.width() + view->frameWidth() * 2 - 1, model.rowCount() * itemSize.height() + view->frameWidth() * 2);
+ QTRY_VERIFY(view->horizontalScrollBar()->isVisible());
+ QTRY_VERIFY(view->verticalScrollBar()->isVisible());
+
+ // finally, coming from a size being to small, resize back to the exactly matching size -> both scroll bars should disappear again
+ view->resize(itemSize.width() + view->frameWidth() * 2, model.rowCount() * itemSize.height() + view->frameWidth() * 2);
+ QTRY_VERIFY(!view->horizontalScrollBar()->isVisible());
+ QTRY_VERIFY(!view->verticalScrollBar()->isVisible());
}
void tst_QListView::horizontalScrollingByVerticalWheelEvents()