mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-04 08:15:30 +08:00
6.5.3 clean
This commit is contained in:
BIN
tests/auto/gui/image/qicoimageformat/icons/masked/24bpp.ico
Normal file
BIN
tests/auto/gui/image/qicoimageformat/icons/masked/24bpp.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
BIN
tests/auto/gui/image/qicoimageformat/icons/masked/24bpp.png
Normal file
BIN
tests/auto/gui/image/qicoimageformat/icons/masked/24bpp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
BIN
tests/auto/gui/image/qicoimageformat/icons/masked/32bpp.ico
Normal file
BIN
tests/auto/gui/image/qicoimageformat/icons/masked/32bpp.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
tests/auto/gui/image/qicoimageformat/icons/masked/32bpp.png
Normal file
BIN
tests/auto/gui/image/qicoimageformat/icons/masked/32bpp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
@ -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"
|
||||
|
||||
|
@ -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 |
@ -0,0 +1,8 @@
|
||||
[Icon Theme]
|
||||
Name=fallbacktheme
|
||||
|
||||
Directories=16x16
|
||||
|
||||
[16x16]
|
||||
Size=16
|
||||
Type=Fixed
|
BIN
tests/auto/gui/image/qicon/icons/hicolor/16x16/hicolor-icon.png
Normal file
BIN
tests/auto/gui/image/qicon/icons/hicolor/16x16/hicolor-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 267 B |
11
tests/auto/gui/image/qicon/icons/hicolor/index.theme
Normal file
11
tests/auto/gui/image/qicon/icons/hicolor/index.theme
Normal 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
|
@ -1,7 +1,7 @@
|
||||
[Icon Theme]
|
||||
_Name=Test
|
||||
_Comment=Test Theme
|
||||
Inherits=crystalsvg, themeparent
|
||||
Inherits=themeparent
|
||||
Example=x-directory-normal
|
||||
|
||||
# KDE Specific Stuff
|
||||
|
@ -1,7 +1,6 @@
|
||||
[Icon Theme]
|
||||
_Name=Test
|
||||
_Comment=Test Theme
|
||||
Inherits=gnome,crystalsvg
|
||||
Example=x-directory-normal
|
||||
|
||||
# KDE Specific Stuff
|
||||
|
@ -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()
|
||||
|
@ -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);
|
||||
|
@ -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()
|
||||
|
@ -16,6 +16,7 @@ qt_internal_add_test(tst_qmovie
|
||||
tst_qmovie.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::TestPrivate
|
||||
TESTDATA ${test_data}
|
||||
)
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -1028,11 +1028,12 @@ void tst_QFileSystemModel::drives()
|
||||
QFileSystemModel model;
|
||||
model.setRootPath(path);
|
||||
model.fetchMore(QModelIndex());
|
||||
QFileInfoList drives = QDir::drives();
|
||||
const QFileInfoList drives = QDir::drives();
|
||||
int driveCount = 0;
|
||||
foreach(const QFileInfo& driveRoot, drives)
|
||||
for (const QFileInfo& driveRoot : drives) {
|
||||
if (driveRoot.exists())
|
||||
driveCount++;
|
||||
}
|
||||
QTRY_COMPARE(model.rowCount(), driveCount);
|
||||
}
|
||||
|
||||
|
@ -14,4 +14,5 @@ qt_internal_add_test(tst_qstandarditemmodel
|
||||
Qt::GuiPrivate
|
||||
Qt::Widgets
|
||||
Qt::WidgetsPrivate
|
||||
Qt::TestPrivate
|
||||
)
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <QAbstractItemModelTester>
|
||||
|
||||
#include <private/qabstractitemmodel_p.h>
|
||||
#include <private/qpropertytesthelper_p.h>
|
||||
#include <private/qtreeview_p.h>
|
||||
|
||||
#include <algorithm>
|
||||
@ -902,6 +903,9 @@ void tst_QStandardItemModel::sortRoleBindings()
|
||||
sortRoleObserver.setBinding([&] { return model.sortRole(); });
|
||||
model.setSortRole(Qt::EditRole);
|
||||
QCOMPARE(sortRoleObserver, Qt::EditRole);
|
||||
|
||||
QTestPrivate::testReadWritePropertyBasics(model, static_cast<int>(Qt::DisplayRole),
|
||||
static_cast<int>(Qt::EditRole), "sortRole");
|
||||
}
|
||||
|
||||
void tst_QStandardItemModel::findItems()
|
||||
|
@ -29,7 +29,7 @@ endif()
|
||||
add_subdirectory(qpixelformat)
|
||||
add_subdirectory(qrasterwindow)
|
||||
add_subdirectory(qaddpostroutine)
|
||||
if(NOT ANDROID AND NOT UIKIT)
|
||||
if(NOT UIKIT)
|
||||
add_subdirectory(qclipboard)
|
||||
endif()
|
||||
if(TARGET Qt::Network)
|
||||
|
5
tests/auto/gui/kernel/qclipboard/test/BLACKLIST
Normal file
5
tests/auto/gui/kernel/qclipboard/test/BLACKLIST
Normal file
@ -0,0 +1,5 @@
|
||||
# QTBUG-87429
|
||||
[testSignals]
|
||||
android
|
||||
[setMimeData]
|
||||
android
|
@ -41,6 +41,7 @@ private slots:
|
||||
void testSignals();
|
||||
void setMimeData();
|
||||
void clearBeforeSetText();
|
||||
void getTextFromHTMLMimeType();
|
||||
# ifdef Q_OS_WIN
|
||||
void testWindowsMimeRegisterType();
|
||||
void testWindowsMime_data();
|
||||
@ -61,7 +62,7 @@ void tst_QClipboard::initTestCase()
|
||||
#if QT_CONFIG(clipboard)
|
||||
void tst_QClipboard::init()
|
||||
{
|
||||
#if QT_CONFIG(process)
|
||||
#if QT_CONFIG(process) && !defined(Q_OS_ANDROID)
|
||||
const QString testdataDir = QFileInfo(QFINDTESTDATA("copier")).absolutePath();
|
||||
QVERIFY2(QDir::setCurrent(testdataDir), qPrintable("Could not chdir to " + testdataDir));
|
||||
#endif
|
||||
@ -424,6 +425,24 @@ void tst_QClipboard::clearBeforeSetText()
|
||||
QCOMPARE(QGuiApplication::clipboard()->text(), text);
|
||||
}
|
||||
|
||||
void tst_QClipboard::getTextFromHTMLMimeType()
|
||||
{
|
||||
QClipboard * clipboard = QGuiApplication::clipboard();
|
||||
QMimeData * mimeData = new QMimeData();
|
||||
const QString testString("TEST");
|
||||
const QString htmlString(QLatin1String("<html><body>") + testString + QLatin1String("</body></html>"));
|
||||
|
||||
mimeData->setText(testString);
|
||||
mimeData->setHtml(htmlString);
|
||||
clipboard->setMimeData(mimeData);
|
||||
|
||||
QCOMPARE(clipboard->text(), testString);
|
||||
QVERIFY(clipboard->mimeData()->hasText());
|
||||
QVERIFY(clipboard->mimeData()->hasHtml());
|
||||
QCOMPARE(clipboard->mimeData()->text(), testString);
|
||||
QCOMPARE(clipboard->mimeData()->html(), htmlString);
|
||||
}
|
||||
|
||||
# ifdef Q_OS_WIN
|
||||
|
||||
using QWindowsMimeConverter = QWindowsMimeConverter;
|
||||
|
@ -122,8 +122,8 @@ void tst_QGuiApplication::desktopFileName()
|
||||
|
||||
QCOMPARE(QGuiApplication::desktopFileName(), QString());
|
||||
|
||||
QGuiApplication::setDesktopFileName("io.qt.QGuiApplication.desktop");
|
||||
QCOMPARE(QGuiApplication::desktopFileName(), QString::fromLatin1("io.qt.QGuiApplication.desktop"));
|
||||
QGuiApplication::setDesktopFileName("io.qt.QGuiApplication");
|
||||
QCOMPARE(QGuiApplication::desktopFileName(), QString::fromLatin1("io.qt.QGuiApplication"));
|
||||
|
||||
QGuiApplication::setDesktopFileName(QString());
|
||||
QCOMPARE(QGuiApplication::desktopFileName(), QString());
|
||||
|
@ -11,4 +11,5 @@ qt_internal_add_test(tst_qguitimer
|
||||
LIBRARIES
|
||||
Qt::CorePrivate
|
||||
Qt::Gui
|
||||
Qt::TestPrivate
|
||||
)
|
||||
|
@ -1576,6 +1576,13 @@ void tst_QWindow::sizes()
|
||||
window.resize(80, 80);
|
||||
window.setMaximumSize(QSize(70, 70));
|
||||
QCOMPARE(window.size(), QSize(70, 70));
|
||||
|
||||
// QTBUG-113233
|
||||
// test for an invalid min/max pair
|
||||
window.setMinimumSize(QSize(80, 80)); // current maximumSize = QSize(70, 70)
|
||||
QCOMPARE(window.size(), QSize(70, 70));
|
||||
window.setMaximumSize(QSize(90, 90));
|
||||
QCOMPARE(window.size(), QSize(80, 80));
|
||||
}
|
||||
|
||||
class CloseOnCloseEventWindow : public QWindow
|
||||
|
@ -5235,12 +5235,33 @@ void tst_QRhi::leakedResourceDestroy()
|
||||
rt->setRenderPassDescriptor(rpDesc.data());
|
||||
QVERIFY(rt->create());
|
||||
|
||||
QRhiRenderBuffer *rb = rhi->newRenderBuffer(QRhiRenderBuffer::DepthStencil, QSize(512, 512));
|
||||
QVERIFY(rb->create());
|
||||
|
||||
QRhiShaderResourceBindings *srb = rhi->newShaderResourceBindings();
|
||||
QVERIFY(srb->create());
|
||||
|
||||
if (impl == QRhi::Vulkan)
|
||||
qDebug("Vulkan validation layer warnings may be printed below - this is expected");
|
||||
|
||||
qDebug("QRhi resource leak check warnings may be printed below - this is expected");
|
||||
|
||||
// make the QRhi go away early
|
||||
rhi.reset();
|
||||
|
||||
// let the scoped ptr do its job with the resources
|
||||
// see if the internal rhi backpointer got nulled out
|
||||
QVERIFY(buffer->rhi() == nullptr);
|
||||
QVERIFY(texture->rhi() == nullptr);
|
||||
QVERIFY(rt->rhi() == nullptr);
|
||||
QVERIFY(rpDesc->rhi() == nullptr);
|
||||
QVERIFY(rb->rhi() == nullptr);
|
||||
QVERIFY(srb->rhi() == nullptr);
|
||||
|
||||
// test out deleteLater on some of the resources
|
||||
rb->deleteLater();
|
||||
srb->deleteLater();
|
||||
|
||||
// let the scoped ptr do its job with the rest
|
||||
}
|
||||
|
||||
void tst_QRhi::renderToFloatTexture_data()
|
||||
|
@ -319,8 +319,8 @@ void tst_QFontDatabase::fallbackFonts()
|
||||
layout.createLine();
|
||||
layout.endLayout();
|
||||
|
||||
QList<QGlyphRun> runs = layout.glyphRuns(0, 1);
|
||||
foreach (QGlyphRun run, runs) {
|
||||
const QList<QGlyphRun> runs = layout.glyphRuns(0, 1);
|
||||
for (QGlyphRun run : runs) {
|
||||
QRawFont rawFont = run.rawFont();
|
||||
QVERIFY(rawFont.isValid());
|
||||
|
||||
|
@ -490,7 +490,7 @@ void tst_QRawFont::supportedWritingSystems_data()
|
||||
void tst_QRawFont::supportedWritingSystems()
|
||||
{
|
||||
QFETCH(QString, fileName);
|
||||
QFETCH(WritingSystemList, writingSystems);
|
||||
QFETCH(const WritingSystemList, writingSystems);
|
||||
QFETCH(QFont::HintingPreference, hintingPreference);
|
||||
|
||||
QRawFont font(fileName, 10, hintingPreference);
|
||||
@ -499,7 +499,7 @@ void tst_QRawFont::supportedWritingSystems()
|
||||
WritingSystemList actualWritingSystems = font.supportedWritingSystems();
|
||||
QCOMPARE(actualWritingSystems.size(), writingSystems.size());
|
||||
|
||||
foreach (QFontDatabase::WritingSystem writingSystem, writingSystems)
|
||||
for (QFontDatabase::WritingSystem writingSystem : writingSystems)
|
||||
QVERIFY(actualWritingSystems.contains(writingSystem));
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ qt_internal_add_test(tst_qstatictext
|
||||
## Scopes:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_extend_target(tst_qstatictext CONDITION QT_FEATURE_private_tests
|
||||
qt_internal_extend_target(tst_qstatictext CONDITION QT_FEATURE_developer_build
|
||||
LIBRARIES
|
||||
Qt::CorePrivate
|
||||
Qt::GuiPrivate
|
||||
|
@ -1097,11 +1097,12 @@ void tst_QTextScriptEngine::combiningMarks_qtbug15675_data()
|
||||
|
||||
bool hasTests = false;
|
||||
|
||||
QStringList families;
|
||||
families << QStringLiteral("Monaco");
|
||||
families << QStringLiteral("DejaVu Sans Mono");
|
||||
const QString families[] = {
|
||||
QStringLiteral("Monaco"),
|
||||
QStringLiteral("DejaVu Sans Mono"),
|
||||
};
|
||||
|
||||
foreach (const QString &family, families) {
|
||||
for (const QString &family : families) {
|
||||
QFont font(family);
|
||||
font.setStyleStrategy(QFont::NoFontMerging);
|
||||
if (QFontInfo(font).family() != family)
|
||||
|
@ -417,7 +417,7 @@ void tst_QDoubleValidator::fixup_data()
|
||||
QTest::newRow("C standard with invalid digit grouping")
|
||||
<< "C" << QDoubleValidator::StandardNotation << -1 << "1,234,5.678"
|
||||
<< "12345.678";
|
||||
QTest::newRow("C standard with invalid number of decimals")
|
||||
QTest::newRow("C standard with invalid group size")
|
||||
<< "C" << QDoubleValidator::StandardNotation << 2 << "-12,34.678"
|
||||
<< "-1234.68";
|
||||
QTest::newRow("C standard truncate decimals")
|
||||
@ -446,7 +446,7 @@ void tst_QDoubleValidator::fixup_data()
|
||||
QTest::newRow("C scientific with invalid digit grouping")
|
||||
<< "C" << QDoubleValidator::ScientificNotation << -1 << "12,34.98765e2"
|
||||
<< "1.23498765e+05";
|
||||
QTest::newRow("C scientific with invalid number of decimals")
|
||||
QTest::newRow("C scientific with invalid group size")
|
||||
<< "C" << QDoubleValidator::ScientificNotation << 2 << "-12,34.98765e2"
|
||||
<< "-1.23e+05";
|
||||
QTest::newRow("C scientific truncate decimals")
|
||||
@ -486,7 +486,7 @@ void tst_QDoubleValidator::fixup_data()
|
||||
QTest::newRow("en standard with invalid digit grouping")
|
||||
<< "en" << QDoubleValidator::StandardNotation << -1 << "-1,234,5.678"
|
||||
<< "-12,345.678";
|
||||
QTest::newRow("en standard with invalid number of decimals")
|
||||
QTest::newRow("en standard with invalid group size")
|
||||
<< "en" << QDoubleValidator::StandardNotation << 2 << "12,34.678"
|
||||
<< "1,234.68";
|
||||
QTest::newRow("en standard no fractional part")
|
||||
@ -502,7 +502,7 @@ void tst_QDoubleValidator::fixup_data()
|
||||
QTest::newRow("en scientific with invalid digit grouping")
|
||||
<< "en" << QDoubleValidator::ScientificNotation << -1 << "-12,34.98765e2"
|
||||
<< "-1.23498765E+05";
|
||||
QTest::newRow("en scientific with invalid number of decimals")
|
||||
QTest::newRow("en scientific with invalid group size")
|
||||
<< "en" << QDoubleValidator::ScientificNotation << 2 << "12,34.98765e2"
|
||||
<< "1.23E+05";
|
||||
QTest::newRow("en scientific no fractional part")
|
||||
@ -529,7 +529,7 @@ void tst_QDoubleValidator::fixup_data()
|
||||
QTest::newRow("de standard with invalid digit grouping")
|
||||
<< "de" << QDoubleValidator::StandardNotation << -1 << "1.234.5,678"
|
||||
<< "12.345,678";
|
||||
QTest::newRow("de standard with invalid number of decimals")
|
||||
QTest::newRow("de standard with invalid group size")
|
||||
<< "de" << QDoubleValidator::StandardNotation << 2 << "-12.34,678"
|
||||
<< "-1.234,68";
|
||||
QTest::newRow("de standard no fractional part")
|
||||
@ -544,7 +544,7 @@ void tst_QDoubleValidator::fixup_data()
|
||||
QTest::newRow("de scientific with invalid digit grouping")
|
||||
<< "de" << QDoubleValidator::ScientificNotation << -1 << "12.34,98765e2"
|
||||
<< "1,23498765E+05";
|
||||
QTest::newRow("de scientific with invalid number of decimals")
|
||||
QTest::newRow("de scientific with invalid group size")
|
||||
<< "de" << QDoubleValidator::ScientificNotation << 2 << "-12.34,98765e2"
|
||||
<< "-1,23E+05";
|
||||
QTest::newRow("de scientific no fractional part")
|
||||
@ -560,6 +560,22 @@ void tst_QDoubleValidator::fixup_data()
|
||||
<< "de" << QDoubleValidator::ScientificNotation << -1 << "-12.34"
|
||||
<< "-1,234E+03";
|
||||
|
||||
// es locale uses ',' as decimal point and '.' as grouping separator.
|
||||
// It doesn't apply grouping unless the the next-to-least significant group
|
||||
// has more than one digit in it.
|
||||
QTest::newRow("es standard no digit grouping")
|
||||
<< "es" << QDoubleValidator::StandardNotation << -1 << "1234,567" << "1234,567";
|
||||
QTest::newRow("es standard with digit grouping")
|
||||
<< "es" << QDoubleValidator::StandardNotation << -1 << "-12.345,678" << "-12.345,678";
|
||||
QTest::newRow("es standard with invalid group size")
|
||||
<< "es" << QDoubleValidator::StandardNotation << -1 << "1.234.5,678" << "12.345,678";
|
||||
QTest::newRow("es standard with invalid digit grouping")
|
||||
<< "es" << QDoubleValidator::StandardNotation << 2 << "-1.234,678" << "-1234,68";
|
||||
QTest::newRow("es standard big with invalid digit grouping")
|
||||
<< "es" << QDoubleValidator::StandardNotation << 2 << "-1234.678,9" << "-1.234.678,9";
|
||||
QTest::newRow("es standard no fractional part")
|
||||
<< "es" << QDoubleValidator::StandardNotation << -1 << "12.34" << "1234";
|
||||
|
||||
// hi locale uses '.' as decimal point and ',' as grouping separator.
|
||||
// The rightmost group is of three digits, all the others contain two
|
||||
// digits.
|
||||
|
@ -307,9 +307,9 @@ void tst_QIntValidator::fixup_data()
|
||||
// Normally the groups contain three digits, but the leftmost group should
|
||||
// have at least two digits.
|
||||
QTest::newRow("es no digit grouping 1000") << "es" << "1000" << "1000";
|
||||
QTest::newRow("es no digit grouping 10000") << "es" << "10000" << "10.000";
|
||||
QTest::newRow("es with digit grouping") << "es" << "1000.000" << "1000.000";
|
||||
QTest::newRow("es invalid digit grouping") << "es" << "1.000.000" << "1000.000";
|
||||
QTest::newRow("es with digit grouping 10000") << "es" << "10000" << "10.000";
|
||||
QTest::newRow("es with digit grouping million") << "es" << "1.000.000" << "1.000.000";
|
||||
QTest::newRow("es invalid digit grouping") << "es" << "1000.000" << "1.000.000";
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_QIntValidator)
|
||||
|
Reference in New Issue
Block a user