← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-12 into lp:ubuntu-filemanager-app

 

Carlos Jose Mazieri has proposed merging lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-12 into lp:ubuntu-filemanager-app with lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-11 as a prerequisite.

Commit message:
 * SmbPlaces which provides shares list to used in the places
 * SmbUserShare a utility class that can be used in the UI to allow the user create/remove shares

Requested reviews:
  Ubuntu File Manager Developers (ubuntu-filemanager-dev)

For more details, see:
https://code.launchpad.net/~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-12/+merge/253129

New classes:
    * SmbPlaces which provides shares list to used in the places
    * SmbUserShare a utility class that can be used in the UI to allow the user create/remove shares
-- 
Your team Ubuntu File Manager Developers is requested to review the proposed merge of lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-12 into lp:ubuntu-filemanager-app.
=== added file 'src/plugin/folderlistmodel/smb/qsambaclient/qsambaclient_lib.pro'
--- src/plugin/folderlistmodel/smb/qsambaclient/qsambaclient_lib.pro	1970-01-01 00:00:00 +0000
+++ src/plugin/folderlistmodel/smb/qsambaclient/qsambaclient_lib.pro	2015-03-16 22:13:13 +0000
@@ -0,0 +1,1 @@
+ 

=== added file 'src/plugin/folderlistmodel/smb/qsambaclient/qsambaclient_test.pro'
--- src/plugin/folderlistmodel/smb/qsambaclient/qsambaclient_test.pro	1970-01-01 00:00:00 +0000
+++ src/plugin/folderlistmodel/smb/qsambaclient/qsambaclient_test.pro	2015-03-16 22:13:13 +0000
@@ -0,0 +1,22 @@
+
+TEMPLATE = app
+CONFIG   += console
+CONFIG   -= app_bundle
+
+DEFINES +=  REGRESSION_TEST_QSAMBACLIENT
+
+include (qsambaclient.pri)
+
+include(test/testsuite.pri)
+
+include (ubuntuFM/ubuntuFM_dependencies.pri)   
+
+##main
+SOURCES += $$PWD/test/main_testqsambaclient.cpp
+
+OTHER_FILES += \
+    TODO.txt
+
+
+
+

=== added directory 'src/plugin/folderlistmodel/smb/qsambaclient/test'
=== added file 'src/plugin/folderlistmodel/smb/qsambaclient/test/main_testqsambaclient.cpp'
--- src/plugin/folderlistmodel/smb/qsambaclient/test/main_testqsambaclient.cpp	1970-01-01 00:00:00 +0000
+++ src/plugin/folderlistmodel/smb/qsambaclient/test/main_testqsambaclient.cpp	2015-03-16 22:13:13 +0000
@@ -0,0 +1,94 @@
+/**************************************************************************
+ *
+ * Copyright 2014 Canonical Ltd.
+ * Copyright 2014 Carlos J Mazieri <carlos.mazieri@xxxxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * File: main_qsamba.cpp
+ * Date: 03/12/2014
+ */
+
+#include "testqsambasuite.h"
+
+#include <QCoreApplication>
+#include <QStringList>
+#include <QTest>
+
+int main(int argc, char *argv[])
+{
+    QCoreApplication app(argc, argv);
+    TestQSambaSuite tc;
+    QStringList args = QCoreApplication::arguments();
+    QString permanentShareToCreate;
+    QString permanentShareToOpen;
+    bool    listAll = false;
+    bool    listLocal = false;
+    int count = args.count();
+    while (count--)
+    {
+       //Ubuntu Touch parameter
+       if (args.at(count).startsWith(QLatin1String("--desktop_file_hint")))
+       {
+          args.removeAt(count);        
+       }
+       else
+       if (args.at(count).startsWith(QLatin1String("--create")) && count > 0)
+       {
+           permanentShareToCreate = args.at(count+1);
+           args.removeAt(count+1);
+           args.removeAt(count);
+       }
+       else
+       if (args.at(count).startsWith(QLatin1String("--open")) && count > 0)
+       {
+           permanentShareToOpen = args.at(count+1);
+           args.removeAt(count+1);
+           args.removeAt(count);
+       }
+       else
+       if (args.at(count).startsWith(QLatin1String("--lall")) && count > 0)
+       {
+           listAll = true;
+           args.removeAt(count);
+       }
+       else
+       if (args.at(count).startsWith(QLatin1String("--llocal")) && count > 0)
+       {
+           listLocal = true;
+           args.removeAt(count);
+       }
+    }
+
+    if (!permanentShareToOpen.isEmpty())
+    {
+        return tc.openPermanenteShare(permanentShareToOpen) ? 0 : 1;
+    }
+    if (!permanentShareToCreate.isEmpty())
+    {
+        return  tc.createPermanentShare(permanentShareToCreate) ? 0 : 1;
+    }
+    if (listAll)
+    {
+       return tc.listRecursive();
+    }
+    if (listLocal)
+    {
+        return tc.listLocalhost();
+    }
+
+    return  QTest::qExec(&tc, args);
+}
+
+
+

