summaryrefslogtreecommitdiffstats
path: root/tests/auto/qstyle/tst_qstyle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qstyle/tst_qstyle.cpp')
-rw-r--r--tests/auto/qstyle/tst_qstyle.cpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/tests/auto/qstyle/tst_qstyle.cpp b/tests/auto/qstyle/tst_qstyle.cpp
index e020f9e..c555a5c 100644
--- a/tests/auto/qstyle/tst_qstyle.cpp
+++ b/tests/auto/qstyle/tst_qstyle.cpp
@@ -58,6 +58,7 @@
#include <qcdestyle.h>
#include <qmotifstyle.h>
#include <qcommonstyle.h>
+#include <qproxystyle.h>
#include <qstylefactory.h>
#include <qimagereader.h>
@@ -140,6 +141,7 @@ private slots:
void testWindowsMobileStyle();
void testS60Style();
void testStyleFactory();
+ void testProxyStyle();
void pixelMetric();
void progressBarChangeStyle();
void defaultFont();
@@ -222,6 +224,44 @@ void tst_QStyle::testStyleFactory()
}
}
+class CustomProxy : public QProxyStyle
+{
+ virtual int pixelMetric(PixelMetric metric, const QStyleOption *option = 0,
+ const QWidget *widget = 0) const
+ {
+ if (metric == QStyle::PM_ButtonIconSize)
+ return 13;
+ return QProxyStyle::pixelMetric(metric, option, widget);
+ }
+};
+
+void tst_QStyle::testProxyStyle()
+{
+ QProxyStyle *proxyStyle = new QProxyStyle();
+ QVERIFY(proxyStyle->baseStyle());
+ QStyle *style = new QWindowsStyle;
+ QVERIFY(style->proxy() == style);
+
+ proxyStyle->setBaseStyle(style);
+ QVERIFY(style->proxy() == proxyStyle);
+ QVERIFY(style->parent() == proxyStyle);
+ QVERIFY(proxyStyle->baseStyle() == style);
+
+ testAllFunctions(proxyStyle);
+ proxyStyle->setBaseStyle(0);
+ QVERIFY(proxyStyle->baseStyle());
+ qApp->setStyle(proxyStyle);
+
+ QProxyStyle doubleProxy(new QProxyStyle(new QWindowsStyle()));
+ testAllFunctions(&doubleProxy);
+
+ CustomProxy customStyle;
+ QLineEdit edit;
+ edit.setStyle(&customStyle);
+ QVERIFY(!customStyle.parent());
+ QVERIFY(edit.style()->pixelMetric(QStyle::PM_ButtonIconSize) == 13);
+}
+
void tst_QStyle::drawItemPixmap()
{
testWidget->resize(300, 300);
@@ -324,7 +364,7 @@ void tst_QStyle::testAllFunctions(QStyle *style)
testScrollBarSubControls(style);
}
-void tst_QStyle::testScrollBarSubControls(QStyle *style)
+void tst_QStyle::testScrollBarSubControls(QStyle *)
{
#ifdef Q_OS_WINCE_WM
if (qobject_cast<QWindowsMobileStyle*>(style) && qt_wince_is_smartphone())