forked from qt-creator/qt-creator
debugger: test the data that ends up displayed, not the raw data
Change-Id: I9453abd43299416e8d8535f9567fe96ff976e413 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -299,7 +299,6 @@ public:
|
||||
void reportTestError(const QString &msg, int line);
|
||||
bool m_testsPossible;
|
||||
QStringList m_testContents;
|
||||
QString m_testErrors;
|
||||
TaskHub *m_taskHub;
|
||||
QString m_testFileName;
|
||||
};
|
||||
@@ -1117,9 +1116,6 @@ void DebuggerEngine::setState(DebuggerState state, bool forced)
|
||||
BreakHandler *handler = breakHandler();
|
||||
foreach (BreakpointModelId id, handler->engineBreakpointIds(this))
|
||||
handler->notifyBreakpointReleased(id);
|
||||
|
||||
if (!d->m_testErrors.isEmpty())
|
||||
showMessage(_("\nTest Errors\n\n") + d->m_testErrors);
|
||||
}
|
||||
|
||||
const bool running = d->m_state == InferiorRunOk;
|
||||
@@ -1736,10 +1732,12 @@ void DebuggerEnginePrivate::handleAutoTestLine(int line)
|
||||
reportTestError(_("'Check' needs arguments."), line);
|
||||
} else {
|
||||
QByteArray iname = "local." + name.toLatin1();
|
||||
const WatchData *data = m_engine->watchHandler()->findItem(iname);
|
||||
if (data) {
|
||||
QString found = m_engine->watchHandler()->displayForAutoTest(iname);
|
||||
if (found.isEmpty()) {
|
||||
reportTestError(_("Check referes to unknown variable %1.")
|
||||
.arg(name), line);
|
||||
} else {
|
||||
QString needle = s.section(QLatin1Char(' '), 2, -1);
|
||||
QString found = data->value + QString::fromLatin1(" " + data->type);
|
||||
if (needle == found) {
|
||||
m_engine->showMessage(_("Check in line %1 for %2 was successful")
|
||||
.arg(line).arg(needle));
|
||||
@@ -1747,9 +1745,6 @@ void DebuggerEnginePrivate::handleAutoTestLine(int line)
|
||||
reportTestError(_("Check for %1 failed. Got %2.")
|
||||
.arg(needle).arg(found), line);
|
||||
}
|
||||
} else {
|
||||
reportTestError(_("Check referes to unknown variable %1.")
|
||||
.arg(name), line);
|
||||
}
|
||||
}
|
||||
handleAutoTestLine(line + 1);
|
||||
@@ -1762,8 +1757,6 @@ void DebuggerEnginePrivate::handleAutoTestLine(int line)
|
||||
void DebuggerEnginePrivate::reportTestError(const QString &msg, int line)
|
||||
{
|
||||
m_engine->showMessage(_("### Line %1: %2").arg(line).arg(msg));
|
||||
m_testErrors.append(msg);
|
||||
m_testErrors.append(QLatin1Char('\n'));
|
||||
|
||||
if (!m_taskHub) {
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
|
||||
@@ -691,6 +691,43 @@ static inline QString expression(const WatchItem *item)
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString WatchModel::display(const WatchItem *item, int col) const
|
||||
{
|
||||
QString result;
|
||||
switch (col) {
|
||||
case 0:
|
||||
if (item->name.isEmpty())
|
||||
result = tr("<Edit>");
|
||||
else if (item->name == QLatin1String("*") && item->parent)
|
||||
result = QLatin1Char('*') + item->parent->name;
|
||||
else
|
||||
result = removeInitialNamespace(item->name);
|
||||
break;
|
||||
case 1:
|
||||
result = removeInitialNamespace(
|
||||
truncateValue(formattedValue(*item)));
|
||||
if (item->referencingAddress) {
|
||||
result += QLatin1String(" @");
|
||||
result += QString::fromLatin1(item->hexAddress());
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
result = removeNamespaces(displayType(*item));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QString WatchModel::displayForAutoTest(const QByteArray &iname) const
|
||||
{
|
||||
const WatchItem *item = findItem(iname, m_root);
|
||||
if (item)
|
||||
return display(item, 1) + QLatin1Char(' ') + display(item, 2);
|
||||
return QString();
|
||||
}
|
||||
|
||||
QVariant WatchModel::data(const QModelIndex &idx, int role) const
|
||||
{
|
||||
const WatchItem *item = watchItem(idx);
|
||||
@@ -724,33 +761,8 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
|
||||
}
|
||||
}
|
||||
|
||||
case Qt::DisplayRole: {
|
||||
QString result;
|
||||
switch (idx.column()) {
|
||||
case 0:
|
||||
if (data.name.isEmpty())
|
||||
result = tr("<Edit>");
|
||||
else if (data.name == QLatin1String("*") && item->parent)
|
||||
result = QLatin1Char('*') + item->parent->name;
|
||||
else
|
||||
result = removeInitialNamespace(data.name);
|
||||
break;
|
||||
case 1:
|
||||
result = removeInitialNamespace(
|
||||
truncateValue(formattedValue(data)));
|
||||
if (data.referencingAddress) {
|
||||
result += QLatin1String(" @");
|
||||
result += QString::fromLatin1(data.hexAddress());
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
result = removeNamespaces(displayType(data));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
case Qt::DisplayRole:
|
||||
return display(item, idx.column());
|
||||
|
||||
case Qt::ToolTipRole:
|
||||
return debuggerCore()->boolSetting(UseToolTipsInLocalsView)
|
||||
@@ -1657,6 +1669,13 @@ const WatchData *WatchHandler::findItem(const QByteArray &iname) const
|
||||
return model->findItem(iname, model->m_root);
|
||||
}
|
||||
|
||||
QString WatchHandler::displayForAutoTest(const QByteArray &iname) const
|
||||
{
|
||||
const WatchModel *model = modelForIName(iname);
|
||||
QTC_ASSERT(model, return 0);
|
||||
return model->displayForAutoTest(iname);
|
||||
}
|
||||
|
||||
QModelIndex WatchHandler::itemIndex(const QByteArray &iname) const
|
||||
{
|
||||
if (const WatchModel *model = modelForIName(iname))
|
||||
|
||||
@@ -102,6 +102,7 @@ private:
|
||||
void reinsertAllDataHelper(WatchItem *item, QList<WatchData> *data);
|
||||
void insertBulkData(const QList<WatchData> &data);
|
||||
WatchItem *findItem(const QByteArray &iname, WatchItem *root) const;
|
||||
QString displayForAutoTest(const QByteArray &iname) const;
|
||||
void reinitialize();
|
||||
void removeOutdated();
|
||||
void removeOutdatedHelper(WatchItem *item);
|
||||
@@ -129,6 +130,7 @@ private:
|
||||
QString removeNamespaces(QString str) const;
|
||||
void formatRequests(QByteArray *out, const WatchItem *item) const;
|
||||
DebuggerEngine *engine() const;
|
||||
QString display(const WatchItem *item, int col) const;
|
||||
int itemFormat(const WatchData &data) const;
|
||||
int m_generationCounter;
|
||||
|
||||
@@ -165,6 +167,7 @@ public:
|
||||
|
||||
const WatchData *watchData(WatchType type, const QModelIndex &) const;
|
||||
const WatchData *findItem(const QByteArray &iname) const;
|
||||
QString displayForAutoTest(const QByteArray &iname) const;
|
||||
QModelIndex itemIndex(const QByteArray &iname) const;
|
||||
|
||||
void loadSessionData();
|
||||
|
||||
Reference in New Issue
Block a user