=== added file 'src/plugin/folderlistmodel/smb/qsambaclient/test/testqsambasuite.cpp'
--- src/plugin/folderlistmodel/smb/qsambaclient/test/testqsambasuite.cpp	1970-01-01 00:00:00 +0000
+++ src/plugin/folderlistmodel/smb/qsambaclient/test/testqsambasuite.cpp	2015-03-16 22:13:13 +0000
@@ -0,0 +1,701 @@
+/**************************************************************************
+ *
+ * Copyright 2014 Canonical Ltd.
+ * Copyright 2014 Carlos J Mazieri <carlos.mazieri@xxxxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * File: testqsambasuite.cpp
+ * Date: 03/12/2014
+ */
+
+#include "testqsambasuite.h"
+#include "smbusershare.h"
+#include "smbiteminfo.h"
+#include "smbplaces.h"
+#include "locationurl.h"
+#include "smbutil.h"
+#include "smblocationdiriterator.h"
+#include <sys/stat.h>
+
+#include <QTest>
+#include <QFile>
+#include <QTemporaryDir>
+#include <QFileInfo>
+#include <QDebug>
+
+
+#define RETURN_SHARE_STATUS_WHEN_FALSE(x,y) if (! (x == y) ) { \
+                                             qDebug() << "ERROR:" << Q_FUNC_INFO << "line:" << __LINE__ << "compare failed"; \
+                                             return ret; \
+                                            }
+
+ShareCreationStatus::ShareCreationStatus(const QString& dirNameMask) :
+  status(false),
+  tempDir(new QTemporaryDir(QDir::tempPath() + QDir::separator() + dirNameMask))
+{
+   sharedDirPath = tempDir->path();
+}
+
+ShareCreationStatus::ShareCreationStatus(const ShareCreationStatus & o)
+{  
+    *this = o;
+}
+
+
+ShareCreationStatus::~ShareCreationStatus()
+{
+    if (tempDir)
+    {
+        delete tempDir;
+    }
+}
+
+ShareCreationStatus &
+ShareCreationStatus::operator=(const ShareCreationStatus & o)
+{
+    ShareCreationStatus *other = const_cast<ShareCreationStatus*> (&o);
+    *this = *other;
+    return *this;
+}
+
+ShareCreationStatus &
+ShareCreationStatus::operator=(ShareCreationStatus & o)
+{
+
+    sharedDirPath  = o.sharedDirPath;
+    shareName      = o.shareName;
+    fileContent    = o.fileContent;
+    status         = o.status;
+    tempDir        = o.tempDir;
+    url            = o.url;
+    if (tempDir)
+    {
+      tempDir->setAutoRemove(true);
+    }
+    o.tempDir      = 0;
+    return *this;
+}
+
+
+TestQSambaSuite::TestQSambaSuite(QObject *parent) :
+    QObject(parent)
+   ,m_smbShares( new SmbPlaces() )
+{
+}
+
+
+TestQSambaSuite::~TestQSambaSuite()
+{
+    delete m_smbShares;
+}
+
+
+void TestQSambaSuite::initTestCase()
+{   
+    QCOMPARE(SmbUserShare::canCreateShares(), true);
+}
+
+
+void TestQSambaSuite::cleanupTestCase()
+{
+
+}
+
+
+void TestQSambaSuite::init()
+{
+    m_curShareName.clear();
+}
+
+/*!
+ * \brief TestQSambaSuite::cleanup()
+ *
+ *  It is called after every test case, removes the shared indicated by m_curShareName
+ *    and checks if it was removed
+ *
+ */
+void TestQSambaSuite::cleanup()
+{
+    if (!m_curShareName.isEmpty())
+    {
+        SmbUserShare::removeShare(m_curShareName);
+        SmbUserShare::UserShareFile share = SmbUserShare::search(m_curShareName);
+        QCOMPARE(share.exists() , false);
+    }
+}
+
+// ============== utils
+
+/*!
+ * \brief TestQSambaSuite::createTempFile() creates a file \a name  inside \a path
+ * \param path
+ * \param name
+ * \param content some content or nothing
+ *
+ * \return fullpath of the file if it was able to create
+ */
+QString TestQSambaSuite::createTempFile(const QString &path,
+                                        const QString &name,
+                                        const QByteArray &content)
+
+{
+    QString ret;
+    QFile f( path + QDir::separator() + name );
+    if (f.open(QFile::WriteOnly))
+    {
+        if (f.write(content) == content.size())
+        {
+            ret = f.fileName();
+        }
+        f.close();
+    }
+    return ret;
+}
+
+
+/*!
+ * \brief TestQSambaSuite::existShare(0 checks is share name exist in a such list of shares
+ * \param sharesFullPathList someting like ("smb://localhost/samba-devel", "smb://localhost/mac-devel")
+ * \param shareName          e.g. "samba-devel"
+ * \return true if exists
+ */
+bool TestQSambaSuite::existsShare(const QStringList& sharesFullPathList, const QString &shareName)
+{
+    bool ret = false;
+    int counter = sharesFullPathList.count();
+    while (counter--)
+    {
+        if (sharesFullPathList.at(counter).contains(shareName))
+        {
+            ret = true;
+            break;
+        }
+    }
+    return ret;
+}
+
+
+ShareCreationStatus TestQSambaSuite::createTempShare(const QString &maskName,
+                                                     bool fullAccess,
+                                                     bool allowGuests)
+{
+
+    ShareCreationStatus ret(maskName);
+    QTemporaryDir * shareDir = ret.tempDir;
+    RETURN_SHARE_STATUS_WHEN_FALSE(shareDir->isValid(),   true);
+
+    m_curShareName = QFileInfo(shareDir->path()).fileName();
+
+    //put some content in it
+    QString filename = createTempFile(shareDir->path(), "somecontent.txt", "hello Samba");
+    RETURN_SHARE_STATUS_WHEN_FALSE(filename.isEmpty(),    false);
+
+    ret.fileContent = filename;
+
+    //save current samba shares list
+    QStringList currentShares = m_smbShares->listPlacesSync();
+
+    //get the supposed share name that is going to be created
+    QString     shareDirName  = SmbUserShare::proposedName(shareDir->path());
+    ret.shareName = shareDirName;
+
+    //make sure shareDirName does not exist in the current samba share list
+    RETURN_SHARE_STATUS_WHEN_FALSE(shareDirName.isEmpty(),  false);
+    RETURN_SHARE_STATUS_WHEN_FALSE(shareDirName,  m_curShareName);
+    bool exists = existsShare(currentShares,shareDirName);
+    RETURN_SHARE_STATUS_WHEN_FALSE(exists, false);
+
+    //create the share
+    bool created = SmbUserShare::createShareForFolder(shareDir->path(),
+                                                      fullAccess ? SmbUserShare::ReadWrite : SmbUserShare::Readonly,
+                                                      allowGuests);
+    RETURN_SHARE_STATUS_WHEN_FALSE(created,   true);
+
+    // now make sure the new share is created
+    QStringList moreOneShare =  m_smbShares->listPlacesSync();
+    exists = existsShare(moreOneShare, shareDirName);
+    RETURN_SHARE_STATUS_WHEN_FALSE(exists,   true);
+
+    //everything is OK
+    ret.status = true;
+
+    //let the share be removed by its path instead of the name
+    m_curShareName = shareDir->path();
+    ret.url = LocationUrl::SmbURL + "localhost/" + ret.shareName;
+
+    //remove this
+    //=============================================================
+    m_curShareName.clear();
+
+    return ret;
+}
+
+
+//================ test  cases==================
+void TestQSambaSuite::positive_createReadOnlyUserShare()
+{
+    //create a directory to share its content
+    QTemporaryDir shareDir (QDir::tempPath() + QDir::separator() + "positive_createReadOnlyUserShare");
+    m_curShareName = QFileInfo(shareDir.path()).fileName();
+    QCOMPARE(shareDir.isValid(),   true);
+
+    //put some content in it
+    QString filename = createTempFile(shareDir.path(), "sometext.xt", "hello Samba");
+    QCOMPARE(filename.isEmpty(),    false);
+
+    //save current samba shares list
+    QStringList currentShares = m_smbShares->listPlacesSync();
+    qDebug() << "currentShares:" << currentShares;
+
+    //get the supposed share name that is going to be created
+    QString     shareDirName  = SmbUserShare::proposedName(shareDir.path());
+
+    //make sure shareDirName does not exist in the current samba share list
+    QCOMPARE(shareDirName.isEmpty(),  false);
+    QCOMPARE(shareDirName,  m_curShareName);
+    bool exists = existsShare(currentShares,shareDirName);
+    QCOMPARE(exists, false);
+
+    //create the share
+    bool created = SmbUserShare::createShareForFolder(shareDir.path());
+    QCOMPARE(created,   true);
+
+    // now make sure the new share is created
+    QStringList moreOneShare =  m_smbShares->listPlacesSync();
+    exists = existsShare(moreOneShare, shareDirName);
+    qDebug() << "moreOneShare:" << moreOneShare;
+    QCOMPARE(exists,   true);
+
+    //using share name
+    SmbUserShare::Access  readAccess = SmbUserShare::getEveryoneAccess(m_curShareName);
+    bool isReadOnlyAccess = readAccess == SmbUserShare::Readonly;
+    QCOMPARE(isReadOnlyAccess,   true);
+}
+
+
+
+void TestQSambaSuite::positive_createFullAccessUserShare()
+{
+    //create a directory to share its content
+    QTemporaryDir shareDir (QDir::tempPath() + QDir::separator() + "positive_createFullAccessUserShare");
+    m_curShareName = QFileInfo(shareDir.path()).fileName();
+    QCOMPARE(shareDir.isValid(),   true);
+
+    //put some content in it
+    QString filename = createTempFile(shareDir.path(), "sometext.xt", "hello Samba");
+    QCOMPARE(filename.isEmpty(),    false);
+
+    //save current samba shares list
+    QStringList currentShares = m_smbShares->listPlacesSync();
+    qDebug() << "currentShares:" << currentShares;
+
+    //get the supposed share name that is going to be created
+    QString     shareDirName  = SmbUserShare::proposedName(shareDir.path());
+
+    //make sure shareDirName does not exist in the current samba share list
+    QCOMPARE(shareDirName.isEmpty(),  false);
+    QCOMPARE(shareDirName,  m_curShareName);
+    bool exists = existsShare(currentShares,shareDirName);
+    QCOMPARE(exists, false);
+
+    //create the share
+    bool created = SmbUserShare::createShareForFolder(shareDir.path(), SmbUserShare::ReadWrite);
+    QCOMPARE(created,   true);
+
+    // now make sure the new share is created
+    QStringList moreOneShare =  m_smbShares->listPlacesSync();
+    exists = existsShare(moreOneShare, shareDirName);
+    qDebug() << "moreOneShare:" << moreOneShare;
+    QCOMPARE(exists,   true);
+
+    //using dir full path
+    SmbUserShare::Access  readWrite = SmbUserShare::getEveryoneAccess(shareDir.path());
+    bool isReadOnlyAccess = readWrite == SmbUserShare::ReadWrite;
+    QCOMPARE(isReadOnlyAccess,   true);
+
+    //let the share be removed by its path instead of the name
+    m_curShareName = shareDir.path();
+}
+
+
+void TestQSambaSuite::positive_itemInfoRoot()
+{
+    SmbItemInfo root(LocationUrl::SmbURL);
+    QCOMPARE(root.isLocal() , false);
+    QCOMPARE(root.isHost(),   false);
+    QCOMPARE(root.exists(),   true);
+    QCOMPARE(root.isRelative(),false);
+    QCOMPARE(root.isAbsolute(), true);
+    QCOMPARE(root.isRoot(), true);
+    QCOMPARE(root.isSharedDir(), false);
+    QCOMPARE(root.isHost(),   false);
+    QCOMPARE(root.isWorkGroup(), false);
+    QCOMPARE(root.isShare(), false);
+    QCOMPARE(root.absoluteFilePath(), LocationUrl::SmbURL);
+    QCOMPARE(root.fileName().isEmpty(),  true);
+    QCOMPARE(root.absolutePath(),  LocationUrl::SmbURL);
+    QCOMPARE(root.sharePath().isEmpty(),  true);
+}
+
+
+void TestQSambaSuite::positive_itemInfoLocalHost()
+{
+    SmbItemInfo localhost(LocationUrl::SmbURL + "localhost");
+    QCOMPARE(localhost.isLocal() , false);
+    QCOMPARE(localhost.isHost(),   true);
+    QCOMPARE(localhost.exists(),   true);
+    QCOMPARE(localhost.isRelative(),false);
+    QCOMPARE(localhost.isAbsolute(), true);
+    QCOMPARE(localhost.isRoot(),   false);
+    QCOMPARE(localhost.isSharedDir(), false);
+    QCOMPARE(localhost.isWorkGroup(), false);
+    QCOMPARE(localhost.isShare(), false);
+    QCOMPARE(localhost.path(), LocationUrl::SmbURL);
+    QCOMPARE(localhost.filePath(), LocationUrl::SmbURL + "localhost");
+    QCOMPARE(localhost.absoluteFilePath(), LocationUrl::SmbURL + "localhost");
+    //for hosts sharePath() are the hostitself
+    QCOMPARE(localhost.sharePath(), localhost.absoluteFilePath());
+}
+
+
+void TestQSambaSuite::positive_itemInfoShare()
+{
+    ShareCreationStatus share(createTempShare("positive_itemInfoShare"));
+    if (share.tempDir)
+    {
+        share.tempDir->setAutoRemove(true);
+    }
+    QCOMPARE(share.status, true);
+    QFileInfo file(share.fileContent);
+    QCOMPARE(file.exists(),   true);
+
+    QString urlPath("smb://localhost/" + share.shareName);
+    //basic share/dir information
+    SmbItemInfo dirinfo(urlPath);
+    QCOMPARE(dirinfo.isLocal() , false);
+    QCOMPARE(dirinfo.isHost(),   false);
+    QCOMPARE(dirinfo.exists(),   true);
+    QCOMPARE(dirinfo.isRelative(),false);
+    QCOMPARE(dirinfo.isAbsolute(), true);
+    QCOMPARE(dirinfo.isDir(),    true);   // shares also are directories
+    QCOMPARE(dirinfo.isFile(),   false);
+    QCOMPARE(dirinfo.isReadable(), true);
+    QCOMPARE(dirinfo.isWritable(), true);
+    QCOMPARE(dirinfo.isExecutable(), true);
+    QCOMPARE(dirinfo.isSelected(), false);
+    QCOMPARE(dirinfo.isSharedDir(), false);
+    QCOMPARE(dirinfo.isRoot(), false);
+    QCOMPARE(dirinfo.isHost(),   false);
+    QCOMPARE(dirinfo.isWorkGroup(), false);
+    QCOMPARE(dirinfo.isShare(), true);
+    QCOMPARE(dirinfo.sharePath(), dirinfo.absoluteFilePath());
+}
+
+void TestQSambaSuite::positive_itemInfoCommonPermissions()
+{
+    ShareCreationStatus share(createTempShare("iteminfoCommonPermission"));
+    if (share.tempDir)
+    {
+        share.tempDir->setAutoRemove(true);
+    }
+    QCOMPARE(share.status, true);
+    QFileInfo file(share.fileContent);
+    QCOMPARE(file.exists(),   true);
+
+    //set a common permission to the file
+    QFile::Permissions  myPermissions = QFile::ReadOwner | QFile::WriteOwner |
+                                        QFile::ReadGroup | QFile::ReadOther;
+    QCOMPARE(QFile::setPermissions(share.fileContent, myPermissions), true);
+
+    QString urlPath("smb://localhost/" + share.shareName);
+    QString url(urlPath + QDir::separator() + file.fileName());
+    //basic file information from share
+    SmbItemInfo fileinfo(url);
+    QCOMPARE(fileinfo.isLocal() , false);
+    QCOMPARE(fileinfo.isHost(),   false);
+    QCOMPARE(fileinfo.exists(),   true);
+    QCOMPARE(fileinfo.isRelative(),false);
+    QCOMPARE(fileinfo.isAbsolute(), true);
+    QCOMPARE(fileinfo.isDir(),    false);
+    QCOMPARE(fileinfo.isFile(),   true);
+    QCOMPARE(fileinfo.isReadable(), true);
+    QCOMPARE(fileinfo.isWritable(), true);
+    QCOMPARE(fileinfo.isExecutable(), false);
+    QCOMPARE(fileinfo.isSelected(), false);
+    QCOMPARE(fileinfo.isSharedDir(), false);
+    QCOMPARE(fileinfo.isRoot(), false);
+    QCOMPARE(fileinfo.isRemote(), true);
+    QCOMPARE(fileinfo.isSymLink(), false);
+    QCOMPARE(fileinfo.absolutePath(), urlPath);
+    QCOMPARE(fileinfo.filePath(), url);
+    QCOMPARE(fileinfo.fileName(), file.fileName());
+    QCOMPARE(fileinfo.absoluteFilePath(), url);
+    QCOMPARE(fileinfo.permissions(), myPermissions);
+    QCOMPARE(fileinfo.sharePath(),  urlPath);
+}
+
+
+void TestQSambaSuite::negative_emptyItemInfo()
+{
+    SmbItemInfo notSmb;
+    QCOMPARE(notSmb.isValid(),  false);
+    QCOMPARE(notSmb.exists(),   false);
+    QCOMPARE(notSmb.isHost(),   false);
+}
+
+
+void TestQSambaSuite::negative_itemInfo()
+{
+    SmbItemInfo notSmb("test://localhost");
+    QCOMPARE(notSmb.isValid(),  false);
+    QCOMPARE(notSmb.exists(),   false);
+
+    SmbItemInfo notHost("smb://__this_host_must_not_exist_");
+    QCOMPARE(notHost.isValid(),  true);
+    QCOMPARE(notHost.exists(),   false);
+
+    SmbItemInfo notShare("smb://localhost/__this_share_must_not_exist_");
+    QCOMPARE(notShare.isValid(),  true);
+    QCOMPARE(notShare.exists(),   false);
+
+    SmbPlaces  shares;
+    QStringList existentShares = shares.listPlacesSync();
+    if (existentShares.count() > 0)
+    {
+        SmbItemInfo parent(existentShares.at(0));
+        QCOMPARE(parent.isValid(),  true);
+        QCOMPARE(parent.exists(),   true);
+        // it may not have permission to access
+        if (parent.isReadable())
+        {
+            QCOMPARE(parent.isShare(),  true);
+            SmbItemInfo dir(existentShares.at(0) +
+                            QDir::separator() +
+                            "__this_dir_must_not_exist_");
+            QCOMPARE(dir.isValid(),  true);
+            QCOMPARE(dir.exists(),   false);
+        }
+    }
+}
+
+void TestQSambaSuite::negative_createShareDirDoesNotExist()
+{
+   QDir d(QDir::homePath() + "___2323_hope_this_does_not_exist_");
+   while (d.exists())
+   {
+       d.setPath(d.path() + QChar('1'));
+   }
+
+   bool ret = SmbUserShare::createShareForFolder(d.path());
+
+   QCOMPARE(ret,  false);
+}
+
+
+void TestQSambaSuite::negative_dirIterator()
+{
+    SmbLocationDirIterator iterator1("Nome");
+    QCOMPARE(iterator1.hasNext() , false);
+
+    SmbLocationDirIterator iterator2("smb://localhost/_IT_MUST_NOT_EXIST_I_HOPE_");
+    QCOMPARE(iterator2.hasNext() , false);
+}
+
+
+void TestQSambaSuite::positive_dirIterator()
+{
+    ShareCreationStatus share(createTempShare("positive_dirIterator"));
+    if (share.tempDir)
+    {
+        share.tempDir->setAutoRemove(true);
+    }
+    QCOMPARE(share.status, true);
+    QFileInfo file(share.fileContent);
+    QCOMPARE(file.exists(),   true);
+
+    //create a second directory inside the temporary share
+    QString secondDirStr("secondDir");
+    QString secondElementPath = share.sharedDirPath + QDir::separator() + secondDirStr;
+    QCOMPARE(QDir().mkpath(secondElementPath),  true);
+
+    //create a file inside secondElementPath
+    QString secondElementContent(secondElementPath + QDir::separator() + "test.readme");
+    QFile f(secondElementContent);
+    QCOMPARE(f.open(QFile::WriteOnly), true);
+    f.close();
+
+    //recursive 3 items
+    int counter;
+    SmbLocationDirIterator tree(share.url, QDir::AllEntries, QDirIterator::Subdirectories);
+    for(counter=0; tree.hasNext() ; ++counter)
+    {
+        tree.next();
+    }
+    QCOMPARE(counter,  3);
+
+    //using a mask
+    QStringList nameFilter = QStringList() << "*.readme";
+    SmbLocationDirIterator  onlyReadme(share.url, nameFilter,QDir::AllEntries, QDirIterator::Subdirectories);
+    for(counter=0; onlyReadme.hasNext() ; ++counter)
+    {
+        onlyReadme.next();
+    }
+    QCOMPARE(counter,  1);
+
+    //2 items
+    SmbLocationDirIterator lowLevelIterator(share.url);   
+    for(counter=0; lowLevelIterator.hasNext() ; ++counter)
+    {
+        lowLevelIterator.next();
+    }
+    QCOMPARE(counter,  2);
+
+    //2 more "." and "."
+    SmbLocationDirIterator lowLevelIterator2(share.url,QDir::AllEntries | QDir::Hidden);
+    for(counter=0; lowLevelIterator2.hasNext() ; ++counter)
+    {
+        lowLevelIterator2.next();
+    }
+    QCOMPARE(counter,  4);
+
+    //2 more ".."
+    bool dotdot = false;
+    SmbLocationDirIterator lowLevelIterator3(share.url,QDir::AllEntries | QDir::Hidden | QDir::NoDot);
+    for(counter=0; lowLevelIterator3.hasNext() ; ++counter)
+    {      
+        lowLevelIterator3.next();
+        if (lowLevelIterator3.fileName() == "..")
+        {
+            dotdot = true;
+        }
+    }
+    QCOMPARE(counter,  3);
+    QCOMPARE(dotdot, true);
+
+     //2 more "."
+    bool dot = false;
+    SmbLocationDirIterator lowLevelIterator4(share.url,QDir::AllEntries | QDir::Hidden | QDir::NoDotDot);
+    for(counter=0; lowLevelIterator4.hasNext() ; ++counter)
+    {
+        lowLevelIterator4.next();
+        if (lowLevelIterator4.fileName() == ".")
+        {
+            dot = true;
+        }
+    }
+    QCOMPARE(counter,  3);
+    QCOMPARE(dot, true);
+
+    bool secondDir = false;
+    SmbLocationDirIterator dirOnly(share.url,QDir::Dirs | QDir::NoDotAndDotDot);
+    for(counter=0; dirOnly.hasNext() ; ++counter)
+    {
+        dirOnly.next();
+        if (dirOnly.fileName() == secondDirStr)
+        {
+            secondDir = true;
+        }
+    }
+    QCOMPARE(counter,  1);
+    QCOMPARE(secondDir, true);
+
+    bool fileContent = false;
+    SmbLocationDirIterator fileOnly(share.url,QDir::Files);
+    for(counter=0; fileOnly.hasNext() ; ++counter)
+    {
+        fileOnly.next();
+        if (fileOnly.fileName() == QFileInfo(share.fileContent).fileName())
+        {
+            fileContent = true;
+        }
+    }
+    QCOMPARE(counter,  1);
+    QCOMPARE(fileContent, true);
+
+
+}
+
+
+/*!
+ * This is not a test case
+ *
+ * It intends to create a real user share in the local host
+ */
+bool TestQSambaSuite::createPermanentShare(const QString &path, bool fullAccess)
+{
+    SmbUserShare::Access access =  fullAccess ?  SmbUserShare::ReadWrite
+                                              :  SmbUserShare::Readonly;
+    SmbUserShare::createShareForFolder(path, access);
+    SmbUserShare::UserShareFile ret = SmbUserShare::search(path);
+    return ret.exists();
+}
+
+
+/*!
+ * \brief TestQSambaSuite::openPermanenteShare()
+ *
+ *  It is not a test case, just shows some information about an URL
+ *
+ * \param smb_path
+ * \return
+ */
+bool TestQSambaSuite::openPermanenteShare(const QString &smb_path)
+{
+    SmbUtil smb;  
+    struct stat st;
+    bool ok = smb.getStatInfo(smb_path, &st) != -1;
+    qDebug() << st.st_mode
+             << st.st_size
+             << st.st_rdev
+             << st.st_mtime
+             << st.st_uid
+             << st.st_blocks
+             << st.st_ino
+             ;
+    return ok;
+}
+
+/*!
+ * \brief TestQSambaSuite::listLocalhost()
+ *
+ *  It is not a test case
+ */
+bool TestQSambaSuite::listLocalhost()
+{   
+    QString smb_path("smb://localhost");  
+    SmbLocationDirIterator listIterator(smb_path);
+    QStringList shares;
+    while (listIterator.hasNext())
+    {
+        shares.append(listIterator.next());
+    }
+    qDebug() << shares;
+    return shares.count() > 0 ? true : false;
+}
+
+
+bool TestQSambaSuite::listRecursive()
+{
+    SmbUtil smb;
+    QStringList all = smb.listContent(LocationUrl::SmbURL, true);
+    if (all.count() == 0)
+    {
+        return false;
+    }
+    for (int counter=0 ; counter < all.count(); ++ counter)
+    {
+        qDebug() << all.at(counter);
+    }
+    return true;
+}

