File indexing completed on 2024-12-22 04:46:03
0001 /* 0002 SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "uploadfileprogressstatuswidgettest.h" 0008 #include "room/uploadfileprogressstatuswidget.h" 0009 #include <QHBoxLayout> 0010 #include <QLabel> 0011 #include <QProgressBar> 0012 #include <QTest> 0013 #include <QToolButton> 0014 QTEST_MAIN(UploadFileProgressStatusWidgetTest) 0015 UploadFileProgressStatusWidgetTest::UploadFileProgressStatusWidgetTest(QObject *parent) 0016 : QObject(parent) 0017 { 0018 } 0019 0020 void UploadFileProgressStatusWidgetTest::shouldHaveDefaultValues() 0021 { 0022 UploadFileProgressStatusWidget w; 0023 0024 auto hboxLayout = w.findChild<QHBoxLayout *>(QStringLiteral("hboxLayout")); 0025 QVERIFY(hboxLayout); 0026 QCOMPARE(hboxLayout->contentsMargins(), QMargins{}); 0027 0028 auto mProgressBar = w.findChild<QProgressBar *>(QStringLiteral("mProgressBar")); 0029 QVERIFY(mProgressBar); 0030 QCOMPARE(mProgressBar->minimum(), 0); 0031 QCOMPARE(mProgressBar->maximum(), 100); 0032 QCOMPARE(mProgressBar->value(), -1); 0033 0034 auto mFileName = w.findChild<QLabel *>(QStringLiteral("mFileName")); 0035 QVERIFY(mFileName); 0036 QVERIFY(mFileName->text().isEmpty()); 0037 0038 auto mCancelToolButton = w.findChild<QToolButton *>(QStringLiteral("mCancelToolButton")); 0039 QVERIFY(mCancelToolButton); 0040 QVERIFY(!mCancelToolButton->toolTip().isEmpty()); 0041 0042 QCOMPARE(w.identifier(), -1); 0043 } 0044 0045 void UploadFileProgressStatusWidgetTest::shouldChangeText() 0046 { 0047 UploadFileProgressStatusWidget w; 0048 const QString text = QStringLiteral("bla"); 0049 auto mFileName = w.findChild<QLabel *>(QStringLiteral("mFileName")); 0050 QVERIFY(mFileName->text().isEmpty()); 0051 0052 w.setUploadFileName(text); 0053 QCOMPARE(mFileName->text(), text); 0054 } 0055 0056 #include "moc_uploadfileprogressstatuswidgettest.cpp"