6.5.3 clean

This commit is contained in:
kleuter
2023-11-01 18:02:52 +01:00
parent bbe896803b
commit 7018d9e6c8
2170 changed files with 57471 additions and 43550 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -27,6 +27,8 @@ private slots:
void pngCompression();
void write_data();
void write();
void icoMask_data();
void icoMask();
private:
QString m_IconPath;
@ -319,6 +321,33 @@ void tst_QIcoImageFormat::write()
}
}
void tst_QIcoImageFormat::icoMask_data()
{
QTest::addColumn<QString>("inFile");
QTest::addColumn<QString>("outFile");
QTest::newRow("24bpp") << "masked/24bpp.ico" << "masked/24bpp.png";
QTest::newRow("32bpp") << "masked/32bpp.ico" << "masked/32bpp.png";
}
void tst_QIcoImageFormat::icoMask()
{
QFETCH(QString, inFile);
QFETCH(QString, outFile);
QImage inImage;
QImageReader inReader(m_IconPath + QLatin1Char('/') + inFile);
inReader.read(&inImage);
QImage outImage;
QImageReader outReader(m_IconPath + QLatin1Char('/') + outFile);
outReader.read(&outImage);
outImage.setColorSpace(inImage.colorSpace());
outImage = outImage.convertToFormat(inImage.format());
QCOMPARE(inImage, outImage);
}
QTEST_MAIN(tst_QIcoImageFormat)
#include "tst_qicoimageformat.moc"

View File

@ -56,6 +56,10 @@ set(tst_qicon_resource_files
"./icons/themeparent/index.theme"
"./icons/themeparent/scalable/actions/address-book-new.svg"
"./icons/themeparent/scalable/actions/appointment-new.svg"
"./icons/fallbacktheme/index.theme"
"./icons/fallbacktheme/16x16/edit-cut.png"
"./icons/hicolor/index.theme"
"./icons/hicolor/16x16/hicolor-icon.png"
"./second_icons/testtheme/32x32/actions/appointment-new.png"
"./styles/commonstyle/images/standardbutton-open-128.png"
"./styles/commonstyle/images/standardbutton-open-16.png"

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B

View File

@ -0,0 +1,8 @@
[Icon Theme]
Name=fallbacktheme
Directories=16x16
[16x16]
Size=16
Type=Fixed

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B

View File

@ -0,0 +1,11 @@
[Icon Theme]
Name=hicolor
# Provide a minimal hicolor theme, so that our hicolor fallback
# lookup during testing will find that theme on all systems.
Directories=16x16
[16x16]
Size=16
Type=Fixed

View File

@ -1,7 +1,7 @@
[Icon Theme]
_Name=Test
_Comment=Test Theme
Inherits=crystalsvg, themeparent
Inherits=themeparent
Example=x-directory-normal
# KDE Specific Stuff

View File

@ -1,7 +1,6 @@
[Icon Theme]
_Name=Test
_Comment=Test Theme
Inherits=gnome,crystalsvg
Example=x-directory-normal
# KDE Specific Stuff

View File

@ -717,14 +717,38 @@ void tst_QIcon::fromTheme()
QCOMPARE(i.availableSizes(), abIcon.availableSizes());
}
// Check that setting a fallback theme invalidates earlier lookups
QVERIFY(QIcon::fromTheme("edit-cut").isNull());
QIcon::setFallbackThemeName("fallbacktheme");
QVERIFY(!QIcon::fromTheme("edit-cut").isNull());
// Make sure setting the theme name clears the state
QIcon::setThemeName("");
abIcon = QIcon::fromTheme("address-book-new");
QVERIFY(abIcon.isNull());
// Test fallback icon behavior for empty theme names.
// Can only reliably test this on systems that don't have a
// named system icon theme.
QIcon::setThemeName(""); // Reset user-theme
if (QIcon::themeName().isEmpty()) {
// Test icon from fallback theme even when theme name is empty
QIcon::setFallbackThemeName("fallbacktheme");
QVERIFY(!QIcon::fromTheme("edit-cut").isNull());
// Test icon from fallback path even when theme name is empty
fallbackIcon = QIcon::fromTheme("red");
QVERIFY(!fallbackIcon.isNull());
QVERIFY(QIcon::hasThemeIcon("red"));
QCOMPARE(fallbackIcon.availableSizes().size(), 1);
}
// Passing a full path to fromTheme is not very useful, but should work anyway
QIcon fullPathIcon = QIcon::fromTheme(m_pngImageFileName);
QVERIFY(!fullPathIcon.isNull());
// Restore to system fallback theme
QIcon::setFallbackThemeName("");
}
static inline QString findGtkUpdateIconCache()

