File indexing completed on 2025-02-23 04:57:26

0001 /*
0002    SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "statusbarprogresswidgettest.h"
0008 #include "../progressdialog.h"
0009 #include "../progressmanager.h"
0010 #include "../statusbarprogresswidget.h"
0011 #include "progresswidget/ssllabel.h"
0012 #include <QHBoxLayout>
0013 #include <QProgressBar>
0014 #include <QPushButton>
0015 #include <QStackedWidget>
0016 #include <QStandardPaths>
0017 #include <QTest>
0018 QTEST_MAIN(StatusbarProgressWidgetTest)
0019 
0020 StatusbarProgressWidgetTest::StatusbarProgressWidgetTest(QObject *parent)
0021     : QObject(parent)
0022 {
0023     QStandardPaths::setTestModeEnabled(true);
0024 }
0025 
0026 void StatusbarProgressWidgetTest::shouldHaveDefaultValue()
0027 {
0028     auto widget = new QWidget;
0029     auto progress = new KPIM::ProgressDialog(widget, widget);
0030     KPIM::StatusbarProgressWidget w(progress, widget);
0031     auto boxLayout = w.findChild<QHBoxLayout *>(QStringLiteral("boxLayout"));
0032     QVERIFY(boxLayout);
0033     QCOMPARE(boxLayout->contentsMargins(), QMargins(0, 0, 0, 0));
0034     QCOMPARE(boxLayout->spacing(), 0);
0035 
0036     auto mButton = w.findChild<QPushButton *>(QStringLiteral("button"));
0037     QVERIFY(mButton);
0038     QVERIFY(mButton->text().isEmpty());
0039 
0040     auto mStackedWidget = w.findChild<QStackedWidget *>(QStringLiteral("stackedwidget"));
0041     QVERIFY(mStackedWidget);
0042 
0043     auto mSslLabel = w.findChild<KPIM::SSLLabel *>(QStringLiteral("ssllabel"));
0044     QVERIFY(mSslLabel);
0045 
0046     auto mProgressBar = w.findChild<QProgressBar *>(QStringLiteral("progressbar"));
0047     QVERIFY(mProgressBar);
0048 
0049     auto mLabel = w.findChild<QLabel *>(QStringLiteral("emptylabel"));
0050     QVERIFY(mLabel);
0051 }
0052 
0053 void StatusbarProgressWidgetTest::shouldShowItems()
0054 {
0055     /*
0056     QWidget *widget = new QWidget;
0057     KPIM::ProgressDialog *progress = new KPIM::ProgressDialog(widget, widget);
0058     KPIM::StatusbarProgressWidget w(progress, widget);
0059     w.show();
0060     QPushButton *mButton = w.findChild<QPushButton *>(QStringLiteral("button"));
0061 
0062     QProgressBar *mProgressBar = w.findChild<QProgressBar *>(QStringLiteral("progressbar"));
0063     QVERIFY(!mProgressBar->isVisible());
0064 
0065     KPIM::ProgressManager::createProgressItem(KPIM::ProgressManager::getUniqueID(), QStringLiteral("Title"), QString(), true);
0066     QVERIFY(mProgressBar->isVisible());
0067     */
0068 }
0069 
0070 #include "moc_statusbarprogresswidgettest.cpp"