mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 18:32:55 +00:00
add QIcon benchmark
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
97bd327766
commit
9164995c91
5 changed files with 845 additions and 0 deletions
3
tests/benchmarks/gui/image/qicon/CMakeLists.txt
Normal file
3
tests/benchmarks/gui/image/qicon/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
katie_gui_test(tst_bench_qicon
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tst_qicon.cpp
|
||||
)
|
BIN
tests/benchmarks/gui/image/qicon/images/bench.kat
Normal file
BIN
tests/benchmarks/gui/image/qicon/images/bench.kat
Normal file
Binary file not shown.
BIN
tests/benchmarks/gui/image/qicon/images/bench.png
Normal file
BIN
tests/benchmarks/gui/image/qicon/images/bench.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
730
tests/benchmarks/gui/image/qicon/images/bench.svg
Normal file
730
tests/benchmarks/gui/image/qicon/images/bench.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 94 KiB |
112
tests/benchmarks/gui/image/qicon/tst_qicon.cpp
Normal file
112
tests/benchmarks/gui/image/qicon/tst_qicon.cpp
Normal file
|
@ -0,0 +1,112 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2023 Ivailo Monev
|
||||
**
|
||||
** This file is part of the test suite of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qtest.h>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
#include <QImageReader>
|
||||
|
||||
//TESTED_FILES=
|
||||
|
||||
class tst_QIcon : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
tst_QIcon();
|
||||
virtual ~tst_QIcon();
|
||||
|
||||
private slots:
|
||||
void iconPixmap_data();
|
||||
void iconPixmap();
|
||||
|
||||
void iconFromTheme_data();
|
||||
void iconFromTheme();
|
||||
|
||||
private:
|
||||
QList< QPair<QString, QByteArray> > images; // filename, format
|
||||
};
|
||||
|
||||
tst_QIcon::tst_QIcon()
|
||||
{
|
||||
foreach (const QByteArray &format, QImageReader::supportedImageFormats()) {
|
||||
const QString benchfilepath = QLatin1String(SRCDIR "/images/bench.") + format;
|
||||
|
||||
if (QFile::exists(benchfilepath)) {
|
||||
images << QPair<QString, QByteArray>(benchfilepath, format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tst_QIcon::~tst_QIcon()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QIcon::iconPixmap_data()
|
||||
{
|
||||
QTest::addColumn<QString>("fileName");
|
||||
QTest::addColumn<QByteArray>("format");
|
||||
|
||||
for (int i = 0; i < images.size(); ++i) {
|
||||
const QString file = images[i].first;
|
||||
const QByteArray format = images[i].second;
|
||||
QTest::newRow(qPrintable(file)) << file << format;
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QIcon::iconPixmap()
|
||||
{
|
||||
QFETCH(QString, fileName);
|
||||
QFETCH(QByteArray, format);
|
||||
|
||||
const QSize iconSize = QSize(32, 32);
|
||||
QBENCHMARK {
|
||||
QIcon icon(fileName);
|
||||
QPixmap pixmap = icon.pixmap(iconSize);
|
||||
QVERIFY(!pixmap.isNull());
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QIcon::iconFromTheme_data()
|
||||
{
|
||||
QTest::addColumn<QString>("fileName");
|
||||
|
||||
QTest::newRow("folder") << QString::fromLatin1("folder");
|
||||
QTest::newRow("dialog-close") << QString::fromLatin1("dialog-close");
|
||||
QTest::newRow("user-home") << QString::fromLatin1("user-home");
|
||||
}
|
||||
|
||||
void tst_QIcon::iconFromTheme()
|
||||
{
|
||||
QFETCH(QString, fileName);
|
||||
|
||||
const QSize iconSize = QSize(32, 32);
|
||||
QBENCHMARK {
|
||||
QIcon icon = QIcon::fromTheme(fileName);
|
||||
QPixmap pixmap = icon.pixmap(iconSize);
|
||||
QVERIFY(!pixmap.isNull());
|
||||
}
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QIcon)
|
||||
|
||||
#include "moc_tst_qicon.cpp"
|
Loading…
Add table
Reference in a new issue