View File

@ -1133,10 +1133,9 @@ void tst_QImage::rotate_data()
QTest::addColumn<QImage::Format>("format");
QTest::addColumn<int>("degrees");
QList<int> degrees;
degrees << 0 << 90 << 180 << 270;
constexpr int degrees[] = {0, 90, 180, 270};
foreach (int d, degrees) {
for (int d : degrees) {
const QString dB = QString::number(d);
for (int i = QImage::Format_Indexed8; i < QImage::NImageFormats; i++) {
QImage::Format format = static_cast<QImage::Format>(i);

View File

@ -11,7 +11,7 @@
#include <QImageReader>
#include <QImageWriter>
#include <QPixmap>
#include <QSet>
#include <QScopeGuard>
#include <QTcpSocket>
#include <QTcpServer>
#include <QTimer>
@ -594,41 +594,31 @@ void tst_QImageReader::multiWordNamedColorXPM()
QCOMPARE(image.pixel(0, 2), qRgb(255, 250, 205)); // lemon chiffon
}
namespace {
template <typename ForwardIterator>
bool is_sorted_unique(ForwardIterator first, ForwardIterator last)
{
// a range is sorted with no dups iff each *i < *(i+1), so check that none are >=:
return std::adjacent_find(first, last, std::greater_equal<>{}) == last;
}
}
void tst_QImageReader::supportedFormats()
{
QList<QByteArray> formats = QImageReader::supportedImageFormats();
QList<QByteArray> sortedFormats = formats;
std::sort(sortedFormats.begin(), sortedFormats.end());
// check that the list is sorted
QCOMPARE(formats, sortedFormats);
QSet<QByteArray> formatSet;
foreach (QByteArray format, formats)
formatSet << format;
// check that the list does not contain duplicates
QCOMPARE(formatSet.size(), formats.size());
const QList<QByteArray> formats = QImageReader::supportedImageFormats();
auto printOnFailure = qScopeGuard([&] { qDebug() << formats; });
QVERIFY(is_sorted_unique(formats.begin(), formats.end()));
printOnFailure.dismiss();
}
void tst_QImageReader::supportedMimeTypes()
{
QList<QByteArray> mimeTypes = QImageReader::supportedMimeTypes();
QList<QByteArray> sortedMimeTypes = mimeTypes;
std::sort(sortedMimeTypes.begin(), sortedMimeTypes.end());
// check that the list is sorted
QCOMPARE(mimeTypes, sortedMimeTypes);
QSet<QByteArray> mimeTypeSet;
foreach (QByteArray mimeType, mimeTypes)
mimeTypeSet << mimeType;
const QList<QByteArray> mimeTypes = QImageReader::supportedMimeTypes();
auto printOnFailure = qScopeGuard([&] { qDebug() << mimeTypes; });
QVERIFY(is_sorted_unique(mimeTypes.begin(), mimeTypes.end()));
// check the list as a minimum contains image/bmp
QVERIFY(mimeTypeSet.contains("image/bmp"));
// check that the list does not contain duplicates
QCOMPARE(mimeTypeSet.size(), mimeTypes.size());
QVERIFY(mimeTypes.contains("image/bmp"));
printOnFailure.dismiss();
}
void tst_QImageReader::setBackgroundColor_data()
@ -1623,43 +1613,56 @@ void tst_QImageReader::supportsOption_data()
QTest::addColumn<QIntList>("options");
QTest::newRow("png") << QString("black.png")
<< (QIntList() << QImageIOHandler::Gamma
<< QImageIOHandler::Description
<< QImageIOHandler::Quality
<< QImageIOHandler::CompressionRatio
<< QImageIOHandler::Size
<< QImageIOHandler::ScaledSize);
<< QIntList{
QImageIOHandler::Gamma,
QImageIOHandler::Description,
QImageIOHandler::Quality,
QImageIOHandler::CompressionRatio,
QImageIOHandler::Size,
QImageIOHandler::ScaledSize,
QImageIOHandler::ImageFormat,
};
}
void tst_QImageReader::supportsOption()
{
QFETCH(QString, fileName);
QFETCH(QIntList, options);
QSet<QImageIOHandler::ImageOption> allOptions;
allOptions << QImageIOHandler::Size
<< QImageIOHandler::ClipRect
<< QImageIOHandler::Description
<< QImageIOHandler::ScaledClipRect
<< QImageIOHandler::ScaledSize
<< QImageIOHandler::CompressionRatio
<< QImageIOHandler::Gamma
<< QImageIOHandler::Quality
<< QImageIOHandler::Name
<< QImageIOHandler::SubType
<< QImageIOHandler::IncrementalReading
<< QImageIOHandler::Endianness
<< QImageIOHandler::Animation
<< QImageIOHandler::BackgroundColor;
QFETCH(const QIntList, options);
QImageReader reader(prefix + fileName);
for (int i = 0; i < options.size(); ++i) {
QVERIFY(reader.supportsOption(QImageIOHandler::ImageOption(options.at(i))));
allOptions.remove(QImageIOHandler::ImageOption(options.at(i)));
}
foreach (QImageIOHandler::ImageOption option, allOptions)
QVERIFY(!reader.supportsOption(option));
for (int i = 0; ; ++i) {
// this switch ensures the compiler warns when we miss an enumerator [-Wswitch]
// do _not_ add a default case!
switch (const auto o = QImageIOHandler::ImageOption(i)) {
case QImageIOHandler::Size:
case QImageIOHandler::ClipRect:
case QImageIOHandler::Description:
case QImageIOHandler::ScaledClipRect:
case QImageIOHandler::ScaledSize:
case QImageIOHandler::CompressionRatio:
case QImageIOHandler::Gamma:
case QImageIOHandler::Quality:
case QImageIOHandler::Name:
case QImageIOHandler::SubType:
case QImageIOHandler::IncrementalReading:
case QImageIOHandler::Endianness:
case QImageIOHandler::Animation:
case QImageIOHandler::BackgroundColor:
case QImageIOHandler::ImageFormat:
case QImageIOHandler::SupportedSubTypes:
case QImageIOHandler::OptimizedWrite:
case QImageIOHandler::ProgressiveScanWrite:
case QImageIOHandler::ImageTransformation:
{
auto printOnFailure = qScopeGuard([&] { qDebug("failed at %d", i); });
QCOMPARE(reader.supportsOption(o), options.contains(i));
printOnFailure.dismiss();
continue; // ... as long as `i` represents a valid ImageOption value
}
}
break; // ... once `i` no longer represents a valid ImageOption value
}
}
void tst_QImageReader::autoDetectImageFormat()

View File

@ -16,6 +16,7 @@ qt_internal_add_test(tst_qmovie
tst_qmovie.cpp
LIBRARIES
Qt::Gui
Qt::TestPrivate
TESTDATA ${test_data}
)

View File

@ -5,6 +5,7 @@
#include <QTest>
#include <QTestEventLoop>
#include <QSignalSpy>
#include <QtTest/private/qpropertytesthelper_p.h>
#include <QIODevice>
#ifndef QT_NO_WIDGETS
@ -41,6 +42,7 @@ private slots:
#endif
void emptyMovie();
void bindings();
void automatedBindings();
};
// Testing get/set functions
@ -239,5 +241,23 @@ void tst_QMovie::bindings()
QCOMPARE(cacheModeObserver, QMovie::CacheAll);
}
void tst_QMovie::automatedBindings()
{
QMovie movie;
QTestPrivate::testReadWritePropertyBasics(movie, 50, 100, "speed");
if (QTest::currentTestFailed()) {
qDebug("Failed property test for QMovie::speed");
return;
}
QTestPrivate::testReadWritePropertyBasics(movie, QMovie::CacheAll, QMovie::CacheNone,
"cacheMode");
if (QTest::currentTestFailed()) {
qDebug("Failed property test for QMovie::cacheMode");
return;
}
}
QTEST_MAIN(tst_QMovie)
#include "tst_qmovie.moc"

