AssetDownloader: Add manual test

Task-number: QTBUG-122550
Fixes: QTBUG-126020
Pick-to: 6.8
Change-Id: Ide7c68ca46d7edd39d966f53e892bcd8b3fa88f4
Reviewed-by: Ali Kianian <ali.kianian@qt.io>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
This commit is contained in:
Jarek Kobus 2024-06-05 15:55:22 +02:00
parent 6dff842b2a
commit d0a58028da
7 changed files with 77 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,4 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(downloader)

View File

@ -0,0 +1,3 @@
TEMPLATE=subdirs
SUBDIRS = downloader

View File

@ -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
)

View File

@ -0,0 +1,5 @@
QT += examples_asset_downloader-private widgets
TARGET = tst_manual_downloader
SOURCES += main.cpp

View File

@ -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 <QtExamplesAssetDownloader/assetdownloader.h>
#include <QApplication>
#include <QMessageBox>
#include <QProgressDialog>
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();
}

View File

@ -2,6 +2,7 @@ TEMPLATE=subdirs
QT_FOR_CONFIG += network-private gui-private
SUBDIRS = \
assets \
filetest \
embeddedintoforeignwindow \
foreignwindows \