Changeset View
Changeset View
Standalone View
Standalone View
smb/autotests/smburltest.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | SPDX-FileCopyrightText: 2020 Harald Sitter <sitter@kde.org> | ||||
3 | SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL | ||||
4 | */ | ||||
5 | | ||||
6 | #include <QTest> | ||||
7 | #include <QAbstractItemModelTester> | ||||
8 | | ||||
9 | #include "smburl.h" | ||||
10 | | ||||
11 | class SMBUrlTest : public QObject | ||||
12 | { | ||||
13 | Q_OBJECT | ||||
14 | private Q_SLOTS: | ||||
15 | void testMinimalToSmbcValid() | ||||
16 | { | ||||
17 | // libsmbclient is a bit picky. make sure we convert to minimal applicable form | ||||
18 | { | ||||
19 | SMBUrl url(QUrl("smb:/")); | ||||
20 | QCOMPARE(url.toSmbcUrl(), "smb://"); | ||||
21 | } | ||||
22 | | ||||
23 | // But at the same time it will happily deal with smb: | ||||
24 | { | ||||
25 | SMBUrl url(QUrl("smb:")); | ||||
26 | QCOMPARE(url.toSmbcUrl(), "smb:"); | ||||
27 | } | ||||
28 | } | ||||
29 | | ||||
30 | void testType() | ||||
31 | { | ||||
32 | QCOMPARE(SMBUrl(QUrl("smb://")).getType(), SMBURLTYPE_ENTIRE_NETWORK); | ||||
33 | QCOMPARE(SMBUrl(QUrl("smb://host")).getType(), SMBURLTYPE_WORKGROUP_OR_SERVER); | ||||
34 | QCOMPARE(SMBUrl(QUrl("smb://host/share/file")).getType(), SMBURLTYPE_SHARE_OR_PATH); | ||||
35 | QCOMPARE(SMBUrl(QUrl()).getType(), SMBURLTYPE_UNKNOWN); | ||||
36 | } | ||||
37 | | ||||
38 | void testPart() | ||||
39 | { | ||||
40 | SMBUrl url(QUrl("smb://host/share/file")); | ||||
41 | QCOMPARE(url.partUrl().toString(), "smb://host/share/file.part"); | ||||
42 | } | ||||
43 | | ||||
44 | void testUp() | ||||
45 | { | ||||
46 | SMBUrl url(QUrl("smb://host/share/file")); | ||||
47 | url.cdUp(); | ||||
48 | QCOMPARE(url.toSmbcUrl(), "smb://host/share"); | ||||
49 | } | ||||
50 | | ||||
51 | void testAddPath() | ||||
52 | { | ||||
53 | SMBUrl url(QUrl("smb://host/share")); | ||||
54 | url.addPath("file"); | ||||
55 | QCOMPARE(url.toSmbcUrl(), "smb://host/share/file"); | ||||
56 | } | ||||
57 | | ||||
58 | void testCifs() | ||||
59 | { | ||||
60 | // We treat cifs as an alias but need to translate it to smb. | ||||
61 | // https://bugs.kde.org/show_bug.cgi?id=327295 | ||||
62 | SMBUrl url(QUrl("cifs://host/share/file")); | ||||
63 | QCOMPARE(url.toSmbcUrl(), "smb://host/share/file"); | ||||
64 | } | ||||
65 | }; | ||||
66 | | ||||
67 | QTEST_GUILESS_MAIN(SMBUrlTest) | ||||
68 | | ||||
69 | #include "smburltest.moc" |