View File

@ -7,12 +7,16 @@
#include <qpixmapcache.h>
#include "private/qpixmapcache_p.h"
#include <functional>
QT_BEGIN_NAMESPACE // The test requires QT_BUILD_INTERNAL
Q_AUTOTEST_EXPORT void qt_qpixmapcache_flush_detached_pixmaps();
Q_AUTOTEST_EXPORT int qt_qpixmapcache_qpixmapcache_total_used();
Q_AUTOTEST_EXPORT int q_QPixmapCache_keyHashSize();
QT_END_NAMESPACE
using namespace Qt::StringLiterals;
class tst_QPixmapCache : public QObject
{
Q_OBJECT
@ -29,13 +33,20 @@ private slots:
void setCacheLimit();
void find();
void insert();
void failedInsertReturnsInvalidKey();
void replace();
void remove();
void clear();
void pixmapKey();
void noLeak();
void clearDoesNotLeakStringKeys();
void evictionDoesNotLeakStringKeys();
void reducingCacheLimitDoesNotLeakStringKeys();
void strictCacheLimit();
void noCrashOnLargeInsert();
private:
void stringLeak_impl(std::function<void()> whenOp);
};
static QPixmapCache::KeyData* getPrivate(QPixmapCache::Key &key)
@ -102,16 +113,16 @@ void tst_QPixmapCache::setCacheLimit()
//The int part of the API
p1 = new QPixmap(2, 3);
QPixmapCache::Key key = QPixmapCache::insert(*p1);
QVERIFY(QPixmapCache::find(key, p1) != 0);
QVERIFY(QPixmapCache::find(key, p1));
delete p1;
QPixmapCache::setCacheLimit(0);
QVERIFY(QPixmapCache::find(key, p1) == 0);
QVERIFY(!QPixmapCache::find(key, p1));
p1 = new QPixmap(2, 3);
QPixmapCache::setCacheLimit(1000);
QPixmapCache::replace(key, *p1);
QVERIFY(QPixmapCache::find(key, p1) == 0);
p1 = new QPixmap(2, 3);
QVERIFY(!QPixmapCache::replace(key, *p1));
QVERIFY(!QPixmapCache::find(key, p1));
delete p1;
@ -120,10 +131,10 @@ void tst_QPixmapCache::setCacheLimit()
QPixmapCache::clear();
p1 = new QPixmap(2, 3);
key = QPixmapCache::insert(*p1);
QVERIFY(QPixmapCache::find(key, p1) != 0);
QVERIFY(QPixmapCache::find(key, p1));
p1->detach(); // dectach so that the cache thinks no-one is using it.
QPixmapCache::setCacheLimit(0);
QVERIFY(QPixmapCache::find(key, p1) == 0);
QVERIFY(!QPixmapCache::find(key, p1));
QPixmapCache::setCacheLimit(1000);
key = QPixmapCache::insert(*p1);
QVERIFY(key.isValid());
@ -137,7 +148,7 @@ void tst_QPixmapCache::setCacheLimit()
QPixmap p2;
p1 = new QPixmap(2, 3);
key = QPixmapCache::insert(*p1);
QVERIFY(QPixmapCache::find(key, &p2) != 0);
QVERIFY(QPixmapCache::find(key, &p2));
//we flush the cache
p1->detach();
p2.detach();
@ -145,8 +156,8 @@ void tst_QPixmapCache::setCacheLimit()
QPixmapCache::setCacheLimit(1000);
QPixmapCache::Key key2 = QPixmapCache::insert(*p1);
QCOMPARE(getPrivate(key2)->key, 1);
QVERIFY(QPixmapCache::find(key, &p2) == 0);
QVERIFY(QPixmapCache::find(key2, &p2) != 0);
QVERIFY(!QPixmapCache::find(key, &p2));
QVERIFY(QPixmapCache::find(key2, &p2));
QCOMPARE(p2, *p1);
delete p1;
@ -169,7 +180,7 @@ void tst_QPixmapCache::setCacheLimit()
QCOMPARE(getPrivate(key2)->key, 1);
//This old key is not valid anymore after the flush
QVERIFY(!key.isValid());
QVERIFY(QPixmapCache::find(key, &p2) == 0);
QVERIFY(!QPixmapCache::find(key, &p2));
delete p1;
}
@ -207,7 +218,7 @@ void tst_QPixmapCache::find()
QPixmapCache::insert(p5);
//at that time the first key has been erase because no more place in the cache
QVERIFY(QPixmapCache::find(key, &p1) == 0);
QVERIFY(!QPixmapCache::find(key, &p1));
QVERIFY(!key.isValid());
}
@ -266,6 +277,7 @@ void tst_QPixmapCache::insert()
for (int i = 0; i < numberOfKeys; ++i) {
QPixmap p3(10,10);
keys.append(QPixmapCache::insert(p3));
QVERIFY(keys.back().isValid());
}
num = 0;
@ -279,6 +291,32 @@ void tst_QPixmapCache::insert()
QVERIFY(num <= estimatedNum);
}
void tst_QPixmapCache::failedInsertReturnsInvalidKey()
{
//
// GIVEN: a pixmap whose memory footprint exceeds the cache's limit:
//
QPixmapCache::setCacheLimit(20);
QPixmap pm(256, 256);
pm.fill(Qt::transparent);
QCOMPARE_GT(pm.width() * pm.height() * pm.depth() / 8,
QPixmapCache::cacheLimit() * 1024);
//
// WHEN: trying to add this pixmap to the cache
//
const auto success = QPixmapCache::insert(u"foo"_s, pm); // QString API
{ QPixmap r; QVERIFY(!QPixmapCache::find(u"foo"_s, &r)); }
const auto key = QPixmapCache::insert(pm); // "int" API
//
// THEN: failure is reported to the user
//
QVERIFY(!key.isValid()); // "int" API
QVERIFY(!success); // QString API
}
void tst_QPixmapCache::replace()
{
//The int part of the API
@ -340,11 +378,11 @@ void tst_QPixmapCache::remove()
QVERIFY(p1.toImage() == p1.toImage()); // sanity check
QPixmapCache::remove(key);
QVERIFY(QPixmapCache::find(key, &p1) == 0);
QVERIFY(!QPixmapCache::find(key, &p1));
//Broken key
QPixmapCache::remove(QPixmapCache::Key());
QVERIFY(QPixmapCache::find(QPixmapCache::Key(), &p1) == 0);
QVERIFY(!QPixmapCache::find(QPixmapCache::Key(), &p1));
//Test if keys are release
QPixmapCache::clear();
@ -358,7 +396,7 @@ void tst_QPixmapCache::remove()
QPixmapCache::clear();
key = QPixmapCache::insert(p1);
QCOMPARE(getPrivate(key)->key, 1);
QVERIFY(QPixmapCache::find(key, &p1) != 0);
QVERIFY(QPixmapCache::find(key, &p1));
QPixmapCache::remove(key);
QCOMPARE(p1.isDetached(), true);
@ -368,8 +406,8 @@ void tst_QPixmapCache::remove()
QPixmapCache::insert("red", p1);
key = QPixmapCache::insert(p1);
QPixmapCache::remove(key);
QVERIFY(QPixmapCache::find(key, &p1) == 0);
QVERIFY(QPixmapCache::find("red", &p1) != 0);
QVERIFY(!QPixmapCache::find(key, &p1));
QVERIFY(QPixmapCache::find("red", &p1));
}
void tst_QPixmapCache::clear()
@ -413,7 +451,7 @@ void tst_QPixmapCache::clear()
QPixmapCache::clear();
for (int k = 0; k < numberOfKeys; ++k) {
QVERIFY(QPixmapCache::find(keys.at(k), &p1) == 0);
QVERIFY(!QPixmapCache::find(keys.at(k), &p1));
QVERIFY(!keys[k].isValid());
}
}
@ -478,6 +516,68 @@ void tst_QPixmapCache::noLeak()
QCOMPARE(oldSize, newSize);
}
void tst_QPixmapCache::clearDoesNotLeakStringKeys()
{
stringLeak_impl([] { QPixmapCache::clear(); });
}
void tst_QPixmapCache::evictionDoesNotLeakStringKeys()
{
stringLeak_impl([] {
// fill the cache with other pixmaps to force eviction of "our" pixmap:
constexpr int Iterations = 10;
for (int i = 0; i < Iterations; ++i) {
QPixmap pm(64, 64);
pm.fill(Qt::transparent);
[[maybe_unused]] auto r = QPixmapCache::insert(pm);
}
});
}
void tst_QPixmapCache::reducingCacheLimitDoesNotLeakStringKeys()
{
stringLeak_impl([] {
QPixmapCache::setCacheLimit(0);
});
}
void tst_QPixmapCache::stringLeak_impl(std::function<void()> whenOp)
{
QVERIFY(whenOp);
QPixmapCache::setCacheLimit(20); // 20KiB
//
// GIVEN: a QPixmap with QString key `key` in QPixmapCache
//
QString key;
{
QPixmap pm(64, 64);
QCOMPARE_LT(pm.width() * pm.height() * std::ceil(pm.depth() / 8.0),
QPixmapCache::cacheLimit() * 1024);
pm.fill(Qt::transparent);
key = u"theKey"_s.repeated(20); // avoid eventual QString SSO
QVERIFY(key.isDetached());
QPixmapCache::insert(key, pm);
}
QVERIFY(!key.isDetached()); // was saved inside QPixmapCache
//
// WHEN: performing the given operation
//
whenOp();
if (QTest::currentTestFailed())
return;
//
// THEN: `key` is no longer referenced by QPixmapCache:
//
QVERIFY(key.isDetached());
// verify that the pixmap is really gone from the cache
// (do it after the key check, because QPixmapCache cleans up `key` on a failed lookup)
QPixmap r;
QVERIFY(!QPixmapCache::find(key, &r));
}
void tst_QPixmapCache::strictCacheLimit()
{