diff options
author | Jens Bache-Wiig <jens.bache-wiig@digia.com> | 2012-09-19 17:45:25 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-09-21 02:44:22 +0200 |
commit | fe966e5f48da975bfa63bb547398153b74fbd534 (patch) | |
tree | a1019bd73e6787f27c770f6a72a2f0d5f72b3bc4 /tests/auto/widgets/styles/qstyle/tst_qstyle.cpp | |
parent | e92313bf7e2346f44deec4dd4ea70289a621c4ca (diff) |
Fix regression in QAbstractScrollArea
The style hint SH_ScrollView_FrameOnlyAroundContents was currently
being ignored by QAbstractScrollArea. This looks like an accidental
regression following 10c6f015f45092040c281bb90a65179f598a00b1.
This code path does not execute on mac so it should have no impact
on that patch.
Change-Id: I78ca0a6b87dfdd7d426acbb3ef49480390211af2
Reviewed-by: Christoph Schleifenbaum <christoph.schleifenbaum@kdab.com>
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'tests/auto/widgets/styles/qstyle/tst_qstyle.cpp')
-rw-r--r-- | tests/auto/widgets/styles/qstyle/tst_qstyle.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp index 2fb0ffe911..119ea33fc3 100644 --- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp +++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp @@ -72,6 +72,7 @@ #include <qradiobutton.h> #include <qlineedit.h> #include <qmdiarea.h> +#include <qscrollarea.h> #include <QCleanlooksStyle> @@ -148,6 +149,7 @@ private slots: #endif void defaultFont(); void testDrawingShortcuts(); + void testFrameOnlyAroundContents(); private: void lineUpLayoutTest(QStyle *); QWidget *testWidget; @@ -763,6 +765,7 @@ public: int alignment; }; + void tst_QStyle::testDrawingShortcuts() { { @@ -796,5 +799,41 @@ void tst_QStyle::testDrawingShortcuts() } } +#define SCROLLBAR_SPACING 33 + +class FrameTestStyle : public QWindowsStyle { + int styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn *returnData) const { + if (hint == QStyle::SH_ScrollView_FrameOnlyAroundContents) + return 1; + return QWindowsStyle ::styleHint(hint, opt, widget, returnData); + } + + int pixelMetric(PixelMetric pm, const QStyleOption *option, const QWidget *widget) const { + if (pm == QStyle::PM_ScrollView_ScrollBarSpacing) + return SCROLLBAR_SPACING; + return QWindowsStyle ::pixelMetric(pm, option ,widget); + } +}; + +void tst_QStyle::testFrameOnlyAroundContents() +{ + QScrollArea area; + area.setGeometry(0, 0, 200, 200); + QWindowsStyle winStyle; + FrameTestStyle frameStyle; + QWidget *widget = new QWidget(&area); + widget->setGeometry(0, 0, 400, 400); + area.setStyle(&winStyle); + area.verticalScrollBar()->setStyle(&winStyle); + area.setWidget(widget); + area.setVisible(true); + int viewPortWidth = area.viewport()->width(); + area.verticalScrollBar()->setStyle(&frameStyle); + area.setStyle(&frameStyle); + // Test that we reserve space for scrollbar spacing + QVERIFY(viewPortWidth == area.viewport()->width() + SCROLLBAR_SPACING); +} + + QTEST_MAIN(tst_QStyle) #include "tst_qstyle.moc" |