]> cloud.milkyroute.net Git - dolphin.git/blob - src/tests/draganddrophelpertest.cpp
Merge branch 'release/20.08' into master
[dolphin.git] / src / tests / draganddrophelpertest.cpp
1 /*
2 * SPDX-FileCopyrightText: 2017 Emirald Mateli <aldo.mateli@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #include <QTest>
8 #include <views/draganddrophelper.h>
9
10 class DragAndDropHelperTest : public QObject
11 {
12 Q_OBJECT
13
14 private slots:
15 void testUrlListMatchesUrl_data();
16 void testUrlListMatchesUrl();
17 };
18
19 void DragAndDropHelperTest::testUrlListMatchesUrl_data()
20 {
21 QTest::addColumn<QList<QUrl>>("urlList");
22 QTest::addColumn<QUrl>("url");
23 QTest::addColumn<bool>("expected");
24
25 QTest::newRow("test_equal")
26 << QList<QUrl> {QUrl::fromLocalFile("/root")}
27 << QUrl::fromLocalFile("/root")
28 << true;
29
30 QTest::newRow("test_trailing_slash")
31 << QList<QUrl> {QUrl::fromLocalFile("/root/")}
32 << QUrl::fromLocalFile("/root")
33 << true;
34
35 QTest::newRow("test_ftp_scheme")
36 << QList<QUrl> {QUrl("ftp://server:2211/dir")}
37 << QUrl("ftp://server:2211/dir")
38 << true;
39
40 QTest::newRow("test_not_matched")
41 << QList<QUrl> {QUrl::fromLocalFile("/usr/share"), QUrl::fromLocalFile("/usr/local/bin")}
42 << QUrl::fromLocalFile("/usr/bin")
43 << false;
44
45 QTest::newRow("test_empty_target")
46 << QList<QUrl> {QUrl::fromLocalFile("/usr/share"), QUrl::fromLocalFile("/usr/local/bin")}
47 << QUrl()
48 << false;
49
50 QTest::newRow("test_empty_list")
51 << QList<QUrl>()
52 << QUrl::fromLocalFile("/usr/bin")
53 << false;
54 }
55
56 void DragAndDropHelperTest::testUrlListMatchesUrl()
57 {
58 QFETCH(QList<QUrl>, urlList);
59 QFETCH(QUrl, url);
60 QFETCH(bool, expected);
61
62 QCOMPARE(DragAndDropHelper::urlListMatchesUrl(urlList, url), expected);
63 }
64
65
66 QTEST_MAIN(DragAndDropHelperTest)
67
68 #include "draganddrophelpertest.moc"