=== added file 'src/plugin/folderlistmodel/smb/qsambaclient/test/testqsambasuite.h'
--- src/plugin/folderlistmodel/smb/qsambaclient/test/testqsambasuite.h	1970-01-01 00:00:00 +0000
+++ src/plugin/folderlistmodel/smb/qsambaclient/test/testqsambasuite.h	2015-03-16 22:13:13 +0000
@@ -0,0 +1,96 @@
+/**************************************************************************
+ *
+ * Copyright 2014 Canonical Ltd.
+ * Copyright 2014 Carlos J Mazieri <carlos.mazieri@xxxxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * File: testqsambasuite.h
+ * Date: 03/12/2014
+ */
+
+#ifndef TESTQSAMBASUITE_H
+#define TESTQSAMBASUITE_H
+
+#include <QObject>
+
+class SmbPlaces;
+class QTemporaryDir;
+
+struct ShareCreationStatus
+{
+   ShareCreationStatus(const QString& dirNameMask);
+   ShareCreationStatus(const ShareCreationStatus & o);
+   ShareCreationStatus(ShareCreationStatus & o);
+   ~ShareCreationStatus();
+   ShareCreationStatus &operator=(const ShareCreationStatus & o);
+   ShareCreationStatus &operator=(ShareCreationStatus & o);
+   QString sharedDirPath;
+   QString shareName;
+   QString fileContent;
+   QString url;
+   bool    status;
+   QTemporaryDir * tempDir;
+private:
+   ShareCreationStatus() {} // not allowed
+};
+
+
+
+class TestQSambaSuite : public QObject
+{
+    Q_OBJECT
+public:
+    explicit TestQSambaSuite(QObject *parent = 0);
+     ~TestQSambaSuite();
+
+public:
+    bool     createPermanentShare(const QString& path, bool fullAccess=true);
+    bool     openPermanenteShare(const QString& smb_path);
+    bool     listLocalhost();
+    bool     listRecursive();
+    bool     existsShare(const QStringList& sharesFullPathList, const QString& shareName);
+    ShareCreationStatus createTempShare(const QString& maskName, bool fullAccess = true, bool allowGuests = true);
+
+private Q_SLOTS:
+    void initTestCase();       //before all tests
+    void cleanupTestCase();    //after all tests
+    void init();               //before every test
+    void cleanup();            //after every test
+
+private Q_SLOTS: // test cases
+    void positive_createReadOnlyUserShare();
+    void positive_createFullAccessUserShare();
+    void positive_itemInfoRoot();
+    void positive_itemInfoLocalHost();
+    void positive_itemInfoShare();
+    void positive_itemInfoCommonPermissions();
+    void positive_dirIterator();
+    void negative_itemInfo();
+    void negative_createShareDirDoesNotExist();
+    void negative_emptyItemInfo();
+    void negative_dirIterator();
+
+
+protected:   
+    QString createTempFile(const QString& path,
+                           const QString& name,
+                           const QByteArray& content = QByteArray(0));   
+
+private:
+    SmbPlaces      *m_smbShares;
+    QString        m_curShareName;
+
+};
+
+#endif // TESTQSAMBASUITE_H

