1
/**************************************************************************
3
* Copyright 2014 Canonical Ltd.
4
* Copyright 2014 Carlos J Mazieri <carlos.mazieri@gmail.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published by
8
* the Free Software Foundation; version 3.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
* File: testqsambasuite.h
22
#ifndef TESTQSAMBASUITE_H
23
#define TESTQSAMBASUITE_H
30
//for a local share in the localhost
31
struct SmbSharedPathAccess
33
QString diskPathname; //full path name for disk access
34
QString smbUrl; //full path name for smb access
37
struct ShareCreationStatus
39
ShareCreationStatus(const QString& dirNameMask);
40
ShareCreationStatus(const ShareCreationStatus & o);
41
ShareCreationStatus(ShareCreationStatus & o);
42
~ShareCreationStatus();
43
ShareCreationStatus &operator=(const ShareCreationStatus & o);
44
ShareCreationStatus &operator=(ShareCreationStatus & o);
45
SmbSharedPathAccess createPathForItem(const QString& item);
46
SmbSharedPathAccess createPathForItems(const QStringList& items);
47
SmbSharedPathAccess fileContent; // a simple file is created in evey share
48
QString sharedDirPath; //share path in the localhost
49
QString shareName; //share name
50
QString url; //share url
52
QTemporaryDir * tempDir;
54
ShareCreationStatus() {} // not allowed
59
class TestQSambaSuite : public QObject
63
explicit TestQSambaSuite(QObject *parent = 0);
67
bool createPermanentShare(const QString& path, bool fullAccess=true);
68
bool openPermanenteShare(const QString& smb_path);
71
bool existsShare(const QStringList& sharesFullPathList, const QString& shareName);
72
ShareCreationStatus createTempShare(const QString& maskName, bool fullAccess = true, bool allowGuests = true);
75
void initTestCase(); //before all tests
76
void cleanupTestCase(); //after all tests
77
void init(); //before every test
78
void cleanup(); //after every test
80
private Q_SLOTS: // test cases
81
void positive_createReadOnlyUserShare();
82
void positive_createFullAccessUserShare();
83
void positive_itemInfoRoot();
84
void positive_itemInfoLocalHost();
85
void positive_itemInfoShare();
86
void positive_itemInfoCommonPermissions();
87
void positive_dirIterator();
88
void negative_itemInfo();
89
void negative_createShareDirDoesNotExist();
90
void negative_emptyItemInfo();
91
void negative_dirIterator();
93
private Q_SLOTS: //unit test for SmbLocationItemFile class
94
void unit_QFile_rename();
95
void unit_QFile_remove();
96
void unit_QFile_open();
97
void unit_QFile_read();
98
void unit_QFile_write();
99
void unit_QFile_atEnd();
100
void unit_QFile_size();
101
void unit_QFile_isOpen();
102
void unit_QFile_setPermissions();
103
void unit_QFile_permissions();
105
private Q_SLOTS: //unit test for SmbLocationItemDir class
106
void unit_QDir_exists();
107
void unit_QDir_mkdir();
108
void unit_QDir_mkpath();
109
void unit_QDir_rmdir();
111
private Q_SLOTS: //unit test for SmbLocationItemDirIterator class
112
void unit_QDirIterator_path();
115
void positive_statvfs();
118
QString createTempFile(const QString& path,
120
const QByteArray& content = QByteArray(0));
123
SmbPlaces *m_smbShares;
124
QString m_curShareName;
129
#endif // TESTQSAMBASUITE_H