From d0a58028daf0a33e27c1a5cfe5b8422bc6b0bc98 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 5 Jun 2024 15:55:22 +0200 Subject: [PATCH] AssetDownloader: Add manual test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-122550 Fixes: QTBUG-126020 Pick-to: 6.8 Change-Id: Ide7c68ca46d7edd39d966f53e892bcd8b3fa88f4 Reviewed-by: Ali Kianian Reviewed-by: Kai Köhne --- tests/manual/CMakeLists.txt | 1 + tests/manual/assets/CMakeLists.txt | 4 ++ tests/manual/assets/assets.pro | 3 ++ tests/manual/assets/downloader/CMakeLists.txt | 15 ++++++ tests/manual/assets/downloader/downloader.pro | 5 ++ tests/manual/assets/downloader/main.cpp | 48 +++++++++++++++++++ tests/manual/manual.pro | 1 + 7 files changed, 77 insertions(+) create mode 100644 tests/manual/assets/CMakeLists.txt create mode 100644 tests/manual/assets/assets.pro create mode 100644 tests/manual/assets/downloader/CMakeLists.txt create mode 100644 tests/manual/assets/downloader/downloader.pro create mode 100644 tests/manual/assets/downloader/main.cpp diff --git a/tests/manual/CMakeLists.txt b/tests/manual/CMakeLists.txt index f8c7ecb07f3..20475da6c49 100644 --- a/tests/manual/CMakeLists.txt +++ b/tests/manual/CMakeLists.txt @@ -6,6 +6,7 @@ if(UIKIT) return() endif() +add_subdirectory(assets) add_subdirectory(corelib) add_subdirectory(filetest) # diaglib is broken in dev due to missing diff --git a/tests/manual/assets/CMakeLists.txt b/tests/manual/assets/CMakeLists.txt new file mode 100644 index 00000000000..03643aa8537 --- /dev/null +++ b/tests/manual/assets/CMakeLists.txt @@ -0,0 +1,4 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +add_subdirectory(downloader) diff --git a/tests/manual/assets/assets.pro b/tests/manual/assets/assets.pro new file mode 100644 index 00000000000..43f09ba46e6 --- /dev/null +++ b/tests/manual/assets/assets.pro @@ -0,0 +1,3 @@ +TEMPLATE=subdirs + +SUBDIRS = downloader diff --git a/tests/manual/assets/downloader/CMakeLists.txt b/tests/manual/assets/downloader/CMakeLists.txt new file mode 100644 index 00000000000..b95161ac02d --- /dev/null +++ b/tests/manual/assets/downloader/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +##################################################################### +## tst_manual_downloader Binary: +##################################################################### + +qt_internal_add_manual_test(tst_manual_downloader + GUI + SOURCES + main.cpp + LIBRARIES + Qt::ExamplesAssetDownloaderPrivate + Qt::Widgets +) diff --git a/tests/manual/assets/downloader/downloader.pro b/tests/manual/assets/downloader/downloader.pro new file mode 100644 index 00000000000..53976c538f0 --- /dev/null +++ b/tests/manual/assets/downloader/downloader.pro @@ -0,0 +1,5 @@ +QT += examples_asset_downloader-private widgets + +TARGET = tst_manual_downloader + +SOURCES += main.cpp diff --git a/tests/manual/assets/downloader/main.cpp b/tests/manual/assets/downloader/main.cpp new file mode 100644 index 00000000000..fd1a56b1704 --- /dev/null +++ b/tests/manual/assets/downloader/main.cpp @@ -0,0 +1,48 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include + +#include +#include +#include + +using namespace Assets::Downloader; + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + app.setOrganizationName("QtProject"); + app.setApplicationName("Asset Downloader"); + + QProgressDialog progress; + progress.setAutoClose(false); + progress.setRange(0, 0); + QObject::connect(&progress, &QProgressDialog::canceled, &app, &QApplication::quit); + + AssetDownloader downloader; + downloader.setJsonFileName("car-configurator-assets-v1.json"); + downloader.setZipFileName("car-configurator-assets-v1.zip"); + downloader.setDownloadBase(QUrl("https://download.qt.io/learning/examples/")); + + QObject::connect(&downloader, &AssetDownloader::started, + &progress, &QProgressDialog::show); + QObject::connect(&downloader, &AssetDownloader::progressChanged, &progress, [&progress]( + int progressValue, int progressMaximum, const QString &progressText) { + progress.setLabelText(progressText); + progress.setMaximum(progressMaximum); + progress.setValue(progressValue); + }); + QObject::connect(&downloader, &AssetDownloader::finished, &progress, [&](bool success) { + progress.reset(); + progress.hide(); + if (success) + QMessageBox::information(nullptr, "Asset Downloader", "Download Finished Successfully."); + else + QMessageBox::warning(nullptr, "Asset Downloader", "Download Finished with an Error."); + }); + + downloader.start(); + + return app.exec(); +} diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index ef52a609522..c3bfad32e9a 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -2,6 +2,7 @@ TEMPLATE=subdirs QT_FOR_CONFIG += network-private gui-private SUBDIRS = \ +assets \ filetest \ embeddedintoforeignwindow \ foreignwindows \