Changeset View
Changeset View
Standalone View
Standalone View
autotests/filesystem_entry_test.cpp
- This file was added.
1 | /*************************************************************************** | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2019 by David Hallas <david@davidhallas.dk> * | ||||
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 "filesystem_entry_test.h" | ||||
21 | #include <solid/devices/backends/fstab/filesystem_entry.h> | ||||
22 | | ||||
23 | #include <QTest> | ||||
24 | | ||||
25 | namespace Fstab = Solid::Backends::Fstab; | ||||
26 | | ||||
27 | namespace { | ||||
28 | | ||||
29 | const QLatin1Literal Device("/dev/sda1"); | ||||
30 | const QLatin1Literal MountPath("/mnt"); | ||||
31 | const QLatin1Literal Type("ext4"); | ||||
32 | const QStringList MountOptions{QLatin1Literal("ro"), QLatin1Literal("noatime")}; | ||||
33 | | ||||
34 | } // unnamed namespace | ||||
35 | | ||||
36 | void FilesystemEntryTest::testDevice() | ||||
37 | { | ||||
38 | Fstab::FilesystemEntry testObject(Device, MountPath, Type, MountOptions); | ||||
39 | QCOMPARE(Device, testObject.device()); | ||||
40 | } | ||||
41 | | ||||
42 | void FilesystemEntryTest::testMountPath() | ||||
43 | { | ||||
44 | Fstab::FilesystemEntry testObject(Device, MountPath, Type, MountOptions); | ||||
45 | QCOMPARE(MountPath, testObject.mountPath()); | ||||
46 | } | ||||
47 | | ||||
48 | void FilesystemEntryTest::testType() | ||||
49 | { | ||||
50 | Fstab::FilesystemEntry testObject(Device, MountPath, Type, MountOptions); | ||||
51 | QCOMPARE(Type, testObject.type()); | ||||
52 | } | ||||
53 | | ||||
54 | void FilesystemEntryTest::testMountOptions() | ||||
55 | { | ||||
56 | Fstab::FilesystemEntry testObject(Device, MountPath, Type, MountOptions); | ||||
57 | QCOMPARE(MountOptions, testObject.mountOptions()); | ||||
58 | } | ||||
59 | | ||||
60 | void FilesystemEntryTest::testId_data() | ||||
61 | { | ||||
62 | QTest::addColumn<QString>("device"); | ||||
63 | QTest::addColumn<QString>("mountPath"); | ||||
64 | QTest::addColumn<QString>("type"); | ||||
65 | QTest::addColumn<QString>("id"); | ||||
66 | QTest::newRow("Device as id") << QString(Device) << QString(MountPath) << QString(Type) << QString(Device); | ||||
67 | QTest::newRow("encfs") << QString(QLatin1Literal("encfs")) << QString(MountPath) | ||||
68 | << QString(QLatin1Literal("fuse.encfs")) | ||||
69 | << QLatin1Literal("encfs") + QLatin1Char('@') + MountPath; | ||||
70 | } | ||||
71 | | ||||
72 | void FilesystemEntryTest::testId() | ||||
73 | { | ||||
74 | QFETCH(QString, device); | ||||
75 | QFETCH(QString, mountPath); | ||||
76 | QFETCH(QString, type); | ||||
77 | QFETCH(QString, id); | ||||
78 | Fstab::FilesystemEntry testObject(device, mountPath, type, MountOptions); | ||||
79 | QCOMPARE(id, testObject.id()); | ||||
80 | } | ||||
81 | | ||||
82 | QTEST_MAIN(FilesystemEntryTest) |