From afa13623cdc44b64a8801d3f9dff67bdec788a11 Mon Sep 17 00:00:00 2001 From: Christian Kandeler <christian.kandeler@nokia.com> Date: Fri, 1 Apr 2011 09:58:29 +0200 Subject: [PATCH] SSH: Fix tests to adapt to new location (utils vs. core plugin). --- tests/manual/ssh/errorhandling/main.cpp | 30 +++++++++---------- .../ssh/remoteprocess/argumentscollector.cpp | 22 +++++++------- .../ssh/remoteprocess/argumentscollector.h | 6 ++-- tests/manual/ssh/remoteprocess/main.cpp | 6 ++-- .../ssh/remoteprocess/remoteprocesstest.cpp | 6 ++-- .../ssh/remoteprocess/remoteprocesstest.h | 6 ++-- tests/manual/ssh/sftp/argumentscollector.cpp | 18 +++++------ tests/manual/ssh/sftp/argumentscollector.h | 2 +- tests/manual/ssh/sftp/main.cpp | 6 ++-- tests/manual/ssh/sftp/parameters.h | 6 ++-- tests/manual/ssh/sftp/sftptest.cpp | 10 +++---- tests/manual/ssh/sftp/sftptest.h | 22 +++++++------- 12 files changed, 70 insertions(+), 70 deletions(-) diff --git a/tests/manual/ssh/errorhandling/main.cpp b/tests/manual/ssh/errorhandling/main.cpp index 75668f5493f..3900ab43c24 100644 --- a/tests/manual/ssh/errorhandling/main.cpp +++ b/tests/manual/ssh/errorhandling/main.cpp @@ -31,9 +31,9 @@ ** **************************************************************************/ -#include <coreplugin/ssh/sftpchannel.h> -#include <coreplugin/ssh/sshconnection.h> -#include <coreplugin/ssh/sshremoteprocess.h> +#include <utils/ssh/sftpchannel.h> +#include <utils/ssh/sshconnection.h> +#include <utils/ssh/sshremoteprocess.h> #include <QtCore/QCoreApplication> #include <QtCore/QList> @@ -41,7 +41,7 @@ #include <QtCore/QPair> #include <QtCore/QTimer> -using namespace Core; +using namespace Utils; class Test : public QObject { Q_OBJECT @@ -69,24 +69,24 @@ public: noUser.host = QLatin1String("localhost"); noUser.port = 22; noUser.timeout = 30; - noUser.authType = SshConnectionParameters::AuthByPwd; - noUser.uname = QLatin1String("dumdidumpuffpuff"); - noUser.uname = QLatin1String("whatever"); + noUser.authenticationType = SshConnectionParameters::AuthenticationByPassword; + noUser.userName = QLatin1String("dumdidumpuffpuff"); + noUser.password = QLatin1String("whatever"); SshConnectionParameters wrongPwd=SshConnectionParameters(SshConnectionParameters::DefaultProxy); wrongPwd.host = QLatin1String("localhost"); wrongPwd.port = 22; wrongPwd.timeout = 30; - wrongPwd.authType = SshConnectionParameters::AuthByPwd; - wrongPwd.uname = QLatin1String("root"); - noUser.uname = QLatin1String("thiscantpossiblybeapasswordcanit"); + wrongPwd.authenticationType = SshConnectionParameters::AuthenticationByPassword; + wrongPwd.userName = QLatin1String("root"); + noUser.password = QLatin1String("thiscantpossiblybeapasswordcanit"); SshConnectionParameters invalidKeyFile=SshConnectionParameters(SshConnectionParameters::DefaultProxy); invalidKeyFile.host = QLatin1String("localhost"); invalidKeyFile.port = 22; invalidKeyFile.timeout = 30; - invalidKeyFile.authType = SshConnectionParameters::AuthByKey; - invalidKeyFile.uname = QLatin1String("root"); + invalidKeyFile.authenticationType = SshConnectionParameters::AuthenticationByKey; + invalidKeyFile.userName = QLatin1String("root"); invalidKeyFile.privateKeyFile = QLatin1String("somefilenamethatwedontexpecttocontainavalidkey"); @@ -129,7 +129,7 @@ private slots: qApp->quit(); } - void handleError(Core::SshError error) + void handleError(Utils::SshError error) { if (m_testSet.isEmpty()) { qDebug("Error: Received error %d, but no test was running.", error); @@ -173,8 +173,8 @@ private: SLOT(handleDisconnected())); connect(m_connection.data(), SIGNAL(dataAvailable(QString)), this, SLOT(handleDataAvailable(QString))); - connect(m_connection.data(), SIGNAL(error(Core::SshError)), this, - SLOT(handleError(Core::SshError))); + connect(m_connection.data(), SIGNAL(error(Utils::SshError)), this, + SLOT(handleError(Utils::SshError))); const TestItem &nextItem = m_testSet.first(); m_timeoutTimer.stop(); m_timeoutTimer.setInterval(qMax(10000, nextItem.params.timeout * 1000)); diff --git a/tests/manual/ssh/remoteprocess/argumentscollector.cpp b/tests/manual/ssh/remoteprocess/argumentscollector.cpp index 51d97c34601..9c8940173e2 100644 --- a/tests/manual/ssh/remoteprocess/argumentscollector.cpp +++ b/tests/manual/ssh/remoteprocess/argumentscollector.cpp @@ -36,16 +36,16 @@ #include <iostream> using namespace std; -using namespace Core; +using namespace Utils; ArgumentsCollector::ArgumentsCollector(const QStringList &args) : m_arguments(args) { } -Core::SshConnectionParameters ArgumentsCollector::collect(bool &success) const +Utils::SshConnectionParameters ArgumentsCollector::collect(bool &success) const { - SshConnectionParameters parameters(Core::SshConnectionParameters::NoProxy); + SshConnectionParameters parameters(Utils::SshConnectionParameters::NoProxy); try { bool authTypeGiven = false; bool portGiven = false; @@ -55,24 +55,24 @@ Core::SshConnectionParameters ArgumentsCollector::collect(bool &success) const int port; for (pos = 1; pos < m_arguments.count() - 1; ++pos) { if (checkAndSetStringArg(pos, parameters.host, "-h") - || checkAndSetStringArg(pos, parameters.uname, "-u")) + || checkAndSetStringArg(pos, parameters.userName, "-u")) continue; if (checkAndSetIntArg(pos, port, portGiven, "-p") || checkAndSetIntArg(pos, parameters.timeout, timeoutGiven, "-t")) continue; - if (checkAndSetStringArg(pos, parameters.pwd, "-pwd")) { + if (checkAndSetStringArg(pos, parameters.password, "-pwd")) { if (!parameters.privateKeyFile.isEmpty()) throw ArgumentErrorException(QLatin1String("-pwd and -k are mutually exclusive.")); - parameters.authType - = SshConnectionParameters::AuthByPwd; + parameters.authenticationType + = SshConnectionParameters::AuthenticationByPassword; authTypeGiven = true; continue; } if (checkAndSetStringArg(pos, parameters.privateKeyFile, "-k")) { - if (!parameters.pwd.isEmpty()) + if (!parameters.password.isEmpty()) throw ArgumentErrorException(QLatin1String("-pwd and -k are mutually exclusive.")); - parameters.authType - = SshConnectionParameters::AuthByKey; + parameters.authenticationType + = SshConnectionParameters::AuthenticationByKey; authTypeGiven = true; continue; } @@ -90,7 +90,7 @@ Core::SshConnectionParameters ArgumentsCollector::collect(bool &success) const throw ArgumentErrorException(QLatin1String("No authentication argument given.")); if (parameters.host.isEmpty()) throw ArgumentErrorException(QLatin1String("No host given.")); - if (parameters.uname.isEmpty()) + if (parameters.userName.isEmpty()) throw ArgumentErrorException(QLatin1String("No user name given.")); parameters.port = portGiven ? port : 22; diff --git a/tests/manual/ssh/remoteprocess/argumentscollector.h b/tests/manual/ssh/remoteprocess/argumentscollector.h index aef3c9e03a2..f1d3335cbf2 100644 --- a/tests/manual/ssh/remoteprocess/argumentscollector.h +++ b/tests/manual/ssh/remoteprocess/argumentscollector.h @@ -34,7 +34,7 @@ #ifndef ARGUMENTSCOLLECTOR_H #define ARGUMENTSCOLLECTOR_H -#include <coreplugin/ssh/sshconnection.h> +#include <utils/ssh/sshconnection.h> #include <QtCore/QStringList> @@ -42,7 +42,7 @@ class ArgumentsCollector { public: ArgumentsCollector(const QStringList &args); - Core::SshConnectionParameters collect(bool &success) const; + Utils::SshConnectionParameters collect(bool &success) const; private: struct ArgumentErrorException { @@ -55,7 +55,7 @@ private: bool checkAndSetIntArg(int &pos, int &val, bool &alreadyGiven, const char *opt) const; bool checkForNoProxy(int &pos, - Core::SshConnectionParameters::ProxyType &type, + Utils::SshConnectionParameters::ProxyType &type, bool &alreadyGiven) const; const QStringList m_arguments; diff --git a/tests/manual/ssh/remoteprocess/main.cpp b/tests/manual/ssh/remoteprocess/main.cpp index b9eab672956..6fe29901b14 100644 --- a/tests/manual/ssh/remoteprocess/main.cpp +++ b/tests/manual/ssh/remoteprocess/main.cpp @@ -34,7 +34,7 @@ #include "argumentscollector.h" #include "remoteprocesstest.h" -#include <coreplugin/ssh/sshconnection.h> +#include <utils/ssh/sshconnection.h> #include <QtCore/QCoreApplication> #include <QtCore/QObject> @@ -43,13 +43,13 @@ #include <cstdlib> #include <iostream> -using namespace Core; +using namespace Utils; int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); bool parseSuccess; - const Core::SshConnectionParameters ¶meters + const Utils::SshConnectionParameters ¶meters = ArgumentsCollector(app.arguments()).collect(parseSuccess); if (!parseSuccess) return EXIT_FAILURE; diff --git a/tests/manual/ssh/remoteprocess/remoteprocesstest.cpp b/tests/manual/ssh/remoteprocess/remoteprocesstest.cpp index 8cda3c3234c..303abed4d09 100644 --- a/tests/manual/ssh/remoteprocess/remoteprocesstest.cpp +++ b/tests/manual/ssh/remoteprocess/remoteprocesstest.cpp @@ -38,7 +38,7 @@ #include <iostream> -using namespace Core; +using namespace Utils; RemoteProcessTest::RemoteProcessTest(const SshConnectionParameters ¶ms) : m_timeoutTimer(new QTimer(this)), @@ -53,7 +53,7 @@ RemoteProcessTest::~RemoteProcessTest() { } void RemoteProcessTest::run() { - connect(m_remoteRunner.data(), SIGNAL(connectionError(Core::SshError)), + connect(m_remoteRunner.data(), SIGNAL(connectionError(Utils::SshError)), SLOT(handleConnectionError())); connect(m_remoteRunner.data(), SIGNAL(processStarted()), SLOT(handleProcessStarted())); @@ -88,7 +88,7 @@ void RemoteProcessTest::handleProcessStarted() } else { m_started = true; if (m_state == TestingCrash) { - Core::SshRemoteProcess::Ptr killer + Utils::SshRemoteProcess::Ptr killer = m_remoteRunner->connection()->createRemoteProcess("pkill -9 sleep"); killer->start(); } diff --git a/tests/manual/ssh/remoteprocess/remoteprocesstest.h b/tests/manual/ssh/remoteprocess/remoteprocesstest.h index 2cb4cfb676f..97772c1533d 100644 --- a/tests/manual/ssh/remoteprocess/remoteprocesstest.h +++ b/tests/manual/ssh/remoteprocess/remoteprocesstest.h @@ -34,7 +34,7 @@ #ifndef SFTPTEST_H #define SFTPTEST_H -#include <coreplugin/ssh/sshremoteprocessrunner.h> +#include <utils/ssh/sshremoteprocessrunner.h> QT_FORWARD_DECLARE_CLASS(QTimer); #include <QtCore/QObject> @@ -43,7 +43,7 @@ class RemoteProcessTest : public QObject { Q_OBJECT public: - RemoteProcessTest(const Core::SshConnectionParameters ¶ms); + RemoteProcessTest(const Utils::SshConnectionParameters ¶ms); ~RemoteProcessTest(); void run(); @@ -59,7 +59,7 @@ private: enum State { Inactive, TestingSuccess, TestingFailure, TestingCrash }; QTimer * const m_timeoutTimer; - const Core::SshRemoteProcessRunner::Ptr m_remoteRunner; + const Utils::SshRemoteProcessRunner::Ptr m_remoteRunner; QByteArray m_remoteStdout; QByteArray m_remoteStderr; State m_state; diff --git a/tests/manual/ssh/sftp/argumentscollector.cpp b/tests/manual/ssh/sftp/argumentscollector.cpp index b4ea1ef20ad..fd9723203b3 100644 --- a/tests/manual/ssh/sftp/argumentscollector.cpp +++ b/tests/manual/ssh/sftp/argumentscollector.cpp @@ -36,7 +36,7 @@ #include <iostream> using namespace std; -using namespace Core; +using namespace Utils; ArgumentsCollector::ArgumentsCollector(const QStringList &args) : m_arguments(args) @@ -57,26 +57,26 @@ Parameters ArgumentsCollector::collect(bool &success) const int port; for (pos = 1; pos < m_arguments.count() - 1; ++pos) { if (checkAndSetStringArg(pos, parameters.sshParams.host, "-h") - || checkAndSetStringArg(pos, parameters.sshParams.uname, "-u")) + || checkAndSetStringArg(pos, parameters.sshParams.userName, "-u")) continue; if (checkAndSetIntArg(pos, port, portGiven, "-p") || checkAndSetIntArg(pos, parameters.sshParams.timeout, timeoutGiven, "-t") || checkAndSetIntArg(pos, parameters.smallFileCount, smallFileCountGiven, "-c") || checkAndSetIntArg(pos, parameters.bigFileSize, bigFileSizeGiven, "-s")) continue; - if (checkAndSetStringArg(pos, parameters.sshParams.pwd, "-pwd")) { + if (checkAndSetStringArg(pos, parameters.sshParams.password, "-pwd")) { if (!parameters.sshParams.privateKeyFile.isEmpty()) throw ArgumentErrorException(QLatin1String("-pwd and -k are mutually exclusive.")); - parameters.sshParams.authType - = SshConnectionParameters::AuthByPwd; + parameters.sshParams.authenticationType + = SshConnectionParameters::AuthenticationByPassword; authTypeGiven = true; continue; } if (checkAndSetStringArg(pos, parameters.sshParams.privateKeyFile, "-k")) { - if (!parameters.sshParams.pwd.isEmpty()) + if (!parameters.sshParams.password.isEmpty()) throw ArgumentErrorException(QLatin1String("-pwd and -k are mutually exclusive.")); - parameters.sshParams.authType - = SshConnectionParameters::AuthByKey; + parameters.sshParams.authenticationType + = SshConnectionParameters::AuthenticationByKey; authTypeGiven = true; continue; } @@ -94,7 +94,7 @@ Parameters ArgumentsCollector::collect(bool &success) const throw ArgumentErrorException(QLatin1String("No authentication argument given.")); if (parameters.sshParams.host.isEmpty()) throw ArgumentErrorException(QLatin1String("No host given.")); - if (parameters.sshParams.uname.isEmpty()) + if (parameters.sshParams.userName.isEmpty()) throw ArgumentErrorException(QLatin1String("No user name given.")); parameters.sshParams.port = portGiven ? port : 22; diff --git a/tests/manual/ssh/sftp/argumentscollector.h b/tests/manual/ssh/sftp/argumentscollector.h index df3d2c89f8c..0430e62fa4e 100644 --- a/tests/manual/ssh/sftp/argumentscollector.h +++ b/tests/manual/ssh/sftp/argumentscollector.h @@ -55,7 +55,7 @@ private: bool checkAndSetIntArg(int &pos, int &val, bool &alreadyGiven, const char *opt) const; bool checkForNoProxy(int &pos, - Core::SshConnectionParameters::ProxyType &type, + Utils::SshConnectionParameters::ProxyType &type, bool &alreadyGiven) const; const QStringList m_arguments; diff --git a/tests/manual/ssh/sftp/main.cpp b/tests/manual/ssh/sftp/main.cpp index 2966ab4aa9e..e29ee3c6ced 100644 --- a/tests/manual/ssh/sftp/main.cpp +++ b/tests/manual/ssh/sftp/main.cpp @@ -34,8 +34,8 @@ #include "argumentscollector.h" #include "sftptest.h" -#include <coreplugin/ssh/sftpchannel.h> -#include <coreplugin/ssh/sshconnection.h> +#include <utils/ssh/sftpchannel.h> +#include <utils/ssh/sshconnection.h> #include <QtCore/QCoreApplication> #include <QtCore/QObject> @@ -44,7 +44,7 @@ #include <cstdlib> #include <iostream> -using namespace Core; +using namespace Utils; int main(int argc, char *argv[]) { diff --git a/tests/manual/ssh/sftp/parameters.h b/tests/manual/ssh/sftp/parameters.h index 2e475de5e95..60cd8015420 100644 --- a/tests/manual/ssh/sftp/parameters.h +++ b/tests/manual/ssh/sftp/parameters.h @@ -34,12 +34,12 @@ #ifndef PARAMETERS_H #define PARAMETERS_H -#include <coreplugin/ssh/sshconnection.h> +#include <utils/ssh/sshconnection.h> struct Parameters { - Parameters() : sshParams(Core::SshConnectionParameters::DefaultProxy) {} + Parameters() : sshParams(Utils::SshConnectionParameters::DefaultProxy) {} - Core::SshConnectionParameters sshParams; + Utils::SshConnectionParameters sshParams; int smallFileCount; int bigFileSize; }; diff --git a/tests/manual/ssh/sftp/sftptest.cpp b/tests/manual/ssh/sftp/sftptest.cpp index 854c654ff05..8e795eea433 100644 --- a/tests/manual/ssh/sftp/sftptest.cpp +++ b/tests/manual/ssh/sftp/sftptest.cpp @@ -41,7 +41,7 @@ #include <iostream> -using namespace Core; +using namespace Utils; SftpTest::SftpTest(const Parameters ¶ms) : m_parameters(params), m_state(Inactive), m_error(false), @@ -61,7 +61,7 @@ void SftpTest::run() m_connection = SshConnection::create(); connect(m_connection.data(), SIGNAL(connected()), this, SLOT(handleConnected())); - connect(m_connection.data(), SIGNAL(error(Core::SshError)), this, + connect(m_connection.data(), SIGNAL(error(Utils::SshError)), this, SLOT(handleError())); connect(m_connection.data(), SIGNAL(disconnected()), this, SLOT(handleDisconnected())); @@ -84,8 +84,8 @@ void SftpTest::handleConnected() SLOT(handleChannelInitialized())); connect(m_channel.data(), SIGNAL(initializationFailed(QString)), this, SLOT(handleChannelInitializationFailure(QString))); - connect(m_channel.data(), SIGNAL(finished(Core::SftpJobId, QString)), - this, SLOT(handleJobFinished(Core::SftpJobId, QString))); + connect(m_channel.data(), SIGNAL(finished(Utils::SftpJobId, QString)), + this, SLOT(handleJobFinished(Utils::SftpJobId, QString))); connect(m_channel.data(), SIGNAL(closed()), this, SLOT(handleChannelClosed())); m_state = InitializingChannel; @@ -192,7 +192,7 @@ void SftpTest::handleChannelClosed() m_connection->disconnectFromHost(); } -void SftpTest::handleJobFinished(Core::SftpJobId job, const QString &error) +void SftpTest::handleJobFinished(Utils::SftpJobId job, const QString &error) { switch (m_state) { case UploadingSmall: diff --git a/tests/manual/ssh/sftp/sftptest.h b/tests/manual/ssh/sftp/sftptest.h index 666542bba22..be4e51fd131 100644 --- a/tests/manual/ssh/sftp/sftptest.h +++ b/tests/manual/ssh/sftp/sftptest.h @@ -36,8 +36,8 @@ #include "parameters.h" -#include <coreplugin/ssh/sftpchannel.h> -#include <coreplugin/ssh/sshconnection.h> +#include <utils/ssh/sftpchannel.h> +#include <utils/ssh/sshconnection.h> #include <QtCore/QElapsedTimer> #include <QtCore/QHash> @@ -61,11 +61,11 @@ private slots: void handleDisconnected(); void handleChannelInitialized(); void handleChannelInitializationFailure(const QString &reason); - void handleJobFinished(Core::SftpJobId job, const QString &error); + void handleJobFinished(Utils::SftpJobId job, const QString &error); void handleChannelClosed(); private: - typedef QHash<Core::SftpJobId, QString> JobMap; + typedef QHash<Utils::SftpJobId, QString> JobMap; typedef QSharedPointer<QFile> FilePtr; enum State { Inactive, Connecting, InitializingChannel, UploadingSmall, DownloadingSmall, RemovingSmall, UploadingBig, DownloadingBig, @@ -77,25 +77,25 @@ private: QString cmpFileName(const QString &localFileName) const; QString remoteFilePath(const QString &localFileName) const; void earlyDisconnectFromHost(); - bool handleJobFinished(Core::SftpJobId job, JobMap &jobMap, + bool handleJobFinished(Utils::SftpJobId job, JobMap &jobMap, const QString &error, const char *activity); - bool handleBigJobFinished(Core::SftpJobId job, Core::SftpJobId expectedJob, + bool handleBigJobFinished(Utils::SftpJobId job, Utils::SftpJobId expectedJob, const QString &error, const char *activity); bool compareFiles(QFile *orig, QFile *copy); const Parameters m_parameters; State m_state; bool m_error; - Core::SshConnection::Ptr m_connection; - Core::SftpChannel::Ptr m_channel; + Utils::SshConnection::Ptr m_connection; + Utils::SftpChannel::Ptr m_channel; QList<FilePtr> m_localSmallFiles; JobMap m_smallFilesUploadJobs; JobMap m_smallFilesDownloadJobs; JobMap m_smallFilesRemovalJobs; FilePtr m_localBigFile; - Core::SftpJobId m_bigFileUploadJob; - Core::SftpJobId m_bigFileDownloadJob; - Core::SftpJobId m_bigFileRemovalJob; + Utils::SftpJobId m_bigFileUploadJob; + Utils::SftpJobId m_bigFileDownloadJob; + Utils::SftpJobId m_bigFileRemovalJob; QElapsedTimer m_bigJobTimer; }; -- GitLab