Fix krazy warnings/some includes in qttest.

Change-Id: I4c11aa5977efb3fa726e8394bec25c86a6fe049f
Reviewed-on: http://codereview.qt.nokia.com/3725
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Bill King <bill.king@nokia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
Friedemann Kleint
2011-08-29 11:33:16 +02:00
parent 662c66ef6b
commit c952834ff2
27 changed files with 673 additions and 645 deletions

View File

@@ -90,14 +90,14 @@ void SelectDlg::addSelectableItem(const QString &item)
if (groupsList->columnCount() > 1) { if (groupsList->columnCount() > 1) {
int row = groupsList->rowCount(); int row = groupsList->rowCount();
groupsList->insertRow(row); groupsList->insertRow(row);
QStringList tmp = item.split("|"); QStringList tmp = item.split(QLatin1Char('|'));
if (tmp.count() > groupsList->columnCount()) { if (tmp.count() > groupsList->columnCount()) {
for (int i = 0; i < (groupsList->columnCount() - 1); ++i) for (int i = 0; i < (groupsList->columnCount() - 1); ++i)
groupsList->setItem(row, i, new QTableWidgetItem(tmp[i])); groupsList->setItem(row, i, new QTableWidgetItem(tmp[i]));
QString s; QString s;
for (int i = groupsList->columnCount(); i < tmp.count(); ++i) { for (int i = groupsList->columnCount(); i < tmp.count(); ++i) {
if (!s.isEmpty()) s+= "|"; if (!s.isEmpty()) s+= QLatin1Char('|');
s += tmp[i]; s += tmp[i];
} }
groupsList->setItem(row, (groupsList->columnCount() - 1), new QTableWidgetItem(s)); groupsList->setItem(row, (groupsList->columnCount() - 1), new QTableWidgetItem(s));
@@ -105,7 +105,7 @@ void SelectDlg::addSelectableItem(const QString &item)
for (int i = 0; i < tmp.count(); ++i) for (int i = 0; i < tmp.count(); ++i)
groupsList->setItem(row, i, new QTableWidgetItem(tmp[i])); groupsList->setItem(row, i, new QTableWidgetItem(tmp[i]));
for (int i = tmp.count(); i < groupsList->columnCount(); ++i) for (int i = tmp.count(); i < groupsList->columnCount(); ++i)
groupsList->setItem(row, i, new QTableWidgetItem("")); groupsList->setItem(row, i, new QTableWidgetItem(QString()));
} else { } else {
for (int i = 0; i < tmp.count(); ++i) for (int i = 0; i < tmp.count(); ++i)
groupsList->setItem(row, i, new QTableWidgetItem(tmp[i])); groupsList->setItem(row, i, new QTableWidgetItem(tmp[i]));
@@ -130,7 +130,7 @@ QStringList SelectDlg::selectedItems()
if (item && item->isSelected()) { if (item && item->isSelected()) {
QString S = item->text(); QString S = item->text();
for (int col = 1; col < groupsList->columnCount(); ++col) { for (int col = 1; col < groupsList->columnCount(); ++col) {
S+= "|"; S+= QLatin1Char('|');
item = groupsList->item(row, col); item = groupsList->item(row, col);
if (item) if (item)
S += item->text(); S += item->text();

View File

@@ -65,7 +65,7 @@ class NewTestFunctionDlg : public QDialog, public Ui::NewTestFunctionDlg
Q_OBJECT Q_OBJECT
public: public:
NewTestFunctionDlg(const QString &testCase, QWidget *parent = 0); explicit NewTestFunctionDlg(const QString &testCase, QWidget *parent = 0);
private slots: private slots:
void onChanged(); void onChanged();

View File

@@ -88,15 +88,15 @@ QString QSystem::userName()
QString userName; QString userName;
#if defined Q_OS_TEMP #if defined Q_OS_TEMP
userName = "WinCE"; userName = QLatin1String("WinCE");
#elif defined Q_OS_WIN32 #elif defined Q_OS_WIN32
userName = getenv("USERNAME"); userName = QString::fromLocal8Bit(qgetenv("USERNAME"));
#elif defined Q_OS_UNIX #elif defined Q_OS_UNIX
userName = getenv("USER"); userName = QString::fromLocal8Bit(qgetenv("USER"));
if (userName == "") if (userName.isEmpty())
userName = getenv("LOGNAME"); userName = QString::fromLocal8Bit(qgetenv("LOGNAME"));
#elif defined Q_OS_MAC #elif defined Q_OS_MAC
userName = getenv(); userName = getenv(); // TODO?
#endif #endif
return userName.toLower(); return userName.toLower();
@@ -116,10 +116,9 @@ QString QSystem::hostName()
hostName = QHostInfo::localHostName(); hostName = QHostInfo::localHostName();
// convert anarki.troll.no to anarki // convert anarki.troll.no to anarki
int pos = hostName.indexOf("."); const int pos = hostName.indexOf(QLatin1Char('.'));
if (pos > 0) if (pos > 0)
hostName = hostName.left(pos); hostName.truncate(pos);
return hostName; return hostName;
} }
@@ -129,86 +128,86 @@ QString QSystem::hostName()
QString QSystem::OSName() QString QSystem::OSName()
{ {
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
return "Mac-OSX"; return QLatin1String("Mac-OSX");
#elif defined(Q_OS_MSDOS) #elif defined(Q_OS_MSDOS)
return "MSDOS"; return QLatin1String("MSDOS");
#elif defined(Q_OS_OS2EMX) #elif defined(Q_OS_OS2EMX)
return "OS2EMX"; return QLatin1String("OS2EMX");
#elif defined(Q_OS_OS2) #elif defined(Q_OS_OS2)
return "OS2"; return QLatin1String("OS2");
#elif defined(Q_OS_WIN32) || defined (Q_OS_WIN64) #elif defined(Q_OS_WIN)
return "Windows"; return QLatin1String("Windows");
#elif defined(Q_OS_SOLARIS) #elif defined(Q_OS_SOLARIS)
return "Solaris"; return QLatin1String("Solaris");
#elif defined(Q_OS_SUN) && defined(Q_OS_BSD4) #elif defined(Q_OS_SUN) && defined(Q_OS_BSD4)
return "Sun"; return QLatin1String("Sun");
#elif defined(Q_OS_HPUX) #elif defined(Q_OS_HPUX)
return "HPUX"; return QLatin1String("HPUX");
#elif defined(Q_OS_ULTRIX) #elif defined(Q_OS_ULTRIX)
return "ULTRIX"; return QLatin1String("ULTRIX");
#elif defined(Q_OS_RELIANT) #elif defined(Q_OS_RELIANT)
return "RELIANT"; return QLatin1String("RELIANT");
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)
return "Linux"; return QLatin1String("Linux");
#elif defined(Q_OS_FREEBSD) && defined(Q_OS_BSD4) #elif defined(Q_OS_FREEBSD) && defined(Q_OS_BSD4)
return "FREEBSD"; return QLatin1String("FREEBSD");
#elif defined(Q_OS_NETBSD) && defined(Q_OS_BSD4) #elif defined(Q_OS_NETBSD) && defined(Q_OS_BSD4)
return "NETBSD"; return QLatin1String("NETBSD");
#elif defined(Q_OS_OPENBSD) && defined(Q_OS_BSD4) #elif defined(Q_OS_OPENBSD) && defined(Q_OS_BSD4)
return "OPENBSD"; return QLatin1String("OPENBSD");
#elif defined(Q_OS_BSDI) && defined(Q_OS_BSD4) #elif defined(Q_OS_BSDI) && defined(Q_OS_BSD4)
return "BSDI"; return QLatin1String("BSDI");
#elif defined(Q_OS_IRIX) #elif defined(Q_OS_IRIX)
return "IRIX"; return QLatin1String("IRIX");
#elif defined(Q_OS_OSF) #elif defined(Q_OS_OSF)
return "OSF"; return QLatin1String("OSF");
#elif defined(Q_OS_AIX) #elif defined(Q_OS_AIX)
return "AIX"; return QLatin1String("AIX");
#elif defined(Q_OS_LYNX) #elif defined(Q_OS_LYNX)
return "LYNX"; return QLatin1String("LYNX");
#elif defined(Q_OS_UNIXWARE) #elif defined(Q_OS_UNIXWARE)
return "UNIXWARE"; return QLatin1String("UNIXWARE");
#elif defined(Q_OS_HURD) #elif defined(Q_OS_HURD)
return "HURD"; return QLatin1String("HURD");
#elif defined(Q_OS_DGUX) #elif defined(Q_OS_DGUX)
return "DGUX"; return QLatin1String("DGUX");
#elif defined(Q_OS_QNX6) #elif defined(Q_OS_QNX6)
return "QNX6"; return QLatin1String("QNX6");
#elif defined(Q_OS_QNX) #elif defined(Q_OS_QNX)
return "QNX"; return QLatin1String("QNX");
#elif defined(Q_OS_SCO) #elif defined(Q_OS_SCO)
return "SCO"; return QLatin1String("SCO");
#elif defined(Q_OS_UNIXWARE7) #elif defined(Q_OS_UNIXWARE7)
return "UNIXWARE7"; return QLatin1String("UNIXWARE7");
#elif defined(Q_OS_DYNIX) #elif defined(Q_OS_DYNIX)
return "DYNIX"; return QLatin1String("DYNIX");
#elif defined(Q_OS_SVR4) #elif defined(Q_OS_SVR4)
return "SVR4"; return QLatin1String("SVR4");
#else #else
return "UNKNOWN"; return QLatin1String("UNKNOWN");
#endif #endif
} }
QString which_p(const QString &path, const QString &applicationName) QString which_p(const QString &path, const QString &applicationName)
{ {
QStringList paths; QStringList paths;
#if defined Q_OS_WIN32 #if defined Q_OS_WIN
paths = path.split(";"); paths = path.split(QLatin1Char(';'));
#else #else
paths = path.split(":"); paths = path.split(QLatin1Char(':'));
#endif #endif
foreach (const QString &p, paths) { foreach (const QString &p, paths) {
QString fname = p + QDir::separator() + applicationName; QString fname = p + QDir::separator() + applicationName;
if (QFile::exists(fname)) if (QFile::exists(fname))
return fname; return fname;
#if defined Q_OS_WIN32 #if defined Q_OS_WIN
if (QFile::exists(fname + ".exe")) if (QFile::exists(fname + QLatin1String(".exe")))
return fname + ".exe"; return fname + QLatin1String(".exe");
if (QFile::exists(fname + ".bat")) if (QFile::exists(fname + QLatin1String(".bat")))
return fname + ".bat"; return fname + QLatin1String(".bat");
#endif #endif
} }
return ""; return QString();
} }
/*! /*!
@@ -219,8 +218,8 @@ QString which_p(const QString &path, const QString &applicationName)
QString QSystem::which(const QString &path, const QString &applicationName) QString QSystem::which(const QString &path, const QString &applicationName)
{ {
QString ret = which_p(path, applicationName); QString ret = which_p(path, applicationName);
if (ret.contains(" ")) if (ret.contains(QLatin1Char(' ')))
return '"' + ret + '"'; return QLatin1Char('"') + ret + QLatin1Char('"');
return ret; return ret;
} }
@@ -268,20 +267,20 @@ bool QSystem::processEnvValue(QStringList *envList, QString &envString)
QString prefix; QString prefix;
bool isSetCmd = false; bool isSetCmd = false;
if (_envString.startsWith("export ")) { if (_envString.startsWith(QLatin1String("export "))) {
_envString = _envString.mid(7); _envString = _envString.mid(7);
prefix = "export "; prefix = QLatin1String("export ");
isSetCmd = true; isSetCmd = true;
} }
if (_envString.startsWith("set ")) { if (_envString.startsWith(QLatin1String("set "))) {
_envString = _envString.mid(4); _envString = _envString.mid(4);
prefix = "set "; prefix = QLatin1String("set ");
isSetCmd = true; isSetCmd = true;
} }
if (isSetCmd) { if (isSetCmd) {
int pos = _envString.indexOf("="); int pos = _envString.indexOf(QLatin1Char('='));
if (pos < 0) { if (pos < 0) {
// nothing to do // nothing to do
return false; return false;
@@ -292,7 +291,7 @@ bool QSystem::processEnvValue(QStringList *envList, QString &envString)
if (processEnvValue(envList, value)) { if (processEnvValue(envList, value)) {
setEnvKey(envList, key, value); setEnvKey(envList, key, value);
envString = /*prefix +*/ key + "=" + value; envString = /*prefix +*/ key + QLatin1Char('=') + value;
return true; return true;
} else { } else {
return false; return false;
@@ -309,7 +308,7 @@ bool QSystem::processEnvValue(QStringList *envList, QString &envString)
int len = key.length()+1; int len = key.length()+1;
if (_envString.at(pos) == '%') if (_envString.at(pos) == '%')
len++; len++;
if (_envString.indexOf("("+ key + ")") == (pos + 1)) if (_envString.indexOf(QLatin1Char('(')+ key + QLatin1Char(')')) == (pos + 1))
len += 2; len += 2;
_envString.remove(pos, len); _envString.remove(pos, len);
_envString.insert(pos, replacementValue); _envString.insert(pos, replacementValue);
@@ -332,7 +331,7 @@ bool QSystem::processEnvValue(QStringList *envList, QString &envString)
bool QSystem::hasEnvKey(const QString &envString, QString &key, int &pos, int start) bool QSystem::hasEnvKey(const QString &envString, QString &key, int &pos, int start)
{ {
pos = -1; pos = -1;
key = ""; key.clear();
int end = -1; int end = -1;
bool winKey = false; bool winKey = false;
@@ -340,9 +339,9 @@ bool QSystem::hasEnvKey(const QString &envString, QString &key, int &pos, int st
++start; ++start;
int pos1, pos2, pos3; int pos1, pos2, pos3;
pos1 = envString.indexOf("$", start); pos1 = envString.indexOf(QLatin1Char('$'), start);
pos2 = envString.indexOf("%", start); pos2 = envString.indexOf(QLatin1Char('%'), start);
pos3 = envString.indexOf("%", pos2 + 1); pos3 = envString.indexOf(QLatin1Char('%'), pos2 + 1);
if (pos1 < 0 && pos2 < 0) if (pos1 < 0 && pos2 < 0)
return false; return false;
@@ -371,20 +370,20 @@ bool QSystem::hasEnvKey(const QString &envString, QString &key, int &pos, int st
end = -1; end = -1;
if (winKey) { if (winKey) {
// if we found a % we only look for a closing one // if we found a % we only look for a closing one
end = envString.indexOf("%", pos+1); end = envString.indexOf(QLatin1Char('%'), pos+1);
} else { } else {
// else look for some other characters that close a KEY // else look for some other characters that close a KEY
const uint maxSrch = 8; const uint maxSrch = 8;
int term[maxSrch]; int term[maxSrch];
term[0] = envString.indexOf("/", pos+1); term[0] = envString.indexOf(QLatin1Char('/'), pos+1);
term[1] = envString.indexOf(":", pos+1); term[1] = envString.indexOf(QLatin1Char(':'), pos+1);
term[2] = envString.indexOf("\\", pos+1); term[2] = envString.indexOf(QLatin1Char('\\'), pos+1);
term[3] = envString.indexOf(";", pos+1); term[3] = envString.indexOf(QLatin1Char(';'), pos+1);
term[4] = envString.indexOf(" ", pos+1); term[4] = envString.indexOf(QLatin1Char(' '), pos+1);
term[5] = envString.indexOf("-", pos+1); term[5] = envString.indexOf(QLatin1Char('-'), pos+1);
term[6] = envString.indexOf(".", pos+1); term[6] = envString.indexOf(QLatin1Char('.'), pos+1);
term[7] = envString.length(); term[7] = envString.length();
// now lets see which char comes first after pos: Thats the one we are looking for. // now lets see which char comes first after pos: Thats the one we are looking for.
@@ -404,7 +403,7 @@ bool QSystem::hasEnvKey(const QString &envString, QString &key, int &pos, int st
QString tmpKey = envString.mid(pos + 1, end - (pos+1)); QString tmpKey = envString.mid(pos + 1, end - (pos+1));
// see if we have a string that looks like $(QTDIR) and convert it to QTDIR // see if we have a string that looks like $(QTDIR) and convert it to QTDIR
if (tmpKey.startsWith("(") && tmpKey.endsWith(")")) if (tmpKey.startsWith(QLatin1Char('(')) && tmpKey.endsWith(QLatin1Char(')')))
tmpKey = tmpKey.mid(1, tmpKey.length()-2); tmpKey = tmpKey.mid(1, tmpKey.length()-2);
if (!tmpKey.isEmpty()) { if (!tmpKey.isEmpty()) {
@@ -418,7 +417,7 @@ bool QSystem::hasEnvKey(const QString &envString, QString &key, int &pos, int st
} }
/*! /*!
Removes any occurance of environment \a key from the environment \a list. Removes any occurrence of environment \a key from the environment \a list.
The function returns true if the list was valid and no more instances of \a key The function returns true if the list was valid and no more instances of \a key
exist in the list. exist in the list.
*/ */
@@ -434,7 +433,7 @@ bool QSystem::unsetEnvKey(QStringList *list, const QString &key)
QStringList::Iterator it; QStringList::Iterator it;
for (int i = list->size() - 1; i > 0; --i) { for (int i = list->size() - 1; i > 0; --i) {
QString s = list->at(i); QString s = list->at(i);
int pos = s.indexOf("="); int pos = s.indexOf(QLatin1Char('='));
if (pos > 0) { if (pos > 0) {
QString keyName = (s.left(pos)).toUpper(); QString keyName = (s.left(pos)).toUpper();
if (keyName == envKey) { if (keyName == envKey) {
@@ -469,7 +468,7 @@ bool QSystem::setEnvKey(QStringList *list, const QString &key, const QString &va
replacementValue = QSystem::envKey(list, tmpKey.toUpper()); replacementValue = QSystem::envKey(list, tmpKey.toUpper());
if (!replacementValue.isEmpty()) { if (!replacementValue.isEmpty()) {
int len = tmpKey.length() + 1; int len = tmpKey.length() + 1;
if (envValue.at(pos) == '%') if (envValue.at(pos) == QLatin1Char('%'))
++len; ++len;
envValue.remove(pos, len); envValue.remove(pos, len);
envValue.insert(pos, replacementValue); envValue.insert(pos, replacementValue);
@@ -482,18 +481,18 @@ bool QSystem::setEnvKey(QStringList *list, const QString &key, const QString &va
QStringList::Iterator end = list->end(); QStringList::Iterator end = list->end();
for (QStringList::Iterator it = list->begin(); it != end; ++it) { for (QStringList::Iterator it = list->begin(); it != end; ++it) {
QString s = *it; QString s = *it;
pos = s.indexOf("="); pos = s.indexOf(QLatin1Char('='));
if (pos > 0) { if (pos > 0) {
QString keyName = (s.left(pos)).toUpper(); QString keyName = (s.left(pos)).toUpper();
if (keyName == envKey) { if (keyName == envKey) {
*it = envKey + "=" + envValue; *it = envKey + QLatin1Char('=') + envValue;
list->sort(); list->sort();
return true; return true;
} }
} }
} }
list->append(envKey + "=" + envValue); list->append(envKey + QLatin1Char('=') + envValue);
list->sort(); list->sort();
return true; return true;
} }
@@ -503,9 +502,9 @@ void QSystem::addEnvPath(QStringList *environment, const QString &key, const QSt
QString dyldPath = QSystem::envKey(environment, key); QString dyldPath = QSystem::envKey(environment, key);
if (!dyldPath.contains(addedPath)) { if (!dyldPath.contains(addedPath)) {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
dyldPath = addedPath + ";" + dyldPath; dyldPath = addedPath + QLatin1Char(';') + dyldPath;
#else #else
dyldPath = addedPath + ":" + dyldPath; dyldPath = addedPath + QLatin1Char(':') + dyldPath;
#endif #endif
QSystem::setEnvKey(environment, key, dyldPath); QSystem::setEnvKey(environment, key, dyldPath);
} }
@@ -520,7 +519,7 @@ QString QSystem::envKey(QStringList *list, const QString &key)
{ {
QString value; QString value;
if (list == 0) if (list == 0)
return ""; return QString();
QString srchKey = key.toUpper(); QString srchKey = key.toUpper();
@@ -528,14 +527,14 @@ QString QSystem::envKey(QStringList *list, const QString &key)
QStringList::Iterator end = list->end(); QStringList::Iterator end = list->end();
for (QStringList::Iterator it = list->begin(); it != end; ++it) { for (QStringList::Iterator it = list->begin(); it != end; ++it) {
QString s = *it; QString s = *it;
pos = s.indexOf("="); pos = s.indexOf(QLatin1Char('='));
if (pos > 0) { if (pos > 0) {
QString keyName = (s.left(pos)).toUpper(); QString keyName = (s.left(pos)).toUpper();
if (keyName == srchKey) { if (keyName == srchKey) {
value = s.mid(pos+1); value = s.mid(pos+1);
if (value.endsWith(";%" + keyName + "%")) { if (value.endsWith(QLatin1String(";%") + keyName + QLatin1Char('%'))) {
value = value.left(value.length() - (3 + keyName.length())); value = value.left(value.length() - (3 + keyName.length()));
} else if (value.endsWith(":$" + keyName)) { } else if (value.endsWith(QLatin1String(":$") + keyName)) {
value = value.left(value.length() - (2 + keyName.length())); value = value.left(value.length() - (2 + keyName.length()));
} }
return value; return value;
@@ -543,5 +542,5 @@ QString QSystem::envKey(QStringList *list, const QString &key)
} }
} }
return ""; return QString();
} }

View File

@@ -35,6 +35,11 @@
#include "dialogs.h" #include "dialogs.h"
#include "qsystem.h" #include "qsystem.h"
#include "testsettingspropertiespage.h" #include "testsettingspropertiespage.h"
#include "resultsview.h"
#include "testexecuter.h"
#include "testcontextmenu.h"
#include "testsuite.h"
#include "testoutputwindow.h"
#include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/actioncontainer.h>
@@ -48,6 +53,7 @@
#include <coreplugin/progressmanager/progressmanager.h> #include <coreplugin/progressmanager/progressmanager.h>
#include <qmljseditor/qmljseditorconstants.h> #include <qmljseditor/qmljseditorconstants.h>
#include <texteditor/basetexteditor.h>
#include <cppeditor/cppeditorconstants.h> #include <cppeditor/cppeditorconstants.h>
#include <cpptools/cpptoolsconstants.h> #include <cpptools/cpptoolsconstants.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
@@ -76,6 +82,8 @@
using namespace QtTest::Internal; using namespace QtTest::Internal;
enum { debug = 0 };
Core::NavigationView TestNavigationWidgetFactory::createWidget() Core::NavigationView TestNavigationWidgetFactory::createWidget()
{ {
Core::NavigationView view; Core::NavigationView view;
@@ -109,16 +117,15 @@ Core::NavigationView TestNavigationWidgetFactory::createWidget()
QString TestNavigationWidgetFactory::displayName() const QString TestNavigationWidgetFactory::displayName() const
{ {
return "Tests"; return QtTestPlugin::tr("Tests");
} }
//****************************************** //******************************************
QtTestPlugin::QtTestPlugin() QtTestPlugin::QtTestPlugin() :
m_messageOutputWindow(0), m_testResultsWindow(0),
m_contextMenu(new TestContextMenu(this))
{ {
m_messageOutputWindow = 0;
m_testResultsWindow = 0;
m_contextMenu = new TestContextMenu(this);
} }
QtTestPlugin::~QtTestPlugin() QtTestPlugin::~QtTestPlugin()
@@ -235,8 +242,9 @@ void QtTestPlugin::testDebug()
Debugger::DebuggerRunControl *runControl = 0; Debugger::DebuggerRunControl *runControl = 0;
Debugger::DebuggerStartParameters params; Debugger::DebuggerStartParameters params;
params.startMode = Debugger::NoStartMode; // we'll start the test runner here params.startMode = Debugger::NoStartMode; // we'll start the test runner here
params.executable = ".qtt"; params.executable = QLatin1String(".qtt");
runControl = Debugger::DebuggerPlugin::createDebugger(params); runControl = Debugger::DebuggerPlugin::createDebugger(params);
if (debug)
qDebug() << "Debugger run control" << runControl; qDebug() << "Debugger run control" << runControl;
runControl->start(); runControl->start();
@@ -276,7 +284,7 @@ void QtTestPlugin::retryTests(const QStringList &tests)
QStringList newSelection; QStringList newSelection;
foreach (const QString &test, currentSelection) { foreach (const QString &test, currentSelection) {
QString testName = test.mid(test.lastIndexOf("/") + 1); QString testName = test.mid(test.lastIndexOf(QLatin1Char('/')) + 1);
if (tests.contains(testName)) if (tests.contains(testName))
newSelection.append(test); newSelection.append(test);
} }
@@ -288,8 +296,8 @@ void QtTestPlugin::insertTestFunction()
{ {
TestCode *currentTest = m_testCollection.currentEditedTest(); TestCode *currentTest = m_testCollection.currentEditedTest();
if (currentTest) { if (currentTest) {
QString prompt = "<b>" + currentTest->testTypeString() QString prompt = QLatin1String("<b>") + currentTest->testTypeString()
+ " Test: </b>" + currentTest->testCase(); + QLatin1String(" Test: </b>") + currentTest->testCase();
NewTestFunctionDlg dlg(prompt); NewTestFunctionDlg dlg(prompt);
dlg.exec(); dlg.exec();

View File

@@ -33,17 +33,16 @@
#ifndef QTTESTPLUGIN_H #ifndef QTTESTPLUGIN_H
#define QTTESTPLUGIN_H #define QTTESTPLUGIN_H
#include "testoutputwindow.h"
#include "testselector.h"
#include "resultsview.h"
#include "testexecuter.h"
#include "testcontextmenu.h"
#include "testsuite.h" #include "testsuite.h"
#include <coreplugin/inavigationwidgetfactory.h> #include <coreplugin/inavigationwidgetfactory.h>
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
#include <QtCore/QObject> #include <QtCore/QObject>
class TestContextMenu;
class TestResultsWindow;
class TestOutputWindow;
namespace QtTest { namespace QtTest {
namespace Internal { namespace Internal {

View File

@@ -54,12 +54,13 @@
#include <QApplication> #include <QApplication>
#include <QDebug> #include <QDebug>
enum { enum
RES_SIZE = 100, {
RESULT_POS = 0, ResultSize = 100,
DETAILS_POS = 1, ResultPosition = 0,
REASON_POS = 2, DetailsPosition = 1,
SCREEN_POS = 3 ReasonPosition = 2,
ScreenPosition = 3
}; };
// Role for data which holds the identifier for use with m_pendingScreenshots // Role for data which holds the identifier for use with m_pendingScreenshots
@@ -67,9 +68,6 @@ static const int ScreenshotIdRole = Qt::UserRole + 10;
// Role for the link to the .png file of a failure screenshot // Role for the link to the .png file of a failure screenshot
static const int ScreenshotLinkRole = Qt::UserRole + 100; static const int ScreenshotLinkRole = Qt::UserRole + 100;
static QBrush passBrush(QColor("lightgreen"));
static QBrush failBrush(QColor("orangered"));
static QBrush unexpectedBrush(QColor("orange"));
/* /*
Constructs a screenshot ID for the test failure at the given \a file and Constructs a screenshot ID for the test failure at the given \a file and
@@ -80,10 +78,15 @@ static QString screenshotId(const QString &file, int line)
return QString::fromLatin1("%1 %2").arg(QFileInfo(file).canonicalFilePath()).arg(line); return QString::fromLatin1("%1 %2").arg(QFileInfo(file).canonicalFilePath()).arg(line);
} }
ResultsView::ResultsView(QWidget *parent, const char *name) : ResultsView::ResultsView(QWidget *parent) :
QTableWidget(parent) QTableWidget(parent),
m_lastRow(-1),
m_ignoreEvent(false),
m_userLock(false),
m_passBrush(QColor("lightgreen")),
m_failBrush(QColor("orangered")),
m_unexpectedBrush(QColor("orange"))
{ {
setObjectName(name);
setColumnCount(3); setColumnCount(3);
setGridStyle(Qt::NoPen); setGridStyle(Qt::NoPen);
@@ -103,11 +106,6 @@ ResultsView::ResultsView(QWidget *parent, const char *name) :
verticalHeader()->hide(); verticalHeader()->hide();
horizontalHeader()->show(); horizontalHeader()->show();
m_lastRow = -1;
m_ignoreEvent = false;
m_userLock = false;
connect(this, SIGNAL(currentCellChanged(int,int,int,int)), connect(this, SIGNAL(currentCellChanged(int,int,int,int)),
this, SLOT(onChanged()), Qt::DirectConnection); this, SLOT(onChanged()), Qt::DirectConnection);
connect(this, SIGNAL(itemClicked(QTableWidgetItem*)), connect(this, SIGNAL(itemClicked(QTableWidgetItem*)),
@@ -122,14 +120,14 @@ ResultsView::~ResultsView()
void ResultsView::resize(int width) void ResultsView::resize(int width)
{ {
resizeColumnToContents(RESULT_POS); resizeColumnToContents(ResultPosition);
if (columnWidth(RESULT_POS) < RES_SIZE) if (columnWidth(ResultPosition) < ResultSize)
setColumnWidth(RESULT_POS, RES_SIZE); setColumnWidth(ResultPosition, ResultSize);
resizeColumnToContents(DETAILS_POS); resizeColumnToContents(DetailsPosition);
if (columnWidth(DETAILS_POS) < RES_SIZE) if (columnWidth(DetailsPosition) < ResultSize)
setColumnWidth(DETAILS_POS, RES_SIZE); setColumnWidth(DetailsPosition, ResultSize);
setColumnWidth(DETAILS_POS, columnWidth(DETAILS_POS) + 20); setColumnWidth(DetailsPosition, columnWidth(DetailsPosition) + 20);
setColumnWidth(REASON_POS, width - columnWidth(RESULT_POS) - columnWidth(DETAILS_POS)); setColumnWidth(ReasonPosition, width - columnWidth(ResultPosition) - columnWidth(DetailsPosition));
} }
void ResultsView::resizeEvent(QResizeEvent *event) void ResultsView::resizeEvent(QResizeEvent *event)
@@ -177,7 +175,7 @@ void ResultsView::addScreenshot(const QString &screenshot, const QString &testfu
void ResultsView::updateScreenshots() void ResultsView::updateScreenshots()
{ {
for (int row = 0; row < rowCount(); ++row) { for (int row = 0; row < rowCount(); ++row) {
QTableWidgetItem *result = item(row, RESULT_POS); QTableWidgetItem *result = item(row, ResultPosition);
if (!result) if (!result)
continue; continue;
// If there is a screenshot for this result, put a link to it in the table. // If there is a screenshot for this result, put a link to it in the table.
@@ -189,7 +187,7 @@ void ResultsView::updateScreenshots()
QTableWidgetItem* shot = new QTableWidgetItem(QIcon(QPixmap(QLatin1String(":/testrun.png"))), QString()); QTableWidgetItem* shot = new QTableWidgetItem(QIcon(QPixmap(QLatin1String(":/testrun.png"))), QString());
shot->setData(ScreenshotLinkRole, screenshot); shot->setData(ScreenshotLinkRole, screenshot);
shot->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); shot->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
setItem(row, SCREEN_POS, shot); setItem(row, ScreenPosition, shot);
} }
} }
@@ -214,16 +212,16 @@ void ResultsView::append(const QString &res, const QString &test, const QString
QTableWidgetItem* result = new QTableWidgetItem(res); QTableWidgetItem* result = new QTableWidgetItem(res);
result->setTextAlignment(Qt::AlignCenter); result->setTextAlignment(Qt::AlignCenter);
if (res.startsWith(QLatin1String("PASS"))) { if (res.startsWith(QLatin1String("PASS"))) {
result->setBackground(passBrush); result->setBackground(m_passBrush);
setRowHidden(row, !m_showPassing); setRowHidden(row, !m_showPassing);
} else if (res.startsWith(QLatin1String("FAIL"))) { } else if (res.startsWith(QLatin1String("FAIL"))) {
result->setBackground(failBrush); result->setBackground(m_failBrush);
} else if (res.startsWith(QLatin1String("QDEBUG"))) { } else if (res.startsWith(QLatin1String("QDEBUG"))) {
setRowHidden(row, !m_showDebug); setRowHidden(row, !m_showDebug);
} else if (res.startsWith(QLatin1String("SKIP"))) { } else if (res.startsWith(QLatin1String("SKIP"))) {
setRowHidden(row, !m_showSkipped); setRowHidden(row, !m_showSkipped);
} else if (res.startsWith(QLatin1String("XFAIL")) || res.startsWith(QLatin1String("XPASS"))) { } else if (res.startsWith(QLatin1String("XFAIL")) || res.startsWith(QLatin1String("XPASS"))) {
result->setBackground(unexpectedBrush); result->setBackground(m_unexpectedBrush);
} }
if ((res.contains(QLatin1String("FAIL")) || res.startsWith(QLatin1String("XPASS"))) && !m_failedTests.contains(test)) if ((res.contains(QLatin1String("FAIL")) || res.startsWith(QLatin1String("XPASS"))) && !m_failedTests.contains(test))
@@ -235,14 +233,14 @@ void ResultsView::append(const QString &res, const QString &test, const QString
QTableWidgetItem *testDetails = new QTableWidgetItem(formatTestDetails(test, dataTag)); QTableWidgetItem *testDetails = new QTableWidgetItem(formatTestDetails(test, dataTag));
testDetails->setToolTip(formatLocation(file, line)); testDetails->setToolTip(formatLocation(file, line));
setItem(row, RESULT_POS, result); setItem(row, ResultPosition, result);
setItem(row, DETAILS_POS, testDetails); setItem(row, DetailsPosition, testDetails);
setItem(row, REASON_POS, new QTableWidgetItem(reason)); setItem(row, ReasonPosition, new QTableWidgetItem(reason));
resize(width()); resize(width());
resizeRowToContents(row); resizeRowToContents(row);
if (currentRow() == -1) if (currentRow() == -1)
scrollToItem(item(row, REASON_POS)); scrollToItem(item(row, ReasonPosition));
m_resultsWindow->navigateStateChanged(); m_resultsWindow->navigateStateChanged();
updateScreenshots(); updateScreenshots();
@@ -302,7 +300,7 @@ QString ResultsView::result(int row)
if (row >= rowCount()) if (row >= rowCount())
return QString(); return QString();
return item(row, RESULT_POS)->text().simplified(); return item(row, ResultPosition)->text().simplified();
} }
QString ResultsView::reason(int row) QString ResultsView::reason(int row)
@@ -310,7 +308,7 @@ QString ResultsView::reason(int row)
if (row >= rowCount()) if (row >= rowCount())
return QString(); return QString();
QString txt = item(row, REASON_POS)->text(); QString txt = item(row, ReasonPosition)->text();
const int pos = txt.indexOf(QLatin1Char('\n')); const int pos = txt.indexOf(QLatin1Char('\n'));
if (pos > 0) if (pos > 0)
txt.truncate(pos); txt.truncate(pos);
@@ -322,7 +320,7 @@ QString ResultsView::location(int row)
if (row >= rowCount()) if (row >= rowCount())
return QString(); return QString();
return item(row, DETAILS_POS)->toolTip(); return item(row, DetailsPosition)->toolTip();
} }
QString ResultsView::file(int row) QString ResultsView::file(int row)
@@ -440,7 +438,7 @@ void ResultsView::showSkipped(bool show)
void ResultsView::updateHidden(const QString &result, bool show) void ResultsView::updateHidden(const QString &result, bool show)
{ {
for (int row = 0; row < rowCount(); ++row) { for (int row = 0; row < rowCount(); ++row) {
QTableWidgetItem *resultItem = item(row, RESULT_POS); QTableWidgetItem *resultItem = item(row, ResultPosition);
if (resultItem && resultItem->text().startsWith(result)) if (resultItem && resultItem->text().startsWith(result))
setRowHidden(row, !show); setRowHidden(row, !show);
} }
@@ -679,10 +677,10 @@ void ResultsView::copyResults()
QString html = QLatin1String("<html><table>"); QString html = QLatin1String("<html><table>");
QString text; QString text;
for (int row = 0; row < rowCount(); ++row) { for (int row = 0; row < rowCount(); ++row) {
QString result = item(row, RESULT_POS)->text().trimmed(); QString result = item(row, ResultPosition)->text().trimmed();
QString detail = item(row, DETAILS_POS)->text(); QString detail = item(row, DetailsPosition)->text();
QString location = item(row, DETAILS_POS)->toolTip(); QString location = item(row, DetailsPosition)->toolTip();
QString reason = item(row, REASON_POS)->text(); QString reason = item(row, ReasonPosition)->text();
html += QString::fromLatin1("<tr><td>%1</td><td>%2</td><td>%3</td><td>%4</td></tr>") html += QString::fromLatin1("<tr><td>%1</td><td>%2</td><td>%3</td><td>%4</td></tr>")
.arg(result).arg(detail).arg(location).arg(htmlQuote(reason)); .arg(result).arg(detail).arg(location).arg(htmlQuote(reason));
text += QString::fromLatin1("%1\n%2\n%3\n%4\n").arg(result).arg(detail).arg(location).arg(reason); text += QString::fromLatin1("%1\n%2\n%3\n%4\n").arg(result).arg(detail).arg(location).arg(reason);

View File

@@ -37,7 +37,9 @@
#include "testsettings.h" #include "testsettings.h"
#include <coreplugin/ioutputpane.h> #include <coreplugin/ioutputpane.h>
#include <QTableWidget> #include <QTableWidget>
#include <QBrush>
class ResultsView; class ResultsView;
class TestResultsWindow; class TestResultsWindow;
@@ -50,7 +52,7 @@ class ResultsView : public QTableWidget
Q_OBJECT Q_OBJECT
public: public:
ResultsView(QWidget *parent = 0, const char *name = 0); explicit ResultsView(QWidget *parent = 0);
virtual ~ResultsView(); virtual ~ResultsView();
QString result(int row); QString result(int row);
@@ -78,6 +80,14 @@ public slots:
signals: signals:
void defectSelected(TestCaseRec rec); void defectSelected(TestCaseRec rec);
private slots:
void onChanged();
void emitCurSelection();
void onItemClicked(QTableWidgetItem *);
void showPassing(bool);
void showDebugMessages(bool);
void showSkipped(bool);
private: private:
QString formatTestDetails(const QString &test, const QString &dataTag); QString formatTestDetails(const QString &test, const QString &dataTag);
QString formatLocation(const QString &file, const QString &line); QString formatLocation(const QString &file, const QString &line);
@@ -106,14 +116,9 @@ private:
bool m_showSkipped; bool m_showSkipped;
QStringList m_failedTests; QStringList m_failedTests;
TestSettings m_testSettings; TestSettings m_testSettings;
const QBrush m_passBrush;
private slots: const QBrush m_failBrush;
void onChanged(); const QBrush m_unexpectedBrush;
void emitCurSelection();
void onItemClicked(QTableWidgetItem *);
void showPassing(bool);
void showDebugMessages(bool);
void showSkipped(bool);
}; };
class TestResultsWindow : public Core::IOutputPane class TestResultsWindow : public Core::IOutputPane

View File

@@ -42,9 +42,16 @@
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <texteditor/basetexteditor.h>
#include <coreplugin/icontext.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <qmljs/parser/qmljsastvisitor_p.h> #include <qmljs/parser/qmljsastvisitor_p.h>
#include <qmljs/parser/qmljsast_p.h> #include <qmljs/parser/qmljsast_p.h>
#include <AST.h> #include <AST.h>
#include <ASTVisitor.h> #include <ASTVisitor.h>
#include <Literals.h> #include <Literals.h>
@@ -85,8 +92,8 @@ private:
bool visit(QmlJS::AST::IdentifierExpression *identifier) bool visit(QmlJS::AST::IdentifierExpression *identifier)
{ {
QString name = identifier->name->asString(); QString name = identifier->name->asString();
m_foundTestCase = (name == "testcase"); m_foundTestCase = (name == QLatin1String("testcase"));
if (!m_foundTestCase && (name == "prompt" || name == "manualTest")) if (!m_foundTestCase && (name == QLatin1String("prompt") || name == QLatin1String("manualTest")))
m_testCode->setManualTest(identifier->identifierToken.offset); m_testCode->setManualTest(identifier->identifierToken.offset);
return true; return true;
} }
@@ -175,7 +182,7 @@ protected:
if (symbol->name()) { if (symbol->name()) {
const CPlusPlus::QualifiedNameId *qn = symbol->name()->asQualifiedNameId(); const CPlusPlus::QualifiedNameId *qn = symbol->name()->asQualifiedNameId();
if (qn && qn->base()) { if (qn && qn->base()) {
QString name = QString("%1::%2").arg(qn->base()->identifier()->chars()) QString name = QString::fromLatin1("%1::%2").arg(qn->base()->identifier()->chars())
.arg(qn->name()->identifier()->chars()); .arg(qn->name()->identifier()->chars());
if (m_knownTestFunctions.contains(name)) if (m_knownTestFunctions.contains(name))
m_testCode->processFunction(QString(symbol->name()->identifier()->chars()), m_testCode->processFunction(QString(symbol->name()->identifier()->chars()),
@@ -197,7 +204,7 @@ protected:
CPlusPlus::Symbol *member = *it; CPlusPlus::Symbol *member = *it;
CPlusPlus::Function *fun = member->type()->asFunctionType(); CPlusPlus::Function *fun = member->type()->asFunctionType();
if (fun && fun->isSlot() && member && member->name() && member->name()->identifier()) { if (fun && fun->isSlot() && member && member->name() && member->name()->identifier()) {
m_knownTestFunctions.append(className + "::" m_knownTestFunctions.append(className + QLatin1String("::")
+ QString(member->name()->identifier()->chars())); + QString(member->name()->identifier()->chars()));
m_testCode->processFunction(QString(member->name()->identifier()->chars()), m_testCode->processFunction(QString(member->name()->identifier()->chars()),
fun->line(), fun->startOffset(), fun->endOffset()); fun->line(), fun->startOffset(), fun->endOffset());
@@ -259,11 +266,11 @@ TestFunctionInfo& TestFunctionInfo::operator=(const TestFunctionInfo &other)
bool TestFunctionInfo::validFunctionName(const QString &funcName) bool TestFunctionInfo::validFunctionName(const QString &funcName)
{ {
return (!funcName.isEmpty() return (!funcName.isEmpty()
&& funcName != "init" && funcName != QLatin1String("init")
&& funcName != "initTestCase" && funcName != QLatin1String("initTestCase")
&& funcName != "cleanup" && funcName != QLatin1String("cleanup")
&& funcName != "cleanupTestCase" && funcName != QLatin1String("cleanupTestCase")
&& !funcName.endsWith("_data")); && !funcName.endsWith(QLatin1String("_data")));
} }
TestCode::TestCode(const QString &basePath, const QString &externalPath, const QString &fileName) : TestCode::TestCode(const QString &basePath, const QString &externalPath, const QString &fileName) :
@@ -278,13 +285,13 @@ TestCode::TestCode(const QString &basePath, const QString &externalPath, const Q
m_errored(false) m_errored(false)
{ {
QString baseName = baseFileName(); QString baseName = baseFileName();
if (baseName.endsWith(".qtt")) if (baseName.endsWith(QLatin1String(".qtt")))
m_testType = TypeSystemTest; m_testType = TypeSystemTest;
else if (baseName.startsWith("prf_")) else if (baseName.startsWith(QLatin1String("prf_")))
m_testType = TypePerformanceTest; m_testType = TypePerformanceTest;
else if (baseName.startsWith("int_")) else if (baseName.startsWith(QLatin1String("int_")))
m_testType = TypeIntegrationTest; m_testType = TypeIntegrationTest;
else if (baseName.endsWith(".cpp")) else if (baseName.endsWith(QLatin1String(".cpp")))
m_testType = TypeUnitTest; m_testType = TypeUnitTest;
connect(&m_parseTimer, SIGNAL(timeout()), this, SLOT(parseDocument()), Qt::DirectConnection); connect(&m_parseTimer, SIGNAL(timeout()), this, SLOT(parseDocument()), Qt::DirectConnection);
@@ -297,17 +304,17 @@ TestCode::~TestCode()
bool TestCode::parseComments(const QString &contents) bool TestCode::parseComments(const QString &contents)
{ {
static QRegExp componentRegEx("//TESTED_COMPONENT=(.*)"); static QRegExp componentRegEx(QLatin1String("//TESTED_COMPONENT=(.*)"));
static QRegExp fileRegEx("//TESTED_FILE=(.*)"); static QRegExp fileRegEx(QLatin1String("//TESTED_FILE=(.*)"));
static QRegExp classRegEx("//TESTED_CLASS=(.*)"); static QRegExp classRegEx(QLatin1String("//TESTED_CLASS=(.*)"));
static QRegExp groupsRegEx("\\\\groups\\s+(.*)"); static QRegExp groupsRegEx(QLatin1String("\\\\groups\\s+(.*)"));
m_testedComponent.clear(); m_testedComponent.clear();
m_testedFile.clear(); m_testedFile.clear();
m_testedClass.clear(); m_testedClass.clear();
int offset = 0; int offset = 0;
QStringList fileContents = contents.split("\n"); QStringList fileContents = contents.split(QLatin1Char('\n'));
foreach (const QString &line, fileContents) { foreach (const QString &line, fileContents) {
if (m_testedComponent.isEmpty() && line.contains(componentRegEx)) { if (m_testedComponent.isEmpty() && line.contains(componentRegEx)) {
m_testedComponent = componentRegEx.cap(1); m_testedComponent = componentRegEx.cap(1);
@@ -348,10 +355,10 @@ bool TestCode::openTestInEditor(const QString &testFunction)
m_codeEditor = qobject_cast<TextEditor::BaseTextEditor*>(edit); m_codeEditor = qobject_cast<TextEditor::BaseTextEditor*>(edit);
if (m_codeEditor) { if (m_codeEditor) {
if (m_fileName.endsWith(".qtt")) { if (m_fileName.endsWith(QLatin1String(".qtt"))) {
connect(edit, SIGNAL(contextHelpIdRequested(TextEditor::ITextEditor*,int)), connect(edit, SIGNAL(contextHelpIdRequested(TextEditor::ITextEditor*,int)),
this, SLOT(onContextHelpIdRequested(TextEditor::ITextEditor*,int))); this, SLOT(onContextHelpIdRequested(TextEditor::ITextEditor*,int)));
m_codeEditor->setContextHelpId("QtUiTest Manual"); m_codeEditor->setContextHelpId(QLatin1String("QtUiTest Manual"));
} }
} }
@@ -399,7 +406,7 @@ bool TestCode::testFunctionExists(QString funcName)
QString TestCode::testedComponent() const QString TestCode::testedComponent() const
{ {
if (m_testedComponent.isEmpty()) if (m_testedComponent.isEmpty())
return "other"; return QLatin1String("other");
return m_testedComponent; return m_testedComponent;
} }
@@ -506,19 +513,19 @@ QString TestCode::testTypeString() const
QString ret; QString ret;
switch (m_testType) { switch (m_testType) {
case TypeUnitTest: case TypeUnitTest:
ret = "Unit"; ret = QLatin1String("Unit");
break; break;
case TypeIntegrationTest: case TypeIntegrationTest:
ret = "Integration"; ret = QLatin1String("Integration");
break; break;
case TypePerformanceTest: case TypePerformanceTest:
ret = "Performance"; ret = QLatin1String("Performance");
break; break;
case TypeSystemTest: case TypeSystemTest:
ret = "System"; ret = QLatin1String("System");
break; break;
default: default:
ret = "Unknown"; ret = QLatin1String("Unknown");
break; break;
} }
return ret; return ret;
@@ -574,7 +581,7 @@ void TestCode::parseDocument()
m_testCase.clear(); m_testCase.clear();
if (m_testType == TypeSystemTest) { if (m_testType == TypeSystemTest) {
static QRegExp fileNameReg(".*/(.*)/.*\\.qtt$"); static QRegExp fileNameReg(QLatin1String(".*/(.*)/.*\\.qtt$"));
if (fileNameReg.indexIn(QDir::fromNativeSeparators(m_qmlJSDoc->fileName())) >= 0) if (fileNameReg.indexIn(QDir::fromNativeSeparators(m_qmlJSDoc->fileName())) >= 0)
m_testCase = fileNameReg.cap(1); m_testCase = fileNameReg.cap(1);
SystemTestCodeSync sync(this); SystemTestCodeSync sync(this);
@@ -584,10 +591,10 @@ void TestCode::parseDocument()
m_errored = true; m_errored = true;
} else { } else {
// Determine the testcase class name // Determine the testcase class name
foreach (const CPlusPlus::Document::MacroUse macro, m_cppDoc->macroUses()) { foreach (const CPlusPlus::Document::MacroUse &macro, m_cppDoc->macroUses()) {
QString macroName(macro.macro().name()); QString macroName(macro.macro().name());
if (macro.isFunctionLike() && ((macroName == "QTEST_MAIN") if (macro.isFunctionLike() && ((macroName == QLatin1String("QTEST_MAIN"))
|| (macroName == "QTEST_APPLESS_MAIN") || (macroName == "QTEST_NOOP_MAIN"))) { || (macroName == QLatin1String("QTEST_APPLESS_MAIN")) || (macroName == QLatin1String("QTEST_NOOP_MAIN")))) {
int pos = macro.arguments()[0].position(); int pos = macro.arguments()[0].position();
int length = macro.arguments()[0].length(); int length = macro.arguments()[0].length();
m_testCase = contents.mid(pos, length); m_testCase = contents.mid(pos, length);
@@ -628,15 +635,15 @@ QString TestCode::projectFileName()
// Figure out what the pro file is. // Figure out what the pro file is.
QString srcPath = QDir::convertSeparators(m_fileInfo->absolutePath()); QString srcPath = QDir::convertSeparators(m_fileInfo->absolutePath());
QDir D(srcPath); QDir D(srcPath);
QStringList files = D.entryList(QStringList("*.pro")); QStringList files = D.entryList(QStringList(QLatin1String("*.pro")));
if (files.count() > 1) { if (files.count() > 1) {
qDebug() << "CFAIL", "I am confused: Multiple .pro files (" + files.join(",") qDebug() << "CFAIL", "I am confused: Multiple .pro files (" + files.join(QString(QLatin1Char(',')))
+ ") found in '" + srcPath + "'."; + ") found in '" + srcPath + "'.";
return ""; return QString();
} }
if (files.count() == 0) if (files.count() == 0)
return ""; return QString();
return QString(srcPath + QDir::separator() + files[0]); return QString(srcPath + QDir::separator() + files[0]);
} }
@@ -645,19 +652,19 @@ QString TestCode::execFileName()
{ {
QString proFile = projectFileName(); QString proFile = projectFileName();
if (proFile.isEmpty()) if (proFile.isEmpty())
return ""; return QString();
QFile F(proFile); QFile F(proFile);
if (F.open(QFile::ReadOnly)) { if (F.open(QFile::ReadOnly)) {
QTextStream S(&F); QTextStream S(&F);
while (!S.atEnd()) { while (!S.atEnd()) {
QString line = S.readLine(); QString line = S.readLine();
if (line.contains("TARGET")) { if (line.contains(QLatin1String("TARGET"))) {
line = line.mid(line.indexOf("=") + 1); line = line.mid(line.indexOf(QLatin1Char('=')) + 1);
line = line.simplified(); line = line.simplified();
if (line.contains("$$TARGET")) { if (line.contains(QLatin1String("$$TARGET"))) {
QFileInfo inf(proFile); QFileInfo inf(proFile);
line.replace("$$TARGET",inf.baseName()); line.replace(QLatin1String("$$TARGET"),inf.baseName());
} }
return line; return line;
} }
@@ -670,7 +677,7 @@ QString TestCode::execFileName()
return fInfo.baseName(); return fInfo.baseName();
} }
return ""; return QString();
} }
@@ -755,7 +762,7 @@ bool TestCollection_p::isUnitTestCase(const CPlusPlus::Document::Ptr &doc,
{ {
// If a source file #includes QtTest/QTest, assume it is a testcase // If a source file #includes QtTest/QTest, assume it is a testcase
foreach (const CPlusPlus::Document::Include &i, doc->includes()) { foreach (const CPlusPlus::Document::Include &i, doc->includes()) {
if (i.fileName().contains("QtTest") || i.fileName().contains("QTest")) if (i.fileName().contains(QLatin1String("QtTest")) || i.fileName().contains(QLatin1String("QTest")))
return true; return true;
if (visited.contains(i.fileName())) if (visited.contains(i.fileName()))
@@ -833,7 +840,7 @@ void TestCollection_p::scanTests(const QString &suitePath)
if (!D.exists()) if (!D.exists())
return; return;
QFileInfoList qttTestFiles = D.entryInfoList(QStringList() << "*.qtt", QDir::Files); QFileInfoList qttTestFiles = D.entryInfoList(QStringList(QLatin1String("*.qtt")), QDir::Files);
QStringList qttTests; QStringList qttTests;
foreach (const QFileInfo &qttTestFile, qttTestFiles) { foreach (const QFileInfo &qttTestFile, qttTestFiles) {
qttTests << qttTestFile.absoluteFilePath(); qttTests << qttTestFile.absoluteFilePath();
@@ -843,7 +850,7 @@ void TestCollection_p::scanTests(const QString &suitePath)
if (!qttTests.isEmpty()) if (!qttTests.isEmpty())
m_qmlJSModelManager->updateSourceFiles(qttTests, true); m_qmlJSModelManager->updateSourceFiles(qttTests, true);
QFileInfoList cppTestFiles = D.entryInfoList(QStringList() << "*.cpp", QDir::Files); QFileInfoList cppTestFiles = D.entryInfoList(QStringList(QLatin1String("*.cpp")), QDir::Files);
QStringList cppTests; QStringList cppTests;
const CPlusPlus::Snapshot snapshot = m_cppModelManager->snapshot(); const CPlusPlus::Snapshot snapshot = m_cppModelManager->snapshot();
foreach (const QFileInfo &cppTestFile, cppTestFiles) { foreach (const QFileInfo &cppTestFile, cppTestFiles) {
@@ -860,11 +867,11 @@ void TestCollection_p::scanTests(const QString &suitePath)
m_cppModelManager->updateSourceFiles(cppTests); m_cppModelManager->updateSourceFiles(cppTests);
QStringList potentialSubdirs = QStringList potentialSubdirs =
D.entryList(QStringList() << "*", QDir::Dirs|QDir::NoDotAndDotDot); D.entryList(QStringList(QString(QLatin1Char('*'))), QDir::Dirs|QDir::NoDotAndDotDot);
foreach (const QString &dname, potentialSubdirs) { foreach (const QString &dname, potentialSubdirs) {
// stop scanning subdirs if we've ended up in a testdata subdir // stop scanning subdirs if we've ended up in a testdata subdir
if (dname != "testdata") if (dname != QLatin1String("testdata"))
scanTests(suitePath + QDir::separator() + dname); scanTests(suitePath + QDir::separator() + dname);
} }
} }
@@ -893,12 +900,12 @@ TestCode *TestCollection_p::findCode(const QString &fileName, const QString &bas
QFileInfo inf(fileName); QFileInfo inf(fileName);
if (inf.exists() && inf.isFile()) { if (inf.exists() && inf.isFile()) {
tmp = new TestCode(basePath, extraPath, fileName); tmp = new TestCode(basePath, extraPath, fileName);
if (fileName.endsWith(".qtt")) { if (fileName.endsWith(QLatin1String(".qtt"))) {
m_qttDocumentMap[fileName] = tmp; m_qttDocumentMap[fileName] = tmp;
m_qmlJSModelManager->updateSourceFiles(QStringList() << fileName, true); m_qmlJSModelManager->updateSourceFiles(QStringList(fileName), true);
} else { } else {
m_cppDocumentMap[fileName] = tmp; m_cppDocumentMap[fileName] = tmp;
m_cppModelManager->updateSourceFiles(QStringList() << fileName); m_cppModelManager->updateSourceFiles(QStringList(fileName));
} }
if (tmp) { if (tmp) {
m_codeList.append(tmp); m_codeList.append(tmp);
@@ -969,8 +976,11 @@ QStringList TestCollection_p::manualTests(const QString &startPath, bool compone
if (tmp && (startPath.isEmpty() || tmp->visualFileName(componentMode).startsWith(startPath))) { if (tmp && (startPath.isEmpty() || tmp->visualFileName(componentMode).startsWith(startPath))) {
for (uint j = 0; j < tmp->testFunctionCount(); ++j) { for (uint j = 0; j < tmp->testFunctionCount(); ++j) {
TestFunctionInfo *inf = tmp->testFunction(j); TestFunctionInfo *inf = tmp->testFunction(j);
if (inf && inf->isManualTest()) if (inf && inf->isManualTest()) {
ret.append(QString("%1::%2").arg(tmp->testCase()).arg(inf->functionName())); ret.append(tmp->testCase());
ret.append(QLatin1String("::"));
ret.append(inf->functionName());
}
} }
} }
} }
@@ -1116,8 +1126,8 @@ void TestCode::setManualTest(int offset)
bool TestCode::validFunctionName(const QString &funcName) bool TestCode::validFunctionName(const QString &funcName)
{ {
if (funcName.isEmpty() || funcName == "initTestCase" || funcName == "init" if (funcName.isEmpty() || funcName == QLatin1String("initTestCase") || funcName == QLatin1String("init")
|| funcName == "cleanupTestCase" || funcName == "cleanup" || funcName.endsWith("_data")) { || funcName == QLatin1String("cleanupTestCase") || funcName == QLatin1String("cleanup") || funcName.endsWith(QLatin1String("_data"))) {
return false; return false;
} }
return true; return true;
@@ -1166,7 +1176,7 @@ void TestCode::addTestFunction(const QString &newFuncName, const QString &newFun
} }
QString insertString = QString insertString =
QString("\n\n %1_data:\n {\n },\n\n %1: function()\n {\n }") QString::fromLatin1("\n\n %1_data:\n {\n },\n\n %1: function()\n {\n }")
.arg(newFuncName); .arg(newFuncName);
m_codeEditor->setCursorPosition(entryPoint); m_codeEditor->setCursorPosition(entryPoint);
@@ -1175,10 +1185,10 @@ void TestCode::addTestFunction(const QString &newFuncName, const QString &newFun
QString lineBefore = m_codeEditor->textAt(m_codeEditor->position(), lineLength).simplified(); QString lineBefore = m_codeEditor->textAt(m_codeEditor->position(), lineLength).simplified();
m_codeEditor->setCursorPosition(m_codeEditor->position(TextEditor::ITextEditor::EndOfLine)); m_codeEditor->setCursorPosition(m_codeEditor->position(TextEditor::ITextEditor::EndOfLine));
if (!lineBefore.endsWith(",") && !m_testFunctions.isEmpty()) if (!lineBefore.endsWith(QLatin1Char(',')) && !m_testFunctions.isEmpty())
insertString.prepend(","); insertString.prepend(QLatin1Char(','));
else else
insertString.append(","); insertString.append(QLatin1Char(','));
m_codeEditor->insert(insertString); m_codeEditor->insert(insertString);
} else { } else {
@@ -1228,7 +1238,7 @@ void TestCode::addTestFunction(const QString &newFuncName, const QString &newFun
m_codeEditor->gotoLine(declLine); m_codeEditor->gotoLine(declLine);
m_codeEditor->setCursorPosition(m_codeEditor->position(TextEditor::ITextEditor::StartOfLine)); m_codeEditor->setCursorPosition(m_codeEditor->position(TextEditor::ITextEditor::StartOfLine));
insertString = QString(" void %1_data();\n void %1();\n").arg(newFuncName); insertString = QString::fromLatin1(" void %1_data();\n void %1();\n").arg(newFuncName);
m_codeEditor->insert(insertString); m_codeEditor->insert(insertString);
m_codeEditor->gotoLine(entryLine + 2); m_codeEditor->gotoLine(entryLine + 2);
} }
@@ -1260,18 +1270,18 @@ QString TestCode::actualBasePath()
QString TestCode::fullVisualSuitePath(bool componentViewMode) const QString TestCode::fullVisualSuitePath(bool componentViewMode) const
{ {
if (m_fileName.isEmpty()) if (m_fileName.isEmpty())
return ""; return QString();
if (componentViewMode) if (componentViewMode)
return QDir::convertSeparators(m_basePath + QDir::separator() + testedComponent()); return QDir::convertSeparators(m_basePath + QDir::separator() + testedComponent());
if (!m_fileName.endsWith(".cpp") && !m_fileName.endsWith(".qtt")) if (!m_fileName.endsWith(QLatin1String(".cpp")) && !m_fileName.endsWith(QLatin1String(".qtt")))
return m_fileName; return m_fileName;
QString fn = m_fileName; QString fn = m_fileName;
if (!m_externalPath.isEmpty() && fn.startsWith(m_externalPath)) { if (!m_externalPath.isEmpty() && fn.startsWith(m_externalPath)) {
fn.remove(m_externalPath); fn.remove(m_externalPath);
fn = m_basePath + QDir::separator() + "tests" + QDir::separator() + "external" + fn; fn = m_basePath + QDir::separator() + QLatin1String("tests") + QDir::separator() + QLatin1String("external") + fn;
} }
QFileInfo inf(fn); QFileInfo inf(fn);
@@ -1282,7 +1292,7 @@ QString TestCode::fullVisualSuitePath(bool componentViewMode) const
fn = fn.left(fn.length() - (inf.baseName().length() + 1)); fn = fn.left(fn.length() - (inf.baseName().length() + 1));
// remove '/tests" if that's on the end // remove '/tests" if that's on the end
QString eolstr = QString(QDir::separator()) + "tests"; QString eolstr = QString(QDir::separator()) + QLatin1String("tests");
if (fn.endsWith(eolstr)) { if (fn.endsWith(eolstr)) {
int pos = fn.lastIndexOf(eolstr); int pos = fn.lastIndexOf(eolstr);
if (pos) fn = fn.left(pos); if (pos) fn = fn.left(pos);
@@ -1320,8 +1330,8 @@ QString TestCode::targetFileName(const QString &buildPath) const
QString fn = m_fileName; QString fn = m_fileName;
if (!m_externalPath.isEmpty() && fn.startsWith(m_externalPath)) { if (!m_externalPath.isEmpty() && fn.startsWith(m_externalPath)) {
fn.remove(m_externalPath); fn.remove(m_externalPath);
fn = m_basePath + QDir::separator() + "tests" + QDir::separator() fn = m_basePath + QDir::separator() + QLatin1String("tests") + QDir::separator()
+ "external" + QDir::separator() + fn; + QLatin1String("external") + QDir::separator() + fn;
} }
fn.remove(m_basePath); fn.remove(m_basePath);
@@ -1359,20 +1369,20 @@ void TestCode::onContextHelpIdRequested(TextEditor::ITextEditor *editor, int pos
if (!qstSlots.contains(slot)) if (!qstSlots.contains(slot))
qstSlots << slot.left(slot.indexOf('(')); qstSlots << slot.left(slot.indexOf('('));
} }
qstSlots << "compare" << "verify" << "waitFor" qstSlots << QLatin1String("compare") << QLatin1String("verify") << QLatin1String("waitFor")
<< "expect" << "fail" << "tabBar" << "menuBar"; << QLatin1String("expect") << QLatin1String("fail") << QLatin1String("tabBar") << QLatin1String("menuBar");
} }
if (start < end) { if (start < end) {
QString function = text.mid(start, end - start); QString function = text.mid(start, end - start);
if (qstSlots.contains(function)) { if (qstSlots.contains(function)) {
m_codeEditor->setContextHelpId(QString("QSystemTest::%1").arg(function)); m_codeEditor->setContextHelpId(QString::fromLatin1("QSystemTest::%1").arg(function));
return; return;
} }
} }
#endif #endif
m_codeEditor->setContextHelpId("QtUiTest Manual"); m_codeEditor->setContextHelpId(QLatin1String("QtUiTest Manual"));
} }
bool TestCode::hasUnsavedChanges() const bool TestCode::hasUnsavedChanges() const

View File

@@ -35,10 +35,7 @@
#include "testconfigurations.h" #include "testconfigurations.h"
#include <texteditor/basetexteditor.h>
#include <coreplugin/icontext.h>
#include <qmljs/qmljsdocument.h> #include <qmljs/qmljsdocument.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <cplusplus/CppDocument.h> #include <cplusplus/CppDocument.h>
#include <QStringList> #include <QStringList>
@@ -53,6 +50,15 @@ namespace Core {
class IEditor; class IEditor;
} }
namespace TextEditor {
class ITextEditor;
class BaseTextEditor;
}
namespace QmlJS {
class ModelManagerInterface;
}
namespace CPlusPlus { namespace CPlusPlus {
class CppModelManagerInterface; class CppModelManagerInterface;
} }

View File

@@ -134,8 +134,8 @@ void TestConfigurations_p::clear()
bool TestConfigurations_p::load() bool TestConfigurations_p::load()
{ {
return load(QDir::homePath() + QDir::separator() + ".qttest" return load(QDir::homePath() + QDir::separator() + QLatin1String(".qttest")
+ QDir::separator() + "saved_configurations"); + QDir::separator() + QLatin1String("saved_configurations"));
} }
bool TestConfigurations_p::load(const QString &fileName) bool TestConfigurations_p::load(const QString &fileName)
@@ -147,16 +147,16 @@ bool TestConfigurations_p::load(const QString &fileName)
if (f.open(QIODevice::ReadOnly)) { if (f.open(QIODevice::ReadOnly)) {
QTextStream S(&f); QTextStream S(&f);
QString tmpName = S.readLine(); QString tmpName = S.readLine();
if (tmpName.startsWith("VERSION=")) { if (tmpName.startsWith(QLatin1String("VERSION="))) {
bool ok; bool ok;
tmpName = tmpName.mid(8).simplified(); tmpName = tmpName.mid(8).simplified();
version = tmpName.toUInt(&ok); version = tmpName.toUInt(&ok);
if (!ok) { if (!ok) {
qWarning("Couldn't read version in configurations file"); qWarning("Could not read version in configurations file");
return false; return false;
} }
} else { } else {
qWarning("Couldn't read configurations file"); qWarning("Could not read configurations file");
return false; return false;
} }
@@ -178,9 +178,9 @@ bool TestConfigurations_p::load(const QString &fileName)
bool TestConfigurations_p::save() bool TestConfigurations_p::save()
{ {
QDir().mkpath(QDir::homePath() + QDir::separator() + ".qttest"); QDir().mkpath(QDir::homePath() + QDir::separator() + QLatin1String(".qttest"));
return save(QDir::homePath() + QDir::separator() + ".qttest" return save(QDir::homePath() + QDir::separator() + QLatin1String(".qttest")
+ QDir::separator() + "saved_configurations"); + QDir::separator() + QLatin1String("saved_configurations"));
} }
bool TestConfigurations_p::save(const QString &fileName) bool TestConfigurations_p::save(const QString &fileName)
@@ -189,7 +189,7 @@ bool TestConfigurations_p::save(const QString &fileName)
QFile f(fileName); QFile f(fileName);
if (f.open(QIODevice::WriteOnly)) { if (f.open(QIODevice::WriteOnly)) {
QTextStream S(&f); QTextStream S(&f);
S << QString("VERSION=%1").arg(curVersion) << "\n"; S << QString::fromLatin1("VERSION=%1").arg(curVersion) << '\n';
TestConfig *tmp; TestConfig *tmp;
for (int i = 0; i < m_configList.count(); ++i) { for (int i = 0; i < m_configList.count(); ++i) {
tmp = m_configList.at(i); tmp = m_configList.at(i);
@@ -248,9 +248,9 @@ TestConfig *TestConfigurations_p::config(const QString &cfgName)
cfg = new TestConfig(); cfg = new TestConfig();
cfg->setConfigName(cfgName); cfg->setConfigName(cfgName);
cfg->setRunParams(""); cfg->setRunParams(QString());
cfg->setRunScript(""); cfg->setRunScript(QString());
cfg->setPostProcessScript(""); cfg->setPostProcessScript(QString());
m_configList.append(cfg); m_configList.append(cfg);
return cfg; return cfg;
@@ -305,7 +305,7 @@ void TestConfigurations_p::setSelectedTests(const QStringList &list)
QStringList tmpList; QStringList tmpList;
foreach (const QString &selection, list) { foreach (const QString &selection, list) {
QString tcname = selection.left(selection.indexOf("::")); QString tcname = selection.left(selection.indexOf(QLatin1String("::")));
TestCode *tc = m_testCollection.findCodeByTestCaseName(tcname); TestCode *tc = m_testCollection.findCodeByTestCaseName(tcname);
if (tc) { if (tc) {
foreach (const QString &srcPath, srcPaths) { foreach (const QString &srcPath, srcPaths) {
@@ -336,7 +336,7 @@ QString TestConfigurations_p::currentTestCase()
TestConfig *tmp = activeConfiguration(); TestConfig *tmp = activeConfiguration();
if (tmp) if (tmp)
return tmp->currentTestCase(); return tmp->currentTestCase();
return ""; return QString();
} }
QString TestConfigurations_p::currentTestFunction() QString TestConfigurations_p::currentTestFunction()
@@ -346,7 +346,7 @@ QString TestConfigurations_p::currentTestFunction()
if (tmp && tmp->isActive()) if (tmp && tmp->isActive())
return tmp->currentTestFunc(); return tmp->currentTestFunc();
} }
return ""; return QString();
} }
void TestConfigurations_p::rescan() void TestConfigurations_p::rescan()
@@ -410,7 +410,7 @@ void TestConfig::clear()
m_branchDetected = false; m_branchDetected = false;
m_autodetectPlatformConfiguration = true; m_autodetectPlatformConfiguration = true;
m_platformDetected = false; m_platformDetected = false;
m_uploadMethod = "SCP"; m_uploadMethod = QLatin1String("SCP");
m_buildEnvironment.clear(); m_buildEnvironment.clear();
m_uploadMode = UploadAuto; m_uploadMode = UploadAuto;
m_makeCommand.clear(); m_makeCommand.clear();
@@ -427,12 +427,12 @@ QString TestConfig::runScript()
QString TestConfig::copyrightHeader() QString TestConfig::copyrightHeader()
{ {
QString ret = srcPath() + QDir::separator() + "dist" + QDir::separator() QString ret = srcPath() + QDir::separator() + QLatin1String("dist") + QDir::separator()
+ "header-dual-license.txt"; + QLatin1String("header-dual-license.txt");
QFileInfo inf(ret); QFileInfo inf(ret);
if (inf.exists()) if (inf.exists())
return ret; return ret;
return ""; return QString();
} }
void TestConfig::setQMAKESPEC(const QString &newValue) void TestConfig::setQMAKESPEC(const QString &newValue)
@@ -450,7 +450,7 @@ QString TestConfig::QMAKESPEC()
if (qtBuildConfig) if (qtBuildConfig)
return qtBuildConfig->qtVersion()->mkspec(); return qtBuildConfig->qtVersion()->mkspec();
else else
return QSystem::envKey(buildEnvironment(), "QMAKESPEC"); return QSystem::envKey(buildEnvironment(), QLatin1String("QMAKESPEC"));
} }
return m_qmakeMkspec; return m_qmakeMkspec;
@@ -468,12 +468,12 @@ void TestConfig::setQMAKESPECSpecialization(const QString &newValue)
QString TestConfig::PATH() QString TestConfig::PATH()
{ {
return QSystem::envKey(buildEnvironment(), "PATH"); return QSystem::envKey(buildEnvironment(), QLatin1String("PATH"));
} }
QString TestConfig::QTDIR() QString TestConfig::QTDIR()
{ {
return QSystem::envKey(buildEnvironment(), "QTDIR"); return QSystem::envKey(buildEnvironment(), QLatin1String("QTDIR"));
} }
QString TestConfig::runParams() QString TestConfig::runParams()
@@ -493,12 +493,12 @@ QString TestConfig::postProcessScript()
QString TestConfig::makeCommand() QString TestConfig::makeCommand()
{ {
if (m_makeCommand.isEmpty()) { if (m_makeCommand.isEmpty()) {
if (QMAKESPEC().contains("msvc")) if (QMAKESPEC().contains(QLatin1String("msvc")))
m_makeCommand = "nmake"; m_makeCommand = QLatin1String("nmake");
else if (QMAKESPEC().contains("mingw")) else if (QMAKESPEC().contains(QLatin1String("mingw")))
m_makeCommand = "mingw32-make"; m_makeCommand = QLatin1String("mingw32-make");
else else
m_makeCommand = "make"; m_makeCommand = QLatin1String("make");
m_makeCommand = QSystem::which(PATH(), m_makeCommand); m_makeCommand = QSystem::which(PATH(), m_makeCommand);
} }
return m_makeCommand; return m_makeCommand;
@@ -515,7 +515,7 @@ QString TestConfig::qmakeCommand(bool /*desktopQMakeRequested*/)
} }
qWarning() << "Unable to detect qmake command, falling back to \"qmake\""; qWarning() << "Unable to detect qmake command, falling back to \"qmake\"";
return "qmake"; return QLatin1String("qmake");
} }
void TestConfig::setUploadMode(UploadMode mode) void TestConfig::setUploadMode(UploadMode mode)
@@ -534,9 +534,9 @@ bool TestConfig::uploadResults()
return true; return true;
if (m_uploadMode == TestConfig::UploadNoThanks) if (m_uploadMode == TestConfig::UploadNoThanks)
return false; return false;
if (QMessageBox::question(0,"Upload Test Results", if (QMessageBox::question(0, tr("Upload Test Results"),
"You can positively influence the quality of " + configName() tr("You can positively influence the quality of %1"
+ " by contributing test results.\n\nWould you like to upload your Test Results", " by contributing test results.\n\nWould you like to upload your Test Results").arg(configName()),
QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
return true; return true;
return false; return false;
@@ -548,39 +548,39 @@ bool TestConfig::isRemoteTarget(QString &deviceName, QString &testDeviceType,
if (m_activeProject && m_activeProject->activeTarget()) { if (m_activeProject && m_activeProject->activeTarget()) {
ProjectExplorer::RunConfiguration *r = m_activeProject->activeTarget()->activeRunConfiguration(); ProjectExplorer::RunConfiguration *r = m_activeProject->activeTarget()->activeRunConfiguration();
if (r) { if (r) {
if (r->id() == "Qt4ProjectManager.MaemoRunConfiguration") { if (r->id() == QLatin1String("Qt4ProjectManager.MaemoRunConfiguration")) {
RemoteLinux::Internal::MaemoRunConfiguration *mr = static_cast<RemoteLinux::Internal::MaemoRunConfiguration*>(r); RemoteLinux::Internal::MaemoRunConfiguration *mr = static_cast<RemoteLinux::Internal::MaemoRunConfiguration*>(r);
if (mr) { if (mr) {
QSharedPointer<const RemoteLinux::LinuxDeviceConfiguration> mc = mr->deviceConfig(); QSharedPointer<const RemoteLinux::LinuxDeviceConfiguration> mc = mr->deviceConfig();
if (mc){ if (mc){
deviceName = mc->name(); deviceName = mc->name();
sshParameters = mc->sshParameters(); sshParameters = mc->sshParameters();
testDeviceType = "Maemo";//Qt4Test::TestController::Maemo; testDeviceType = QLatin1String("Maemo");//Qt4Test::TestController::Maemo;
return true; return true;
}else{ }else{
qWarning() << "Invalid remote" << deviceName; qWarning() << "Invalid remote" << deviceName;
} }
} }
} else if (r->id() == "Qt4ProjectManager.Qt4RunConfiguration" } else if (r->id() == QLatin1String("Qt4ProjectManager.Qt4RunConfiguration")
|| r->id() == "ProjectExplorer.CustomExecutableRunConfiguration") { || r->id() == QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration")) {
deviceName = "Desktop"; deviceName = QLatin1String("Desktop");
sshParameters.host = "127.0.0.1"; sshParameters.host = QLatin1String("127.0.0.1");
sshParameters.port = 5656; sshParameters.port = 5656;
sshParameters.userName.clear(); sshParameters.userName.clear();
sshParameters.password.clear(); sshParameters.password.clear();
sshParameters.privateKeyFile.clear(); sshParameters.privateKeyFile.clear();
testDeviceType = "Desktop";//Qt4Test::TestController::Desktop; testDeviceType = QLatin1String("Desktop");//Qt4Test::TestController::Desktop;
return false; return false;
} }
} }
} }
deviceName = "Unknown"; deviceName = QLatin1String("Unknown");
sshParameters.host = "0.0.0.0"; sshParameters.host = QLatin1String("0.0.0.0");
sshParameters.port = 0; sshParameters.port = 0;
sshParameters.userName.clear(); sshParameters.userName.clear();
sshParameters.password.clear(); sshParameters.password.clear();
sshParameters.privateKeyFile.clear(); sshParameters.privateKeyFile.clear();
testDeviceType = "Desktop";//Qt4Test::TestController::Desktop; testDeviceType = QLatin1String("Desktop"); //Qt4Test::TestController::Desktop;
return false; return false;
} }
@@ -590,7 +590,7 @@ void TestConfig::loadLine(QTextStream *s, const QString &id, QString &value)
Q_UNUSED(id); Q_UNUSED(id);
QString tmp = s->readLine(); QString tmp = s->readLine();
int pos = tmp.indexOf("="); int pos = tmp.indexOf(QLatin1Char('='));
value = tmp.mid(pos + 1); value = tmp.mid(pos + 1);
} }
@@ -599,7 +599,7 @@ void TestConfig::loadLine(QTextStream *s, const QString &id, int &value)
Q_UNUSED(id); Q_UNUSED(id);
QString tmp = s->readLine(); QString tmp = s->readLine();
int pos = tmp.indexOf("="); int pos = tmp.indexOf(QLatin1Char('='));
value = tmp.mid(pos + 1).toInt(); value = tmp.mid(pos + 1).toInt();
} }
@@ -611,61 +611,61 @@ bool TestConfig::load(uint version, QTextStream *s)
return false; return false;
QString tmp = s->readLine(); QString tmp = s->readLine();
if (tmp == "CONFIG-START") { if (tmp == QLatin1String("CONFIG-START")) {
loadLine(s, "", m_configName); loadLine(s, QString(), m_configName);
loadLine(s, "", m_runParams); loadLine(s, QString(), m_runParams);
loadLine(s, "", m_postprocessScript); loadLine(s, QString(), m_postprocessScript);
loadLine(s, "", m_runScript); loadLine(s, QString(), m_runScript);
loadLine(s, "", m_lastTestcase); loadLine(s, QString(), m_lastTestcase);
loadLine(s, "", m_lastTestfunc); loadLine(s, QString(), m_lastTestfunc);
QString tmp; QString tmp;
loadLine(s, "", tmp); loadLine(s, QString(), tmp);
m_lastSelectedTests = tmp.split(",", QString::SkipEmptyParts); m_lastSelectedTests = tmp.split(QLatin1Char(','), QString::SkipEmptyParts);
if (version > 1) { if (version > 1) {
loadLine(s, "", m_uploadChange); loadLine(s, QString(), m_uploadChange);
loadLine(s, "", m_uploadBranch); loadLine(s, QString(), m_uploadBranch);
loadLine(s, "", m_uploadPlatform); loadLine(s, QString(), m_uploadPlatform);
if (version < 8) if (version < 8)
tmp = s->readLine(); tmp = s->readLine();
} }
if (version > 2) { if (version > 2) {
if (version < 8) tmp = s->readLine(); if (version < 8) tmp = s->readLine();
tmp = s->readLine(); tmp = s->readLine();
m_autodetectPlatformConfiguration = (tmp == "AUTO-PLATFORM=1"); m_autodetectPlatformConfiguration = (tmp == QLatin1String("AUTO-PLATFORM=1"));
loadLine(s, "", m_uploadMethod); loadLine(s, QString(), m_uploadMethod);
} }
if (version > 3) { if (version > 3) {
loadLine(s, "", tmp); loadLine(s, QString(), tmp);
m_extraTests = tmp.split(":", QString::SkipEmptyParts); m_extraTests = tmp.split(QLatin1Char(':'), QString::SkipEmptyParts);
} }
if (version > 4) { if (version > 4) {
int tmp; int tmp;
loadLine(s, "", tmp); loadLine(s, QString(), tmp);
m_uploadMode = static_cast<UploadMode>(tmp); m_uploadMode = static_cast<UploadMode>(tmp);
} }
if (version > 5 && version < 7) { if (version > 5 && version < 7) {
QString dummy; QString dummy;
loadLine(s, "", dummy); loadLine(s, QString(), dummy);
loadLine(s, "", dummy); loadLine(s, QString(), dummy);
loadLine(s, "", dummy); loadLine(s, QString(), dummy);
} }
if (version >= 9) { if (version >= 9) {
loadLine(s, "", m_qmakeMkspec); loadLine(s, QString(), m_qmakeMkspec);
loadLine(s, "", m_uploadBranchSpecialization); loadLine(s, QString(), m_uploadBranchSpecialization);
loadLine(s, "", m_qmakeMkspecSpecialization); loadLine(s, QString(), m_qmakeMkspecSpecialization);
} }
//Add member here //Add member here
QString checkSum; QString checkSum;
loadLine(s, "", checkSum); loadLine(s, QString(), checkSum);
return checkSum == "CONFIG-END"; return checkSum == QLatin1String("CONFIG-END");
} }
return false; return false;
} }
void TestConfig::saveLine(QTextStream *s, const QString &id, const QString &value) void TestConfig::saveLine(QTextStream *s, const QString &id, const QString &value)
{ {
*s << id << "=" << value << "\n"; *s << id << '=' << value << '\n';
} }
bool TestConfig::save(QTextStream *s) bool TestConfig::save(QTextStream *s)
@@ -673,29 +673,29 @@ bool TestConfig::save(QTextStream *s)
if (s == 0) if (s == 0)
return false; return false;
QString checkSum = "CONFIG-START"; QString checkSum = QLatin1String("CONFIG-START");
*s << checkSum << "\n"; *s << checkSum << QLatin1Char('\n');
saveLine(s, "NAME", m_configName); saveLine(s, QLatin1String("NAME"), m_configName);
saveLine(s, "RUN_PARAMS", m_runParams); saveLine(s, QLatin1String("RUN_PARAMS"), m_runParams);
saveLine(s, "POSTPROCESS_SCRIPT", m_postprocessScript); saveLine(s, QLatin1String("POSTPROCESS_SCRIPT"), m_postprocessScript);
saveLine(s, "RUN_SCRIPT", m_runScript); saveLine(s, QLatin1String("RUN_SCRIPT"), m_runScript);
saveLine(s, "LAST_TESTCASE", m_lastTestcase); saveLine(s, QLatin1String("LAST_TESTCASE"), m_lastTestcase);
saveLine(s, "LAST_TESTFUNC", m_lastTestfunc); saveLine(s, QLatin1String("LAST_TESTFUNC"), m_lastTestfunc);
saveLine(s, "LAST_SELECTED_TESTS", m_lastSelectedTests.join(",")); saveLine(s, QLatin1String("LAST_SELECTED_TESTS"), m_lastSelectedTests.join(QString(QLatin1Char(','))));
saveLine(s, "CHANGE", m_uploadChange); saveLine(s, QLatin1String("CHANGE"), m_uploadChange);
saveLine(s, "BRANCH", m_uploadBranch); saveLine(s, QLatin1String("BRANCH"), m_uploadBranch);
saveLine(s, "PLATFORM", m_uploadPlatform); saveLine(s, QLatin1String("PLATFORM"), m_uploadPlatform);
saveLine(s, "AUTO-PLATFORM", QString("%1").arg(m_autodetectPlatformConfiguration)); saveLine(s, QLatin1String("AUTO-PLATFORM"), QString::fromLatin1("%1").arg(m_autodetectPlatformConfiguration));
saveLine(s, "UPLOAD_METHOD", m_uploadMethod); saveLine(s, QLatin1String("UPLOAD_METHOD"), m_uploadMethod);
saveLine(s, "EXTRA_TESTS", m_extraTests.join(":")); saveLine(s, QLatin1String("EXTRA_TESTS"), m_extraTests.join(QString(QLatin1Char(':'))));
saveLine(s, "UPLOAD_MODE", QString("%1").arg(static_cast<int>(m_uploadMode))); saveLine(s, QLatin1String("UPLOAD_MODE"), QString::number(static_cast<int>(m_uploadMode)));
saveLine(s, "QMAKESPEC", m_qmakeMkspec); saveLine(s, QLatin1String("QMAKESPEC"), m_qmakeMkspec);
saveLine(s, "BRANCH_SPECIALIZATION", m_uploadBranchSpecialization); saveLine(s, QLatin1String("BRANCH_SPECIALIZATION"), m_uploadBranchSpecialization);
saveLine(s, "QMAKESPEC_SPECIALIZATION", m_qmakeMkspecSpecialization); saveLine(s, QLatin1String("QMAKESPEC_SPECIALIZATION"), m_qmakeMkspecSpecialization);
//Add member here //Add member here
checkSum = "CONFIG-END"; checkSum = QLatin1String("CONFIG-END");
*s << checkSum << "\n"; *s << checkSum << '\n';
return true; return true;
} }
@@ -737,7 +737,7 @@ QString TestConfig::uploadChange()
proc.setEnvironment(*buildEnvironment()); proc.setEnvironment(*buildEnvironment());
proc.setWorkingDirectory(srcPath()); proc.setWorkingDirectory(srcPath());
proc.start("git", QStringList() << "log" << "-1" << "--pretty=oneline"); proc.start(QLatin1String("git"), QStringList() << QLatin1String("log") << QLatin1String("-1") << QLatin1String("--pretty=oneline"));
bool ok = proc.waitForStarted(); bool ok = proc.waitForStarted();
if (ok) if (ok)
ok = proc.waitForFinished(); ok = proc.waitForFinished();
@@ -745,7 +745,7 @@ QString TestConfig::uploadChange()
if (ok) { if (ok) {
QString output = proc.readAllStandardOutput(); QString output = proc.readAllStandardOutput();
if (!output.isEmpty()) { if (!output.isEmpty()) {
QStringList tmp = output.split(" "); QStringList tmp = output.split(QLatin1Char(' '));
if (tmp.count() >= 2) { if (tmp.count() >= 2) {
m_uploadChange = tmp[0]; m_uploadChange = tmp[0];
m_changeDetected = true; m_changeDetected = true;
@@ -768,7 +768,7 @@ QString TestConfig::uploadBranch()
proc.setEnvironment(*buildEnvironment()); proc.setEnvironment(*buildEnvironment());
proc.setWorkingDirectory(srcPath()); proc.setWorkingDirectory(srcPath());
proc.start("git", QStringList() << "branch"); proc.start(QLatin1String("git"), QStringList(QLatin1String("branch")));
bool ok = proc.waitForStarted(); bool ok = proc.waitForStarted();
if (ok) if (ok)
ok = proc.waitForFinished(); ok = proc.waitForFinished();
@@ -776,9 +776,9 @@ QString TestConfig::uploadBranch()
if (ok) { if (ok) {
QString output = proc.readAllStandardOutput(); QString output = proc.readAllStandardOutput();
if (!output.isEmpty()) { if (!output.isEmpty()) {
QStringList tmp = output.split("\n"); QStringList tmp = output.split(QLatin1Char('\n'));
foreach (QString line, tmp) { foreach (const QString &line, tmp) {
if (line.startsWith("*")) { if (line.startsWith(QLatin1Char('*'))) {
m_uploadBranch = line.mid(2); m_uploadBranch = line.mid(2);
m_branchDetected = true; m_branchDetected = true;
} }
@@ -789,7 +789,7 @@ QString TestConfig::uploadBranch()
if (m_branchDetected){ if (m_branchDetected){
// prepend <Product>- to the branch name // prepend <Product>- to the branch name
// this only supports remotes using git@... and git:// // this only supports remotes using git@... and git://
proc.start("git", QStringList() << "remote" << "-v"); proc.start(QLatin1String("git"), QStringList() << QLatin1String("remote") << QLatin1String("-v"));
ok = proc.waitForStarted(); ok = proc.waitForStarted();
if (ok) if (ok)
ok = proc.waitForFinished(); ok = proc.waitForFinished();
@@ -799,16 +799,16 @@ QString TestConfig::uploadBranch()
if (!output.isEmpty()) { if (!output.isEmpty()) {
QRegExp gitRemoteRegEx(QLatin1String("(\\w+\\s+\\w+@[^:]+):(\\w+)/\(.*)")); QRegExp gitRemoteRegEx(QLatin1String("(\\w+\\s+\\w+@[^:]+):(\\w+)/\(.*)"));
QRegExp gitReadonlyRemoteRegEx(QLatin1String("(\\w+\\s+\\w+://.+)/(\\w+)/(.*)")); QRegExp gitReadonlyRemoteRegEx(QLatin1String("(\\w+\\s+\\w+://.+)/(\\w+)/(.*)"));
QStringList tmp = output.split("\n"); QStringList tmp = output.split(QLatin1Char('\n'));
foreach (const QString &line, tmp) { foreach (const QString &line, tmp) {
if (gitRemoteRegEx.exactMatch(line)) { if (gitRemoteRegEx.exactMatch(line)) {
m_uploadBranch = gitRemoteRegEx.capturedTexts()[2] m_uploadBranch = gitRemoteRegEx.capturedTexts()[2]
+ "-" + m_uploadBranch; + QLatin1Char('-') + m_uploadBranch;
break; break;
} }
if (gitReadonlyRemoteRegEx.exactMatch(line)) { if (gitReadonlyRemoteRegEx.exactMatch(line)) {
m_uploadBranch = gitReadonlyRemoteRegEx.capturedTexts()[2] m_uploadBranch = gitReadonlyRemoteRegEx.capturedTexts()[2]
+ "-" + m_uploadBranch; + QLatin1Char('-') + m_uploadBranch;
break; break;
} }
} }
@@ -872,20 +872,20 @@ void TestConfig::setAutoDetectPlatformConfiguration(bool doAutoDetect)
bool TestConfig::uploadUsingScp() bool TestConfig::uploadUsingScp()
{ {
return m_uploadMethod == "SCP"; return m_uploadMethod == QLatin1String("SCP");
} }
bool TestConfig::uploadUsingEMail() bool TestConfig::uploadUsingEMail()
{ {
return m_uploadMethod != "SCP"; return m_uploadMethod != QLatin1String("SCP");
} }
void TestConfig::setUploadMethod(bool useScp) void TestConfig::setUploadMethod(bool useScp)
{ {
if (useScp) if (useScp)
m_uploadMethod = "SCP"; m_uploadMethod = QLatin1String("SCP");
else else
m_uploadMethod = "EMAIL"; m_uploadMethod = QLatin1String("EMAIL");
} }
void TestConfig::deactivate() void TestConfig::deactivate()
@@ -940,7 +940,7 @@ void TestConfig::onProjectSettingsChanged()
Core::ICore *core = Core::ICore::instance(); Core::ICore *core = Core::ICore::instance();
Core::ModeManager *mgr = core->modeManager(); Core::ModeManager *mgr = core->modeManager();
if ((mgr && (mgr->currentMode()->id() != "Edit")) || TestConfigurations::instance().updatesDelayed()) { if ((mgr && (mgr->currentMode()->id() != QLatin1String("Edit"))) || TestConfigurations::instance().updatesDelayed()) {
// Try again later. // Try again later.
emitConfigChanged(); emitConfigChanged();
return; return;
@@ -985,13 +985,13 @@ QStringList *TestConfig::runEnvironment()
ProjectExplorer::RunConfiguration *rc = ProjectExplorer::RunConfiguration *rc =
m_activeProject->activeTarget()->activeRunConfiguration(); m_activeProject->activeTarget()->activeRunConfiguration();
if (rc) { if (rc) {
if (rc->id() == "Qt4ProjectManager.Qt4RunConfiguration") { if (rc->id() == QLatin1String("Qt4ProjectManager.Qt4RunConfiguration")) {
m_runEnvironment = m_runEnvironment =
static_cast<Qt4ProjectManager::Internal::Qt4RunConfiguration*>(rc)->environment().toStringList(); static_cast<Qt4ProjectManager::Internal::Qt4RunConfiguration*>(rc)->environment().toStringList();
} else if (rc->id() == "ProjectExplorer.CustomExecutableRunConfiguration") { } else if (rc->id() == QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration")) {
m_runEnvironment = m_runEnvironment =
static_cast<ProjectExplorer::CustomExecutableRunConfiguration*>(rc)->environment().toStringList(); static_cast<ProjectExplorer::CustomExecutableRunConfiguration*>(rc)->environment().toStringList();
} else if (rc->id() == "Qt4ProjectManager.MaemoRunConfiguration") { } else if (rc->id() == QLatin1String("Qt4ProjectManager.MaemoRunConfiguration")) {
m_runEnvironment = m_runEnvironment =
static_cast<RemoteLinux::Internal::MaemoRunConfiguration*>(rc)->environment().toStringList(); static_cast<RemoteLinux::Internal::MaemoRunConfiguration*>(rc)->environment().toStringList();
} }
@@ -1003,18 +1003,18 @@ QStringList *TestConfig::runEnvironment()
QString TestConfig::buildPath() QString TestConfig::buildPath()
{ {
if (!m_activeProject) if (!m_activeProject)
return ""; return QString();
ProjectExplorer::BuildConfiguration *b = ProjectExplorer::BuildConfiguration *b =
m_activeProject->activeTarget()->activeBuildConfiguration(); m_activeProject->activeTarget()->activeBuildConfiguration();
if (!b) if (!b)
return ""; return QString();
return QDir::convertSeparators(b->buildDirectory()); return QDir::convertSeparators(b->buildDirectory());
} }
QString TestConfig::srcPath() QString TestConfig::srcPath()
{ {
if (!m_activeProject) if (!m_activeProject)
return ""; return QString();
return QDir::convertSeparators(m_activeProject->projectDirectory()); return QDir::convertSeparators(m_activeProject->projectDirectory());
} }

View File

@@ -40,13 +40,14 @@
#include "projectexplorer/project.h" #include "projectexplorer/project.h"
#include <../../libs/utils/ssh/sshconnection.h> #include <../../libs/utils/ssh/sshconnection.h>
#include <QTextStream>
#include <QObject>
#include <QList>
#include <QStringList> #include <QStringList>
#include <QPointer> #include <QPointer>
#include <QTimer> #include <QTimer>
QT_BEGIN_NAMESPACE
class QTextStream;
QT_END_NAMESPACE
class TestConfigurations_p; class TestConfigurations_p;
class TestConfig : public QObject class TestConfig : public QObject

View File

@@ -34,10 +34,15 @@
#include "testcode.h" #include "testcode.h"
#include "testsettings.h" #include "testsettings.h"
#include "qsystem.h" #include "qsystem.h"
#include "testsuite.h"
#include "testexecuter.h"
#include "testcode.h"
#include "testoutputwindow.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/inavigationwidgetfactory.h> #include <coreplugin/inavigationwidgetfactory.h>
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
TestContextMenu_p *TestContextMenu::m_instance = 0; TestContextMenu_p *TestContextMenu::m_instance = 0;
@@ -104,19 +109,19 @@ TestContextMenu_p::TestContextMenu_p(QObject *widget)
m_editorInsertTestFunctionAction->setEnabled(false); m_editorInsertTestFunctionAction->setEnabled(false);
m_testRunAction = new QAction(widget); m_testRunAction = new QAction(widget);
m_testRunAction->setIcon(QIcon(QPixmap(":/testrun.png"))); m_testRunAction->setIcon(QIcon(QPixmap(QLatin1String(":/testrun.png"))));
m_testRunAsManualAction = new QAction(widget); m_testRunAsManualAction = new QAction(widget);
m_testRunAsManualAction->setIcon(QIcon(QPixmap(":/testrun.png"))); m_testRunAsManualAction->setIcon(QIcon(QPixmap(QLatin1String(":/testrun.png"))));
m_testDebugAction = new QAction(widget); m_testDebugAction = new QAction(widget);
m_testDebugAction->setIcon(QIcon(QPixmap(":/testlearn.png"))); m_testDebugAction->setIcon(QIcon(QPixmap(QLatin1String(":/testlearn.png"))));
m_editorRunSingleTestAction = new QAction(widget); m_editorRunSingleTestAction = new QAction(widget);
m_editorRunSingleTestAction->setIcon(QIcon(QPixmap(":/testrun.png"))); m_editorRunSingleTestAction->setIcon(QIcon(QPixmap(QLatin1String(":/testrun.png"))));
m_editorRunSingleTestAction->setVisible(false); m_editorRunSingleTestAction->setVisible(false);
m_testStopTestingAction = new QAction(widget); m_testStopTestingAction = new QAction(widget);
m_testStopTestingAction->setIcon(QIcon(QPixmap(":/teststop.png"))); m_testStopTestingAction->setIcon(QIcon(QPixmap(QLatin1String(":/teststop.png"))));
m_editorStopTestingAction = new QAction(widget); m_editorStopTestingAction = new QAction(widget);
m_editorStopTestingAction->setIcon(QIcon(QPixmap(":/teststop.png"))); m_editorStopTestingAction->setIcon(QIcon(QPixmap(QLatin1String(":/teststop.png"))));
m_testLearnAction = new QAction(widget); m_testLearnAction = new QAction(widget);
m_testLearnAction->setCheckable(true); m_testLearnAction->setCheckable(true);
@@ -246,7 +251,7 @@ void TestContextMenu_p::updateActions(bool testVisible, bool testBusy, bool test
void TestContextMenu_p::enableIncludeFile(const QString &fileName) void TestContextMenu_p::enableIncludeFile(const QString &fileName)
{ {
m_includeFile = fileName; m_includeFile = fileName;
m_testOpenIncludeFileAction->setText("Open: '" + fileName + "'"); m_testOpenIncludeFileAction->setText(tr("Open: '%1'").arg(fileName));
m_testOpenIncludeFileAction->setVisible(!fileName.isEmpty()); m_testOpenIncludeFileAction->setVisible(!fileName.isEmpty());
} }

View File

@@ -33,19 +33,21 @@
#ifndef TESTCONTEXTMENU_H #ifndef TESTCONTEXTMENU_H
#define TESTCONTEXTMENU_H #define TESTCONTEXTMENU_H
#include "testsuite.h"
#include "testexecuter.h"
#include "testcode.h"
#include "testoutputwindow.h"
#include "testsettings.h" #include "testsettings.h"
#include "extensionsystem/iplugin.h" #include "extensionsystem/iplugin.h"
#include "projectexplorer/projectexplorer.h" #include "projectexplorer/projectexplorer.h"
#include <QString> #include <QString>
#include <QTreeWidget>
#include <QMenu> namespace Core {
#include <QAction> class IEditor;
}
QT_BEGIN_NAMESPACE
class QAction;
class QMenu;
QT_END_NAMESPACE
class TestContextMenu_p; class TestContextMenu_p;

View File

@@ -43,6 +43,7 @@
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/progressmanager/progressmanager.h> #include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/progressmanager/futureprogress.h> #include <coreplugin/progressmanager/futureprogress.h>
#include <texteditor/basetexteditor.h>
#include <qt4projectmanager/qt4buildconfiguration.h> #include <qt4projectmanager/qt4buildconfiguration.h>
#include <qtsupport/qtversionmanager.h> #include <qtsupport/qtversionmanager.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
@@ -89,14 +90,14 @@ TestExecuter::TestExecuter() :
m_stopTesting = false; m_stopTesting = false;
m_manualStop = false; m_manualStop = false;
m_killTestRequested = false; m_killTestRequested = false;
m_testOutputFile = QString("$HOME%1.qttest%1last_test_output").arg(QDir::separator()); m_testOutputFile = QString::fromLatin1("$HOME%1.qttest%1last_test_output").arg(QDir::separator());
m_pendingFailure = false; m_pendingFailure = false;
m_inBuildMode = false; m_inBuildMode = false;
m_recordingEvents = false; m_recordingEvents = false;
m_abortRecording = false; m_abortRecording = false;
m_progressBar = 0; m_progressBar = 0;
m_testResultsStream = 0; m_testResultsStream = 0;
m_peekedResult = ""; m_peekedResult.clear();
m_executer.setReadChannelMode(QProcess::MergedChannels); m_executer.setReadChannelMode(QProcess::MergedChannels);
m_executer.setReadChannel(QProcess::StandardOutput); m_executer.setReadChannel(QProcess::StandardOutput);
@@ -177,7 +178,7 @@ void TestExecuter::runTests(bool singleTest, bool forceManual)
m_selectedTests = TestConfigurations::instance().selectedTests(); m_selectedTests = TestConfigurations::instance().selectedTests();
} }
if (m_selectedTests.count() == 0) { if (m_selectedTests.count() == 0) {
testOutputPane()->append("No test selected"); testOutputPane()->append(tr("No test selected"));
endTest(); endTest();
return; return;
} }
@@ -197,8 +198,8 @@ void TestExecuter::runSelectedTests(bool forceManual)
bool hasSystemTestsSelected = false; bool hasSystemTestsSelected = false;
int maxProgress = 0; int maxProgress = 0;
m_lastFinishedTest = QString(); m_lastFinishedTest.clear();
QString lastTc = ""; QString lastTc;
bool lastIsSystemTest = false; bool lastIsSystemTest = false;
// pretend we executed these tests - so the progress bar keeps counting nicely. // pretend we executed these tests - so the progress bar keeps counting nicely.
foreach (const QString &item, m_selectedTests) { foreach (const QString &item, m_selectedTests) {
@@ -219,22 +220,22 @@ void TestExecuter::runSelectedTests(bool forceManual)
m_testCfg = TestConfigurations::instance().activeConfiguration(); m_testCfg = TestConfigurations::instance().activeConfiguration();
if (!m_testCfg) { if (!m_testCfg) {
testOutputPane()->append("No test configuration defined. This is unusual."); testOutputPane()->append(tr("No test configuration defined. This is unusual."));
endTest(); endTest();
return; return;
} }
m_pendingInsertions.clear(); m_pendingInsertions.clear();
TestResultsWindow::instance()->clearContents(); TestResultsWindow::instance()->clearContents();
testOutputPane()->append("*********** Start testing *************"); testOutputPane()->append(tr("*********** Start testing *************"));
TestResultsWindow::instance()->popup(); TestResultsWindow::instance()->popup();
m_curTestCode = 0; m_curTestCode = 0;
QString changeNo; QString changeNo;
QString lastConfigName = ""; QString lastConfigName;
QString lastPlatform = ""; QString lastPlatform;
QString lastBranch = ""; QString lastBranch;
m_testCfg = 0; m_testCfg = 0;
m_testFailedUnexpectedly = false; m_testFailedUnexpectedly = false;
@@ -254,7 +255,7 @@ void TestExecuter::runSelectedTests(bool forceManual)
m_progress = 0; m_progress = 0;
m_progressBar->setProgressRange(0, maxProgress); m_progressBar->setProgressRange(0, maxProgress);
m_progressBar->reportStarted(); m_progressBar->reportStarted();
m_progressBar->setProgressValueAndText(0, "Just started"); m_progressBar->setProgressValueAndText(0, tr("Just started"));
m_progressFailCount = 0; m_progressFailCount = 0;
m_progressPassCount = 0; m_progressPassCount = 0;
@@ -267,15 +268,14 @@ void TestExecuter::runSelectedTests(bool forceManual)
// Is this a valid test? // Is this a valid test?
if (!m_curTestCode) { if (!m_curTestCode) {
addTestResult("CFAIL", "", "Path '" + m_curTestCode->actualFileName() addTestResult("CFAIL", QString(), "Path '" + m_curTestCode->actualFileName()
+ "'doesn't contain a valid testcase"); + "' does not contain a valid testcase");
continue; continue;
} }
m_testCfg = TestConfigurations::instance().findConfig(m_curTestCode->actualBasePath()); m_testCfg = TestConfigurations::instance().findConfig(m_curTestCode->actualBasePath());
if (!m_testCfg) { if (!m_testCfg) {
testOutputPane()->append("Test configuration for '" testOutputPane()->append(tr("Test configuration for '%1' not found. Skipping test.").arg(m_curTestCode->actualFileName()));
+ m_curTestCode->actualFileName() + "' not found. Skipping test.");
continue; continue;
} }
@@ -286,7 +286,7 @@ void TestExecuter::runSelectedTests(bool forceManual)
uploadResults = m_testCfg->uploadResults(); uploadResults = m_testCfg->uploadResults();
if (!uploadResults) if (!uploadResults)
testOutputPane()->append("Test results will not be uploaded into the results database."); testOutputPane()->append(tr("Test results will not be uploaded into the results database."));
QSystem::unsetEnvKey(m_testCfg->buildEnvironment(), "QTEST_COLORED"); QSystem::unsetEnvKey(m_testCfg->buildEnvironment(), "QTEST_COLORED");
QSystem::addEnvPath(m_testCfg->buildEnvironment(), "PATH", QSystem::addEnvPath(m_testCfg->buildEnvironment(), "PATH",
m_testCfg->buildPath() + QDir::separator() + "bin"); m_testCfg->buildPath() + QDir::separator() + "bin");
@@ -295,13 +295,13 @@ void TestExecuter::runSelectedTests(bool forceManual)
QRegExp validBranchRegEx(QLatin1String("^(.+)-(.+)")); QRegExp validBranchRegEx(QLatin1String("^(.+)-(.+)"));
QRegExp validBranchSpecializationRegEx(QLatin1String(".*")); QRegExp validBranchSpecializationRegEx(QLatin1String(".*"));
if (m_testCfg->uploadBranch().isEmpty() || !validBranchRegEx.exactMatch(m_testCfg->uploadBranch())) { if (m_testCfg->uploadBranch().isEmpty() || !validBranchRegEx.exactMatch(m_testCfg->uploadBranch())) {
testOutputPane()->append(QString("-- ATTENTION: Uploading of test results failed. No branch specified or branch " testOutputPane()->append(tr("-- ATTENTION: Uploading of test results failed. No branch specified or branch "
"name \"%1\" is not in form: \n\t<Product>-<Version>\n. Check \"Branch\" value in Test Settings.") "name \"%1\" is not in form: \n\t<Product>-<Version>\n. Check \"Branch\" value in Test Settings.")
.arg(m_testCfg->uploadBranch())); .arg(m_testCfg->uploadBranch()));
uploadResults = false; uploadResults = false;
} else { } else {
if (!m_testCfg->uploadBranchSpecialization().isEmpty() && !validBranchSpecializationRegEx.exactMatch(m_testCfg->uploadBranchSpecialization())) { if (!m_testCfg->uploadBranchSpecialization().isEmpty() && !validBranchSpecializationRegEx.exactMatch(m_testCfg->uploadBranchSpecialization())) {
testOutputPane()->append(QString("-- ATTENTION: Uploading of test results failed. " testOutputPane()->append(tr("-- ATTENTION: Uploading of test results failed. "
"Optional Branch specialization value \"%1\" is not in form: \n\t<Specialization>\n. " "Optional Branch specialization value \"%1\" is not in form: \n\t<Specialization>\n. "
"Check \"Branch\" \"Specialization\" value in Test Settings.") "Check \"Branch\" \"Specialization\" value in Test Settings.")
.arg(m_testCfg->uploadBranchSpecialization())); .arg(m_testCfg->uploadBranchSpecialization()));
@@ -310,21 +310,21 @@ void TestExecuter::runSelectedTests(bool forceManual)
lastBranch = m_testCfg->uploadBranch(); lastBranch = m_testCfg->uploadBranch();
if (!m_testCfg->uploadBranchSpecialization().isEmpty()) if (!m_testCfg->uploadBranchSpecialization().isEmpty())
lastBranch += QLatin1String("-") + m_testCfg->uploadBranchSpecialization(); lastBranch += QLatin1String("-") + m_testCfg->uploadBranchSpecialization();
testOutputPane()->append("Tested branch: " + lastBranch); testOutputPane()->append(tr("Tested branch: %1").arg(lastBranch));
} }
} }
lastPlatform = m_testCfg->QMAKESPEC(); lastPlatform = m_testCfg->QMAKESPEC();
if (lastPlatform.isEmpty()) { if (lastPlatform.isEmpty()) {
testOutputPane()->append("-- ATTENTION: Uploading of test results failed. " testOutputPane()->append(tr("-- ATTENTION: Uploading of test results failed. "
"No QMAKESPEC specified. Set QMAKESPEC in project's build environment " "No QMAKESPEC specified. Set QMAKESPEC in project's build environment "
"or set a custom \"QMakespec\" value in Test Settings."); "or set a custom \"QMakespec\" value in Test Settings."));
uploadResults = false; uploadResults = false;
} else { } else {
QRegExp validQmakespecSpecializationRegEx(QLatin1String(".*")); QRegExp validQmakespecSpecializationRegEx(QLatin1String(".*"));
QString lastPlatformSpecialization = m_testCfg->QMAKESPECSpecialization(); QString lastPlatformSpecialization = m_testCfg->QMAKESPECSpecialization();
if (!lastPlatformSpecialization.isEmpty() && !validQmakespecSpecializationRegEx.exactMatch(lastPlatformSpecialization)) { if (!lastPlatformSpecialization.isEmpty() && !validQmakespecSpecializationRegEx.exactMatch(lastPlatformSpecialization)) {
testOutputPane()->append(QString("-- ATTENTION: Uploading of test results failed. " testOutputPane()->append(tr("-- ATTENTION: Uploading of test results failed. "
"QMAKESPEC \"Specialization\" \"%1\" not in form: \n\t <Specialization>\n. " "QMAKESPEC \"Specialization\" \"%1\" not in form: \n\t <Specialization>\n. "
"Set the QMAKESPEC specialization value in Test Settings or clear its current value.") "Set the QMAKESPEC specialization value in Test Settings or clear its current value.")
.arg(lastPlatformSpecialization)); .arg(lastPlatformSpecialization));
@@ -332,26 +332,26 @@ void TestExecuter::runSelectedTests(bool forceManual)
} else { } else {
if (!lastPlatformSpecialization.isEmpty()) if (!lastPlatformSpecialization.isEmpty())
lastPlatform += QLatin1String("_") + lastPlatformSpecialization; lastPlatform += QLatin1String("_") + lastPlatformSpecialization;
testOutputPane()->append("Tested platform: " + lastPlatform); testOutputPane()->append(tr("Tested platform: %1").arg(lastPlatform));
} }
} }
changeNo = m_testCfg->uploadChange(); changeNo = m_testCfg->uploadChange();
if (changeNo.isEmpty()) { if (changeNo.isEmpty()) {
testOutputPane()->append("-- ATTENTION: Uploading of test results failed. " testOutputPane()->append(tr("-- ATTENTION: Uploading of test results failed. "
"No changeNumber specified. Set a custom \"Change\" value in Test Settings."); "No changeNumber specified. Set a custom \"Change\" value in Test Settings."));
uploadResults = false; uploadResults = false;
} else { } else {
testOutputPane()->append("Testing change: " + changeNo); testOutputPane()->append(tr("Testing change: %1").arg(changeNo));
} }
testOutputPane()->append("Tester: " + QSystem::userName()); testOutputPane()->append(tr("Tester: %1").arg(QSystem::userName()));
testOutputPane()->append("Host machine: " + sanitizedForFilename(QSystem::hostName())); testOutputPane()->append(tr("Host machine: ").arg(sanitizedForFilename(QSystem::hostName())));
} }
} }
lastConfigName = m_testCfg->configName(); lastConfigName = m_testCfg->configName();
testOutputPane()->append(""); testOutputPane()->append(QString());
bool ok = buildTestCase(); bool ok = buildTestCase();
if (ok && !m_manualStop) if (ok && !m_manualStop)
ok = runTestCase(forceManual); ok = runTestCase(forceManual);
@@ -361,7 +361,7 @@ void TestExecuter::runSelectedTests(bool forceManual)
m_progressBar->setProgressValue(m_progress); m_progressBar->setProgressValue(m_progress);
if (testStopped()) { if (testStopped()) {
testOutputPane()->append("-- Testing halted by user"); testOutputPane()->append(tr("-- Testing halted by user"));
} else { } else {
m_progressLabel->setText(tr("%1 failed\n%2 passed") m_progressLabel->setText(tr("%1 failed\n%2 passed")
.arg(m_progressFailCount).arg(m_progressPassCount)); .arg(m_progressFailCount).arg(m_progressPassCount));
@@ -372,8 +372,8 @@ void TestExecuter::runSelectedTests(bool forceManual)
} }
} }
testOutputPane()->append(""); testOutputPane()->append(QString());
testOutputPane()->append("******** All testing finished **********"); testOutputPane()->append(tr("******** All testing finished **********"));
TestResultsWindow::instance()->popup(); TestResultsWindow::instance()->popup();
@@ -399,10 +399,10 @@ void TestExecuter::endTest()
bool TestExecuter::buildTestCase() bool TestExecuter::buildTestCase()
{ {
m_syntaxError = ""; m_syntaxError.clear();
if (!m_testCfg) { if (!m_testCfg) {
testOutputPane()->append("No test configuration defined: building test case aborted"); testOutputPane()->append(tr("No test configuration defined: building test case aborted"));
return false; return false;
} }
@@ -413,11 +413,11 @@ bool TestExecuter::buildTestCase()
QString tgtPath = QDir::convertSeparators(tgtInf.absolutePath()); QString tgtPath = QDir::convertSeparators(tgtInf.absolutePath());
QDir().mkpath(tgtPath); QDir().mkpath(tgtPath);
testOutputPane()->append("********** Build " + tgtInf.baseName() + " **********"); testOutputPane()->append(tr("********** Build %1 **********").arg(tgtInf.baseName()));
QString proFile = m_curTestCode->projectFileName(); QString proFile = m_curTestCode->projectFileName();
if (proFile.isEmpty()) { if (proFile.isEmpty()) {
addTestResult("CFAIL", "", "No .pro file found."); addTestResult("CFAIL", QString(), "No .pro file found.");
return false; return false;
} }
m_inBuildMode = true; m_inBuildMode = true;
@@ -426,8 +426,8 @@ bool TestExecuter::buildTestCase()
if (ok && m_curTestCode->testType() != TestCode::TypeSystemTest) { if (ok && m_curTestCode->testType() != TestCode::TypeSystemTest) {
if (m_testCfg->makeCommand().isEmpty()) { if (m_testCfg->makeCommand().isEmpty()) {
testOutputPane()->append("-- No 'make' or 'nmake' instance found in PATH (" const QString path = QSystem::envKey(m_testCfg->buildEnvironment(), "PATH");
+ QSystem::envKey(m_testCfg->buildEnvironment(), "PATH") + ")."); testOutputPane()->append(tr("-- No 'make' or 'nmake' instance found in PATH (%1).").arg(path));
return false; return false;
} }
@@ -441,7 +441,7 @@ bool TestExecuter::buildTestCase()
bool TestExecuter::postProcess() bool TestExecuter::postProcess()
{ {
if (!m_testCfg) { if (!m_testCfg) {
testOutputPane()->append("No test configuration defined: post processing results aborted"); testOutputPane()->append(tr("No test configuration defined: post processing results aborted"));
return false; return false;
} }
@@ -455,9 +455,8 @@ bool TestExecuter::postProcess()
if (exec(cmd,QStringList())) if (exec(cmd,QStringList()))
return true; return true;
addTestResult("FAIL", "", addTestResult("FAIL", QString(),
QString("Could not run postprocess script on Test Case '" QString::fromLatin1("Could not run postprocess script on Test Case '%1'").arg(m_curTestCode->actualFileName()));
+ m_curTestCode->actualFileName() + "'"));
return false; return false;
} }
@@ -465,7 +464,7 @@ bool xmlLineStartsWith(QString &line, const QString &expression, QString &variab
{ {
if (line.startsWith(expression)) { if (line.startsWith(expression)) {
variable = line.mid(expression.length()); variable = line.mid(expression.length());
variable = variable.left(variable.indexOf("\"")); variable = variable.left(variable.indexOf(QLatin1Char('"')));
variable = variable.left(variable.indexOf("</")); variable = variable.left(variable.indexOf("</"));
return !variable.isEmpty(); return !variable.isEmpty();
} }
@@ -490,7 +489,7 @@ void xmlLineVariable(QString &line, const QString &expression, QString &variable
int pos = line.indexOf(expression); int pos = line.indexOf(expression);
if (pos > 0) { if (pos > 0) {
variable = line.mid(pos+expression.length()+1); variable = line.mid(pos+expression.length()+1);
variable = variable.left(variable.indexOf("\"")); variable = variable.left(variable.indexOf(QLatin1Char('"')));
} }
} }
@@ -510,7 +509,7 @@ QString TestExecuter::readLine()
if (m_testResultsStream) { if (m_testResultsStream) {
if (!m_peekedResult.isEmpty()) { if (!m_peekedResult.isEmpty()) {
QString tmp = m_peekedResult; QString tmp = m_peekedResult;
m_peekedResult = ""; m_peekedResult.clear();
return tmp; return tmp;
} }
return m_testResultsStream->readLine(); return m_testResultsStream->readLine();
@@ -525,25 +524,25 @@ QStringList TestExecuter::peek()
QStringList tmp; QStringList tmp;
if (!m_peekedResult.isEmpty()) { if (!m_peekedResult.isEmpty()) {
tmp.append(m_peekedResult); tmp.append(m_peekedResult);
m_peekedResult = ""; m_peekedResult.clear();
} }
while (!m_testResultsStream->atEnd()) { while (!m_testResultsStream->atEnd()) {
QString line = m_testResultsStream->readLine(); QString line = m_testResultsStream->readLine();
if (line.startsWith(" ")) { if (line.startsWith(QLatin1Char(' '))) {
tmp.append(line); tmp.append(line);
} else { } else {
m_peekedResult = line; m_peekedResult = line;
return tmp; return tmp;
} }
} }
m_peekedResult = ""; m_peekedResult.clear();
return tmp; return tmp;
} else { } else {
QByteArray data = m_executer.peek(1024); QByteArray data = m_executer.peek(1024);
QStringList tmp; QStringList tmp;
QStringList lines = QString(data).split("\n"); QStringList lines = QString(data).split(QLatin1Char('\n'));
for (int i = 0; i < lines.size(); ++i) { for (int i = 0; i < lines.size(); ++i) {
if (lines[i].startsWith(" ")) if (lines[i].startsWith(QLatin1Char(' ')))
tmp.append(lines[i]); tmp.append(lines[i]);
else else
return tmp; return tmp;
@@ -555,7 +554,7 @@ QStringList TestExecuter::peek()
void TestExecuter::parseOutput() void TestExecuter::parseOutput()
{ {
if (!m_testCfg) { if (!m_testCfg) {
testOutputPane()->append("No test configuration defined: parsing output aborted"); testOutputPane()->append(tr("No test configuration defined: parsing output aborted"));
return; return;
} }
@@ -570,21 +569,21 @@ void TestExecuter::parseOutput()
if (m_inBuildMode) { if (m_inBuildMode) {
// Parse build output // Parse build output
if (line.contains(" error: ")) { if (line.contains(" error: ")) {
QString file = line.section(':', 0, 0); QString file = line.section(QLatin1Char(':'), 0, 0);
int lineNum = line.section(':', 1, 1).toInt(); int lineNum = line.section(QLatin1Char(':'), 1, 1).toInt();
// The error string will continue across multiple lines so need to peek // The error string will continue across multiple lines so need to peek
QString errorStr = line.section(':', 3); QString errorStr = line.section(QLatin1Char(':'), 3);
errorStr.remove('\n'); errorStr.remove(QLatin1Char('\n'));
QStringList lines = peek(); QStringList lines = peek();
for (int i = 0; i < lines.size(); ++i) for (int i = 0; i < lines.size(); ++i)
errorStr.append(" " + lines[i].trimmed()); errorStr.append(QLatin1Char(' ') + lines[i].trimmed());
addTestResult("CFAIL", "", errorStr, file, lineNum); addTestResult("CFAIL", QString(), errorStr, file, lineNum);
} else { } else {
if (!m_testSettings.showVerbose()) { if (!m_testSettings.showVerbose()) {
QStringList tmp = line.split(" "); QStringList tmp = line.split(QLatin1Char(' '));
if (tmp.count() > 0) { if (tmp.count() > 0) {
QString cmd = tmp[0]; QString cmd = tmp[0];
if (cmd.contains("moc")) { if (cmd.contains("moc")) {
@@ -596,7 +595,7 @@ void TestExecuter::parseOutput()
} else if (tmp.contains("-o")) { } else if (tmp.contains("-o")) {
int pos = tmp.indexOf("-o"); int pos = tmp.indexOf("-o");
if (pos > 0 && (pos < tmp.count()-2)) { if (pos > 0 && (pos < tmp.count()-2)) {
line = cmd + " " + tmp[pos+1].split(QDir::separator()).last(); line = cmd + QLatin1Char(' ') + tmp[pos+1].split(QDir::separator()).last();
} }
} }
} }
@@ -606,15 +605,15 @@ void TestExecuter::parseOutput()
} else { } else {
if (m_xmlMode) { if (m_xmlMode) {
if (line.startsWith("<?xml version")) { if (line.startsWith("<?xml version")) {
m_xmlTestfunction = ""; m_xmlTestfunction.clear();
m_xmlTestcase = ""; m_xmlTestcase.clear();
m_xmlDatatag = ""; m_xmlDatatag.clear();
m_xmlFile = ""; m_xmlFile.clear();
m_xmlLine = "-1"; m_xmlLine = "-1";
m_xmlResult = ""; m_xmlResult.clear();
m_xmlDescription = ""; m_xmlDescription.clear();
m_xmlQtVersion = ""; m_xmlQtVersion.clear();
m_xmlQtestVersion = ""; m_xmlQtestVersion.clear();
m_xmlLog.clear(); m_xmlLog.clear();
continue; continue;
} }
@@ -626,32 +625,32 @@ void TestExecuter::parseOutput()
line = m_xmlResult.toUpper(); line = m_xmlResult.toUpper();
if (line == "FAIL") if (line == "FAIL")
line += "!"; line += QLatin1Char('!');
while (line.length() < 7) while (line.length() < 7)
line += " "; line += QLatin1Char(' ');
QString testDescriptor = m_xmlTestcase + "::" QString testDescriptor = m_xmlTestcase + "::"
+ m_xmlTestfunction + "("+m_xmlDatatag+")"; + m_xmlTestfunction + QLatin1Char('(')+m_xmlDatatag+QLatin1Char(')');
line += ": " + testDescriptor + m_xmlDescription; line += ": " + testDescriptor + m_xmlDescription;
if (!m_xmlFile.isEmpty()) if (!m_xmlFile.isEmpty())
line += "\nLoc: [" + m_xmlFile + "(" + m_xmlLine + ")]"; line += "\nLoc: [" + m_xmlFile + QLatin1Char('(') + m_xmlLine + ")]";
if (m_curTestCode->testType() != TestCode::TypeSystemTest) { if (m_curTestCode->testType() != TestCode::TypeSystemTest) {
if (m_xmlResult.contains("fail") || m_xmlResult.contains("pass")) { if (m_xmlResult.contains("fail") || m_xmlResult.contains("pass")) {
addTestResult(m_xmlResult.toUpper(), "", addTestResult(m_xmlResult.toUpper(), QString(),
testDescriptor + m_xmlDescription, testDescriptor + m_xmlDescription,
m_xmlFile, m_xmlLine.toInt(), m_xmlDatatag); m_xmlFile, m_xmlLine.toInt(), m_xmlDatatag);
} }
} }
} }
m_xmlResult = ""; m_xmlResult.clear();
m_xmlDescription = ""; m_xmlDescription.clear();
} else if (xmlLineCData(line, "<Description>", m_xmlDescription)) { } else if (xmlLineCData(line, "<Description>", m_xmlDescription)) {
if (!m_xmlDescription.isEmpty()) if (!m_xmlDescription.isEmpty())
m_xmlDescription = "\n" + m_xmlDescription; m_xmlDescription = QLatin1Char('\n') + m_xmlDescription;
continue; continue;
} else if (xmlLineCData(line, "<DataTag>", m_xmlDatatag)) { } else if (xmlLineCData(line, "<DataTag>", m_xmlDatatag)) {
@@ -677,30 +676,30 @@ void TestExecuter::parseOutput()
if (line.endsWith("/>")) { if (line.endsWith("/>")) {
line = m_xmlResult.toUpper(); line = m_xmlResult.toUpper();
while (line.length() < 7) while (line.length() < 7)
line += " "; line += QLatin1Char(' ');
QString testDescriptor = m_xmlTestcase + "::" QString testDescriptor = m_xmlTestcase + "::"
+ m_xmlTestfunction + "("+m_xmlDatatag+")"; + m_xmlTestfunction + QLatin1Char('(')+m_xmlDatatag+QLatin1Char(')');
line += ": " + testDescriptor + m_xmlDescription; line += ": " + testDescriptor + m_xmlDescription;
if (!m_xmlFile.isEmpty()) if (!m_xmlFile.isEmpty())
line += "\nLoc: [" + m_xmlFile + "(" + m_xmlLine + ")]"; line += "\nLoc: [" + m_xmlFile + QLatin1Char('(') + m_xmlLine + ")]";
if (m_curTestCode->testType() != TestCode::TypeSystemTest) { if (m_curTestCode->testType() != TestCode::TypeSystemTest) {
if (m_xmlResult.contains("fail") || m_xmlResult.contains("pass")) { if (m_xmlResult.contains("fail") || m_xmlResult.contains("pass")) {
addTestResult(m_xmlResult.toUpper(), "", testDescriptor addTestResult(m_xmlResult.toUpper(), QString(), testDescriptor
+ m_xmlDescription, m_xmlFile, m_xmlLine.toInt(), m_xmlDatatag); + m_xmlDescription, m_xmlFile, m_xmlLine.toInt(), m_xmlDatatag);
} }
} }
} }
} else if (line == "</TestFunction>") { } else if (line == "</TestFunction>") {
m_xmlTestfunction = ""; m_xmlTestfunction.clear();
m_xmlDatatag = ""; m_xmlDatatag.clear();
continue; continue;
} else if (line == "</TestCase>") { } else if (line == "</TestCase>") {
line = "********* Finished testing of " + m_xmlTestcase + " *********"; line = "********* Finished testing of " + m_xmlTestcase + " *********";
m_xmlTestcase = ""; m_xmlTestcase.clear();
// In case the testcase hangs at the end, we need a mechanism // In case the testcase hangs at the end, we need a mechanism
// to terminate the process. So set a timer that will kill the // to terminate the process. So set a timer that will kill the
// executer if we haven't heard anything for 1.5 seconds. // executer if we haven't heard anything for 1.5 seconds.
@@ -723,12 +722,12 @@ void TestExecuter::parseOutput()
continue; continue;
} else if (line.startsWith("<anonymous>()@")) { } else if (line.startsWith("<anonymous>()@")) {
m_xmlFile = line.mid(line.indexOf("@")+1); m_xmlFile = line.mid(line.indexOf(QLatin1Char('@'))+1);
m_xmlLine = m_xmlFile.mid(m_xmlFile.indexOf(":")+1); m_xmlLine = m_xmlFile.mid(m_xmlFile.indexOf(QLatin1Char(':'))+1);
m_xmlFile = m_xmlFile.left(m_xmlFile.indexOf(":")); m_xmlFile = m_xmlFile.left(m_xmlFile.indexOf(QLatin1Char(':')));
if (!m_syntaxError.isEmpty()) { if (!m_syntaxError.isEmpty()) {
addTestResult("CFAIL", "", m_syntaxError, m_xmlFile, m_xmlLine.toInt()); addTestResult("CFAIL", QString(), m_syntaxError, m_xmlFile, m_xmlLine.toInt());
m_syntaxError = ""; m_syntaxError.clear();
} }
} }
} }
@@ -749,7 +748,7 @@ void TestExecuter::parseOutput()
int i = 0; int i = 0;
while (i < filter.count()) { while (i < filter.count()) {
if (line.contains(filter[i])) { if (line.contains(filter[i])) {
line = ""; line.clear();
break; break;
} }
++i; ++i;
@@ -769,7 +768,7 @@ void TestExecuter::onKillTestRequested()
bool TestExecuter::exec(const QString &cmd, const QStringList &arguments, const QString &workDir, int timeout) bool TestExecuter::exec(const QString &cmd, const QStringList &arguments, const QString &workDir, int timeout)
{ {
if (!m_testCfg) { if (!m_testCfg) {
testOutputPane()->append("No test configuration defined: exec aborted"); testOutputPane()->append(tr("No test configuration defined: exec aborted"));
return false; return false;
} }
@@ -780,7 +779,7 @@ bool TestExecuter::exec(const QString &cmd, const QStringList &arguments, const
} }
Q_ASSERT(m_executer.state() == QProcess::NotRunning); Q_ASSERT(m_executer.state() == QProcess::NotRunning);
if ((workDir != "") && (m_executer.workingDirectory() != workDir)) { if ((!workDir.isEmpty()) && (m_executer.workingDirectory() != workDir)) {
if (m_inBuildMode) if (m_inBuildMode)
testOutputPane()->append("cd " + workDir); testOutputPane()->append("cd " + workDir);
m_executer.setWorkingDirectory(workDir); m_executer.setWorkingDirectory(workDir);
@@ -788,7 +787,7 @@ bool TestExecuter::exec(const QString &cmd, const QStringList &arguments, const
m_executer.setEnvironment(*m_testCfg->buildEnvironment()); m_executer.setEnvironment(*m_testCfg->buildEnvironment());
if (m_inBuildMode) if (m_inBuildMode)
testOutputPane()->append(cmd + " " + arguments.join(" ")); testOutputPane()->append(cmd + QLatin1Char(' ') + arguments.join(QString(QLatin1Char(' '))));
m_executerFinished = false; m_executerFinished = false;
if (arguments.count() > 0) { if (arguments.count() > 0) {
@@ -799,8 +798,8 @@ bool TestExecuter::exec(const QString &cmd, const QStringList &arguments, const
realCmd = cmd; realCmd = cmd;
if (realCmd.isEmpty()) { if (realCmd.isEmpty()) {
testOutputPane()->append("-- No '" + cmd + "' instance found in PATH (" const QString path = QSystem::envKey(m_testCfg->buildEnvironment(), "PATH");
+ QSystem::envKey(m_testCfg->buildEnvironment(), "PATH") + ")."); testOutputPane()->append(tr("-- No '%1' instance found in PATH (%2) + ).").arg(cmd, path));
return false; return false;
} }
m_executer.start(realCmd, arguments); m_executer.start(realCmd, arguments);
@@ -821,7 +820,7 @@ bool TestExecuter::exec(const QString &cmd, const QStringList &arguments, const
return m_executer.exitCode() == 0; return m_executer.exitCode() == 0;
} else { } else {
testOutputPane()->append(QString(tr("-- %1 failed: %2, time elapsed: %3")) testOutputPane()->append(QString(tr("-- %1 failed: %2, time elapsed: %3"))
.arg(cmd).arg(m_executer.errorString()).arg(time.elapsed())); .arg(cmd, m_executer.errorString()).arg(time.elapsed()));
return false; return false;
} }
} }
@@ -834,7 +833,7 @@ void TestExecuter::onExecuterFinished()
bool TestExecuter::runTestCase(bool forceManual) bool TestExecuter::runTestCase(bool forceManual)
{ {
if (!m_testCfg) { if (!m_testCfg) {
testOutputPane()->append("No test configuration defined: running test case aborted"); testOutputPane()->append(tr("No test configuration defined: running test case aborted"));
return false; return false;
} }
@@ -845,21 +844,21 @@ bool TestExecuter::runTestCase(bool forceManual)
uint timeout = 30000; uint timeout = 30000;
if (m_curTestCode->testType() == TestCode::TypeSystemTest) { if (m_curTestCode->testType() == TestCode::TypeSystemTest) {
QString m_testPlatform = ""; QString m_testPlatform;
if (m_testCfg->uploadPlatform().toLower().contains("windows")) if (m_testCfg->uploadPlatform().toLower().contains(QLatin1String("windows")))
m_testPlatform = "win"; m_testPlatform = QLatin1String("win");
else if (m_testCfg->uploadPlatform().toLower().contains("mac")) else if (m_testCfg->uploadPlatform().toLower().contains(QLatin1String("mac")))
m_testPlatform = "mac"; m_testPlatform = QLatin1String("mac");
else if (m_testCfg->uploadPlatform().toLower().contains("linux")) else if (m_testCfg->uploadPlatform().toLower().contains(QLatin1String("linux")))
m_testPlatform = "linux"; m_testPlatform = QLatin1String("linux");
else else
m_testPlatform = "symbian"; m_testPlatform = QLatin1String("symbian");
QSystem::setEnvKey(&env, "TESTPLATFORM", m_testPlatform); QSystem::setEnvKey(&env, QLatin1String("TESTPLATFORM"), m_testPlatform);
args << "-env TESTPLATFORM=" + m_testPlatform; args << QLatin1String("-env TESTPLATFORM=") + m_testPlatform;
if (forceManual) if (forceManual)
args << "-force-manual"; args << QLatin1String("-force-manual");
QString deviceName; QString deviceName;
QString deviceType; QString deviceType;
@@ -867,31 +866,31 @@ bool TestExecuter::runTestCase(bool forceManual)
m_testCfg->isRemoteTarget(deviceName, deviceType, sshParam); m_testCfg->isRemoteTarget(deviceName, deviceType, sshParam);
QVariantMap connectionParam; QVariantMap connectionParam;
connectionParam["host"] = sshParam.host; connectionParam[QLatin1String("host")] = sshParam.host;
connectionParam["username"] = sshParam.userName; connectionParam[QLatin1String("username")] = sshParam.userName;
connectionParam["sshPort"] = sshParam.port; connectionParam[QLatin1String("sshPort")] = sshParam.port;
connectionParam["sshTimeout"] = sshParam.timeout; connectionParam[QLatin1String("sshTimeout")] = sshParam.timeout;
if (sshParam.authenticationType == Utils::SshConnectionParameters::AuthenticationByPassword) { if (sshParam.authenticationType == Utils::SshConnectionParameters::AuthenticationByPassword) {
connectionParam["password"] = sshParam.password; connectionParam[QLatin1String("password")] = sshParam.password;
} else { } else {
connectionParam["privateKeyFile"] = sshParam.privateKeyFile; connectionParam[QLatin1String("privateKeyFile")] = sshParam.privateKeyFile;
} }
#ifndef QTTEST_PLUGIN_LEAN #ifndef QTTEST_PLUGIN_LEAN
m_qscriptSystemTest.setConnectionParameters(deviceType, sshParam); m_qscriptSystemTest.setConnectionParameters(deviceType, sshParam);
#else #else
args << "-authost" << sshParam.host; args << QLatin1String("-authost") << sshParam.host;
args << "-username" << sshParam.userName; args << QLatin1String("-username") << sshParam.userName;
if (sshParam.authenticationType == Utils::SshConnectionParameters::AuthenticationByPassword) { if (sshParam.authenticationType == Utils::SshConnectionParameters::AuthenticationByPassword) {
args << "-pwd" << sshParam.password; args << QLatin1String("-pwd") << sshParam.password;
} else { } else {
args << "-private-key" << sshParam.privateKeyFile; args << QLatin1String("-private-key") << sshParam.privateKeyFile;
} }
#endif #endif
timeout = 600000; // 10 minutes to run a manual test should be sufficient? timeout = 600000; // 10 minutes to run a manual test should be sufficient?
cmd = "qtuitestrunner"; cmd = QLatin1String("qtuitestrunner");
} else { } else {
QFileInfo tmp(m_curTestCode->actualFileName()); QFileInfo tmp(m_curTestCode->actualFileName());
QString testRelPath = QDir::convertSeparators(tmp.absolutePath()); QString testRelPath = QDir::convertSeparators(tmp.absolutePath());
@@ -899,10 +898,9 @@ bool TestExecuter::runTestCase(bool forceManual)
QString exePath; QString exePath;
QString exeFile = m_curTestCode->execFileName(); QString exeFile = m_curTestCode->execFileName();
if (exeFile.isEmpty()) { if (exeFile.isEmpty()) {
testOutputPane()->append("Unknown executable name for Test Case '" testOutputPane()->append(tr("Unknown executable name for Test Case '%1'").arg(m_curTestCode->testCase()));
+ m_curTestCode->testCase() + "'"); addTestResult(QLatin1String("FAIL"), QString(),
addTestResult("FAIL", "", QString("Unknown executable name for Test Case '" + m_curTestCode->testCase() + QLatin1Char('\'')));
QString("Unknown executable name for Test Case '" + m_curTestCode->testCase() + "'"));
return false; return false;
} }
@@ -910,55 +908,55 @@ bool TestExecuter::runTestCase(bool forceManual)
exePath1 += testRelPath; exePath1 += testRelPath;
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
exePath1 += "/" + tmp.baseName() + ".app/Contents/MacOS"; exePath1 += QLatin1Char('/') + tmp.baseName() + QLatin1String(".app/Contents/MacOS");
#endif #endif
exePath = QSystem::which(exePath1, exeFile); exePath = QSystem::which(exePath1, exeFile);
QString exePath2, exePath3, exePath4; QString exePath2, exePath3, exePath4;
if (exePath.isEmpty()) { if (exePath.isEmpty()) {
exePath3 = m_testCfg->buildPath(); exePath3 = m_testCfg->buildPath();
exePath3 += QString("%1bin").arg(QDir::separator()); exePath3 += QDir::separator() + QLatin1String("bin");
exePath = QSystem::which(exePath3, exeFile); exePath = QSystem::which(exePath3, exeFile);
if (exePath.isEmpty()) { if (exePath.isEmpty()) {
exePath4 = m_testCfg->buildPath(); exePath4 = m_testCfg->buildPath();
exePath4 += QString("%1build%1tests%1bin").arg(QDir::separator()); exePath4 += QString::fromLatin1("%1build%1tests%1bin").arg(QDir::separator());
exePath = QSystem::which(exePath4, exeFile); exePath = QSystem::which(exePath4, exeFile);
if (exePath.isEmpty()) { if (exePath.isEmpty()) {
exePath2 = QString("%1%2debug").arg(exePath1).arg(QDir::separator()); exePath2 = QString::fromLatin1("%1%2debug").arg(exePath1).arg(QDir::separator());
exePath = QSystem::which(exePath2, exeFile); exePath = QSystem::which(exePath2, exeFile);
} }
} }
} }
if (exePath.isEmpty()) { if (exePath.isEmpty()) {
testOutputPane()->append("Test Case '" + exeFile + "' not found"); testOutputPane()->append(tr("Test Case '%1' not found").arg(exeFile));
addTestResult("FAIL", "", addTestResult(QLatin1String("FAIL"), QString(),
QString("Test Case '" + exeFile + "' not found in:\n - '" + exePath1 QLatin1String("Test Case '") + exeFile + QLatin1String("' not found in:\n - '") + exePath1
+ "' or \n - '" + exePath2 + "' or \n - '" + exePath3 + QLatin1String("' or \n - '") + exePath2 + QLatin1String("' or \n - '") + exePath3
+ "' or \n - '" + exePath4 + "'.")); + QLatin1String("' or \n - '") + exePath4 + QLatin1String("'."));
return false; return false;
} }
cmd = exePath; cmd = exePath;
} }
args << "-xml"; args << QLatin1String("-xml");
if (m_testSettings.learnMode() == 1) if (m_testSettings.learnMode() == 1)
args << "-learn"; args << QLatin1String("-learn");
else if (m_testSettings.learnMode() == 2) else if (m_testSettings.learnMode() == 2)
args << "-learn-all"; args << QLatin1String("-learn-all");
// Grab a list of all the functions we want to execute // Grab a list of all the functions we want to execute
bool hasTests = false; bool hasTests = false;
foreach (const QString &item, m_selectedTests) { foreach (const QString &item, m_selectedTests) {
if (item.startsWith(m_curTestCode->testCase() + "::")) { if (item.startsWith(m_curTestCode->testCase() + QLatin1String("::"))) {
QString func = item.mid(item.indexOf("::")+2); QString func = item.mid(item.indexOf(QLatin1String("::"))+2);
if ((func != "init") && (func != "initTestCase") && (func != "cleanup") if ((func != QLatin1String("init")) && (func != QLatin1String("initTestCase")) && (func != QLatin1String("cleanup"))
&& (func != "cleanupTestCase") && !func.endsWith("_data")) { && (func != QLatin1String("cleanupTestCase")) && !func.endsWith(QLatin1String("_data"))) {
args << func; args << func;
hasTests = true; hasTests = true;
} }
@@ -971,16 +969,16 @@ bool TestExecuter::runTestCase(bool forceManual)
// If we have a postprocessing step, pipe output to a file // If we have a postprocessing step, pipe output to a file
if (!m_testCfg->postProcessScript().isEmpty()) if (!m_testCfg->postProcessScript().isEmpty())
cmd.append(" | tee " + m_testOutputFile); cmd.append(QLatin1String(" | tee ") + m_testOutputFile);
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
QString libPath = QSystem::envKey(m_testCfg->buildEnvironment(), "QTDIR"); QString libPath = QSystem::envKey(m_testCfg->buildEnvironment(), QLatin1String("QTDIR"));
if (!libPath.isEmpty()) { if (!libPath.isEmpty()) {
libPath = libPath + QDir::separator() + "lib"; libPath = libPath + QDir::separator() + QLatin1String("lib");
# ifdef Q_OS_MAC # ifdef Q_OS_MAC
QSystem::addEnvPath(m_testCfg->buildEnvironment(), "DYLD_LIBRARY_PATH", libPath); QSystem::addEnvPath(m_testCfg->buildEnvironment(), QLatin1String("DYLD_LIBRARY_PATH"), libPath);
# else # else
QSystem::addEnvPath(m_testCfg->buildEnvironment(), "LD_LIBRARY_PATH", libPath); QSystem::addEnvPath(m_testCfg->buildEnvironment(), QLatin1String("LD_LIBRARY_PATH"), libPath);
# endif # endif
} }
#endif #endif
@@ -990,10 +988,10 @@ bool TestExecuter::runTestCase(bool forceManual)
if (m_curTestCode->hasUnsavedChanges()) { if (m_curTestCode->hasUnsavedChanges()) {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(tr("Unsaved Changes")); msgBox.setText(tr("Unsaved Changes"));
msgBox.setInformativeText(QString(tr("File '%1' has unsaved changes.\nThe file must be saved before proceeding.")) msgBox.setInformativeText(tr("File '%1' has unsaved changes.\nThe file must be saved before proceeding.")
.arg(m_curTestCode->baseFileName())); .arg(m_curTestCode->baseFileName()));
if (QMessageBox::warning(0, tr("Unsaved Changes"), if (QMessageBox::warning(0, tr("Unsaved Changes"),
QString("File \"%1\" has unsaved changes.\n" tr("File \"%1\" has unsaved changes.\n"
"The file must be saved before proceeding.").arg(m_curTestCode->baseFileName()), "The file must be saved before proceeding.").arg(m_curTestCode->baseFileName()),
QMessageBox::Save | QMessageBox::Cancel, QMessageBox::Save) == QMessageBox::Save) { QMessageBox::Save | QMessageBox::Cancel, QMessageBox::Save) == QMessageBox::Save) {
m_curTestCode->save(); m_curTestCode->save();
@@ -1003,34 +1001,34 @@ bool TestExecuter::runTestCase(bool forceManual)
} }
if (!cancel) { if (!cancel) {
QString testOutput; QString testOutput;
testOutputPane()->append(QString("********* Start testing of %1 *********") testOutputPane()->append(tr("********* Start testing of %1 *********")
.arg(m_curTestCode->baseFileName())); .arg(m_curTestCode->baseFileName()));
args.prepend(m_curTestCode->actualFileName()); args.prepend(m_curTestCode->actualFileName());
testOutputPane()->append(QString("%1 %2").arg(cmd).arg(args.join(" "))); testOutputPane()->append(QString::fromLatin1("%1 %2").arg(cmd).arg(args.join(QString(QLatin1Char(' ')))));
if (exec(cmd, args, m_testCfg->buildPath(), timeout)) if (exec(cmd, args, m_testCfg->buildPath(), timeout))
return true; return true;
testOutputPane()->append(QString("********* Finished testing of %1 *********") testOutputPane()->append(tr("********* Finished testing of %1 *********")
.arg(m_curTestCode->baseFileName())); .arg(m_curTestCode->baseFileName()));
#ifndef QTTEST_PLUGIN_LEAN #ifndef QTTEST_PLUGIN_LEAN
m_qscriptSystemTest.runTest(m_curTestCode->actualFileName(), args, env, &testOutput); m_qscriptSystemTest.runTest(m_curTestCode->actualFileName(), args, env, &testOutput);
if (qscript_system_test.isAborted()) { if (qscript_system_test.isAborted()) {
testOutputPane()->append(QString("********* Aborted testing of %1 *********") testOutputPane()->append(tr("********* Aborted testing of %1 *********")
.arg(m_curTestCode->baseFileName())); .arg(m_curTestCode->baseFileName()));
if (!m_manualStop) if (!m_manualStop)
manualStop(); manualStop();
} else { } else {
testOutputPane()->append(QString("********* Finished testing of %1 *********") testOutputPane()->append(tr("********* Finished testing of %1 *********")
.arg(m_curTestCode->baseFileName())); .arg(m_curTestCode->baseFileName()));
} }
#endif #endif
m_xmlLog = testOutput.split("\n"); m_xmlLog = testOutput.split(QLatin1Char('\n'));
m_xmlLog.removeAll(QString("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>")); m_xmlLog.removeAll(QString("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"));
} else { } else {
addTestResult("FAIL", m_curTestCode->testCase(), addTestResult("FAIL", m_curTestCode->testCase(),
QString("Execution cancelled for Test Case '%1'").arg(m_curTestCode->testCase())); QString::fromLatin1("Execution cancelled for Test Case '%1'").arg(m_curTestCode->testCase()));
return false; return false;
} }
} else { } else {
@@ -1044,9 +1042,9 @@ bool TestExecuter::runTestCase(bool forceManual)
if (m_executer.exitCode() >= 0) if (m_executer.exitCode() >= 0)
return true; return true;
addTestResult("FAIL", m_curTestCode->testCase(), addTestResult(QLatin1String("FAIL"), m_curTestCode->testCase(),
QString("Execution failed for Test Case '%1' with exit code '%2': %3") QString::fromLatin1("Execution failed for Test Case '%1' with exit code '%2': %3")
.arg(m_curTestCode->testCase() + "'") .arg(m_curTestCode->testCase() + QLatin1Char('\''))
.arg(m_executer.exitCode()) .arg(m_executer.exitCode())
.arg(m_executer.errorString())); .arg(m_executer.errorString()));
return false; return false;
@@ -1060,12 +1058,12 @@ bool TestExecuter::testFailedUnexpectedly()
void TestExecuter::addTestResult(const QString &result, const QString &test, const QString &reason, void TestExecuter::addTestResult(const QString &result, const QString &test, const QString &reason,
const QString &file, int line, const QString &dataTag) const QString &file, int line, const QString &dataTag)
{ {
if (result.contains("FAIL")) { if (result.contains(QLatin1String("FAIL"))) {
if (!result.contains("XFAIL")) if (!result.contains(QLatin1String("XFAIL")))
m_testFailedUnexpectedly = true; m_testFailedUnexpectedly = true;
++m_progressFailCount; ++m_progressFailCount;
} else if (result.contains("PASS")) { } else if (result.contains(QLatin1String("PASS"))) {
if (reason.contains("::initTestCase()") || reason.contains("::cleanupTestCase()")) if (reason.contains(QLatin1String("::initTestCase()")) || reason.contains(QLatin1String("::cleanupTestCase()")))
return; return;
++m_progressPassCount; ++m_progressPassCount;
} }
@@ -1086,13 +1084,13 @@ void TestExecuter::addTestResult(const QString &result, const QString &test, con
bool TestExecuter::getNextTest() bool TestExecuter::getNextTest()
{ {
QString curTestName = ""; QString curTestName;
if (m_curTestCode) if (m_curTestCode)
curTestName = m_curTestCode->testCase(); curTestName = m_curTestCode->testCase();
if (m_selectedTests.count() > 0) { if (m_selectedTests.count() > 0) {
if (curTestName.isEmpty()) { if (curTestName.isEmpty()) {
curTestName = m_selectedTests[0].left(m_selectedTests[0].indexOf("::")); curTestName = m_selectedTests[0].left(m_selectedTests[0].indexOf(QLatin1String("::")));
if (!curTestName.isEmpty()) { if (!curTestName.isEmpty()) {
m_curTestCode = m_testCollection.findCodeByTestCaseName(curTestName); m_curTestCode = m_testCollection.findCodeByTestCaseName(curTestName);
return (m_curTestCode != 0); return (m_curTestCode != 0);
@@ -1100,14 +1098,14 @@ bool TestExecuter::getNextTest()
} }
bool tcFound = false; bool tcFound = false;
QString tcName = curTestName + "::"; QString tcName = curTestName + QLatin1String("::");
foreach (const QString &item, m_selectedTests) { foreach (const QString &item, m_selectedTests) {
if (!tcFound) { if (!tcFound) {
if (item.startsWith(tcName)) if (item.startsWith(tcName))
tcFound = true; tcFound = true;
} else { } else {
if (!item.startsWith(tcName)) { if (!item.startsWith(tcName)) {
curTestName = item.left(item.indexOf("::")); curTestName = item.left(item.indexOf(QLatin1String("::")));
if (!curTestName.isEmpty()) { if (!curTestName.isEmpty()) {
m_curTestCode = m_testCollection.findCodeByTestCaseName(curTestName); m_curTestCode = m_testCollection.findCodeByTestCaseName(curTestName);
return m_curTestCode != 0; return m_curTestCode != 0;
@@ -1126,18 +1124,18 @@ bool TestExecuter::testBusy() const
QString TestExecuter::saveResults(const QString &changeNo, const QString &platform, const QString &branch) QString TestExecuter::saveResults(const QString &changeNo, const QString &platform, const QString &branch)
{ {
QString fname = QDir::homePath() + QDir::separator() + ".qttest" QString fname = QDir::homePath() + QDir::separator() + QLatin1String(".qttest")
+ QDir::separator() + "pending_test_results"; + QDir::separator() + QLatin1String("pending_test_results");
QDir().mkpath(fname); QDir().mkpath(fname);
fname += QDir::separator(); fname += QDir::separator();
fname += "creator_upload_USER_"; fname += QLatin1String("creator_upload_USER_");
fname += sanitizedForFilename(QSystem::userName()); fname += sanitizedForFilename(QSystem::userName());
fname += "_HOST_"; fname += QLatin1String("_HOST_");
fname += sanitizedForFilename(QSystem::hostName()); fname += sanitizedForFilename(QSystem::hostName());
fname += "_ON_"; fname += QLatin1String("_ON_");
fname += sanitizedForFilename(QDateTime::currentDateTime().toString()); fname += sanitizedForFilename(QDateTime::currentDateTime().toString());
fname += ".xml"; fname += QLatin1String(".xml");
QFile xmlFile(fname); QFile xmlFile(fname);
xmlFile.remove(); xmlFile.remove();
@@ -1146,23 +1144,23 @@ QString TestExecuter::saveResults(const QString &changeNo, const QString &platfo
if (xmlFile.open(QIODevice::WriteOnly | QIODevice::Append)) { if (xmlFile.open(QIODevice::WriteOnly | QIODevice::Append)) {
QTextStream xml_stream(&xmlFile); QTextStream xml_stream(&xmlFile);
xml_stream << testrHeader(changeNo, platform, branch); xml_stream << testrHeader(changeNo, platform, branch);
xml_stream << "\n"; xml_stream << '\n';
xml_stream << QString("\n<!-- file 1 of 1: filename -->\n"); xml_stream << QString("\n<!-- file 1 of 1: filename -->\n");
xml_stream << m_xmlLog.join("\n"); xml_stream << m_xmlLog.join(QString(QLatin1Char('\n')));
xml_stream << "\n"; xml_stream << '\n';
xml_stream << testrFooter(); xml_stream << testrFooter();
xmlFile.close(); xmlFile.close();
return fname; return fname;
} }
} }
return ""; return QString();
} }
QString TestExecuter::sanitizedForFilename(const QString &in) const QString TestExecuter::sanitizedForFilename(const QString &in) const
{ {
QString out = in; QString out = in;
static const QRegExp replaceRx("[^a-zA-Z0-9\\-_\\.]"); static const QRegExp replaceRx(QLatin1String("[^a-zA-Z0-9\\-_\\.]"));
out.replace(replaceRx, "_"); out.replace(replaceRx, QString(QLatin1Char('_')));
return out; return out;
} }
@@ -1223,8 +1221,7 @@ void TestExecuter::syntaxError(const QString &msg, const QString &file, int line
tmp->gotoLine(line); tmp->gotoLine(line);
} }
QFileInfo fi(file); QFileInfo fi(file);
QString message(QString(tr("Syntax error in %1, near line %2.\n%3")) const QString message = tr("Syntax error in %1, near line %2.\n%3").arg(fi.fileName()).arg(line).arg(msg);
.arg(fi.fileName()).arg(line).arg(msg));
QMessageBox::critical(0, tr("System Test Failure"), message); QMessageBox::critical(0, tr("System Test Failure"), message);
} }
@@ -1316,9 +1313,9 @@ void TestExecuter::applyPendingInsertions()
if (editable) { if (editable) {
QString insertCode = "//BEGIN Recorded Events"; QString insertCode = "//BEGIN Recorded Events";
int column = editable->currentColumn(); int column = editable->currentColumn();
QStringList recordedLines = recordedCode.split('\n'); QStringList recordedLines = recordedCode.split(QLatin1Char('\n'));
QString indent(QString(' ').repeated(column-1)); QString indent(QString(' ').repeated(column-1));
indent.prepend("\n"); indent.prepend(QLatin1Char('\n'));
foreach (const QString &line, recordedLines) { foreach (const QString &line, recordedLines) {
insertCode.append(indent); insertCode.append(indent);
insertCode.append(line); insertCode.append(line);

View File

@@ -46,10 +46,7 @@
#endif #endif
#include <QtCore/QFutureWatcher> #include <QtCore/QFutureWatcher>
#include <QObject>
#include <QTimer>
#include <QProcess> #include <QProcess>
#include <QLabel>
#define NO_X_SERVER_AVAILABLE "No X-server available for testing" #define NO_X_SERVER_AVAILABLE "No X-server available for testing"
#define COMPILE_ERROR "Compile error" #define COMPILE_ERROR "Compile error"
@@ -58,6 +55,11 @@
#define COMPILE_UP_TO_DATE "Not recompiled, binary is up-to-date" #define COMPILE_UP_TO_DATE "Not recompiled, binary is up-to-date"
#define SELF_TEST "self-test" #define SELF_TEST "self-test"
QT_BEGIN_NAMESPACE
class QTextEdit;
class QLabel;
QT_END_NAMESPACE
class TestExecuter : public QObject class TestExecuter : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@@ -45,7 +45,6 @@
TestGenerator::TestGenerator() TestGenerator::TestGenerator()
{ {
m_generatedFilename = "";
m_initialized = false; m_initialized = false;
m_enableComponentNamedTest = true; m_enableComponentNamedTest = true;
} }
@@ -65,7 +64,7 @@ bool TestGenerator::generateProFile()
if (m_genMode != SystemTest) { if (m_genMode != SystemTest) {
src << "load(testcase)\n"; src << "load(testcase)\n";
src << "TARGET = " << m_testCase.toLower() << "\n"; src << "TARGET = " << m_testCase.toLower() << '\n';
src << "QT += testlib\n"; src << "QT += testlib\n";
src << "SOURCES = " << m_testCase.toLower() << ".cpp\n"; src << "SOURCES = " << m_testCase.toLower() << ".cpp\n";
} else if (m_genMode == SystemTest) { } else if (m_genMode == SystemTest) {
@@ -143,80 +142,80 @@ void TestGenerator::initSrc(QTextStream *s)
*s << crfileStream.readAll(); *s << crfileStream.readAll();
} }
*s << "\n"; *s << '\n';
*s << "//TESTED_COMPONENT=" << m_testedComponent << "\n"; *s << "//TESTED_COMPONENT=" << m_testedComponent << '\n';
*s << "//TESTED_CLASS=" << m_testedClass << "\n"; *s << "//TESTED_CLASS=" << m_testedClass << '\n';
*s << "//TESTED_FILE=" << m_includeFile << "\n"; *s << "//TESTED_FILE=" << m_includeFile << '\n';
*s << "\n"; *s << '\n';
*s << "#include <QtTest/QtTest>\n"; *s << "#include <QtTest/QtTest>\n";
if (m_includeFile != "") if (!m_includeFile.isEmpty())
*s << "#include \"" << m_includeFile << "\"\n"; *s << "#include \"" << m_includeFile << "\"\n";
*s << "\n"; *s << '\n';
*s << "/*!\n"; *s << "/*!\n";
*s << " \\internal\n"; *s << " \\internal\n";
*s << "\n"; *s << '\n';
*s << " \\class " << m_testCase << "\n"; *s << " \\class " << m_testCase << '\n';
*s << " \\brief <put brief description here>\n"; *s << " \\brief <put brief description here>\n";
*s << "\n"; *s << '\n';
*s << " <put extended description here>\n"; *s << " <put extended description here>\n";
*s << "\n"; *s << '\n';
if (m_testedClass.isEmpty()) if (m_testedClass.isEmpty())
*s << " \\sa " << "<tested class name>\n"; *s << " \\sa " << "<tested class name>\n";
else else
*s << " \\sa " << m_testedClass << "\n"; *s << " \\sa " << m_testedClass << '\n';
*s << "*/\n"; *s << "*/\n";
*s << "class " << m_testCase << " : public QObject\n"; *s << "class " << m_testCase << " : public QObject\n";
*s << "{\n"; *s << "{\n";
*s << " Q_OBJECT\n"; *s << " Q_OBJECT\n";
*s << "\n"; *s << '\n';
*s << "public:\n"; *s << "public:\n";
*s << " " << m_testCase << "();\n"; *s << " " << m_testCase << "();\n";
*s << " virtual ~" << m_testCase << "();\n"; *s << " virtual ~" << m_testCase << "();\n";
*s << "\n"; *s << '\n';
*s << "private slots:\n"; *s << "private slots:\n";
*s << " virtual void initTestCase();\n"; *s << " virtual void initTestCase();\n";
*s << " virtual void init();\n"; *s << " virtual void init();\n";
*s << " virtual void cleanup();\n"; *s << " virtual void cleanup();\n";
*s << " virtual void cleanupTestCase();\n"; *s << " virtual void cleanupTestCase();\n";
*s << "};\n"; *s << "};\n";
*s << "\n"; *s << '\n';
*s << "QTEST_MAIN(" << m_testCase << ")\n"; *s << "QTEST_MAIN(" << m_testCase << ")\n";
*s << "#include " << '"' << m_testCase.toLower() << ".moc" << '"' << "\n"; *s << "#include " << '"' << m_testCase.toLower() << ".moc" << '"' << '\n';
*s << "\n"; *s << '\n';
*s << "\n"; *s << '\n';
*s << m_testCase << "::" << m_testCase << "()\n"; *s << m_testCase << "::" << m_testCase << "()\n";
*s << "{\n"; *s << "{\n";
*s << "}\n"; *s << "}\n";
*s << "\n"; *s << '\n';
*s << m_testCase << "::~" << m_testCase << "()\n"; *s << m_testCase << "::~" << m_testCase << "()\n";
*s << "{\n"; *s << "{\n";
*s << "}\n"; *s << "}\n";
*s << "\n"; *s << '\n';
*s << "void " << m_testCase << "::initTestCase()\n"; *s << "void " << m_testCase << "::initTestCase()\n";
*s << "{\n"; *s << "{\n";
*s << "}\n"; *s << "}\n";
*s << "\n"; *s << '\n';
*s << "void " << m_testCase << "::init()\n"; *s << "void " << m_testCase << "::init()\n";
*s << "{\n"; *s << "{\n";
*s << "}\n"; *s << "}\n";
*s << "\n"; *s << '\n';
*s << "void " << m_testCase << "::cleanup()\n"; *s << "void " << m_testCase << "::cleanup()\n";
*s << "{\n"; *s << "{\n";
*s << "}\n"; *s << "}\n";
*s << "\n"; *s << '\n';
*s << "void " << m_testCase << "::cleanupTestCase()\n"; *s << "void " << m_testCase << "::cleanupTestCase()\n";
*s << "{\n"; *s << "{\n";
*s << "}\n"; *s << "}\n";
*s << "\n"; *s << '\n';
*s << "\n"; *s << '\n';
} }
void TestGenerator::initScript(QTextStream *s) void TestGenerator::initScript(QTextStream *s)
@@ -234,29 +233,29 @@ void TestGenerator::initScript(QTextStream *s)
*s << crfileStream.readAll(); *s << crfileStream.readAll();
} }
*s << "\n"; *s << '\n';
*s << "//TESTED_COMPONENT=" << m_testedComponent << "\n"; *s << "//TESTED_COMPONENT=" << m_testedComponent << '\n';
*s << "\n"; *s << '\n';
*s << "testcase = {\n"; *s << "testcase = {\n";
*s << " initTestCase: function()\n"; *s << " initTestCase: function()\n";
*s << " {\n"; *s << " {\n";
*s << " },\n"; *s << " },\n";
*s << "\n"; *s << '\n';
*s << " init: function()\n"; *s << " init: function()\n";
*s << " {\n"; *s << " {\n";
*s << " },\n"; *s << " },\n";
*s << "\n"; *s << '\n';
*s << " cleanup: function()\n"; *s << " cleanup: function()\n";
*s << " {\n"; *s << " {\n";
*s << " },\n"; *s << " },\n";
*s << "\n"; *s << '\n';
*s << " cleanupTestCase: function()\n"; *s << " cleanupTestCase: function()\n";
*s << " {\n"; *s << " {\n";
*s << " },\n"; *s << " },\n";
*s << "\n"; *s << '\n';
*s << "\n"; *s << '\n';
*s << "} // end of testcase\n"; *s << "} // end of testcase\n";
*s << "\n"; *s << '\n';
} }
void TestGenerator::setTestCase(GenMode mode, const QString &rootDir, const QString &testDir, void TestGenerator::setTestCase(GenMode mode, const QString &rootDir, const QString &testDir,
@@ -265,12 +264,12 @@ void TestGenerator::setTestCase(GenMode mode, const QString &rootDir, const QStr
{ {
Q_UNUSED(testedClassFile); Q_UNUSED(testedClassFile);
QString testCaseNameSuffix; QString testCaseNameSuffix;
m_generatedFilename = ""; m_generatedFilename.clear();
m_genMode = mode; m_genMode = mode;
m_testedClass = testedClassName; m_testedClass = testedClassName;
m_testedComponent = testedComponent; m_testedComponent = testedComponent;
m_includeFile = ""; m_includeFile.clear();
m_testCase = testCase; m_testCase = testCase;
m_rootDir = rootDir; m_rootDir = rootDir;

View File

@@ -34,8 +34,8 @@
#define TESTGENERATOR_H #define TESTGENERATOR_H
#include <QString> #include <QString>
#include <QTextStream>
#include <QStringList> QT_FORWARD_DECLARE_CLASS(QTextStream)
class TestGenerator class TestGenerator
{ {

View File

@@ -44,9 +44,8 @@ QTextEdit *testOutputPane()
return 0; return 0;
} }
TestOutputWindow::TestOutputWindow() TestOutputWindow::TestOutputWindow() : m_widget(new QTextEdit)
{ {
m_widget = new QTextEdit;
m_widget->setReadOnly(true); m_widget->setReadOnly(true);
m_widget->setFrameStyle(QFrame::NoFrame); m_widget->setFrameStyle(QFrame::NoFrame);
m_instance = this; m_instance = this;

View File

@@ -34,7 +34,8 @@
#define TESTOUTPUTWINDOW_H #define TESTOUTPUTWINDOW_H
#include <coreplugin/ioutputpane.h> #include <coreplugin/ioutputpane.h>
#include <QTextEdit>
QT_FORWARD_DECLARE_CLASS(QTextEdit)
QTextEdit *testOutputPane(); QTextEdit *testOutputPane();

View File

@@ -32,8 +32,10 @@
#include "testresultuploader.h" #include "testresultuploader.h"
#include "testoutputwindow.h" #include "testoutputwindow.h"
#include "qsystem.h"
#include <QFileInfo> #include <QFileInfo>
#include <QTextEdit>
TestResultUploader::TestResultUploader(QObject *parent) : TestResultUploader::TestResultUploader(QObject *parent) :
QObject(parent) QObject(parent)
@@ -66,19 +68,19 @@ void TestResultUploader::uploadResultsToDatabase(const QString &fname, TestConfi
m_srcFname = fname; m_srcFname = fname;
if (!fname.isEmpty()) { if (!fname.isEmpty()) {
m_logFile.setFileName(QDir::homePath() + QDir::separator() + ".qttest" m_logFile.setFileName(QDir::homePath() + QDir::separator() + QLatin1String(".qttest")
+ QDir::separator() + "test_result_upload.log"); + QDir::separator() + QLatin1String("test_result_upload.log"));
m_logFile.open(QFile::WriteOnly); m_logFile.open(QFile::WriteOnly);
if (m_testSettings.uploadServer().isEmpty()) { if (m_testSettings.uploadServer().isEmpty()) {
testOutputPane()->append("-- ATTENTION: Uploading of test results to the database aborted. " testOutputPane()->append(tr("-- ATTENTION: Uploading of test results to the database aborted. "
"Please specify an upload server in the Upload Test Results Settings dialog."); "Please specify an upload server in the Upload Test Results Settings dialog."));
return; return;
} }
m_uploadServerName = m_testSettings.uploadServer(); m_uploadServerName = m_testSettings.uploadServer();
int pos = m_uploadServerName.indexOf(":"); int pos = m_uploadServerName.indexOf(QLatin1Char(':'));
if (pos) if (pos)
m_uploadServerName = m_uploadServerName.left(pos); m_uploadServerName = m_uploadServerName.left(pos);
@@ -87,10 +89,10 @@ void TestResultUploader::uploadResultsToDatabase(const QString &fname, TestConfi
return; return;
m_tgtFname = inf.fileName(); m_tgtFname = inf.fileName();
QString cmd1 = QSystem::which(m_testCfg->PATH(), "scp"); QString cmd1 = QSystem::which(m_testCfg->PATH(), QLatin1String("scp"));
QStringList args1; QStringList args1;
args1 << fname << QString("%1:/tmp/%2").arg(m_uploadServerName).arg(m_tgtFname); args1 << fname << QString::fromLatin1("%1:/tmp/%2").arg(m_uploadServerName, m_tgtFname);
if (exec(cmd1, QStringList() << "-q" << "-v" << "-C" << args1, "", 60000)) if (exec(cmd1, QStringList() << QLatin1String("-q") << QLatin1String("-v") << QLatin1String("-C") << args1, QString(), 60000))
m_uploadState = UploadScp; m_uploadState = UploadScp;
} }
} }
@@ -109,7 +111,7 @@ bool TestResultUploader::exec(const QString &cmd, const QStringList &arguments,
Q_ASSERT(m_executer.state() == QProcess::NotRunning); Q_ASSERT(m_executer.state() == QProcess::NotRunning);
if ((workDir != "") && (m_executer.workingDirectory() != workDir)) if ((!workDir.isEmpty()) && (m_executer.workingDirectory() != workDir))
m_executer.setWorkingDirectory(workDir); m_executer.setWorkingDirectory(workDir);
m_executer.setEnvironment(*m_testCfg->buildEnvironment()); m_executer.setEnvironment(*m_testCfg->buildEnvironment());
@@ -122,8 +124,8 @@ bool TestResultUploader::exec(const QString &cmd, const QStringList &arguments,
realCmd = cmd; realCmd = cmd;
if (realCmd.isEmpty()) { if (realCmd.isEmpty()) {
testOutputPane()->append("-- No '" + cmd + "' instance found in PATH (" const QString path = QSystem::envKey(m_testCfg->buildEnvironment(), "PATH");
+ QSystem::envKey(m_testCfg->buildEnvironment(), "PATH") + ")."); testOutputPane()->append(tr("-- No '%1' instance found in PATH (%2).").arg(cmd, path));
return false; return false;
} }
m_executer.start(realCmd,arguments); m_executer.start(realCmd,arguments);
@@ -135,7 +137,7 @@ bool TestResultUploader::exec(const QString &cmd, const QStringList &arguments,
if (m_logFile.isOpen()) { if (m_logFile.isOpen()) {
m_logFile.write("exec: "); m_logFile.write("exec: ");
m_logFile.write(cmd.toLatin1()); m_logFile.write(cmd.toLatin1());
m_logFile.write(arguments.join(" ").toLatin1()); m_logFile.write(arguments.join(QString(QLatin1Char(' '))).toLatin1());
m_logFile.write("\n"); m_logFile.write("\n");
} }
return m_executer.waitForStarted(30000); return m_executer.waitForStarted(30000);
@@ -149,17 +151,17 @@ void TestResultUploader::execFinished(int exitValue, QProcess::ExitStatus)
m_logFile.write("Upload FAILED!"); m_logFile.write("Upload FAILED!");
m_logFile.close(); m_logFile.close();
QString errFname = QDir::homePath() + QDir::separator() + ".qttest" QString errFname = QDir::homePath() + QDir::separator() + QLatin1String(".qttest")
+ QDir::separator() + "last_test_result_upload_failure.log"; + QDir::separator() + QLatin1String("last_test_result_upload_failure.log");
QFile::remove(errFname); QFile::remove(errFname);
m_logFile.rename(m_logFile.fileName(), errFname); m_logFile.rename(m_logFile.fileName(), errFname);
QFile errorFile(errFname); QFile errorFile(errFname);
QString lastErrorMessage; QString lastErrorMessage;
if (errorFile.open(QIODevice::ReadOnly)){ if (errorFile.open(QIODevice::ReadOnly)){
lastErrorMessage = QString("Upload FAILED: %1").arg(QString(errorFile.readAll())); lastErrorMessage = tr("Upload FAILED: %1").arg(QString::fromLocal8Bit(errorFile.readAll()));
errorFile.close(); errorFile.close();
} else { } else {
lastErrorMessage = QString("Upload FAILED, look at the log file %1").arg(errFname); lastErrorMessage = tr("Upload FAILED, look at the log file %1").arg(errFname);
} }
testOutputPane()->append(lastErrorMessage); testOutputPane()->append(lastErrorMessage);
} }
@@ -173,16 +175,14 @@ void TestResultUploader::execFinished(int exitValue, QProcess::ExitStatus)
QString cmd2 = QSystem::which(m_testCfg->PATH(), "ssh"); QString cmd2 = QSystem::which(m_testCfg->PATH(), "ssh");
QStringList args2; QStringList args2;
args2 << m_uploadServerName args2 << m_uploadServerName
<< "mv" << QLatin1String("mv")
<< "-f" << QLatin1String("-f")
<< QString("/tmp/%1").arg(m_tgtFname) << QLatin1String("/tmp/") + m_tgtFname
<< QString("results/%3").arg(m_tgtFname); << QLatin1String("results/") + m_tgtFname;
exec(cmd2, QStringList() << "-q" << "-v" << args2); exec(cmd2, QStringList() << QLatin1String("-q") << QLatin1String("-v") << args2);
} else if (m_uploadState == UploadMv) { } else if (m_uploadState == UploadMv) {
m_uploadState = UploadIdle; m_uploadState = UploadIdle;
testOutputPane()->append("\nTest results have been uploaded into the results database.\nThank you for supporting " testOutputPane()->append(tr("\nTest results have been uploaded into the results database.\nThank you for supporting %1").arg(m_testCfg->configName()));
+ m_testCfg->configName());
QFile::remove(m_srcFname); QFile::remove(m_srcFname);
m_logFile.close(); m_logFile.close();
m_logFile.remove(); m_logFile.remove();

View File

@@ -38,7 +38,6 @@
#include <QObject> #include <QObject>
#include <QProcess> #include <QProcess>
#include <QDebug>
class TestResultUploader : public QObject class TestResultUploader : public QObject
{ {

View File

@@ -38,6 +38,8 @@
#include "testgenerator.h" #include "testgenerator.h"
#include "dialogs.h" #include "dialogs.h"
#include "testconfigurations.h" #include "testconfigurations.h"
#include "testexecuter.h"
#include "testcontextmenu.h"
#include <projectexplorer/session.h> #include <projectexplorer/session.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
@@ -221,7 +223,7 @@ QString TestViewItem::suiteName()
if (m_parent != 0) if (m_parent != 0)
ret = m_parent->suiteName(); ret = m_parent->suiteName();
if (m_isTestSuite) { if (m_isTestSuite) {
if (!ret.isEmpty()) ret += "/"; if (!ret.isEmpty()) ret += QLatin1Char('/');
ret += m_name; ret += m_name;
} }
return QDir::convertSeparators(ret); return QDir::convertSeparators(ret);
@@ -231,7 +233,7 @@ QString TestViewItem::fullName()
{ {
QString ret = suiteName(); QString ret = suiteName();
if (!m_isTestSuite) { if (!m_isTestSuite) {
ret += "/"+ m_name; ret += QLatin1Char('/')+ m_name;
} }
return QDir::convertSeparators(ret); return QDir::convertSeparators(ret);
} }
@@ -413,7 +415,7 @@ bool splitSuiteName(const QString &fullName, QString &first, QString &rest)
return false; return false;
first = L[0]; first = L[0];
rest = ""; rest.clear();
if (L.count() > 1) { if (L.count() > 1) {
for (int i = 1; i < L.count(); ++i) { for (int i = 1; i < L.count(); ++i) {
if (!rest.isEmpty()) if (!rest.isEmpty())
@@ -564,7 +566,7 @@ QString TestFunctionItem::key(int column, bool /*ascending*/) const
int TestSelector::m_refCount = 0; int TestSelector::m_refCount = 0;
TestSelector::TestSelector(QWidget *parent, const char *name) : TestSelector::TestSelector(QWidget *parent) :
QTreeWidget(parent) QTreeWidget(parent)
{ {
TestSettings testSettings; TestSettings testSettings;
@@ -577,14 +579,12 @@ TestSelector::TestSelector(QWidget *parent, const char *name) :
connect(TestExecuter::instance(), SIGNAL(testFinished()), connect(TestExecuter::instance(), SIGNAL(testFinished()),
this, SLOT(updateActions()), Qt::DirectConnection); this, SLOT(updateActions()), Qt::DirectConnection);
Q_UNUSED(name);
setColumnCount(1); setColumnCount(1);
setSortingEnabled(false); setSortingEnabled(false);
setRootIsDecorated(true); setRootIsDecorated(true);
setSelectionMode(QAbstractItemView::SingleSelection); setSelectionMode(QAbstractItemView::SingleSelection);
m_curTest.m_testFunction = ""; m_curTest.m_testFunction.clear();;
m_curTest.m_line = -1; m_curTest.m_line = -1;
m_curTest.m_code = 0; m_curTest.m_code = 0;
@@ -796,14 +796,14 @@ void TestSelector::onSelectionChanged()
m_testCollection.setCurrentEditedTest(0); m_testCollection.setCurrentEditedTest(0);
m_curTest.m_code = 0; m_curTest.m_code = 0;
m_curTest.m_basePath = ""; m_curTest.m_basePath.clear();
checkSuite(0, selected, multiSelection); checkSuite(0, selected, multiSelection);
if (!selected || multiSelection) { if (!selected || multiSelection) {
// no function and no class selected // no function and no class selected
m_curTest.m_code = 0; m_curTest.m_code = 0;
m_curTest.m_testFunction = ""; m_curTest.m_testFunction.clear();
m_curTest.m_line = -1; m_curTest.m_line = -1;
m_testContextMenu->updateSingleTestAction(""); m_testContextMenu->updateSingleTestAction(QString());
} }
if (m_curTest.m_code) { if (m_curTest.m_code) {
@@ -855,9 +855,9 @@ void TestSelector::selectGroup()
if (inf && (inf->testStartLine() >= 0)) { if (inf && (inf->testStartLine() >= 0)) {
if (!inf->testGroups().isEmpty()) { if (!inf->testGroups().isEmpty()) {
dlg.addSelectableItems(inf->testGroups() dlg.addSelectableItems(inf->testGroups()
.split(",", QString::SkipEmptyParts)); .split(QLatin1Char(','), QString::SkipEmptyParts));
groupsList.append(tc->testCase() + "::" + inf->functionName() groupsList.append(tc->testCase() + "::" + inf->functionName()
+ "@" + inf->testGroups().split(",", QString::SkipEmptyParts).join("@")); + QLatin1Char('@') + inf->testGroups().split(QLatin1Char(','), QString::SkipEmptyParts).join(QString(QLatin1Char('@'))));
} }
} }
} }
@@ -871,7 +871,7 @@ void TestSelector::selectGroup()
while (current < groupsList.count()) { while (current < groupsList.count()) {
bool containsAGroup = false; bool containsAGroup = false;
for (int i = 0; i < selectedGroups.count(); ++i) { for (int i = 0; i < selectedGroups.count(); ++i) {
if (groupsList[current].contains(QString("@" + selectedGroups[i]))) { if (groupsList[current].contains(QString(QLatin1Char('@') + selectedGroups[i]))) {
containsAGroup = true; containsAGroup = true;
break; break;
} }
@@ -879,7 +879,7 @@ void TestSelector::selectGroup()
if (!containsAGroup) { if (!containsAGroup) {
groupsList.removeAt(current); groupsList.removeAt(current);
} else { } else {
groupsList[current] = groupsList[current].left(groupsList[current].indexOf("@")); groupsList[current] = groupsList[current].left(groupsList[current].indexOf(QLatin1Char('@')));
++current; ++current;
} }
} }
@@ -890,7 +890,7 @@ void TestSelector::selectGroup()
QString TestSelector::curTestSuite(bool fullPath) QString TestSelector::curTestSuite(bool fullPath)
{ {
if ((m_curTest.m_code == 0) || m_curTest.m_code->actualFileName().isEmpty()) if ((m_curTest.m_code == 0) || m_curTest.m_code->actualFileName().isEmpty())
return ""; return QString();
if (fullPath) if (fullPath)
return m_curTest.m_code->fullVisualSuitePath(m_testSettings.componentViewMode()); return m_curTest.m_code->fullVisualSuitePath(m_testSettings.componentViewMode());
return m_curTest.m_code->visualBasePath(); return m_curTest.m_code->visualBasePath();
@@ -921,7 +921,7 @@ void TestSelector::checkSuite(TestSuiteItem *base, bool &selected, bool &multiSe
multiSelection = true; multiSelection = true;
selected = true; selected = true;
if (!multiSelection) { if (!multiSelection) {
m_curTest.m_testFunction = ""; m_curTest.m_testFunction.clear();
m_curTest.m_line = -1; m_curTest.m_line = -1;
if (!m_curTest.m_code if (!m_curTest.m_code
|| (m_curTest.m_code->visualFileName(m_testSettings.componentViewMode()) != T->fullName())) { || (m_curTest.m_code->visualFileName(m_testSettings.componentViewMode()) != T->fullName())) {
@@ -943,7 +943,7 @@ void TestSelector::checkSuite(TestSuiteItem *base, bool &selected, bool &multiSe
multiSelection = true; multiSelection = true;
selected = true; selected = true;
if (!multiSelection) { if (!multiSelection) {
m_curTest.m_testFunction = ""; m_curTest.m_testFunction.clear();
m_curTest.m_line = -1; m_curTest.m_line = -1;
if (!m_curTest.m_code if (!m_curTest.m_code
|| (m_curTest.m_code->visualFileName(m_testSettings.componentViewMode()) != testCase->fullName())) { || (m_curTest.m_code->visualFileName(m_testSettings.componentViewMode()) != testCase->fullName())) {
@@ -1190,7 +1190,7 @@ void TestSelector::select(TestCode *tc, const QString &funcName)
QString tcFileName = tc->visualFileName(m_testSettings.componentViewMode()); QString tcFileName = tc->visualFileName(m_testSettings.componentViewMode());
TestCaseItem *testCase = findCase(tcFileName); TestCaseItem *testCase = findCase(tcFileName);
if (testCase) { if (testCase) {
if (funcName != "") { if (!funcName.isEmpty()) {
TestFunctionItem *testFunction; TestFunctionItem *testFunction;
if (testCase->findFunction(funcName, testFunction)) { if (testCase->findFunction(funcName, testFunction)) {
expandItem(testFunction); expandItem(testFunction);
@@ -1480,7 +1480,7 @@ void TestSelector::testInsertUnitOrSystemTest()
gen.enableComponentInTestName(dlg.componentInName()); gen.enableComponentInTestName(dlg.componentInName());
gen.setTestCase(dlg.mode(), gen.setTestCase(dlg.mode(),
dlg.location(), dlg.location(),
"", // use automatic "subdir" selection QString(), // use automatic "subdir" selection
dlg.testCaseName(), dlg.testCaseName(),
dlg.testedComponent(), dlg.testedComponent(),
dlg.testedClassName(), dlg.testedClassName(),

View File

@@ -34,22 +34,21 @@
#define TESTSELECTOR_H #define TESTSELECTOR_H
#include "testsuite.h" #include "testsuite.h"
#include "testexecuter.h"
#include "testcode.h"
#include "testsettings.h" #include "testsettings.h"
#include "testcontextmenu.h"
#include <extensionsystem/iplugin.h>
#include <projectexplorer/projectexplorer.h>
#include <QString> #include <QString>
#include <QTreeWidget> #include <QTreeWidget>
#include <QMenu>
#include <QAction> QT_BEGIN_NAMESPACE
class QMenu;
class QAction;
QT_END_NAMESPACE
class TestSuiteItem; class TestSuiteItem;
class TestCaseItem; class TestCaseItem;
class TestFunctionItem; class TestFunctionItem;
class TestContextMenu;
class TestCode;
class TestViewItem : public QTreeWidgetItem class TestViewItem : public QTreeWidgetItem
{ {
@@ -112,7 +111,7 @@ class TestSelector : public QTreeWidget
Q_OBJECT Q_OBJECT
public: public:
TestSelector(QWidget *parent = 0, const char *name = 0); explicit TestSelector(QWidget *parent = 0);
virtual ~TestSelector(); virtual ~TestSelector();
void setContextMenu(TestContextMenu *contextMenu); void setContextMenu(TestContextMenu *contextMenu);

View File

@@ -83,7 +83,7 @@ TestIniFile::TestIniFile(const QString &fileName)
QString S; QString S;
while (!ds.atEnd()) { while (!ds.atEnd()) {
S = ds.readLine().trimmed(); S = ds.readLine().trimmed();
if (S != "" && !S.startsWith("#")) if (!S.isEmpty() && !S.startsWith(QLatin1Char('#')))
m_settings.append(S); m_settings.append(S);
} }
} }
@@ -101,7 +101,7 @@ bool TestIniFile::find(const QString &key, QString &line)
{ {
foreach (const QString &S, m_settings) { foreach (const QString &S, m_settings) {
if (S.startsWith(key)) { if (S.startsWith(key)) {
int pos = S.indexOf("="); int pos = S.indexOf(QLatin1Char('='));
if (pos > 0) { if (pos > 0) {
line = S.mid(pos+1).trimmed(); line = S.mid(pos+1).trimmed();
return true; return true;
@@ -176,8 +176,8 @@ bool TestIniFile::initSaving(const QString &comment)
} }
} }
foreach (const QString &S, comment.split("\n")) { foreach (const QString &S, comment.split(QLatin1Char('\n'))) {
if (!S.startsWith("#")) if (!S.startsWith(QLatin1Char('#')))
*m_outStream << "# "; *m_outStream << "# ";
*m_outStream << S << "\n"; *m_outStream << S << "\n";
} }
@@ -189,7 +189,7 @@ bool TestIniFile::write(const QString &comment, const QString &key, const QStrin
{ {
if (!initSaving(comment)) if (!initSaving(comment))
return false; return false;
*m_outStream << key << "="; *m_outStream << key << '=';
if (!value.isEmpty()) if (!value.isEmpty())
*m_outStream << value; *m_outStream << value;
*m_outStream << "\n\n"; *m_outStream << "\n\n";
@@ -200,7 +200,7 @@ bool TestIniFile::write(const QString &comment, const QString &key, int value)
{ {
if (!initSaving(comment)) if (!initSaving(comment))
return false; return false;
*m_outStream << key << "=" << QString("%1").arg(value) << "\n\n"; *m_outStream << key << '=' << QString::number(value) << "\n\n";
return true; return true;
} }
@@ -208,7 +208,7 @@ bool TestIniFile::write(const QString &comment, const QString &key, uint value)
{ {
if (!initSaving(comment)) if (!initSaving(comment))
return false; return false;
*m_outStream << key << "=" << QString("%1").arg(value) << "\n\n"; *m_outStream << key << '=' << QString::number(value) << "\n\n";
return true; return true;
} }
@@ -216,9 +216,9 @@ bool TestIniFile::write(const QString &comment, const QString &key, QDateTime va
{ {
if (!initSaving(comment)) if (!initSaving(comment))
return false; return false;
*m_outStream << key << "="; *m_outStream << key << '=';
if (value.isValid()) if (value.isValid())
*m_outStream << QString("%1").arg(value.toString(Qt::ISODate)); *m_outStream << value.toString(Qt::ISODate);
*m_outStream << "\n\n"; *m_outStream << "\n\n";
return true; return true;
} }

View File

@@ -33,10 +33,8 @@
#ifndef TESTSETTINGS_H #ifndef TESTSETTINGS_H
#define TESTSETTINGS_H #define TESTSETTINGS_H
#include "qsystem.h" #include <QObject>
#include <QString> #include <QString>
#include <QStringList>
// class TestSettings_p; // class TestSettings_p;
class TestSettings_p : public QObject class TestSettings_p : public QObject

View File

@@ -31,6 +31,7 @@
**************************************************************************/ **************************************************************************/
#include "testsettingspropertiespage.h" #include "testsettingspropertiespage.h"
#include "testconfigurations.h"
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
@@ -249,13 +250,13 @@ void TestSettingsWidget::onChanged()
// to be used when uploading test results // to be used when uploading test results
if (!m_ui.upload_branch_Specialization->text().trimmed().isEmpty()) if (!m_ui.upload_branch_Specialization->text().trimmed().isEmpty())
m_ui.effectiveBranchName->setText(m_ui.upload_branch->text().trimmed() m_ui.effectiveBranchName->setText(m_ui.upload_branch->text().trimmed()
+ "-" + m_ui.upload_branch_Specialization->text().trimmed()); + QLatin1Char('-') + m_ui.upload_branch_Specialization->text().trimmed());
else else
m_ui.effectiveBranchName->setText(m_ui.upload_branch->text().trimmed()); m_ui.effectiveBranchName->setText(m_ui.upload_branch->text().trimmed());
if (!m_ui.qmakespecSpecialization->text().trimmed().isEmpty()) if (!m_ui.qmakespecSpecialization->text().trimmed().isEmpty())
m_ui.effectiveQMakespec->setText(m_ui.qmakespec->text().trimmed() m_ui.effectiveQMakespec->setText(m_ui.qmakespec->text().trimmed()
+ "_" + m_ui.qmakespecSpecialization->text().trimmed()); + QLatin1Char('_') + m_ui.qmakespecSpecialization->text().trimmed());
else else
m_ui.effectiveQMakespec->setText(m_ui.qmakespec->text().trimmed()); m_ui.effectiveQMakespec->setText(m_ui.qmakespec->text().trimmed());

View File

@@ -33,15 +33,15 @@
#ifndef TESTSETTINGSPROPERTIESPAGE_H #ifndef TESTSETTINGSPROPERTIESPAGE_H
#define TESTSETTINGSPROPERTIESPAGE_H #define TESTSETTINGSPROPERTIESPAGE_H
#include "testconfigurations.h"
#include "testsettings.h" #include "testsettings.h"
#include <projectexplorer/iprojectproperties.h> #include <projectexplorer/iprojectproperties.h>
#include <projectexplorer/iprojectmanager.h>
#include <ui_testsettingspropertiespage.h> #include <ui_testsettingspropertiespage.h>
#include <QStringList> #include <QStringList>
class TestConfig;
namespace QtTest { namespace QtTest {
namespace Internal { namespace Internal {