=== added file 'src/plugin/folderlistmodel/smb/qsambaclient/test/testsuite.pri'
--- src/plugin/folderlistmodel/smb/qsambaclient/test/testsuite.pri	1970-01-01 00:00:00 +0000
+++ src/plugin/folderlistmodel/smb/qsambaclient/test/testsuite.pri	2015-03-16 22:13:13 +0000
@@ -0,0 +1,9 @@
+QT       *= testlib
+TEMPLATE  = app
+CONFIG   *= test
+
+## this suite can be included in any Test Case main file
+SOURCES += $$PWD/testqsambasuite.cpp
+HEADERS += $$PWD/testqsambasuite.h
+
+INCLUDEPATH += $$PWD

=== modified file 'src/plugin/test_folderlistmodel/regression/regression_folderlilstmodel.pro'
--- src/plugin/test_folderlistmodel/regression/regression_folderlilstmodel.pro	2013-10-12 19:25:17 +0000
+++ src/plugin/test_folderlistmodel/regression/regression_folderlilstmodel.pro	2015-03-16 22:13:13 +0000
@@ -16,6 +16,8 @@
 
 include (../../folderlistmodel/folderlistmodel.pri)
 
+include (../../folderlistmodel/smb/qsambaclient/test/testsuite.pri)
+
 HEADERS += \
     tempfiles.h
 

