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.cpp114
1 files changed, 82 insertions, 32 deletions
diff --git a/tests/auto/qstyle/tst_qstyle.cpp b/tests/auto/qstyle/tst_qstyle.cpp
index 961af1b..7c9a8cc 100644
--- a/tests/auto/qstyle/tst_qstyle.cpp
+++ b/tests/auto/qstyle/tst_qstyle.cpp
@@ -70,6 +70,10 @@
#include <qlineedit.h>
#include <qmdiarea.h>
+#if defined(Q_OS_SYMBIAN)
+#define SRCDIR "."
+#endif
+
#include <QCleanlooksStyle>
#ifdef Q_WS_MAC
@@ -99,10 +103,14 @@ static bool qt_wince_is_smartphone() {
}
#endif
+#ifdef Q_WS_S60
+#include <qs60style.h>
+#endif
+
#include <qwidget.h>
//TESTED_CLASS=
-//TESTED_FILES=gui/styles/qstyle.h gui/styles/qstyle.cpp gui/styles/qplastiquestyle.cpp gui/styles/qwindowsstyle.cpp gui/styles/qwindowsxpstyle.cpp gui/styles/qwindowsvistastyle.cpp gui/styles/qmotifstyle.cpp
+//TESTED_FILES=gui/styles/qstyle.h gui/styles/qstyle.cpp gui/styles/qplastiquestyle.cpp gui/styles/qwindowsstyle.cpp gui/styles/qwindowsxpstyle.cpp gui/styles/qwindowsvistastyle.cpp gui/styles/qmotifstyle.cpp gui/styles/qs60style.cpp
class tst_QStyle : public QObject
{
@@ -130,12 +138,13 @@ private slots:
void testMacStyle();
void testWindowsCEStyle();
void testWindowsMobileStyle();
+ void testS60Style();
void testStyleFactory();
void pixelMetric();
void progressBarChangeStyle();
void defaultFont();
private:
- void lineUpLayoutTest(QStyle *);
+ void lineUpLayoutTest(QStyle *);
QWidget *testWidget;
};
@@ -198,10 +207,10 @@ void tst_QStyle::testStyleFactory()
QVERIFY(keys.contains("Motif"));
#endif
#ifdef Q_WS_WIN
- if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP &&
+ if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP &&
QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)
QVERIFY(keys.contains("WindowsXP"));
- if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA &&
+ if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA &&
QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)
QVERIFY(keys.contains("WindowsVista"));
#endif
@@ -217,7 +226,12 @@ void tst_QStyle::drawItemPixmap()
{
testWidget->resize(300, 300);
testWidget->show();
+#if defined(Q_OS_SYMBIAN)
+ const QString prefix = QLatin1String(SRCDIR) + QLatin1String("/");
+ QPixmap p(prefix+"task_25863.png", "PNG");
+#else
QPixmap p("task_25863.png", "PNG");
+#endif
QPixmap actualPix = QPixmap::grabWidget(testWidget);
QVERIFY(pixmapsAreEqual(&actualPix,&p));
testWidget->hide();
@@ -229,17 +243,17 @@ void tst_QStyle::testAllFunctions(QStyle *style)
opt.init(testWidget);
testWidget->setStyle(style);
-
+
//Tests styleHint with default arguments for potential crashes
for ( int hint = 0 ; hint < int(QStyle::SH_Menu_Mask); ++hint) {
style->styleHint(QStyle::StyleHint(hint));
style->styleHint(QStyle::StyleHint(hint), &opt, testWidget);
}
-
+
//Tests pixelMetric with default arguments for potential crashes
for ( int pm = 0 ; pm < int(QStyle::PM_LayoutVerticalSpacing); ++pm) {
style->pixelMetric(QStyle::PixelMetric(pm));
- style->pixelMetric(QStyle::PixelMetric(pm), &opt, testWidget);
+ style->pixelMetric(QStyle::PixelMetric(pm), &opt, testWidget);
}
//Tests drawControl with default arguments for potential crashes
@@ -255,7 +269,7 @@ void tst_QStyle::testAllFunctions(QStyle *style)
QPainter painter(&surface);
QStyleOptionComboBox copt1;
copt1.init(testWidget);
-
+
QStyleOptionGroupBox copt2;
copt2.init(testWidget);
QStyleOptionSizeGrip copt3;
@@ -306,7 +320,7 @@ void tst_QStyle::testAllFunctions(QStyle *style)
style->itemPixmapRect(QRect(0, 0, 100, 100), Qt::AlignHCenter, QPixmap(200, 200));
style->itemTextRect(QFontMetrics(qApp->font()), QRect(0, 0, 100, 100), Qt::AlignHCenter, true, QString("Test"));
-
+
testScrollBarSubControls(style);
}
@@ -321,6 +335,12 @@ void tst_QStyle::testScrollBarSubControls(QStyle *style)
scrollBar.show();
const QStyleOptionSlider opt = qt_qscrollbarStyleOption(&scrollBar);
foreach (int subControl, QList<int>() << 1 << 2 << 4 << 8) {
+
+#ifdef Q_WS_S60
+// in s60style add line and sub line have been removed.
+ if (subControl == QStyle::SC_ScrollBarAddLine || subControl == QStyle::SC_ScrollBarSubLine )
+ continue;
+#endif
QRect sr = testWidget->style()->subControlRect(QStyle::CC_ScrollBar, &opt,
QStyle::SubControl(subControl), &scrollBar);
QVERIFY(sr.isNull() == false);
@@ -405,7 +425,7 @@ void comparePixmap(const QString &filename, const QPixmap &pixmap)
void tst_QStyle::testPainting(QStyle *style, const QString &platform)
{
//Test Menu
- QString fileName = "images/" + platform + "/menu.png";
+ QString fileName = "images/" + platform + "/menu.png";
QMenu menu;
menu.setStyle(style);
menu.show();
@@ -414,7 +434,7 @@ void tst_QStyle::testPainting(QStyle *style, const QString &platform)
QPixmap pixmap = QPixmap::grabWidget(&menu);
comparePixmap(fileName, pixmap);
- //Push button
+ //Push button
fileName = "images/" + platform + "/button.png";
QPushButton button("OK");
button.setStyle(style);
@@ -423,7 +443,7 @@ void tst_QStyle::testPainting(QStyle *style, const QString &platform)
button.hide();
comparePixmap(fileName, pixmap);
- //Push button
+ //Push button
fileName = "images/" + platform + "/radiobutton.png";
QRadioButton radiobutton("Check");
radiobutton.setStyle(style);
@@ -453,7 +473,7 @@ void tst_QStyle::testPainting(QStyle *style, const QString &platform)
spinbox.hide();
comparePixmap(fileName, pixmap);
QLocale::setDefault(QLocale::system());
-
+
//Slider
fileName = "images/" + platform + "/slider.png";
QSlider slider;
@@ -532,6 +552,16 @@ void tst_QStyle::testWindowsMobileStyle()
#endif
}
+void tst_QStyle::testS60Style()
+ {
+#if defined(Q_WS_S60)
+ QS60Style cstyle;
+ testAllFunctions(&cstyle);
+#else
+ QSKIP("No S60Style style", SkipAll);
+#endif
+ }
+
// Helper class...
MyWidget::MyWidget( QWidget* parent, const char* name )
@@ -616,9 +646,9 @@ void tst_QStyle::pixelMetric()
void tst_QStyle::progressBarChangeStyle()
{
#if !defined(QT_NO_STYLE_PLASTIQUE) && !defined(QT_NO_STYLE_WINDOWS)
- //test a crashing situation (task 143530)
+ //test a crashing situation (task 143530)
//where changing the styles and deleting a progressbar would crash
-
+
QWindowsStyle style1;
QPlastiqueStyle style2;
@@ -635,35 +665,55 @@ void tst_QStyle::progressBarChangeStyle()
QTest::qWait(100);
//before the correction, there would be a crash here
+#elif !defined(QT_NO_STYLE_S60) && !defined(QT_NO_STYLE_WINDOWS)
+ //test a crashing situation (task 143530)
+ //where changing the styles and deleting a progressbar would crash
+
+ QWindowsStyle style1;
+ QS60Style style2;
+
+ QProgressBar *progress=new QProgressBar;
+ progress->setStyle(&style1);
+
+ progress->show();
+
+ progress->setStyle(&style2);
+
+ QTest::qWait(100);
+ delete progress;
+
+ QTest::qWait(100);
+
+ //before the correction, there would be a crash here
#else
- QSKIP("Either style Plastique or Windows missing", SkipAll);
+ QSKIP("Either style Plastique or Windows or S60 missing", SkipAll);
#endif
}
void tst_QStyle::lineUpLayoutTest(QStyle *style)
{
- QWidget widget;
- QHBoxLayout layout;
- QFont font;
- font.setPointSize(9); //Plastique is lined up for odd numbers...
- widget.setFont(font);
- QSpinBox spinbox(&widget);
- QLineEdit lineedit(&widget);
- QComboBox combo(&widget);
- combo.setEditable(true);
- layout.addWidget(&spinbox);
- layout.addWidget(&lineedit);
- layout.addWidget(&combo);
- widget.setLayout(&layout);
+ QWidget widget;
+ QHBoxLayout layout;
+ QFont font;
+ font.setPointSize(9); //Plastique is lined up for odd numbers...
+ widget.setFont(font);
+ QSpinBox spinbox(&widget);
+ QLineEdit lineedit(&widget);
+ QComboBox combo(&widget);
+ combo.setEditable(true);
+ layout.addWidget(&spinbox);
+ layout.addWidget(&lineedit);
+ layout.addWidget(&combo);
+ widget.setLayout(&layout);
widget.setStyle(style);
// propagate the style.
foreach (QWidget *w, qFindChildren<QWidget *>(&widget))
w->setStyle(style);
- widget.show();
+ widget.show();
QTest::qWait( 500 );
- QVERIFY(qAbs(spinbox.height() - lineedit.height()) <= 1);
- QVERIFY(qAbs(spinbox.height() - combo.height()) <= 1);
+ QVERIFY(qAbs(spinbox.height() - lineedit.height()) <= 1);
+ QVERIFY(qAbs(spinbox.height() - combo.height()) <= 1);
}
void tst_QStyle::defaultFont()