diff options
Diffstat (limited to 'tests/auto')
30 files changed, 0 insertions, 1153 deletions
diff --git a/tests/auto/.prev_CMakeLists.txt b/tests/auto/.prev_CMakeLists.txt deleted file mode 100644 index bac7e9e..0000000 --- a/tests/auto/.prev_CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# Generated from auto.pro. - -add_subdirectory(cmake) -add_subdirectory(qwinthumbnailtoolbar) -add_subdirectory(qpixmap) -add_subdirectory(qwintaskbarbutton) -add_subdirectory(qwintaskbarprogress) -add_subdirectory(qwinjumplist) diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt deleted file mode 100644 index e8a3f77..0000000 --- a/tests/auto/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# Generated from auto.pro. - -# add_subdirectory(cmake) # special case remove -add_subdirectory(qwinthumbnailtoolbar) -add_subdirectory(qpixmap) -add_subdirectory(qwintaskbarbutton) -add_subdirectory(qwintaskbarprogress) -add_subdirectory(qwinjumplist) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro deleted file mode 100644 index 331bf7a..0000000 --- a/tests/auto/auto.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS += \ - cmake \ - qwinthumbnailtoolbar \ - qpixmap \ - qwintaskbarbutton \ - qwintaskbarprogress \ - qwinjumplist diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt deleted file mode 100644 index 989b8f8..0000000 --- a/tests/auto/cmake/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -# Generated from cmake.pro. - diff --git a/tests/auto/cmake/cmake.pro b/tests/auto/cmake/cmake.pro deleted file mode 100644 index 0afd8fe..0000000 --- a/tests/auto/cmake/cmake.pro +++ /dev/null @@ -1,7 +0,0 @@ - -# Cause make to do nothing. -TEMPLATE = subdirs - -CMAKE_QT_MODULES_UNDER_TEST = winextras - -CONFIG += ctest_testcase diff --git a/tests/auto/qpixmap/CMakeLists.txt b/tests/auto/qpixmap/CMakeLists.txt deleted file mode 100644 index 3fa1407..0000000 --- a/tests/auto/qpixmap/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -# Generated from qpixmap.pro. - -##################################################################### -## tst_qpixmap Test: -##################################################################### - -qt_add_test(tst_qpixmap - SOURCES - tst_qpixmap.cpp - PUBLIC_LIBRARIES - Qt::Gui - Qt::WinExtras -) - -## Scopes: -##################################################################### - -qt_extend_target(tst_qpixmap CONDITION QT_FEATURE_dynamicgl OR (WIN32 AND NOT TARGET Qt::OpenGL) - PUBLIC_LIBRARIES - gdi32 - user32 -) diff --git a/tests/auto/qpixmap/data/icon_32bpp.ico b/tests/auto/qpixmap/data/icon_32bpp.ico Binary files differdeleted file mode 100644 index dbb55cd..0000000 --- a/tests/auto/qpixmap/data/icon_32bpp.ico +++ /dev/null diff --git a/tests/auto/qpixmap/data/icon_32bpp_16x16.png b/tests/auto/qpixmap/data/icon_32bpp_16x16.png Binary files differdeleted file mode 100644 index f23f398..0000000 --- a/tests/auto/qpixmap/data/icon_32bpp_16x16.png +++ /dev/null diff --git a/tests/auto/qpixmap/data/icon_32bpp_256x256.png b/tests/auto/qpixmap/data/icon_32bpp_256x256.png Binary files differdeleted file mode 100644 index 293f1c5..0000000 --- a/tests/auto/qpixmap/data/icon_32bpp_256x256.png +++ /dev/null diff --git a/tests/auto/qpixmap/data/icon_32bpp_32x32.png b/tests/auto/qpixmap/data/icon_32bpp_32x32.png Binary files differdeleted file mode 100644 index bfdb1fe..0000000 --- a/tests/auto/qpixmap/data/icon_32bpp_32x32.png +++ /dev/null diff --git a/tests/auto/qpixmap/data/icon_32bpp_48x48.png b/tests/auto/qpixmap/data/icon_32bpp_48x48.png Binary files differdeleted file mode 100644 index 7dd2d13..0000000 --- a/tests/auto/qpixmap/data/icon_32bpp_48x48.png +++ /dev/null diff --git a/tests/auto/qpixmap/data/icon_8bpp.ico b/tests/auto/qpixmap/data/icon_8bpp.ico Binary files differdeleted file mode 100644 index 4341a33..0000000 --- a/tests/auto/qpixmap/data/icon_8bpp.ico +++ /dev/null diff --git a/tests/auto/qpixmap/data/icon_8bpp_16x16.png b/tests/auto/qpixmap/data/icon_8bpp_16x16.png Binary files differdeleted file mode 100644 index 03b1a65..0000000 --- a/tests/auto/qpixmap/data/icon_8bpp_16x16.png +++ /dev/null diff --git a/tests/auto/qpixmap/data/icon_8bpp_32x32.png b/tests/auto/qpixmap/data/icon_8bpp_32x32.png Binary files differdeleted file mode 100644 index 0ef47c5..0000000 --- a/tests/auto/qpixmap/data/icon_8bpp_32x32.png +++ /dev/null diff --git a/tests/auto/qpixmap/data/icon_8bpp_48x48.png b/tests/auto/qpixmap/data/icon_8bpp_48x48.png Binary files differdeleted file mode 100644 index 2060854..0000000 --- a/tests/auto/qpixmap/data/icon_8bpp_48x48.png +++ /dev/null diff --git a/tests/auto/qpixmap/qpixmap.pro b/tests/auto/qpixmap/qpixmap.pro deleted file mode 100644 index 47c70fc..0000000 --- a/tests/auto/qpixmap/qpixmap.pro +++ /dev/null @@ -1,5 +0,0 @@ -CONFIG += testcase -TARGET = tst_qpixmap -QT += gui testlib winextras -SOURCES += tst_qpixmap.cpp -win32:!qtHaveModule(opengl)|qtConfig(dynamicgl):LIBS += -lgdi32 -luser32 diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp deleted file mode 100644 index e16889d..0000000 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ /dev/null @@ -1,302 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtTest/QtTest> -#include <QtCore/qt_windows.h> -#include <QtCore/QFileInfo> -#include <QtGui/QPainter> -#include <QtGui/QPixmap> -#include <QtGui/QImage> -#include <QtWinExtras/QtWin> - -class tst_QPixmap : public QObject -{ - Q_OBJECT - -public: - tst_QPixmap() : m_dataDirectory(QFINDTESTDATA("data")) {} - -private slots: - void initTestCase(); - - void toHBITMAP_data(); - void toHBITMAP(); - void fromHBITMAP_data(); - void fromHBITMAP(); - - void toHICON_data(); - void toHICON(); - void fromHICON_data(); - void fromHICON(); - - void imageConversion(); - -private: - const QString m_dataDirectory; -}; - -void tst_QPixmap::initTestCase() -{ - QVERIFY(!m_dataDirectory.isEmpty()); -} - -void tst_QPixmap::toHBITMAP_data() -{ - QTest::addColumn<int>("red"); - QTest::addColumn<int>("green"); - QTest::addColumn<int>("blue"); - - QTest::newRow("red") << 255 << 0 << 0; - QTest::newRow("green") << 0 << 255 << 0; - QTest::newRow("blue") << 0 << 0 << 255; -} - -void tst_QPixmap::toHBITMAP() -{ - QFETCH(int, red); - QFETCH(int, green); - QFETCH(int, blue); - - QPixmap pm(100, 100); - pm.fill(QColor(red, green, blue)); - - const HBITMAP bitmap = QtWin::toHBITMAP(pm); - - QVERIFY(bitmap != nullptr); - - // Verify size - BITMAP bitmapInfo; - memset(&bitmapInfo, 0, sizeof(BITMAP)); - - QVERIFY(GetObject(bitmap, sizeof(BITMAP), &bitmapInfo)); - - QCOMPARE(LONG(100), bitmapInfo.bmWidth); - QCOMPARE(LONG(100), bitmapInfo.bmHeight); - - const HDC displayDc = GetDC(nullptr); - const HDC bitmapDc = CreateCompatibleDC(displayDc); - - const auto nullBitmap = static_cast<HBITMAP>(SelectObject(bitmapDc, bitmap)); - - const COLORREF pixel = GetPixel(bitmapDc, 0, 0); - QCOMPARE(int(GetRValue(pixel)), red); - QCOMPARE(int(GetGValue(pixel)), green); - QCOMPARE(int(GetBValue(pixel)), blue); - - // Clean up - SelectObject(bitmapDc, nullBitmap); - DeleteObject(bitmap); - DeleteDC(bitmapDc); - ReleaseDC(nullptr, displayDc); -} - -void tst_QPixmap::fromHBITMAP_data() -{ - toHBITMAP_data(); -} - -void tst_QPixmap::fromHBITMAP() -{ - QFETCH(int, red); - QFETCH(int, green); - QFETCH(int, blue); - - const HDC displayDc = GetDC(nullptr); - const HDC bitmapDc = CreateCompatibleDC(displayDc); - const HBITMAP bitmap = CreateCompatibleBitmap(displayDc, 100, 100); - SelectObject(bitmapDc, bitmap); - - SelectObject(bitmapDc, GetStockObject(NULL_PEN)); - const HGDIOBJ oldBrush = SelectObject(bitmapDc, CreateSolidBrush(RGB(red, green, blue))); - Rectangle(bitmapDc, 0, 0, 100, 100); - - const QPixmap pixmap = QtWin::fromHBITMAP(bitmap); - QCOMPARE(pixmap.width(), 100); - QCOMPARE(pixmap.height(), 100); - - const QImage image = pixmap.toImage(); - const QRgb pixel = image.pixel(0, 0); - QCOMPARE(qRed(pixel), red); - QCOMPARE(qGreen(pixel), green); - QCOMPARE(qBlue(pixel), blue); - - DeleteObject(SelectObject(bitmapDc, oldBrush)); - DeleteObject(SelectObject(bitmapDc, bitmap)); - DeleteDC(bitmapDc); - ReleaseDC(nullptr, displayDc); -} - -static bool compareImages(const QImage &actual, const QImage &expected, - QByteArray *errorMessage) -{ - if (actual.size() != expected.size()) { - QString s; - QDebug(&s) << "Size mismatch, actual: " << actual.size() << " expected: " << expected.size(); - *errorMessage = s.toLocal8Bit(); - return false; - } - if (actual.format() != expected.format()) { - *errorMessage = QByteArrayLiteral("Format mismatch, actual: ") - + QByteArray::number(actual.format()) - + QByteArrayLiteral(", expected: ") + QByteArray::number(expected.format()); - return false; - } - - static const int fuzz = 1; - - for (int y = 0; y < actual.height(); ++y) { - for (int x = 0; x < expected.width(); ++x) { - const QRgb actualRgb = actual.pixel(x, y); - const QRgb expectedRgb = expected.pixel(x, y); - const bool pixelMatches = - qAbs(qRed(actualRgb) - qRed(expectedRgb)) <= fuzz - && qAbs(qGreen(actualRgb) - qGreen(expectedRgb)) <= fuzz - && qAbs(qBlue(actualRgb) - qBlue(expectedRgb)) <= fuzz - && qAbs(qAlpha(actualRgb) - qAlpha(expectedRgb)) <= fuzz; - if (!pixelMatches) { - QString s; - QDebug(&s) << "Pixmal mismatch at " << x << ',' << y << " actual: " - << QColor(actualRgb) << " expected: " << QColor(expectedRgb); - *errorMessage = s.toLocal8Bit(); - return false; - } - } - } - return true; -} - -static inline QString pngFileName(const QString &image, int width, int height) -{ - return image + u'_' + QString::number(width) - + u'x' + QString::number(height) + QStringLiteral(".png"); -} - -void tst_QPixmap::toHICON_data() -{ - QTest::addColumn<QString>("image"); - QTest::addColumn<int>("width"); - QTest::addColumn<int>("height"); - - QTest::newRow("32bpp_16x16") << m_dataDirectory + QStringLiteral("/icon_32bpp") << 16 << 16; - QTest::newRow("32bpp_32x32") << m_dataDirectory + QStringLiteral("/icon_32bpp") << 32 << 32; - QTest::newRow("32bpp_48x48") << m_dataDirectory + QStringLiteral("/icon_32bpp") << 48 << 48; - QTest::newRow("32bpp_256x256") << m_dataDirectory + QStringLiteral("/icon_32bpp") << 256 << 256; - - QTest::newRow("8bpp_16x16") << m_dataDirectory + QStringLiteral("/icon_8bpp") << 16 << 16; - QTest::newRow("8bpp_32x32") << m_dataDirectory + QStringLiteral("/icon_8bpp") << 32 << 32; - QTest::newRow("8bpp_48x48") << m_dataDirectory + QStringLiteral("/icon_8bpp") << 48 << 48; -} - -void tst_QPixmap::toHICON() -{ - QFETCH(int, width); - QFETCH(int, height); - QFETCH(QString, image); - - QPixmap empty(width, height); - empty.fill(Qt::transparent); - - const HDC displayDc = GetDC(nullptr); - const HDC bitmapDc = CreateCompatibleDC(displayDc); - const HBITMAP bitmap = QtWin::toHBITMAP(empty, QtWin::HBitmapAlpha); - SelectObject(bitmapDc, bitmap); - - const QString imageFileName = pngFileName(image, width, height); - QVERIFY2(QFileInfo::exists(imageFileName), qPrintable(imageFileName)); - - const QImage imageFromFile = QImage(imageFileName).convertToFormat(QImage::Format_ARGB32_Premultiplied); - QVERIFY(!imageFromFile.isNull()); - - const HICON icon = QtWin::toHICON(QPixmap::fromImage(imageFromFile)); - - DrawIconEx(bitmapDc, 0, 0, icon, width, height, 0, nullptr, DI_NORMAL); - - DestroyIcon(icon); - DeleteDC(bitmapDc); - - const QImage imageFromHICON = QtWin::fromHBITMAP(bitmap, QtWin::HBitmapAlpha).toImage(); - QVERIFY(!imageFromHICON.isNull()); - - ReleaseDC(nullptr, displayDc); - - // fuzzy comparison must be used, as the pixel values change slightly during conversion - // between QImage::Format_ARGB32 and QImage::Format_ARGB32_Premultiplied, or elsewhere - QByteArray errorMessage; - QVERIFY2(compareImages(imageFromHICON, imageFromFile, &errorMessage), errorMessage.constData()); -} - -void tst_QPixmap::fromHICON_data() -{ - toHICON_data(); -} - -void tst_QPixmap::fromHICON() -{ - QFETCH(int, width); - QFETCH(int, height); - QFETCH(QString, image); - - const QString iconFileName = image + QStringLiteral(".ico"); - QVERIFY2(QFileInfo::exists(iconFileName), qPrintable(iconFileName)); - - const auto icon = - static_cast<HICON>(LoadImage(nullptr, reinterpret_cast<const wchar_t *>(iconFileName.utf16()), - IMAGE_ICON, width, height, LR_LOADFROMFILE)); - const QImage imageFromHICON = QtWin::fromHICON(icon).toImage(); - DestroyIcon(icon); - - const QString imageFileName = pngFileName(image, width, height); - QVERIFY2(QFileInfo::exists(imageFileName), qPrintable(imageFileName)); - - const QImage imageFromFile = QImage(imageFileName).convertToFormat(QImage::Format_ARGB32_Premultiplied); - QVERIFY(!imageFromFile.isNull()); - - // fuzzy comparison must be used, as the pixel values change slightly during conversion - // between QImage::Format_ARGB32 and QImage::Format_ARGB32_Premultiplied, or elsewhere - QByteArray errorMessage; - QVERIFY2(compareImages(imageFromHICON, imageFromFile, &errorMessage), errorMessage.constData()); -} - -void tst_QPixmap::imageConversion() -{ - // Extensive testing of all formats is done in QtGui; this merely tests - // the exports/linkage. - QImage image(73, 57, QImage::Format_ARGB32_Premultiplied); - image.fill(Qt::red); - QPainter painter(&image); - painter.drawLine(0, 0, image.width(), image.height()); - const HBITMAP hBitMap = QtWin::imageToHBITMAP(image); - QVERIFY(hBitMap); - const QImage fromHBitMap = QtWin::imageFromHBITMAP(hBitMap, QtWin::HBitmapPremultipliedAlpha); - QCOMPARE(fromHBitMap, image); - DeleteObject(hBitMap); -} - -QTEST_MAIN(tst_QPixmap) - -#include "tst_qpixmap.moc" diff --git a/tests/auto/qwinjumplist/CMakeLists.txt b/tests/auto/qwinjumplist/CMakeLists.txt deleted file mode 100644 index a300ee8..0000000 --- a/tests/auto/qwinjumplist/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Generated from qwinjumplist.pro. - -##################################################################### -## tst_qwinjumplist Test: -##################################################################### - -qt_add_test(tst_qwinjumplist - SOURCES - tst_qwinjumplist.cpp - PUBLIC_LIBRARIES - Qt::Gui - Qt::WinExtras -) diff --git a/tests/auto/qwinjumplist/qwinjumplist.pro b/tests/auto/qwinjumplist/qwinjumplist.pro deleted file mode 100644 index 70657b4..0000000 --- a/tests/auto/qwinjumplist/qwinjumplist.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase -TARGET = tst_qwinjumplist -QT += testlib winextras -SOURCES += tst_qwinjumplist.cpp diff --git a/tests/auto/qwinjumplist/tst_qwinjumplist.cpp b/tests/auto/qwinjumplist/tst_qwinjumplist.cpp deleted file mode 100644 index 4676524..0000000 --- a/tests/auto/qwinjumplist/tst_qwinjumplist.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtTest/QtTest> -#include <QWinJumpList> -#include <QWinJumpListItem> -#include <QWinJumpListCategory> -#include <QOperatingSystemVersion> - -Q_DECLARE_METATYPE(QWinJumpListItem::Type) - -class tst_QWinJumpList : public QObject -{ - Q_OBJECT - -private slots: - void testRecent(); - void testFrequent(); - void testTasks(); - void testCategories(); - void testItems_data(); - void testItems(); -}; - -static inline QByteArray msgFileNameMismatch(const QString &f1, const QString &f2) -{ - const QString result = u'"' + f1 + QStringLiteral("\" != \"") - + f2 + u'"'; - return result.toLocal8Bit(); -} - -void tst_QWinJumpList::testRecent() -{ - if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows8_1) - QSKIP("QTBUG-48751: Recent items do not work on Windows 8.1 or 10", Continue); - QScopedPointer<QWinJumpList> jumplist(new QWinJumpList); - QWinJumpListCategory *recent1 = jumplist->recent(); - QVERIFY(recent1); - QVERIFY(!recent1->isVisible()); - QVERIFY(recent1->title().isEmpty()); - - recent1->clear(); - QVERIFY(recent1->isEmpty()); - - recent1->addItem(nullptr); - QVERIFY(recent1->isEmpty()); - - recent1->setVisible(true); - QVERIFY(recent1->isVisible()); - recent1->addLink(QStringLiteral("tst_QWinJumpList"), QCoreApplication::applicationFilePath()); - - QTest::ignoreMessage(QtWarningMsg, "QWinJumpListCategory::addItem(): only tasks/custom categories support separators."); - recent1->addSeparator(); - - QTest::ignoreMessage(QtWarningMsg, "QWinJumpListCategory::addItem(): only tasks/custom categories support destinations."); - recent1->addDestination(QCoreApplication::applicationDirPath()); - - // cleanup the first jumplist instance and give the system a little time to update. - // then test that another jumplist instance loads up the recent item(s) added above - jumplist.reset(); - QTest::qWait(100); - - jumplist.reset(new QWinJumpList); - QWinJumpListCategory *recent2 = jumplist->recent(); - QVERIFY(recent2); - QCOMPARE(recent2->count(), 1); - - QWinJumpListItem* item = recent2->items().value(0); - QVERIFY(item); - const QString itemPath = item->filePath(); - const QString applicationFilePath = QCoreApplication::applicationFilePath(); - QVERIFY2(!itemPath.compare(applicationFilePath, Qt::CaseInsensitive), - msgFileNameMismatch(itemPath, applicationFilePath)); - QEXPECT_FAIL("", "QWinJumpListItem::title not supported for recent items", Continue); - QCOMPARE(item->title(), QStringLiteral("tst_QWinJumpList")); - - recent2->clear(); - QVERIFY(recent2->isEmpty()); -} - -void tst_QWinJumpList::testFrequent() -{ - if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows8_1) - QSKIP("QTBUG-48751: Frequent items do not work on Windows 8.1 or 10", Continue); - QScopedPointer<QWinJumpList> jumplist(new QWinJumpList); - QWinJumpListCategory *frequent1 = jumplist->frequent(); - QVERIFY(frequent1); - QVERIFY(!frequent1->isVisible()); - QVERIFY(frequent1->title().isEmpty()); - - frequent1->clear(); - QVERIFY(frequent1->isEmpty()); - - frequent1->addItem(nullptr); - QVERIFY(frequent1->isEmpty()); - - frequent1->setVisible(true); - QVERIFY(frequent1->isVisible()); - frequent1->addLink(QStringLiteral("tst_QWinJumpList"), QCoreApplication::applicationFilePath()); - - QTest::ignoreMessage(QtWarningMsg, "QWinJumpListCategory::addItem(): only tasks/custom categories support separators."); - frequent1->addSeparator(); - - QTest::ignoreMessage(QtWarningMsg, "QWinJumpListCategory::addItem(): only tasks/custom categories support destinations."); - frequent1->addDestination(QCoreApplication::applicationDirPath()); - - // cleanup the first jumplist instance and give the system a little time to update. - // then test that another jumplist instance loads up the frequent item(s) added above - jumplist.reset(); - QTest::qWait(100); - - jumplist.reset(new QWinJumpList); - QWinJumpListCategory *frequent2 = jumplist->frequent(); - QVERIFY(frequent2); - QCOMPARE(frequent2->count(), 1); - - QWinJumpListItem* item = frequent2->items().value(0); - QVERIFY(item); - const QString itemPath = item->filePath(); - const QString applicationFilePath = QCoreApplication::applicationFilePath(); - QVERIFY2(!itemPath.compare(applicationFilePath, Qt::CaseInsensitive), - msgFileNameMismatch(itemPath, applicationFilePath)); - QEXPECT_FAIL("", "QWinJumpListItem::title not supported for frequent items", Continue); - QCOMPARE(item->title(), QStringLiteral("tst_QWinJumpList")); - - frequent2->clear(); - QVERIFY(frequent2->isEmpty()); -} - -void tst_QWinJumpList::testTasks() -{ - QWinJumpList jumplist; - QWinJumpListCategory *tasks = jumplist.tasks(); - QVERIFY(tasks); - QVERIFY(!tasks->isVisible()); - QVERIFY(tasks->isEmpty()); - QVERIFY(tasks->title().isEmpty()); - - tasks->setVisible(true); - QVERIFY(tasks->isVisible()); - - tasks->addItem(nullptr); - QVERIFY(tasks->isEmpty()); - - QWinJumpListItem* link1 = tasks->addLink(QStringLiteral("tst_QWinJumpList"), QCoreApplication::applicationFilePath()); - QCOMPARE(link1->type(), QWinJumpListItem::Link); - QCOMPARE(link1->title(), QStringLiteral("tst_QWinJumpList")); - QCOMPARE(link1->filePath(), QCoreApplication::applicationFilePath()); - QCOMPARE(tasks->count(), 1); - QCOMPARE(tasks->items(), QList<QWinJumpListItem *>() << link1); - - QWinJumpListItem* link2 = tasks->addLink(QStringLiteral("tst_QWinJumpList"), QCoreApplication::applicationFilePath(), QStringList(QStringLiteral("-test"))); - QCOMPARE(link2->type(), QWinJumpListItem::Link); - QCOMPARE(link2->title(), QStringLiteral("tst_QWinJumpList")); - QCOMPARE(link2->filePath(), QCoreApplication::applicationFilePath()); - QCOMPARE(link2->arguments(), QStringList(QStringLiteral("-test"))); - QCOMPARE(tasks->count(), 2); - QCOMPARE(tasks->items(), QList<QWinJumpListItem *>() << link1 << link2); - - QWinJumpListItem* separator = tasks->addSeparator(); - QCOMPARE(separator->type(), QWinJumpListItem::Separator); - QCOMPARE(tasks->count(), 3); - QCOMPARE(tasks->items(), QList<QWinJumpListItem *>() << link1 << link2 << separator); - - QWinJumpListItem* destination = tasks->addDestination(QCoreApplication::applicationDirPath()); - QCOMPARE(destination->type(), QWinJumpListItem::Destination); - QCOMPARE(destination->filePath(), QCoreApplication::applicationDirPath()); - QCOMPARE(tasks->count(), 4); - QCOMPARE(tasks->items(), QList<QWinJumpListItem *>() << link1 << link2 << separator << destination); - - tasks->clear(); - QVERIFY(tasks->isEmpty()); - QVERIFY(tasks->items().isEmpty()); -} - -void tst_QWinJumpList::testCategories() -{ - QWinJumpList jumplist; - QVERIFY(jumplist.categories().isEmpty()); - - jumplist.addCategory(nullptr); - - QWinJumpListCategory *cat1 = new QWinJumpListCategory(QStringLiteral("tmp")); - QCOMPARE(cat1->title(), QStringLiteral("tmp")); - cat1->setTitle(QStringLiteral("cat1")); - QCOMPARE(cat1->title(), QStringLiteral("cat1")); - - jumplist.addCategory(cat1); - QCOMPARE(jumplist.categories().count(), 1); - QCOMPARE(jumplist.categories().at(0), cat1); - - QWinJumpListCategory *cat2 = jumplist.addCategory(QStringLiteral("cat2")); - QCOMPARE(cat2->title(), QStringLiteral("cat2")); - - QCOMPARE(jumplist.categories().count(), 2); - QCOMPARE(jumplist.categories().at(0), cat1); - QCOMPARE(jumplist.categories().at(1), cat2); - - jumplist.clear(); - QVERIFY(jumplist.categories().isEmpty()); -} - -void tst_QWinJumpList::testItems_data() -{ - QTest::addColumn<QWinJumpListItem::Type>("type"); - - QTest::newRow("destination") << QWinJumpListItem::Destination; - QTest::newRow("separator") << QWinJumpListItem::Separator; - QTest::newRow("link") << QWinJumpListItem::Link; -} - -void tst_QWinJumpList::testItems() -{ - QFETCH(QWinJumpListItem::Type, type); - - QWinJumpListItem item(type); - QCOMPARE(item.type(), type); - QVERIFY(item.filePath().isNull()); - QVERIFY(item.workingDirectory().isNull()); - QVERIFY(item.icon().isNull()); - QVERIFY(item.title().isNull()); - QVERIFY(item.description().isNull()); - QVERIFY(item.arguments().isEmpty()); - - item.setType(QWinJumpListItem::Destination); - QCOMPARE(item.type(), QWinJumpListItem::Destination); - - item.setFilePath(QCoreApplication::applicationFilePath()); - QCOMPARE(item.filePath(), QCoreApplication::applicationFilePath()); - - item.setWorkingDirectory(QCoreApplication::applicationDirPath()); - QCOMPARE(item.workingDirectory(), QCoreApplication::applicationDirPath()); - - QIcon icon("qrc:/qt-project.org/qmessagebox/images/qtlogo-64.png"); - item.setIcon(icon); - QCOMPARE(item.icon().cacheKey(), icon.cacheKey()); - - item.setTitle(QStringLiteral("tst_QWinJumpList")); - QCOMPARE(item.title(), QStringLiteral("tst_QWinJumpList")); - - item.setDescription(QStringLiteral("QtWinExras - tst_QWinJumpList")); - QCOMPARE(item.description(), QStringLiteral("QtWinExras - tst_QWinJumpList")); - - item.setArguments(QCoreApplication::arguments()); - QCOMPARE(item.arguments(), QCoreApplication::arguments()); -} - -QTEST_MAIN(tst_QWinJumpList) - -#include "tst_qwinjumplist.moc" diff --git a/tests/auto/qwinmime/CMakeLists.txt b/tests/auto/qwinmime/CMakeLists.txt deleted file mode 100644 index e502d1f..0000000 --- a/tests/auto/qwinmime/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -# Generated from qwinmime.pro. - -##################################################################### -## tst_qwinmime Test: -##################################################################### - -qt_add_test(tst_qwinmime - SOURCES - tst_qwinmime.cpp - PUBLIC_LIBRARIES - Qt::Gui - Qt::Widgets - Qt::WinExtras -) diff --git a/tests/auto/qwintaskbarbutton/CMakeLists.txt b/tests/auto/qwintaskbarbutton/CMakeLists.txt deleted file mode 100644 index f313e0d..0000000 --- a/tests/auto/qwintaskbarbutton/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Generated from qwintaskbarbutton.pro. - -##################################################################### -## tst_qwintaskbarbutton Test: -##################################################################### - -qt_add_test(tst_qwintaskbarbutton - SOURCES - tst_qwintaskbarbutton.cpp - PUBLIC_LIBRARIES - Qt::Gui - Qt::WinExtras -) diff --git a/tests/auto/qwintaskbarbutton/qwintaskbarbutton.pro b/tests/auto/qwintaskbarbutton/qwintaskbarbutton.pro deleted file mode 100644 index fda7013..0000000 --- a/tests/auto/qwintaskbarbutton/qwintaskbarbutton.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase -TARGET = tst_qwintaskbarbutton -QT += testlib winextras -SOURCES += tst_qwintaskbarbutton.cpp diff --git a/tests/auto/qwintaskbarbutton/tst_qwintaskbarbutton.cpp b/tests/auto/qwintaskbarbutton/tst_qwintaskbarbutton.cpp deleted file mode 100644 index a9287a0..0000000 --- a/tests/auto/qwintaskbarbutton/tst_qwintaskbarbutton.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtTest/QtTest> -#include <QWinTaskbarButton> -#include <QWinTaskbarProgress> - -class tst_QWinTaskbarButton : public QObject -{ - Q_OBJECT - -private slots: - void testWindow(); - void testOverlayIcon(); - void testOverlayAccessibleDescription(); - void testProgress(); -}; - -void tst_QWinTaskbarButton::testWindow() -{ - QWindow window; - - QWinTaskbarButton btn1; - QVERIFY(!btn1.window()); - btn1.setWindow(&window); - QCOMPARE(btn1.window(), &window); - - auto *btn2 = new QWinTaskbarButton(&window); - QCOMPARE(btn2->window(), &window); - btn2->setWindow(nullptr); - QVERIFY(!btn2->window()); -} - -void tst_QWinTaskbarButton::testOverlayIcon() -{ - QWinTaskbarButton btn; - QVERIFY(btn.overlayIcon().isNull()); - - QIcon icon; - QPixmap pixmap(64, 64); - pixmap.fill(Qt::transparent); - icon.addPixmap(pixmap); - - btn.setOverlayIcon(icon); - QCOMPARE(btn.overlayIcon(), icon); - - btn.clearOverlayIcon(); - QVERIFY(btn.overlayIcon().isNull()); -} - -void tst_QWinTaskbarButton::testOverlayAccessibleDescription() -{ - QWinTaskbarButton btn; - QVERIFY(btn.overlayAccessibleDescription().isNull()); - - btn.setOverlayAccessibleDescription(QStringLiteral("Qt")); - QCOMPARE(btn.overlayAccessibleDescription(), QStringLiteral("Qt")); - - btn.setOverlayAccessibleDescription(QString()); - QVERIFY(btn.overlayAccessibleDescription().isNull()); -} - -void tst_QWinTaskbarButton::testProgress() -{ - QWinTaskbarButton btn; - QVERIFY(btn.progress()); - QVERIFY(btn.progress()->objectName().isEmpty()); - - btn.progress()->setObjectName(QStringLiteral("DEAD")); - delete btn.progress(); - - QVERIFY(btn.progress()); - QVERIFY(btn.progress()->objectName().isEmpty()); -} - -QTEST_MAIN(tst_QWinTaskbarButton) - -#include "tst_qwintaskbarbutton.moc" diff --git a/tests/auto/qwintaskbarprogress/CMakeLists.txt b/tests/auto/qwintaskbarprogress/CMakeLists.txt deleted file mode 100644 index e218e3e..0000000 --- a/tests/auto/qwintaskbarprogress/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Generated from qwintaskbarprogress.pro. - -##################################################################### -## tst_qwintaskbarprogress Test: -##################################################################### - -qt_add_test(tst_qwintaskbarprogress - SOURCES - tst_qwintaskbarprogress.cpp - PUBLIC_LIBRARIES - Qt::Gui - Qt::WinExtras -) diff --git a/tests/auto/qwintaskbarprogress/qwintaskbarprogress.pro b/tests/auto/qwintaskbarprogress/qwintaskbarprogress.pro deleted file mode 100644 index 76b5697..0000000 --- a/tests/auto/qwintaskbarprogress/qwintaskbarprogress.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase -TARGET = tst_qwintaskbarprogress -QT += testlib winextras -SOURCES += tst_qwintaskbarprogress.cpp diff --git a/tests/auto/qwintaskbarprogress/tst_qwintaskbarprogress.cpp b/tests/auto/qwintaskbarprogress/tst_qwintaskbarprogress.cpp deleted file mode 100644 index f27ba21..0000000 --- a/tests/auto/qwintaskbarprogress/tst_qwintaskbarprogress.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtTest/QtTest> -#include <QWinTaskbarButton> -#include <QWinTaskbarProgress> - -class tst_QWinTaskbarProgress : public QObject -{ - Q_OBJECT - -private slots: - void testValue(); - void testRange(); - void testPause(); - void testVisibility(); - void testStop(); -}; - -void tst_QWinTaskbarProgress::testValue() -{ - QWinTaskbarButton btn; - QWinTaskbarProgress *progress = btn.progress(); - QVERIFY(progress); - QCOMPARE(progress->value(), 0); - QCOMPARE(progress->minimum(), 0); - QCOMPARE(progress->maximum(), 100); - - QSignalSpy valueSpy(progress, SIGNAL(valueChanged(int))); - QVERIFY(valueSpy.isValid()); - - progress->setValue(25); - QCOMPARE(progress->value(), 25); - QCOMPARE(valueSpy.count(), 1); - QCOMPARE(valueSpy.last().at(0).toInt(), 25); - - // under valid range -> no effect - progress->setValue(-50); - QCOMPARE(progress->value(), 25); - QCOMPARE(valueSpy.count(), 1); - - progress->setValue(75); - QCOMPARE(progress->value(), 75); - QCOMPARE(valueSpy.count(), 2); - QCOMPARE(valueSpy.last().at(0).toInt(), 75); - - // over valid range -> no effect - progress->setValue(150); - QCOMPARE(progress->value(), 75); - QCOMPARE(valueSpy.count(), 2); -} - -void tst_QWinTaskbarProgress::testRange() -{ - QWinTaskbarButton btn; - QWinTaskbarProgress *progress = btn.progress(); - QVERIFY(progress); - QCOMPARE(progress->value(), 0); - QCOMPARE(progress->minimum(), 0); - QCOMPARE(progress->maximum(), 100); - - QSignalSpy valueSpy(progress, SIGNAL(valueChanged(int))); - QSignalSpy minimumSpy(progress, SIGNAL(minimumChanged(int))); - QSignalSpy maximumSpy(progress, SIGNAL(maximumChanged(int))); - QVERIFY(valueSpy.isValid()); - QVERIFY(minimumSpy.isValid()); - QVERIFY(maximumSpy.isValid()); - - // value must remain intact - progress->setValue(50); - QCOMPARE(valueSpy.count(), 1); - - progress->setMinimum(25); - QCOMPARE(progress->minimum(), 25); - QCOMPARE(minimumSpy.count(), 1); - QCOMPARE(minimumSpy.last().at(0).toInt(), 25); - - progress->setMaximum(75); - QCOMPARE(progress->maximum(), 75); - QCOMPARE(maximumSpy.count(), 1); - QCOMPARE(maximumSpy.last().at(0).toInt(), 75); - - QCOMPARE(progress->value(), 50); - QCOMPARE(valueSpy.count(), 1); - - // value under valid range -> reset - progress->setMinimum(55); - QCOMPARE(progress->value(), 55); - QCOMPARE(progress->minimum(), 55); - QCOMPARE(valueSpy.count(), 2); - QCOMPARE(valueSpy.last().at(0).toInt(), 55); - QCOMPARE(minimumSpy.count(), 2); - QCOMPARE(minimumSpy.last().at(0).toInt(), 55); - - progress->setValue(70); - QCOMPARE(valueSpy.count(), 3); - - // value over valid range -> reset - progress->setMaximum(65); - QCOMPARE(progress->value(), 55); - QCOMPARE(progress->maximum(), 65); - QCOMPARE(valueSpy.count(), 4); - QCOMPARE(valueSpy.last().at(0).toInt(), 55); - QCOMPARE(maximumSpy.count(), 2); - QCOMPARE(maximumSpy.last().at(0).toInt(), 65); -} - -void tst_QWinTaskbarProgress::testPause() -{ - QWinTaskbarButton btn; - QWinTaskbarProgress *progress = btn.progress(); - QVERIFY(progress); - QVERIFY(!progress->isPaused()); - - QSignalSpy pausedSpy(progress, SIGNAL(pausedChanged(bool))); - QVERIFY(pausedSpy.isValid()); - - progress->setPaused(true); - QVERIFY(progress->isPaused()); - QCOMPARE(pausedSpy.count(), 1); - QCOMPARE(pausedSpy.last().at(0).toBool(), true); - - progress->setPaused(false); - QVERIFY(!progress->isPaused()); - QCOMPARE(pausedSpy.count(), 2); - QCOMPARE(pausedSpy.last().at(0).toBool(), false); - - progress->stop(); - progress->pause(); - QVERIFY(!progress->isPaused()); - QCOMPARE(pausedSpy.count(), 2); - - progress->resume(); - progress->pause(); - QVERIFY(progress->isPaused()); - QCOMPARE(pausedSpy.count(), 3); - QCOMPARE(pausedSpy.last().at(0).toBool(), true); - - progress->resume(); - QVERIFY(!progress->isPaused()); - QCOMPARE(pausedSpy.count(), 4); - QCOMPARE(pausedSpy.last().at(0).toBool(), false); -} - -void tst_QWinTaskbarProgress::testVisibility() -{ - QWinTaskbarButton btn; - QWinTaskbarProgress *progress = btn.progress(); - QVERIFY(progress); - QVERIFY(!progress->isVisible()); - - QSignalSpy visibleSpy(progress, SIGNAL(visibilityChanged(bool))); - QVERIFY(visibleSpy.isValid()); - - progress->setVisible(true); - QVERIFY(progress->isVisible()); - QCOMPARE(visibleSpy.count(), 1); - QCOMPARE(visibleSpy.last().at(0).toBool(), true); - - progress->setVisible(false); - QVERIFY(!progress->isVisible()); - QCOMPARE(visibleSpy.count(), 2); - QCOMPARE(visibleSpy.last().at(0).toBool(), false); -} - -void tst_QWinTaskbarProgress::testStop() -{ - QWinTaskbarButton btn; - QWinTaskbarProgress *progress = btn.progress(); - QVERIFY(progress); - QVERIFY(!progress->isStopped()); - - QSignalSpy stoppedSpy(progress, SIGNAL(stoppedChanged(bool))); - QVERIFY(stoppedSpy.isValid()); - - progress->pause(); - QVERIFY(progress->isPaused()); - QVERIFY(!progress->isStopped()); - progress->stop(); - QVERIFY(!progress->isPaused()); - QVERIFY(progress->isStopped()); - QCOMPARE(stoppedSpy.count(), 1); - QCOMPARE(stoppedSpy.last().at(0).toBool(), true); - - progress->resume(); - QVERIFY(!progress->isStopped()); - QCOMPARE(stoppedSpy.count(), 2); - QCOMPARE(stoppedSpy.last().at(0).toBool(), false); -} - -QTEST_MAIN(tst_QWinTaskbarProgress) - -#include "tst_qwintaskbarprogress.moc" diff --git a/tests/auto/qwinthumbnailtoolbar/CMakeLists.txt b/tests/auto/qwinthumbnailtoolbar/CMakeLists.txt deleted file mode 100644 index ec17682..0000000 --- a/tests/auto/qwinthumbnailtoolbar/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Generated from qwinthumbnailtoolbar.pro. - -##################################################################### -## tst_qwinthumbnailtoolbar Test: -##################################################################### - -qt_add_test(tst_qwinthumbnailtoolbar - SOURCES - tst_qwinthumbnailtoolbar.cpp - PUBLIC_LIBRARIES - Qt::Gui - Qt::WinExtras -) diff --git a/tests/auto/qwinthumbnailtoolbar/qwinthumbnailtoolbar.pro b/tests/auto/qwinthumbnailtoolbar/qwinthumbnailtoolbar.pro deleted file mode 100644 index 7f091f5..0000000 --- a/tests/auto/qwinthumbnailtoolbar/qwinthumbnailtoolbar.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase -TARGET = tst_qwinthumbnailtoolbar -QT += testlib winextras -SOURCES += tst_qwinthumbnailtoolbar.cpp diff --git a/tests/auto/qwinthumbnailtoolbar/tst_qwinthumbnailtoolbar.cpp b/tests/auto/qwinthumbnailtoolbar/tst_qwinthumbnailtoolbar.cpp deleted file mode 100644 index fc53a24..0000000 --- a/tests/auto/qwinthumbnailtoolbar/tst_qwinthumbnailtoolbar.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtTest/QtTest> -#include <QWinThumbnailToolBar> -#include <QWinThumbnailToolButton> - -class tst_QWinThumbnailToolBar : public QObject -{ - Q_OBJECT - -private slots: - void testWindow(); - void testButtons(); -}; - -void tst_QWinThumbnailToolBar::testWindow() -{ - QWindow window; - - QWinThumbnailToolBar tbar1; - QVERIFY(!tbar1.window()); - tbar1.setWindow(&window); - QCOMPARE(tbar1.window(), &window); - - auto *tbar2 = new QWinThumbnailToolBar(&window); - QCOMPARE(tbar2->window(), &window); - tbar2->setWindow(nullptr); - QVERIFY(!tbar2->window()); -} - -void tst_QWinThumbnailToolBar::testButtons() -{ - QWinThumbnailToolBar tbar; - QCOMPARE(tbar.count(), 0); - QVERIFY(tbar.buttons().isEmpty()); - - tbar.addButton(nullptr); - QCOMPARE(tbar.count(), 0); - QVERIFY(tbar.buttons().isEmpty()); - - auto *btn1 = new QWinThumbnailToolButton; - auto *btn2 = new QWinThumbnailToolButton; - - tbar.addButton(btn1); - QCOMPARE(tbar.count(), 1); - QCOMPARE(tbar.buttons().count(), 1); - QCOMPARE(tbar.buttons().at(0), btn1); - - tbar.addButton(btn2); - QCOMPARE(tbar.count(), 2); - QCOMPARE(tbar.buttons().count(), 2); - QCOMPARE(tbar.buttons().at(0), btn1); - QCOMPARE(tbar.buttons().at(1), btn2); - - tbar.clear(); - QCOMPARE(tbar.count(), 0); - QVERIFY(tbar.buttons().isEmpty()); - - QList<QWinThumbnailToolButton *> buttons; - for (int i = 0; i < 3; ++i) - buttons << new QWinThumbnailToolButton; - - tbar.setButtons(buttons); - QCOMPARE(tbar.count(), buttons.count()); - QCOMPARE(tbar.buttons().count(), buttons.count()); - for (int i = 0; i < buttons.count(); ++i) - QCOMPARE(tbar.buttons().at(i), buttons.at(i)); - - tbar.removeButton(buttons.at(1)); - QCOMPARE(tbar.count(), 2); - QCOMPARE(tbar.buttons().count(), 2); - QCOMPARE(tbar.buttons().at(0), buttons.at(0)); - QCOMPARE(tbar.buttons().at(1), buttons.at(2)); - - tbar.removeButton(buttons.at(2)); - QCOMPARE(tbar.count(), 1); - QCOMPARE(tbar.buttons().count(), 1); - QCOMPARE(tbar.buttons().at(0), buttons.at(0)); - - tbar.removeButton(buttons.at(0)); - QCOMPARE(tbar.count(), 0); - QVERIFY(tbar.buttons().isEmpty()); -} - -QTEST_MAIN(tst_QWinThumbnailToolBar) - -#include "tst_qwinthumbnailtoolbar.moc" |