File indexing completed on 2025-05-04 05:17:09

0001 /*
0002     SPDX-FileCopyrightText: 2022 Laurent Montel <montel@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-3.0-or-later
0005 */
0006 #include "clonedialogtest.h"
0007 #include "dialogs/clonedialog.h"
0008 #include <QStandardPaths>
0009 #include <QTest>
0010 QTEST_MAIN(CloneDialogTest)
0011 CloneDialogTest::CloneDialogTest(QObject *parent)
0012     : QObject{parent}
0013 {
0014     QStandardPaths::setTestModeEnabled(true);
0015 }
0016 
0017 void CloneDialogTest::shouldHaveDefaultValues()
0018 {
0019     CloneDialog d;
0020     auto lineEditPath = d.findChild<KUrlRequester *>(QStringLiteral("lineEditPath"));
0021     QVERIFY(lineEditPath);
0022     QVERIFY(lineEditPath->text().isEmpty());
0023 
0024     auto lineEditUrl = d.findChild<QLineEdit *>(QStringLiteral("lineEditUrl"));
0025     QVERIFY(lineEditUrl);
0026     QVERIFY(lineEditUrl->text().isEmpty());
0027 }
0028 
0029 void CloneDialogTest::shouldChangePath_data()
0030 {
0031     QTest::addColumn<QString>("path");
0032     QTest::addColumn<QString>("result");
0033     QTest::addRow("empty") << QString() << QString();
0034     QTest::addRow("pathwithoutgit") << QStringLiteral("/bla/bla/bli") << QStringLiteral("/bla/bla/bli");
0035     QTest::addRow("pathwitgit") << QStringLiteral("/bla/bla/bli.git") << QStringLiteral("/bla/bla/bli.git/bli");
0036 }
0037 
0038 void CloneDialogTest::shouldChangePath()
0039 {
0040     QFETCH(QString, path);
0041     QFETCH(QString, result);
0042 
0043     CloneDialog d;
0044     auto lineEditPath = d.findChild<KUrlRequester *>(QStringLiteral("lineEditPath"));
0045 
0046     d.setLocalPath(path);
0047     QCOMPARE(lineEditPath->text(), result);
0048 }
0049 
0050 #include "moc_clonedialogtest.cpp"