]> cloud.milkyroute.net Git - dolphin.git/blob - src/tests/draganddrophelpertest.cpp
8166b5bf2800fa061139efad4bb3496c0bb99f31
[dolphin.git] / src / tests / draganddrophelpertest.cpp
1 /***************************************************************************
2 * Copyright (C) 2017 by Emirald Mateli <aldo.mateli@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #include <QTest>
21 #include <views/draganddrophelper.h>
22
23 class DragAndDropHelperTest : public QObject
24 {
25 Q_OBJECT
26
27 private slots:
28 void testUrlListMatchesUrl_data();
29 void testUrlListMatchesUrl();
30 };
31
32 void DragAndDropHelperTest::testUrlListMatchesUrl_data()
33 {
34 QTest::addColumn<QList<QUrl>>("urlList");
35 QTest::addColumn<QUrl>("url");
36 QTest::addColumn<bool>("expected");
37
38 QTest::newRow("test_equal")
39 << QList<QUrl> {QUrl::fromLocalFile("/root")}
40 << QUrl::fromLocalFile("/root")
41 << true;
42
43 QTest::newRow("test_trailing_slash")
44 << QList<QUrl> {QUrl::fromLocalFile("/root/")}
45 << QUrl::fromLocalFile("/root")
46 << true;
47
48 QTest::newRow("test_ftp_scheme")
49 << QList<QUrl> {QUrl("ftp://server:2211/dir")}
50 << QUrl("ftp://server:2211/dir")
51 << true;
52
53 QTest::newRow("test_not_matched")
54 << QList<QUrl> {QUrl::fromLocalFile("/usr/share"), QUrl::fromLocalFile("/usr/local/bin")}
55 << QUrl::fromLocalFile("/usr/bin")
56 << false;
57
58 QTest::newRow("test_empty_target")
59 << QList<QUrl> {QUrl::fromLocalFile("/usr/share"), QUrl::fromLocalFile("/usr/local/bin")}
60 << QUrl()
61 << false;
62
63 QTest::newRow("test_empty_list")
64 << QList<QUrl>()
65 << QUrl::fromLocalFile("/usr/bin")
66 << false;
67 }
68
69 void DragAndDropHelperTest::testUrlListMatchesUrl()
70 {
71 QFETCH(QList<QUrl>, urlList);
72 QFETCH(QUrl, url);
73 QFETCH(bool, expected);
74
75 QCOMPARE(DragAndDropHelper::urlListMatchesUrl(urlList, url), expected);
76 }
77
78
79 QTEST_MAIN(DragAndDropHelperTest)
80
81 #include "draganddrophelpertest.moc"