=== modified file 'src/plugin/test_folderlistmodel/regression/tempfiles.cpp'
--- src/plugin/test_folderlistmodel/regression/tempfiles.cpp	2013-07-25 18:07:31 +0000
+++ src/plugin/test_folderlistmodel/regression/tempfiles.cpp	2015-03-16 22:13:13 +0000
@@ -109,9 +109,9 @@
     QString myName;
     while(counter--)
     {
-        myName.sprintf("%s%c%s_%02d", m_dir.toLatin1().constData(),
+        myName.sprintf("%s%c%s_%02d", m_dir.toLocal8Bit().constData(),
                        QDir::separator().toLatin1(),
-                       name.toLatin1().constData(),
+                       name.toLocal8Bit().constData(),
                        counter);
         QFile file(myName);
         if (file.open(QFile::WriteOnly))
@@ -199,7 +199,7 @@
     if (!root.isEmpty() && QFileInfo(root).exists())
     {
         QString cmd("/bin/rm -rf " + root);
-        ret = ::system(cmd.toLatin1().constData()) == 0 ;
+        ret = ::system(cmd.toLocal8Bit().constData()) == 0 ;
     }
     return ret;
 }

=== modified file 'src/plugin/test_folderlistmodel/regression/tst_folderlistmodel.cpp'
--- src/plugin/test_folderlistmodel/regression/tst_folderlistmodel.cpp	2014-12-30 18:23:15 +0000
+++ src/plugin/test_folderlistmodel/regression/tst_folderlistmodel.cpp	2015-03-16 22:13:13 +0000
@@ -9,6 +9,9 @@
 #include "locationsfactory.h"
 #include "disklocation.h"
 #include "qtrashutilinfo.h"
+#include "smbiteminfo.h"
+#include "testqsambasuite.h"
+#include "smbusershare.h"
 
 #if defined(Q_OS_UNIX)
 #include <stdio.h>
@@ -108,7 +111,6 @@
     void  modelCutManyItemsPasteIntoAnotherModel();
     void  fsActionMoveItemsForcingCopyAndThenRemove();
     void  modelCancelRemoveAction();
-    void  modelCancelRemoveSelection();
     void  modelTestFileSize();
     void  modelRemoveDirWithHiddenFilesAndLinks();
     void  modelCancelCopyAction();
@@ -119,6 +121,12 @@
     void  modelCutAndPaste3Times();
     void  modelCutAndPasteInTheSamePlace();
     void  modelCopyAndPasteToBackupFiles();
+    void  diskCdIntoPathRelative();
+    void  diskCdIntoPathAbsolute();
+    void  trashCdIntoPathRelative();
+    void  trashCdIntoPathAbsolute();
+    void  smbCdIntoPathRelative();
+    void  smbCdIntoPathAbsolute();
     void  fileIconProvider();
     void  getThemeIcons();
 #ifndef DO_NOT_USE_TAG_LIB
@@ -200,7 +208,6 @@
     int            m_extFSWatcherPathModifiedCounter;
     int            m_selectedItemsCounter;
     int            m_selectionMode;
-    int            m_minimumProgressToCancelAction;
 
 };
 
