File indexing completed on 2024-06-09 04:59:05
0001 /* 0002 SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "showvideowidgettest.h" 0008 #include "dialogs/showvideowidget.h" 0009 #include <KMessageWidget> 0010 #include <QLabel> 0011 #include <QPushButton> 0012 #include <QSlider> 0013 #include <QStandardPaths> 0014 #include <QTest> 0015 #include <QToolButton> 0016 #include <QVBoxLayout> 0017 #include <QVideoWidget> 0018 QTEST_MAIN(ShowVideoWidgetTest) 0019 ShowVideoWidgetTest::ShowVideoWidgetTest(QObject *parent) 0020 : QObject(parent) 0021 { 0022 QStandardPaths::setTestModeEnabled(true); 0023 } 0024 0025 void ShowVideoWidgetTest::shouldHaveDefaultValues() 0026 { 0027 ShowVideoWidget w(nullptr); 0028 auto mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainLayout")); 0029 QVERIFY(mainLayout); 0030 QCOMPARE(mainLayout->contentsMargins(), QMargins{}); 0031 0032 auto videoWidget = w.findChild<QVideoWidget *>(QStringLiteral("videoWidget")); 0033 QVERIFY(videoWidget); 0034 0035 QBoxLayout *controlLayout = w.findChild<QHBoxLayout *>(QStringLiteral("controlLayout")); 0036 QVERIFY(controlLayout); 0037 QCOMPARE(controlLayout->contentsMargins(), QMargins{}); 0038 0039 auto mPlayButton = w.findChild<QPushButton *>(QStringLiteral("mPlayButton")); 0040 QVERIFY(mPlayButton); 0041 QVERIFY(!mPlayButton->isEnabled()); 0042 0043 auto mPositionSlider = w.findChild<QSlider *>(QStringLiteral("mPositionSlider")); 0044 QVERIFY(mPositionSlider); 0045 0046 auto mMessageWidget = w.findChild<KMessageWidget *>(QStringLiteral("mMessageWidget")); 0047 QVERIFY(mMessageWidget); 0048 QVERIFY(!mMessageWidget->isCloseButtonVisible()); 0049 QVERIFY(mMessageWidget->wordWrap()); 0050 QCOMPARE(mMessageWidget->messageType(), KMessageWidget::Information); 0051 0052 auto mSoundButton = w.findChild<QToolButton *>(QStringLiteral("mSoundButton")); 0053 QVERIFY(mSoundButton); 0054 QVERIFY(mSoundButton->isCheckable()); 0055 QVERIFY(!mSoundButton->icon().isNull()); 0056 0057 auto mSoundSlider = w.findChild<QSlider *>(QStringLiteral("mSoundSlider")); 0058 QVERIFY(mSoundSlider); 0059 QCOMPARE(mSoundSlider->value(), 50); 0060 QCOMPARE(mSoundSlider->minimum(), 0); 0061 QCOMPARE(mSoundSlider->maximum(), 100); 0062 0063 auto mLabelDuration = w.findChild<QLabel *>(QStringLiteral("mLabelDuration")); 0064 QVERIFY(mLabelDuration); 0065 QVERIFY(mLabelDuration->text().isEmpty()); 0066 } 0067 0068 #include "moc_showvideowidgettest.cpp"