Constructs a screenshot ID for the test failure at the given \a file and
\a line.
*/
-QString screenshotId(const QString &file, int line)
+static QString screenshotId(const QString &file, int line)
{
- return QString("%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) :
continue;
QString screenshot = m_pendingScreenshots.take(id);
- QTableWidgetItem* shot = new QTableWidgetItem(QIcon(QPixmap(":/testrun.png")), QString());
+ QTableWidgetItem* shot = new QTableWidgetItem(QIcon(QPixmap(QLatin1String(":/testrun.png"))), QString());
shot->setData(ScreenshotLinkRole, screenshot);
shot->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
setItem(row, SCREEN_POS, shot);
QTableWidgetItem* result = new QTableWidgetItem(res);
result->setTextAlignment(Qt::AlignCenter);
- if (res.startsWith("PASS")) {
+ if (res.startsWith(QLatin1String("PASS"))) {
result->setBackground(passBrush);
setRowHidden(row, !m_showPassing);
- } else if (res.startsWith("FAIL")) {
+ } else if (res.startsWith(QLatin1String("FAIL"))) {
result->setBackground(failBrush);
- } else if (res.startsWith("QDEBUG")) {
+ } else if (res.startsWith(QLatin1String("QDEBUG"))) {
setRowHidden(row, !m_showDebug);
- } else if (res.startsWith("SKIP")) {
+ } else if (res.startsWith(QLatin1String("SKIP"))) {
setRowHidden(row, !m_showSkipped);
- } else if (res.startsWith("XFAIL") || res.startsWith("XPASS")) {
+ } else if (res.startsWith(QLatin1String("XFAIL")) || res.startsWith(QLatin1String("XPASS"))) {
result->setBackground(unexpectedBrush);
}
- if ((res.contains("FAIL") || res.startsWith("XPASS")) && !m_failedTests.contains(test))
+ if ((res.contains(QLatin1String("FAIL")) || res.startsWith(QLatin1String("XPASS"))) && !m_failedTests.contains(test))
m_failedTests.append(test);
// Construct a result id for use in mapping test failures to screenshots.
QString ResultsView::formatTestDetails(const QString &test, const QString &dataTag)
{
QString ret = test;
- if (!dataTag.isEmpty() && dataTag != "...")
- ret += " (" + dataTag + ")";
+ if (!dataTag.isEmpty() && dataTag != QLatin1String("...")) {
+ ret += QLatin1String(" (");
+ ret += dataTag;
+ ret += QLatin1Char(')');
+ }
return ret;
}
{
QString description;
QString _file = file;
- if (_file.startsWith("["))
+ if (_file.startsWith(QLatin1Char('[')))
_file = _file.mid(1);
- if (_file != "" || line != "") {
+ if (!_file.isEmpty() || !line.isEmpty()) {
description += xmlDequote(file);
- if (line != "-1")
- description += ":" + line;
+ if (line != QLatin1String("-1")) {
+ description += QLatin1Char(':');
+ description += line;
+ }
}
return description;
QString ResultsView::result(int row)
{
if (row >= rowCount())
- return false;
+ return QString();
return item(row, RESULT_POS)->text().simplified();
}
QString ResultsView::reason(int row)
{
if (row >= rowCount())
- return false;
+ return QString();
QString txt = item(row, REASON_POS)->text();
- int pos = txt.indexOf("\n");
+ const int pos = txt.indexOf(QLatin1Char('\n'));
if (pos > 0)
- txt = txt.left(pos);
+ txt.truncate(pos);
return txt.simplified();
}
QString ResultsView::location(int row)
{
if (row >= rowCount())
- return false;
+ return QString();
return item(row, DETAILS_POS)->toolTip();
}
{
QString txt = location(row);
if (!txt.isEmpty()) {
- int pos = txt.indexOf(":");
+ const int pos = txt.indexOf(QLatin1Char(':'));
if (pos >= 0)
- txt = txt.left(pos);
+ txt.truncate(pos);
return txt.simplified();
}
- return "";
+ return QString();
}
QString ResultsView::line(int row)
{
QString txt = location(row);
if (!txt.isEmpty()) {
- int pos = txt.indexOf(":");
- if (pos >= 0)
+ const int pos = txt.indexOf(QLatin1Char(':'));
+ if (pos >= 0) {
txt = txt.mid(pos + 1);
- else txt = "";
+ } else {
+ txt.clear();
+ }
return txt.simplified();
}
- return "";
+ return QString();
}
int ResultsView::intLine(int row)
void ResultsView::showPassing(bool show)
{
m_showPassing = show;
- updateHidden("PASS", show);
+ updateHidden(QLatin1String("PASS"), show);
m_testSettings.setShowPassedResults(show);
}
void ResultsView::showDebugMessages(bool show)
{
m_showDebug = show;
- updateHidden("QDEBUG", show);
+ updateHidden(QLatin1String("QDEBUG"), show);
m_testSettings.setShowDebugResults(show);
}
void ResultsView::showSkipped(bool show)
{
m_showSkipped = show;
- updateHidden("SKIP", show);
+ updateHidden(QLatin1String("SKIP"), show);
m_testSettings.setShowSkippedResults(show);
}
void ResultsView::copyResults()
{
QMimeData *md = new QMimeData();
- QString html("<html><table>");
+ QString html = QLatin1String("<html><table>");
QString text;
for (int row = 0; row < rowCount(); ++row) {
QString result = item(row, RESULT_POS)->text().trimmed();
QString detail = item(row, DETAILS_POS)->text();
QString location = item(row, DETAILS_POS)->toolTip();
QString reason = item(row, REASON_POS)->text();
- html += QString("<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));
- text += QString("%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);
}
- html += "</table></html>";
+ html += QLatin1String("</table></html>");
md->setHtml(html);
md->setText(text);
QApplication::clipboard()->setMimeData(md);