@@ -347,12 +354,11 @@
 }
 
 void TestDirModel::cancel(int index, int, int percent)
-{   
-    Q_UNUSED(index);
-    if (percent > m_minimumProgressToCancelAction)
+{
+    DirModel * model = static_cast<DirModel*> (sender());
+    if (index > 1 ||  percent > 1)
     {
-        DirModel * model = static_cast<DirModel*> (sender());
-        model->cancelAction();
+         model->cancelAction();
     }
 }
 
@@ -456,7 +462,6 @@
    m_extFSWatcherPathModifiedCounter = 0;
    m_selectedItemsCounter   = 0;
    m_selectionMode          = -1;
-   m_minimumProgressToCancelAction = 1;
 }
 
 
@@ -479,7 +484,6 @@
     m_extFSWatcherPathModifiedCounter   = 0;
     m_selectedItemsCounter = 0;
     m_selectionMode          = -1;
-    m_minimumProgressToCancelAction = 1;
 }
 
 
@@ -936,23 +940,6 @@
      QCOMPARE(totalCopied, m_progressTotalItems);
 }
 
-
-/*!
- * \brief TestDirModel::modelCancelRemoveAction()
- *
- *  It tests cancel on a remove operation
- *
- *  Two directories with a deep tree of items are created
- *
- *  The first directory is removed and the cancel is triggered after 10 percent of the all files be removed,
- *  then the first phase of the checks are performed
- *
- *  The second phase consists in remove the same directory after the cancel operation
- *  then a new set of checks are performed
- *
- *  The third phase consists in remove the second directory previously created
- *
- */
 void TestDirModel::modelCancelRemoveAction()
 {
      const int level = 30;
@@ -965,131 +952,17 @@
      QCOMPARE(m_dirModel_01->rowCount(), 1);
      connect(m_dirModel_01, SIGNAL(progress(int,int,int)),
              this,          SLOT(progress(int,int,int)));
-
-     connect(m_dirModel_01, SIGNAL(error(QString,QString)),
-             this,          SLOT(slotError(QString,QString)));
-
-     //cancel only after removing some files
-     m_minimumProgressToCancelAction = 10;
      connect(m_dirModel_01, SIGNAL(progress(int,int,int)),
              this,          SLOT(cancel(int,int,int)));
 
-
-     //create a second directory
-     m_deepDir_02 = new DeepDir("modelCancelRemoveAction2", level);
-     QCOMPARE( QFileInfo(m_deepDir_02->path()).exists(),  true);
-
-     m_dirModel_02->setPath(m_deepDir_02->path());
-     QTest::qWait(TIME_TO_REFRESH_DIR);
-     QCOMPARE(m_dirModel_02->rowCount(), 1);
-
-
-     //remove from first directory
      m_dirModel_01->removeIndex(0);
      QTest::qWait(TIME_TO_PROCESS);
      QTest::qWait(5);
 
-     // sub items do not emit removed()
-     QCOMPARE(m_filesRemoved.count(), 0);
+     QCOMPARE(m_filesRemoved.count() , 0);
      QCOMPARE(m_dirModel_01->rowCount(), 1);
      QVERIFY(m_progressCurrentItem > 0);     // some file were performed
      QVERIFY(m_progressPercentDone < 100);   //
-     QCOMPARE(m_receivedErrorSignal, false);
-     // high level item still exists
-     QDir a(m_deepDir_01->path(), QString(), QDir::NoSort,  QDir::AllEntries | QDir::NoDotAndDotDot);
-     QCOMPARE(a.exists(), true);
-     QCOMPARE((int)a.count(), 1);
-
-     //First phase OK cancel worked
-     //SECOND PHASE  now remove everything
-     disconnect(m_dirModel_01, SIGNAL(progress(int,int,int)),
-                this,          SLOT(cancel(int,int,int)));
-
-     m_dirModel_01->removeIndex(0);
-     QTest::qWait(TIME_TO_PROCESS * 2);
-     QTest::qWait(5);
-     QCOMPARE(m_progressPercentDone,  100);
-     QCOMPARE(m_filesRemoved.count(), 1);
-     QCOMPARE(m_dirModel_01->rowCount(), 0);
-     QCOMPARE(m_receivedErrorSignal, false);
-     // high level item does NOT exist anymore
-     QDir b(m_deepDir_01->path(), QString(), QDir::NoSort, QDir::AllEntries | QDir::NoDotAndDotDot);
-     QCOMPARE(b.exists(), true);
-     QCOMPARE((int)b.count(), 0);
-
-     //THIRD PHASE
-     //now remove the second directory
-     QDir c(m_deepDir_02->path(), QString(), QDir::NoSort, QDir::AllEntries | QDir::NoDotAndDotDot);
-     QCOMPARE(c.exists(), true);
-     QCOMPARE((int)c.count(), 1);
-     m_dirModel_02->removeIndex(0);
-     QTest::qWait(TIME_TO_PROCESS * 2);
-     QDir d(m_deepDir_02->path(), QString(), QDir::NoSort, QDir::AllEntries | QDir::NoDotAndDotDot);
-     QCOMPARE(d.exists(), true);
-     QCOMPARE((int)d.count(), 0);
-     QCOMPARE(m_receivedErrorSignal, false);
-     QCOMPARE(m_dirModel_02->rowCount(), 0);
-}
-
-
-void TestDirModel::modelCancelRemoveSelection()
-{
-     QString tmpDir("modelCancelRemoveSelection");
-     m_deepDir_01 = new DeepDir(tmpDir, 0);
-     QCOMPARE( QFileInfo(m_deepDir_01->path()).exists(),  true);
-     TempFiles tempFiles;
-     tempFiles.addSubDirLevel(tmpDir);
-     const int createdFiles = 250;
-     tempFiles.create(createdFiles);
-     m_dirModel_01->setPath(m_deepDir_01->path());    
-     QTest::qWait(TIME_TO_REFRESH_DIR);
-
-     QCOMPARE(m_dirModel_01->rowCount(), createdFiles);
-     connect(m_dirModel_01, SIGNAL(progress(int,int,int)),
-             this,          SLOT(progress(int,int,int)));
-
-     connect(m_dirModel_01, SIGNAL(error(QString,QString)),
-             this,          SLOT(slotError(QString,QString)));
-
-     //cancel only after removing some files
-     m_minimumProgressToCancelAction = 20;
-     connect(m_dirModel_01, SIGNAL(progress(int,int,int)),
-             this,          SLOT(cancel(int,int,int)));
-
-
-    DirSelection  *selection = m_dirModel_01->selectionObject();
-    QVERIFY(selection != 0);
-
-    //remove all, but cancel will be triggered
-    selection->selectAll();
-    m_dirModel_01->removeSelection();
-    QTest::qWait(TIME_TO_PROCESS*2);
-
-    QVERIFY( m_dirModel_01->rowCount() > 0 );
-    QVERIFY( m_dirModel_01->rowCount() <  createdFiles);
-    QVERIFY(m_filesRemoved.count() > 0);
-
-    int notRemoved = createdFiles - m_filesRemoved.count();
-    QVERIFY(notRemoved > 0);
-
-    QDir c(m_deepDir_01->path(), QString(), QDir::NoSort, QDir::AllEntries | QDir::NoDotAndDotDot);
-    QCOMPARE(c.exists(), true);
-    QCOMPARE((int)c.count(), notRemoved);
-
-    disconnect(m_dirModel_01, SIGNAL(progress(int,int,int)),
-             this,          SLOT(cancel(int,int,int)));
-
-    //now remove everything
-    selection->clear();
-    selection->selectAll();
-    QCOMPARE(selection->counter(),  m_dirModel_01->rowCount());
-    m_dirModel_01->removeSelection();
-    QTest::qWait(TIME_TO_PROCESS*2);
-
-    QCOMPARE(m_dirModel_01->rowCount() , 0);
-    QDir d(m_deepDir_01->path(), QString(), QDir::NoSort, QDir::AllEntries | QDir::NoDotAndDotDot);
-    QCOMPARE(d.exists(), true);
-    QCOMPARE((int)d.count(), 0);
 }
 
 void TestDirModel::modelTestFileSize()
