Add unit test for loading QPixmaps and QImages into IconItem

REVIEW: 127269
This commit is contained in:
David Edmundson 2016-03-04 00:20:29 +00:00 committed by David Edmundson
parent 8c4f789b17
commit 531b7f3a95
2 changed files with 30 additions and 0 deletions

View File

@ -127,6 +127,33 @@ void IconItemTest::changeTheme(Plasma::Theme *theme, const QString &themeName)
} }
// ------ Tests // ------ Tests
void IconItemTest::loadPixmap()
{
QScopedPointer<QQuickItem> item(createIconItem());
QPixmap sourcePixmap(QFINDTESTDATA("data/test_image.png"));
item->setProperty("source", sourcePixmap);
QVERIFY(item->property("valid").toBool());
QImage capture = grabImage(item.data());
QCOMPARE(capture, sourcePixmap.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied));
}
//tests setting icon from a QImage
void IconItemTest::loadImage()
{
QScopedPointer<QQuickItem> item(createIconItem());
QImage sourceImage(QFINDTESTDATA("data/test_image.png"));
item->setProperty("source", sourceImage);
QVERIFY(item->property("valid").toBool());
QImage capture = grabImage(item.data());
QCOMPARE(capture, sourceImage.convertToFormat(QImage::Format_ARGB32_Premultiplied));
}
void IconItemTest::invalidIcon() void IconItemTest::invalidIcon()
{ {
QString name("tst-plasma-framework-invalid-icon-name"); QString name("tst-plasma-framework-invalid-icon-name");

View File

@ -37,6 +37,9 @@ private Q_SLOTS:
void initTestCase(); void initTestCase();
void cleanup(); void cleanup();
void loadPixmap();
void loadImage();
void invalidIcon(); void invalidIcon();
void usesPlasmaTheme(); void usesPlasmaTheme();
void animation(); void animation();