summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-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 cb30f83..46e9edc 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>
@@ -131,6 +132,7 @@ private slots:
void testWindowsCEStyle();
void testWindowsMobileStyle();
void testStyleFactory();
+ void testProxyStyle();
void pixelMetric();
void progressBarChangeStyle();
void defaultFont();
@@ -213,6 +215,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);
@@ -310,7 +350,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())