QFrame: add an autotest for visual appearance
Change-Id: I97c24902c9f8dfabd9ececbae868d42ea262653b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: David Faure <david.faure@kdab.com>
BIN
tests/auto/widgets/widgets/qframe/images/box_noshadow_0_0.png
Normal file
After Width: | Height: | Size: 103 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_noshadow_0_1.png
Normal file
After Width: | Height: | Size: 103 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_noshadow_0_2.png
Normal file
After Width: | Height: | Size: 103 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_noshadow_1_0.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_noshadow_1_1.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_noshadow_1_2.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_noshadow_2_0.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_noshadow_2_1.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_noshadow_2_2.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_plain_0_0.png
Normal file
After Width: | Height: | Size: 103 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_plain_0_1.png
Normal file
After Width: | Height: | Size: 103 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_plain_0_2.png
Normal file
After Width: | Height: | Size: 103 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_plain_1_0.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_plain_1_1.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_plain_1_2.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_plain_2_0.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_plain_2_1.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_plain_2_2.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_raised_0_0.png
Normal file
After Width: | Height: | Size: 103 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_raised_0_1.png
Normal file
After Width: | Height: | Size: 129 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_raised_0_2.png
Normal file
After Width: | Height: | Size: 126 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_raised_1_0.png
Normal file
After Width: | Height: | Size: 135 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_raised_1_1.png
Normal file
After Width: | Height: | Size: 158 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_raised_1_2.png
Normal file
After Width: | Height: | Size: 162 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_raised_2_0.png
Normal file
After Width: | Height: | Size: 148 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_raised_2_1.png
Normal file
After Width: | Height: | Size: 182 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_raised_2_2.png
Normal file
After Width: | Height: | Size: 182 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_sunken_0_0.png
Normal file
After Width: | Height: | Size: 103 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_sunken_0_1.png
Normal file
After Width: | Height: | Size: 129 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_sunken_0_2.png
Normal file
After Width: | Height: | Size: 126 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_sunken_1_0.png
Normal file
After Width: | Height: | Size: 138 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_sunken_1_1.png
Normal file
After Width: | Height: | Size: 159 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_sunken_1_2.png
Normal file
After Width: | Height: | Size: 163 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_sunken_2_0.png
Normal file
After Width: | Height: | Size: 148 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_sunken_2_1.png
Normal file
After Width: | Height: | Size: 182 B |
BIN
tests/auto/widgets/widgets/qframe/images/box_sunken_2_2.png
Normal file
After Width: | Height: | Size: 182 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_0.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_1.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_2.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_0.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_1.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_2.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_0.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_1.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_2.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.png
Normal file
After Width: | Height: | Size: 148 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.png
Normal file
After Width: | Height: | Size: 148 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.png
Normal file
After Width: | Height: | Size: 148 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.png
Normal file
After Width: | Height: | Size: 148 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.png
Normal file
After Width: | Height: | Size: 148 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.png
Normal file
After Width: | Height: | Size: 148 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.png
Normal file
After Width: | Height: | Size: 148 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.png
Normal file
After Width: | Height: | Size: 148 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.png
Normal file
After Width: | Height: | Size: 148 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.png
Normal file
After Width: | Height: | Size: 154 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.png
Normal file
After Width: | Height: | Size: 154 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.png
Normal file
After Width: | Height: | Size: 154 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.png
Normal file
After Width: | Height: | Size: 154 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.png
Normal file
After Width: | Height: | Size: 154 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.png
Normal file
After Width: | Height: | Size: 154 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.png
Normal file
After Width: | Height: | Size: 154 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.png
Normal file
After Width: | Height: | Size: 154 B |
BIN
tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.png
Normal file
After Width: | Height: | Size: 154 B |
@ -35,6 +35,9 @@
|
|||||||
#include <QTest>
|
#include <QTest>
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QStyleOptionFrame>
|
#include <QStyleOptionFrame>
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <QStyle>
|
||||||
|
#include <QStyleFactory>
|
||||||
|
|
||||||
class tst_QFrame : public QObject
|
class tst_QFrame : public QObject
|
||||||
{
|
{
|
||||||
@ -43,6 +46,8 @@ private slots:
|
|||||||
void testDefaults();
|
void testDefaults();
|
||||||
void testInitStyleOption_data();
|
void testInitStyleOption_data();
|
||||||
void testInitStyleOption();
|
void testInitStyleOption();
|
||||||
|
void testPainting_data();
|
||||||
|
void testPainting();
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QFrame::Shape)
|
Q_DECLARE_METATYPE(QFrame::Shape)
|
||||||
@ -58,13 +63,7 @@ void tst_QFrame::testDefaults()
|
|||||||
QCOMPARE(frame.frameStyle(), int(QFrame::Box));
|
QCOMPARE(frame.frameStyle(), int(QFrame::Box));
|
||||||
}
|
}
|
||||||
|
|
||||||
class Frame : public QFrame
|
static void provideFrameData()
|
||||||
{
|
|
||||||
public:
|
|
||||||
using QFrame::initStyleOption;
|
|
||||||
};
|
|
||||||
|
|
||||||
void tst_QFrame::testInitStyleOption_data()
|
|
||||||
{
|
{
|
||||||
QTest::addColumn<QString>("basename");
|
QTest::addColumn<QString>("basename");
|
||||||
QTest::addColumn<int>("lineWidth");
|
QTest::addColumn<int>("lineWidth");
|
||||||
@ -95,6 +94,17 @@ void tst_QFrame::testInitStyleOption_data()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Frame : public QFrame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using QFrame::initStyleOption;
|
||||||
|
};
|
||||||
|
|
||||||
|
void tst_QFrame::testInitStyleOption_data()
|
||||||
|
{
|
||||||
|
provideFrameData();
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QFrame::testInitStyleOption()
|
void tst_QFrame::testInitStyleOption()
|
||||||
{
|
{
|
||||||
QFETCH(QString, basename);
|
QFETCH(QString, basename);
|
||||||
@ -137,6 +147,39 @@ void tst_QFrame::testInitStyleOption()
|
|||||||
QVERIFY(styleOption.state & QStyle::State_Raised);
|
QVERIFY(styleOption.state & QStyle::State_Raised);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
Q_GUI_EXPORT QPalette qt_fusionPalette();
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
void tst_QFrame::testPainting_data()
|
||||||
|
{
|
||||||
|
provideFrameData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QFrame::testPainting()
|
||||||
|
{
|
||||||
|
QFETCH(QString, basename);
|
||||||
|
QFETCH(int, lineWidth);
|
||||||
|
QFETCH(int, midLineWidth);
|
||||||
|
QFETCH(QFrame::Shape, shape);
|
||||||
|
QFETCH(QFrame::Shadow, shadow);
|
||||||
|
|
||||||
|
QFrame frame;
|
||||||
|
frame.setStyle(QStyleFactory::create(QStringLiteral("fusion")));
|
||||||
|
frame.setPalette(qt_fusionPalette());
|
||||||
|
frame.setFrameStyle(shape | shadow);
|
||||||
|
frame.setLineWidth(lineWidth);
|
||||||
|
frame.setMidLineWidth(midLineWidth);
|
||||||
|
frame.resize(16, 16);
|
||||||
|
|
||||||
|
const QPixmap pixmap = frame.grab();
|
||||||
|
|
||||||
|
const QString referenceFilePath = QFINDTESTDATA(QStringLiteral("images/%1_%2_%3.png").arg(basename).arg(lineWidth).arg(midLineWidth));
|
||||||
|
const QPixmap referencePixmap(referenceFilePath);
|
||||||
|
QVERIFY2(!referencePixmap.isNull(), qPrintable(QStringLiteral("Could not load reference pixmap %1").arg(referenceFilePath)));
|
||||||
|
QCOMPARE(pixmap, referencePixmap);
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QFrame)
|
QTEST_MAIN(tst_QFrame)
|
||||||
|
|
||||||
#include "tst_qframe.moc"
|
#include "tst_qframe.moc"
|
||||||
|