~ubuntu-filemanager-dev/ubuntu-filemanager-app/trunk

« back to all changes in this revision

Viewing changes to src/plugin/folderlistmodel/smb/qsambaclient/test/testqsambasuite.h

  • Committer: Bileto Bot
  • Date: 2017-04-04 17:06:41 UTC
  • mfrom: (588.1.19 fix-desktop-file)
  • Revision ID: ci-train-bot@canonical.com-20170404170641-1p15lmx8wodlx2ut
* Rename binary file to ubuntu-filemanager-app
* Join plugin packages into the main package 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**************************************************************************
2
 
 *
3
 
 * Copyright 2014 Canonical Ltd.
4
 
 * Copyright 2014 Carlos J Mazieri <carlos.mazieri@gmail.com>
5
 
 *
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.
9
 
 *
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.
14
 
 *
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/>.
17
 
 *
18
 
 * File: testqsambasuite.h
19
 
 * Date: 03/12/2014
20
 
 */
21
 
 
22
 
#ifndef TESTQSAMBASUITE_H
23
 
#define TESTQSAMBASUITE_H
24
 
 
25
 
#include <QObject>
26
 
 
27
 
class SmbPlaces;
28
 
class QTemporaryDir;
29
 
 
30
 
//for a local share in the localhost
31
 
struct SmbSharedPathAccess
32
 
{
33
 
    QString diskPathname;  //full path name for disk access
34
 
    QString smbUrl;        //full path name for smb access
35
 
};
36
 
 
37
 
struct ShareCreationStatus
38
 
{
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
51
 
   bool    status;
52
 
   QTemporaryDir * tempDir;
53
 
private:
54
 
   ShareCreationStatus() {} // not allowed
55
 
};
56
 
 
57
 
 
58
 
 
59
 
class TestQSambaSuite : public QObject
60
 
{
61
 
    Q_OBJECT
62
 
public:
63
 
    explicit TestQSambaSuite(QObject *parent = 0);
64
 
     ~TestQSambaSuite();
65
 
 
66
 
public:
67
 
    bool     createPermanentShare(const QString& path, bool fullAccess=true);
68
 
    bool     openPermanenteShare(const QString& smb_path);
69
 
    bool     listLocalhost();
70
 
    bool     listRecursive();
71
 
    bool     existsShare(const QStringList& sharesFullPathList, const QString& shareName);
72
 
    ShareCreationStatus createTempShare(const QString& maskName, bool fullAccess = true, bool allowGuests = true);
73
 
 
74
 
private Q_SLOTS:
75
 
    void initTestCase();       //before all tests
76
 
    void cleanupTestCase();    //after all tests
77
 
    void init();               //before every test
78
 
    void cleanup();            //after every test
79
 
 
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();
92
 
 
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();
104
 
 
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();
110
 
 
111
 
private Q_SLOTS: //unit test for SmbLocationItemDirIterator class
112
 
    void unit_QDirIterator_path();
113
 
 
114
 
private Q_SLOTS:
115
 
    void positive_statvfs();
116
 
 
117
 
protected:   
118
 
    QString createTempFile(const QString& path,
119
 
                           const QString& name,
120
 
                           const QByteArray& content = QByteArray(0));   
121
 
 
122
 
private:
123
 
    SmbPlaces      *m_smbShares;
124
 
    QString        m_curShareName;
125
 
    mode_t         m_curUmask;
126
 
 
127
 
};
128
 
 
129
 
#endif // TESTQSAMBASUITE_H