@@ -1788,8 +1661,8 @@
                                 QFileDevice::ReadOwner | QFileDevice::ExeOwner | QFileDevice::WriteOwner);
 
     QCOMPARE(ok,   true);
-    qWarning("created  %s", m_dirModel_01->curPathCreatedDateLocaleShort().toLatin1().constData());
-    qWarning("modified %s", m_dirModel_01->curPathModifiedDateLocaleShort().toLatin1().constData());
+    qWarning("created  %s", m_dirModel_01->curPathCreatedDateLocaleShort().toLocal8Bit().constData());
+    qWarning("modified %s", m_dirModel_01->curPathModifiedDateLocaleShort().toLocal8Bit().constData());
 
 }
 
@@ -1949,7 +1822,7 @@
         bool ret = !md5IconsTable.contains(md5);
         qWarning("%s icon using QIcon::fromTheme() for mime type %s",
                   ret ? "GOOD" : "BAD ",
-                   mimetype.name().toLatin1().constData());
+                   mimetype.name().toLocal8Bit().constData());
         md5IconsTable.insert(md5, mimesToTest.at(counter));
     }
 }
@@ -2539,7 +2412,7 @@
 
    //turn stick bit on
    QString cmd("chmod +t " + trashDir);
-   QCOMPARE(system(cmd.toLatin1().constData()),   0);
+   QCOMPARE(system(cmd.toLocal8Bit().constData()),   0);
    QCOMPARE(trash.isMountPointSharedWithStickBit((m_deepDir_01->path())),  true);
 
    //test validate Trash Dir()
@@ -2580,7 +2453,7 @@
    }
 
    //test XDG Home Trash
-   ::setenv("XDG_DATA_HOME", m_deepDir_02->path().toLatin1().constData(), true );
+   ::setenv("XDG_DATA_HOME", m_deepDir_02->path().toLocal8Bit().constData(), true );
    QString xdgTrashDir(trash.homeTrash());
    QCOMPARE(trash.validate(xdgTrashDir, false),  true);
    QCOMPARE(trash.homeTrash() , xdgTrashDir);
@@ -2714,7 +2587,7 @@
 
     //create a Trash to have
 
-    ::setenv("XDG_DATA_HOME", m_deepDir_01->path().toLatin1().constData(), true );
+    ::setenv("XDG_DATA_HOME", m_deepDir_01->path().toLocal8Bit().constData(), true );
     QString xdgTrashDir(trash.homeTrash());
     QCOMPARE(trash.validate(xdgTrashDir, true),  true);
     QCOMPARE(trash.homeTrash() , xdgTrashDir);
@@ -2925,6 +2798,184 @@
 
 
 
