File indexing completed on 2024-04-21 16:19:57

0001 /*  This file is part of the KDE libraries
0002     SPDX-FileCopyrightText: 2015 Alejandro Fiestas Olivares <afiestas@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #include "../src/platformtheme/kdirselectdialog_p.h"
0008 #include "../src/platformtheme/kfiletreeview_p.h"
0009 #include <QTest>
0010 
0011 class KDirSelectDialog_UnitTest : public QObject
0012 {
0013     Q_OBJECT
0014 private Q_SLOTS:
0015     void testSetCurrentUrl_data()
0016     {
0017         QTest::addColumn<QUrl>("url");
0018         QTest::addColumn<QUrl>("expectedUrl");
0019 
0020         QTest::newRow("only_scheme") << QUrl(QStringLiteral("trash:")) << QUrl(QStringLiteral("trash:/"));
0021         QTest::newRow("with_no_host") << QUrl(QStringLiteral("trash://")) << QUrl(QStringLiteral("trash://"));
0022         QTest::newRow("with_root_path") << QUrl(QStringLiteral("trash:///")) << QUrl(QStringLiteral("trash:///"));
0023     }
0024 
0025     void testSetCurrentUrl()
0026     {
0027         QFETCH(QUrl, url);
0028         QFETCH(QUrl, expectedUrl);
0029 
0030         KDirSelectDialog dirDialog;
0031         dirDialog.setCurrentUrl(url);
0032 
0033         QCOMPARE(dirDialog.rootUrl(), expectedUrl);
0034     }
0035 };
0036 
0037 QTEST_MAIN(KDirSelectDialog_UnitTest)
0038 
0039 #include "kdirselectdialog_unittest.moc"