Files
qt-creator/src/plugins/autotest/qtest/qttestframework.cpp
Christian Stenger d2656c60e6 AutoTest: Widen scope for run under cursor
..and debug under cursor for QtTest and GTest.

Depending on the information coming from the code model
we may be able to get a correct scope even when standing
inside the function that is defining the test.
This makes more sense than the original behavior which
made it a hard requirement to stand on a literal to
run or debug a test under cursor.
But as the codemodel does not provide usable information
for all frameworks keep the original behavior as fallback.

Task-number: QTCREATORBUG-28752
Change-Id: I13ea7b0ad1e8207da6cb884d212667c4c657957c
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-02-07 13:56:07 +00:00

49 lines
1.1 KiB
C++

// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qttestframework.h"
#include "qttestconstants.h"
#include "qttestparser.h"
#include "qttesttreeitem.h"
#include "../autotesttr.h"
namespace Autotest {
namespace Internal {
ITestParser *QtTestFramework::createTestParser()
{
return new QtTestParser(this);
}
ITestTreeItem *QtTestFramework::createRootNode()
{
return new QtTestTreeItem(this, displayName(), {}, ITestTreeItem::Root);
}
const char *QtTestFramework::name() const
{
return QtTest::Constants::FRAMEWORK_NAME;
}
QString QtTestFramework::displayName() const
{
return Tr::tr(QtTest::Constants::FRAMEWORK_SETTINGS_CATEGORY);
}
unsigned QtTestFramework::priority() const
{
return QtTest::Constants::FRAMEWORK_PRIORITY;
}
QStringList QtTestFramework::testNameForSymbolName(const QString &symbolName) const
{
int index = symbolName.lastIndexOf("::");
if (index == -1)
return {};
return { symbolName.left(index), symbolName.mid(index + 2) };
}
} // namespace Internal
} // namespace Autotest