GV auto tests: kill QWindowsStyle dependencies

Change-Id: I6236b7ca23897c5075bef21f5e62fe01f4cfc611
Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
This commit is contained in:
J-P Nurmi 2012-11-27 18:22:05 +01:00 committed by The Qt Project
parent 226f245c71
commit a3fe4c6337
5 changed files with 19 additions and 26 deletions

View File

@ -45,7 +45,8 @@
#include <QtWidgets/qgraphicswidget.h>
#include <QtWidgets/qgraphicsproxywidget.h>
#include <QtWidgets/qgraphicsview.h>
#include <QtWidgets/qwindowsstyle.h>
#include <QtWidgets/qstylefactory.h>
#include <QtWidgets/qproxystyle.h>
class tst_QGraphicsAnchorLayout : public QObject {
@ -1119,11 +1120,11 @@ void tst_QGraphicsAnchorLayout::setSpacing()
delete view;
}
class CustomLayoutStyle : public QWindowsStyle
class CustomLayoutStyle : public QProxyStyle
{
Q_OBJECT
public:
CustomLayoutStyle() : QWindowsStyle()
CustomLayoutStyle() : QProxyStyle(QStyleFactory::create("windows"))
{
hspacing = 5;
vspacing = 10;
@ -1194,7 +1195,7 @@ int CustomLayoutStyle::pixelMetric(PixelMetric metric, const QStyleOption * opti
default:
break;
}
return QWindowsStyle::pixelMetric(metric, option, widget);
return QProxyStyle::pixelMetric(metric, option, widget);
}
void tst_QGraphicsAnchorLayout::styleDefaults()

View File

@ -47,7 +47,6 @@
#include <qgraphicsscene.h>
#include <qgraphicsview.h>
#include <qapplication.h>
#include <qwindowsstyle.h>
class tst_QGraphicsLinearLayout : public QObject {
Q_OBJECT
@ -152,7 +151,7 @@ void tst_QGraphicsLinearLayout::initTestCase()
{
// since the style will influence the results, we have to ensure
// that the tests are run using the same style on all platforms
QApplication::setStyle(new QWindowsStyle);
QApplication::setStyle("windows");
}
// This will be called after the last test function is executed.

View File

@ -2793,7 +2793,7 @@ void tst_QGraphicsProxyWidget::windowOpacity()
void tst_QGraphicsProxyWidget::stylePropagation()
{
QPointer<QWindowsStyle> windowsStyle = new QWindowsStyle;
QPointer<QStyle> windowsStyle = QStyleFactory::create("windows");
QLineEdit *edit = new QLineEdit;
QGraphicsProxyWidget proxy;

View File

@ -3406,7 +3406,7 @@ void tst_QGraphicsScene::tabFocus_sceneWithNestedFocusWidgets()
void tst_QGraphicsScene::style()
{
QPointer<QWindowsStyle> windowsStyle = new QWindowsStyle;
QPointer<QStyle> windowsStyle = QStyleFactory::create("windows");
QGraphicsScene scene;
QLineEdit *edit = new QLineEdit;

View File

@ -52,9 +52,8 @@
#include <math.h>
#include <QtWidgets/QLabel>
#if !defined(QT_NO_STYLE_WINDOWS)
#include <QtWidgets/QWindowsStyle>
#endif
#include <QtWidgets/QStyleFactory>
#include <QtWidgets/QCommonStyle>
#include <QtGui/QPainterPath>
#include <QtWidgets/QRubberBand>
#include <QtWidgets/QScrollBar>
@ -2770,7 +2769,7 @@ void tst_QGraphicsView::scrollBarRanges()
view.setStyle(new FauxMotifStyle);
} else {
#if !defined(QT_NO_STYLE_WINDOWS)
view.setStyle(new QWindowsStyle);
view.setStyle(QStyleFactory::create("windows"));
#endif
}
view.setStyleSheet(" "); // enables style propagation ;-)
@ -3282,15 +3281,11 @@ void tst_QGraphicsView::scrollAfterResize_data()
QTest::addColumn<QTransform>("x2");
QTest::addColumn<QTransform>("x3");
#if !defined(QT_NO_STYLE_WINDOWS)
QWindowsStyle style;
#else
QCommonStyle style;
#endif
QStyle *style = QStyleFactory::create("windows");
int frameWidth = style.pixelMetric(QStyle::PM_DefaultFrameWidth);
int extent = style.pixelMetric(QStyle::PM_ScrollBarExtent);
int inside = style.styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents);
int frameWidth = style->pixelMetric(QStyle::PM_DefaultFrameWidth);
int extent = style->pixelMetric(QStyle::PM_ScrollBarExtent);
int inside = style->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents);
int viewportWidth = 300;
int scrollBarIndent = viewportWidth - extent - (inside ? 4 : 2)*frameWidth;
@ -3302,6 +3297,7 @@ void tst_QGraphicsView::scrollAfterResize_data()
<< QTransform().translate(scrollBarIndent, 0)
<< QTransform().translate(scrollBarIndent + 100, 0)
<< QTransform().translate(scrollBarIndent + 110, 0);
delete style;
}
void tst_QGraphicsView::scrollAfterResize()
@ -3311,15 +3307,11 @@ void tst_QGraphicsView::scrollAfterResize()
QFETCH(QTransform, x2);
QFETCH(QTransform, x3);
#if !defined(QT_NO_STYLE_WINDOWS)
QWindowsStyle style;
#else
QCommonStyle style;
#endif
QStyle *style = QStyleFactory::create("windows");
QWidget toplevel;
QGraphicsView view(&toplevel);
view.setStyle(&style);
view.setStyle(style);
if (reverse)
view.setLayoutDirection(Qt::RightToLeft);
@ -3334,6 +3326,7 @@ void tst_QGraphicsView::scrollAfterResize()
QCOMPARE(view.viewportTransform(), x2);
view.horizontalScrollBar()->setValue(10);
QCOMPARE(view.viewportTransform(), x3);
delete style;
}
void tst_QGraphicsView::moveItemWhileScrolling_data()