From a0d379bc9a76dfcce08c69abb30d1fea821fd7d7 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 27 Nov 2012 18:31:06 +0100 Subject: Style auto tests: kill QWindowsStyle dependencies Change-Id: I135fe2b0aae81c73c1cca6272f71db07ecb3fa6b Reviewed-by: Lars Knoll --- tests/auto/widgets/styles/qstyle/tst_qstyle.cpp | 40 ++++++++++++++----------- 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'tests/auto/widgets/styles/qstyle/tst_qstyle.cpp') diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp index 7cbd30ebb3..d266692096 100644 --- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp +++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp @@ -55,7 +55,6 @@ #include #include -#include #include #include #include @@ -212,7 +211,7 @@ void tst_QStyle::testProxyStyle() { QProxyStyle *proxyStyle = new QProxyStyle(); QVERIFY(proxyStyle->baseStyle()); - QStyle *style = new QWindowsStyle; + QStyle *style = QStyleFactory::create("Windows"); QVERIFY(style->proxy() == style); proxyStyle->setBaseStyle(style); @@ -225,7 +224,7 @@ void tst_QStyle::testProxyStyle() QVERIFY(proxyStyle->baseStyle()); qApp->setStyle(proxyStyle); - QProxyStyle doubleProxy(new QProxyStyle(new QWindowsStyle())); + QProxyStyle doubleProxy(new QProxyStyle(QStyleFactory::create("Windows"))); QVERIFY(testAllFunctions(&doubleProxy)); CustomProxy customStyle; @@ -363,16 +362,17 @@ void tst_QStyle::testFusionStyle() void tst_QStyle::testWindowsStyle() { - QWindowsStyle wstyle; - QVERIFY(testAllFunctions(&wstyle)); - lineUpLayoutTest(&wstyle); + QStyle *wstyle = QStyleFactory::create("Windows"); + QVERIFY(testAllFunctions(wstyle)); + lineUpLayoutTest(wstyle); // Tests drawing indeterminate progress with 0 size: QTBUG-15973 QStyleOptionProgressBar pb; pb.rect = QRect(0,0,-9,0); QPixmap surface(QSize(200, 200)); QPainter painter(&surface); - wstyle.drawControl(QStyle::CE_ProgressBar, &pb, &painter, 0); + wstyle->drawControl(QStyle::CE_ProgressBar, &pb, &painter, 0); + delete wstyle; } #if defined(Q_OS_WIN) && !defined(QT_NO_STYLE_WINDOWSXP) @@ -566,11 +566,11 @@ void MyWidget::paintEvent( QPaintEvent* ) } -class Qt42Style : public QWindowsStyle +class Qt42Style : public QCommonStyle { Q_OBJECT public: - Qt42Style() : QWindowsStyle() + Qt42Style() : QCommonStyle() { margin_toplevel = 10; margin = 5; @@ -602,7 +602,7 @@ int Qt42Style::pixelMetric(PixelMetric metric, const QStyleOption * option /*= 0 default: break; } - return QWindowsStyle::pixelMetric(metric, option, widget); + return -1; } @@ -636,11 +636,11 @@ void tst_QStyle::progressBarChangeStyle() //test a crashing situation (task 143530) //where changing the styles and deleting a progressbar would crash - QWindowsStyle style1; + QStyle *style1 = QStyleFactory::create("Windows"); QStyle *style2 = QStyleFactory::create("Fusion"); QProgressBar *progress=new QProgressBar; - progress->setStyle(&style1); + progress->setStyle(style1); progress->show(); @@ -652,6 +652,7 @@ void tst_QStyle::progressBarChangeStyle() QTest::qWait(100); //before the correction, there would be a crash here + delete style1; delete style2; } #endif @@ -746,17 +747,19 @@ void tst_QStyle::testDrawingShortcuts() #define SCROLLBAR_SPACING 33 -class FrameTestStyle : public QWindowsStyle { +class FrameTestStyle : public QProxyStyle { +public: + FrameTestStyle() : QProxyStyle(QStyleFactory::create("Windows")) { } 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); + return QProxyStyle ::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); + return QProxyStyle ::pixelMetric(pm, option ,widget); } }; @@ -764,12 +767,12 @@ void tst_QStyle::testFrameOnlyAroundContents() { QScrollArea area; area.setGeometry(0, 0, 200, 200); - QWindowsStyle winStyle; + QStyle *winStyle = QStyleFactory::create("Windows"); FrameTestStyle frameStyle; QWidget *widget = new QWidget(&area); widget->setGeometry(0, 0, 400, 400); - area.setStyle(&winStyle); - area.verticalScrollBar()->setStyle(&winStyle); + area.setStyle(winStyle); + area.verticalScrollBar()->setStyle(winStyle); area.setWidget(widget); area.setVisible(true); int viewPortWidth = area.viewport()->width(); @@ -777,6 +780,7 @@ void tst_QStyle::testFrameOnlyAroundContents() area.setStyle(&frameStyle); // Test that we reserve space for scrollbar spacing QVERIFY(viewPortWidth == area.viewport()->width() + SCROLLBAR_SPACING); + delete winStyle; } -- cgit v1.2.3