+void TestDirModel::diskCdIntoPathAbsolute()
+{
+    QString dirName("diskCdIntoPathAbsolute");
+    m_deepDir_01 = new DeepDir(dirName,0);
+    m_dirModel_01->setPath(m_deepDir_01->path());
+    QTest::qWait(TIME_TO_REFRESH_DIR);
+    bool ret = m_dirModel_01->cdIntoPath("/IT_MUST_NOT_EXIST/____IT_MUST_NOT_EXIST__");
+    QCOMPARE(ret,  false);
+    ret = m_dirModel_01->cdIntoPath(QDir::homePath());
+    QCOMPARE(ret , true);
+    QCOMPARE(m_dirModel_01->path(),  QDir::homePath());
+}
+
+void TestDirModel::diskCdIntoPathRelative()
+{
+    QString dirName("diskCdIntoPathRelative");
+    m_deepDir_01 = new DeepDir(dirName,1);
+    m_dirModel_01->setPath(m_deepDir_01->path());
+    QTest::qWait(TIME_TO_REFRESH_DIR);
+
+    QModelIndex firstIdx  = m_dirModel_01->index(0, 0);
+    QString subdir = m_dirModel_01->data(firstIdx).toString();
+    QString fullSubdir = m_deepDir_01->path() + QDir::separator() + subdir;
+    bool ret = m_dirModel_01->cdIntoPath(subdir);
+    QTest::qWait(TIME_TO_REFRESH_DIR);
+    QCOMPARE(ret,  true);
+    QCOMPARE(m_dirModel_01->path(),  fullSubdir);
+    ret = m_dirModel_01->cdIntoPath("..");
+    QTest::qWait(TIME_TO_REFRESH_DIR);
+    QCOMPARE(ret,  true);
+    QCOMPARE(m_dirModel_01->path(),  m_deepDir_01->path());
+}
+
+
+
+void TestDirModel::trashCdIntoPathAbsolute()
+{
+    QString orig("trashCdIntoPathAbsolute");
+    m_deepDir_01  = new DeepDir(orig, 1);
+    m_dirModel_01->setPath(m_deepDir_01->path());
+    QTest::qWait(TIME_TO_REFRESH_DIR);
+    QCOMPARE(m_dirModel_01->rowCount() , 1);
+
+    QString tempTrash("tempTrashDir");
+    m_deepDir_02  = new DeepDir(tempTrash, 0);
+    createTempHomeTrashDir(m_deepDir_02->path());
+
+    QModelIndex firstIdx  = m_dirModel_01->index(0, 0);
+
+    QString subdirInTrash   =  LocationUrl::TrashRootURL +
+                              m_dirModel_01->data(firstIdx).toString();
+
+    // move item to Trash
+    m_dirModel_01->moveIndexToTrash(0);
+    QTest::qWait(TIME_TO_REFRESH_DIR);
+
+
+    bool ret = m_dirModel_01->cdIntoPath(subdirInTrash);
+    QTest::qWait(TIME_TO_REFRESH_DIR);
+    QCOMPARE(ret, true);
+    QCOMPARE(m_dirModel_01->path(),  subdirInTrash);
+}
+
+
+void TestDirModel::trashCdIntoPathRelative()
+{
+    QString orig("trashCdIntoPathRelative");
+    m_deepDir_01  = new DeepDir(orig, 1);
+    m_dirModel_01->setPath(m_deepDir_01->path());
+    QTest::qWait(TIME_TO_REFRESH_DIR);
+    QCOMPARE(m_dirModel_01->rowCount() , 1);
+
+    QString tempTrash("tempTrashDir");
+    m_deepDir_02  = new DeepDir(tempTrash, 0);
+    createTempHomeTrashDir(m_deepDir_02->path());
+
+    QModelIndex firstIdx  = m_dirModel_01->index(0, 0);
+    QString subdir        = m_dirModel_01->data(firstIdx).toString();
+    QString subdirInTrash  =  LocationUrl::TrashRootURL + subdir;
+
+
+    // move item to Trash
+    m_dirModel_01->moveIndexToTrash(0);
+    QTest::qWait(TIME_TO_REFRESH_DIR);
+
+    bool ret = m_dirModel_01->cdIntoPath(LocationUrl::TrashRootURL);
+    QTest::qWait(TIME_TO_REFRESH_DIR);
+    QCOMPARE(ret, true);
+    QCOMPARE(m_dirModel_01->path(),  LocationUrl::TrashRootURL);
+
+    //cd relative
+    ret = m_dirModel_01->cdIntoPath(subdir);
+    QTest::qWait(TIME_TO_REFRESH_DIR);
+    QCOMPARE(ret, true);
+    QCOMPARE(m_dirModel_01->path(),  subdirInTrash);
+}
+
+
+
+void TestDirModel::smbCdIntoPathAbsolute()
+{
+   SmbItemInfo  smbOK(LocationUrl::SmbURL);
+   QCOMPARE(smbOK.isValid(),  true);
+   QCOMPARE(smbOK.isRoot(),   true);
+   QCOMPARE(smbOK.needsAuthentication(), false);
+   QCOMPARE(smbOK.urlPath(), LocationUrl::SmbURL);
+
+   if (SmbUserShare::canCreateShares())
+   {
+       QString shareName("smbShareCdIntoPathAbsolute");
+
+       TestQSambaSuite smbTest(this);
+
+       ShareCreationStatus tmpShare(smbTest.createTempShare(shareName));
+       if (tmpShare.tempDir)
+       {
+           tmpShare.tempDir->setAutoRemove(true);
+       }
+       QString createdDir("createdDir");
+       QString createDirFullPath = tmpShare.sharedDirPath + QDir::separator() + createdDir;
+       bool ret = QDir().mkdir(createDirFullPath);
+       QCOMPARE(ret , true);
+       QString absUrl = LocationUrl::SmbURL + "localhost" +
+               QDir::separator() + tmpShare.shareName +
+               QDir::separator() + createdDir;
+
+       ret = m_dirModel_01->cdIntoPath(absUrl);
+       QTest::qWait(TIME_TO_PROCESS);
+       QCOMPARE(ret, true);
+       QCOMPARE(m_dirModel_01->path(), absUrl );
+   }
+}
+
+void TestDirModel::smbCdIntoPathRelative()
+{
+   SmbItemInfo  smbOK(LocationUrl::SmbURL);
+   QCOMPARE(smbOK.isValid(),  true);
+   QCOMPARE(smbOK.isRoot(),   true);
+   QCOMPARE(smbOK.needsAuthentication(), false);
+   QCOMPARE(smbOK.urlPath(), LocationUrl::SmbURL);
+   if (SmbUserShare::canCreateShares())
+   {
+       QString shareName("smbsmbCdIntoPathRelative");
+
+       TestQSambaSuite smbTest(this);
+
+       ShareCreationStatus tmpShare(smbTest.createTempShare(shareName));
+       if (tmpShare.tempDir)
+       {
+           tmpShare.tempDir->setAutoRemove(true);
+       }
+       QString createdDir1("createdDir1");
+       QString createdDir2("createdDir2");
+       QString createDirFullPath = tmpShare.sharedDirPath + QDir::separator() + createdDir1
+                                   + QDir::separator() + createdDir2;
+       bool ret = QDir().mkpath(createDirFullPath);
+       QCOMPARE(ret , true);
+       QString absUrl = LocationUrl::SmbURL + "localhost" +
+               QDir::separator() + tmpShare.shareName +
+               QDir::separator() + createdDir1;
+
+       ret = m_dirModel_01->cdIntoPath(absUrl);
+       QTest::qWait(TIME_TO_PROCESS);
+       QCOMPARE(ret, true);
+       QCOMPARE(m_dirModel_01->path(), absUrl );
+       QCOMPARE(m_dirModel_01->rowCount() , 1);
+
+       //cd relative
+       absUrl += QDir::separator() + createdDir2;
+       ret = m_dirModel_01->cdIntoPath(createdDir2);
+       QTest::qWait(TIME_TO_PROCESS);
+       QCOMPARE(ret, true);
+       QCOMPARE(m_dirModel_01->path(), absUrl );
+       QCOMPARE(m_dirModel_01->rowCount() , 0);
+   }
+}
+
+
 int main(int argc, char *argv[])
 {
     QApplication app(argc, argv);
@@ -2988,7 +3039,7 @@
     if (existentDir.startsWith(QDir::tempPath()) && (d.exists() || d.mkpath(existentDir)))
     {
         QTrashDir trash;
-        ::setenv("XDG_DATA_HOME", existentDir.toLatin1().constData(), true );
+        ::setenv("XDG_DATA_HOME", existentDir.toLocal8Bit().constData(), true );
         QString xdgTrashDir(trash.homeTrash());
         ret = trash.validate(xdgTrashDir, true);
     }


Follow ups