forked from qt-creator/qt-creator
AutoTest: Pass context object to lambda connections
Remove some unneeded lambda () brackets. Glue lambda brackets with parameters brackets. Change-Id: I414f7dbbaf60b452cb71f77d53d972937f121a47 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -152,7 +152,7 @@ AutotestPluginPrivate::AutotestPluginPrivate()
|
||||
this, [this] { m_runconfigCache.clear(); });
|
||||
|
||||
connect(sessionManager, &ProjectExplorer::SessionManager::aboutToRemoveProject,
|
||||
this, [] (ProjectExplorer::Project *project) {
|
||||
this, [](ProjectExplorer::Project *project) {
|
||||
const auto it = s_projectSettings.constFind(project);
|
||||
if (it != s_projectSettings.constEnd()) {
|
||||
delete it.value();
|
||||
|
@@ -37,8 +37,8 @@ QStringList filterInterfering(const QStringList &provided, QStringList *omitted)
|
||||
"--gtest_print_time="
|
||||
};
|
||||
|
||||
QStringList allowed = Utils::filtered(provided, [] (const QString &arg) {
|
||||
return Utils::allOf(knownInterferingOptions, [&arg] (const QString &interfering) {
|
||||
QStringList allowed = Utils::filtered(provided, [](const QString &arg) {
|
||||
return Utils::allOf(knownInterferingOptions, [&arg](const QString &interfering) {
|
||||
return !arg.startsWith(interfering);
|
||||
});
|
||||
});
|
||||
|
@@ -511,7 +511,7 @@ QSet<QString> internalTargets(const TestTreeItem &item)
|
||||
return cppMM->dependingInternalTargets(item.filePath());
|
||||
for (const CppEditor::ProjectPart::ConstPtr &projectPart : projectParts) {
|
||||
if (Utils::FilePath::fromString(projectPart->projectFile) == item.proFile()
|
||||
&& Utils::anyOf(projectPart->files, [&file] (const CppEditor::ProjectFile &pf) {
|
||||
&& Utils::anyOf(projectPart->files, [&file](const CppEditor::ProjectFile &pf) {
|
||||
return pf.path == file;
|
||||
})) {
|
||||
result.insert(projectPart->buildSystemTarget);
|
||||
|
@@ -86,8 +86,7 @@ ProjectTestSettingsWidget::ProjectTestSettingsWidget(ProjectExplorer::Project *p
|
||||
m_projectSettings->setRunAfterBuild(RunAfterBuildMode(index));
|
||||
});
|
||||
m_syncTimer.setSingleShot(true);
|
||||
connect(&m_syncTimer, &QTimer::timeout,
|
||||
[this]() {
|
||||
connect(&m_syncTimer, &QTimer::timeout, this, [this] {
|
||||
auto testTreeModel = TestTreeModel::instance();
|
||||
if (m_syncType & ITestBase::Framework)
|
||||
testTreeModel->synchronizeTestFrameworks();
|
||||
|
@@ -76,7 +76,7 @@ static bool qtTestLibDefined(const Utils::FilePath &fileName)
|
||||
const QList<CppEditor::ProjectPart::ConstPtr> parts =
|
||||
CppEditor::CppModelManager::instance()->projectPart(fileName);
|
||||
if (parts.size() > 0) {
|
||||
return Utils::anyOf(parts.at(0)->projectMacros, [] (const ProjectExplorer::Macro ¯o) {
|
||||
return Utils::anyOf(parts.at(0)->projectMacros, [](const ProjectExplorer::Macro ¯o) {
|
||||
return macro.key == "QT_TESTLIB_LIB";
|
||||
});
|
||||
}
|
||||
@@ -218,7 +218,7 @@ static bool containsFunction(const QMap<QString, QtTestCodeLocationAndType> &tes
|
||||
const QString &function)
|
||||
{
|
||||
const QString search = "::" + function;
|
||||
return Utils::anyOf(testFunctions.keys(), [&search] (const QString &key) {
|
||||
return Utils::anyOf(testFunctions.keys(), [&search](const QString &key) {
|
||||
return key.endsWith(search);
|
||||
});
|
||||
}
|
||||
|
@@ -83,10 +83,10 @@ static QString quickTestSrcDir(const CppEditor::CppModelManager *cppMM,
|
||||
const QList<CppEditor::ProjectPart::ConstPtr> parts = cppMM->projectPart(fileName);
|
||||
if (parts.size() > 0) {
|
||||
const ProjectExplorer::Macros ¯os = parts.at(0)->projectMacros;
|
||||
auto found = std::find_if(
|
||||
macros.cbegin(),
|
||||
macros.cend(),
|
||||
[] (const ProjectExplorer::Macro ¯o) { return macro.key == "QUICK_TEST_SOURCE_DIR"; });
|
||||
auto found = std::find_if(macros.cbegin(), macros.cend(),
|
||||
[](const ProjectExplorer::Macro ¯o) {
|
||||
return macro.key == "QUICK_TEST_SOURCE_DIR";
|
||||
});
|
||||
if (found != macros.cend()) {
|
||||
QByteArray result = found->value;
|
||||
if (result.startsWith('"'))
|
||||
@@ -96,7 +96,7 @@ static QString quickTestSrcDir(const CppEditor::CppModelManager *cppMM,
|
||||
return QLatin1String(result);
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
QString QuickTestParser::quickTestName(const CPlusPlus::Document::Ptr &doc) const
|
||||
@@ -326,7 +326,7 @@ QuickTestParser::QuickTestParser(ITestFramework *framework)
|
||||
: CppParser(framework)
|
||||
{
|
||||
connect(ProjectExplorer::SessionManager::instance(),
|
||||
&ProjectExplorer::SessionManager::startupProjectChanged, [this] {
|
||||
&ProjectExplorer::SessionManager::startupProjectChanged, this, [this] {
|
||||
const QStringList &dirs = m_directoryWatcher.directories();
|
||||
if (!dirs.isEmpty())
|
||||
m_directoryWatcher.removePaths(dirs);
|
||||
|
@@ -27,7 +27,7 @@ TestQmlVisitor::TestQmlVisitor(QmlJS::Document::Ptr doc, const QmlJS::Snapshot &
|
||||
static bool documentImportsQtTest(const QmlJS::Document *doc)
|
||||
{
|
||||
if (const QmlJS::Bind *bind = doc->bind()) {
|
||||
return Utils::anyOf(bind->imports(), [] (const QmlJS::ImportInfo &info) {
|
||||
return Utils::anyOf(bind->imports(), [](const QmlJS::ImportInfo &info) {
|
||||
return info.isValid() && info.name() == "QtTest";
|
||||
});
|
||||
}
|
||||
|
@@ -46,7 +46,7 @@ TestCodeParser::TestCodeParser()
|
||||
connect(&m_futureWatcher, &QFutureWatcher<TestParseResultPtr>::finished,
|
||||
this, &TestCodeParser::onFinished);
|
||||
connect(&m_futureWatcher, &QFutureWatcher<TestParseResultPtr>::resultReadyAt,
|
||||
this, [this] (int index) {
|
||||
this, [this](int index) {
|
||||
emit testParseResultReady(m_futureWatcher.resultAt(index));
|
||||
});
|
||||
connect(this, &TestCodeParser::parsingFinished, this, &TestCodeParser::releaseParserInternals);
|
||||
@@ -112,7 +112,7 @@ void TestCodeParser::emitUpdateTestTree(ITestParser *parser)
|
||||
|
||||
qCDebug(LOG) << "adding singleShot";
|
||||
m_singleShotScheduled = true;
|
||||
QTimer::singleShot(1000, this, [this]() { updateTestTree(m_updateParsers); });
|
||||
QTimer::singleShot(1000, this, [this] { updateTestTree(m_updateParsers); });
|
||||
}
|
||||
|
||||
void TestCodeParser::updateTestTree(const QSet<ITestParser *> &parsers)
|
||||
@@ -310,7 +310,7 @@ void TestCodeParser::scanForTests(const Utils::FilePaths &fileList,
|
||||
TestTreeModel::instance()->updateCheckStateCache();
|
||||
if (isFullParse) {
|
||||
// remove qml files as they will be found automatically by the referencing cpp file
|
||||
list = Utils::filtered(list, [] (const Utils::FilePath &fn) {
|
||||
list = Utils::filtered(list, [](const Utils::FilePath &fn) {
|
||||
return !fn.endsWith(".qml");
|
||||
});
|
||||
if (!parsers.isEmpty()) {
|
||||
|
@@ -84,8 +84,7 @@ TestNavigationWidget::TestNavigationWidget(QWidget *parent) :
|
||||
this, &TestNavigationWidget::onParsingFinished);
|
||||
connect(m_model->parser(), &TestCodeParser::parsingFailed,
|
||||
this, &TestNavigationWidget::onParsingFinished);
|
||||
connect(m_model, &TestTreeModel::updatedActiveFrameworks,
|
||||
this, [this] (int numberOfActive) {
|
||||
connect(m_model, &TestTreeModel::updatedActiveFrameworks, this, [this](int numberOfActive) {
|
||||
m_missingFrameworksWidget->setVisible(numberOfActive == 0);
|
||||
});
|
||||
ProjectExplorer::SessionManager *sm = ProjectExplorer::SessionManager::instance();
|
||||
@@ -122,14 +121,12 @@ void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||
if (item->canProvideTestConfiguration()) {
|
||||
runThisTest = new QAction(Tr::tr("Run This Test"), &menu);
|
||||
runThisTest->setEnabled(enabled);
|
||||
connect(runThisTest, &QAction::triggered,
|
||||
this, [this] () {
|
||||
connect(runThisTest, &QAction::triggered, this, [this] {
|
||||
onRunThisTestTriggered(TestRunMode::Run);
|
||||
});
|
||||
runWithoutDeploy = new QAction(Tr::tr("Run Without Deployment"), &menu);
|
||||
runWithoutDeploy->setEnabled(enabled);
|
||||
connect(runWithoutDeploy, &QAction::triggered,
|
||||
this, [this] () {
|
||||
connect(runWithoutDeploy, &QAction::triggered, this, [this] {
|
||||
onRunThisTestTriggered(TestRunMode::RunWithoutDeploy);
|
||||
});
|
||||
}
|
||||
@@ -139,14 +136,12 @@ void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||
if (ttitem && ttitem->canProvideDebugConfiguration()) {
|
||||
debugThisTest = new QAction(Tr::tr("Debug This Test"), &menu);
|
||||
debugThisTest->setEnabled(enabled);
|
||||
connect(debugThisTest, &QAction::triggered,
|
||||
this, [this] () {
|
||||
connect(debugThisTest, &QAction::triggered, this, [this] {
|
||||
onRunThisTestTriggered(TestRunMode::Debug);
|
||||
});
|
||||
debugWithoutDeploy = new QAction(Tr::tr("Debug Without Deployment"), &menu);
|
||||
debugWithoutDeploy->setEnabled(enabled);
|
||||
connect(debugWithoutDeploy, &QAction::triggered,
|
||||
this, [this] () {
|
||||
connect(debugWithoutDeploy, &QAction::triggered, this, [this] {
|
||||
onRunThisTestTriggered(TestRunMode::DebugWithoutDeploy);
|
||||
});
|
||||
}
|
||||
@@ -216,13 +211,13 @@ QList<QToolButton *> TestNavigationWidget::createToolButtons()
|
||||
collapse->setIcon(Utils::Icons::COLLAPSE_TOOLBAR.icon());
|
||||
collapse->setToolTip(Tr::tr("Collapse All"));
|
||||
|
||||
connect(expand, &QToolButton::clicked, m_view, [this]() {
|
||||
connect(expand, &QToolButton::clicked, m_view, [this] {
|
||||
m_view->blockSignals(true);
|
||||
m_view->expandAll();
|
||||
m_view->blockSignals(false);
|
||||
updateExpandedStateCache();
|
||||
});
|
||||
connect(collapse, &QToolButton::clicked, m_view, [this]() {
|
||||
connect(collapse, &QToolButton::clicked, m_view, [this] {
|
||||
m_view->blockSignals(true);
|
||||
m_view->collapseAll();
|
||||
m_view->blockSignals(false);
|
||||
|
@@ -135,10 +135,10 @@ TestResultsPane::TestResultsPane(QObject *parent) :
|
||||
trd, &TestResultDelegate::currentChanged);
|
||||
connect(m_treeView, &Utils::TreeView::customContextMenuRequested,
|
||||
this, &TestResultsPane::onCustomContextMenuRequested);
|
||||
connect(m_treeView, &ResultsTreeView::copyShortcutTriggered, [this] () {
|
||||
connect(m_treeView, &ResultsTreeView::copyShortcutTriggered, this, [this] {
|
||||
onCopyItemTriggered(getTestResult(m_treeView->currentIndex()));
|
||||
});
|
||||
connect(m_model, &TestResultModel::requestExpansion, [this] (const QModelIndex &idx) {
|
||||
connect(m_model, &TestResultModel::requestExpansion, this, [this](const QModelIndex &idx) {
|
||||
m_treeView->expand(m_filterModel->mapFromSource(idx));
|
||||
});
|
||||
connect(TestRunner::instance(), &TestRunner::testRunStarted,
|
||||
@@ -159,7 +159,7 @@ void TestResultsPane::createToolButtons()
|
||||
m_expandCollapse->setToolTip(Tr::tr("Expand All"));
|
||||
m_expandCollapse->setCheckable(true);
|
||||
m_expandCollapse->setChecked(false);
|
||||
connect(m_expandCollapse, &QToolButton::clicked, [this] (bool checked) {
|
||||
connect(m_expandCollapse, &QToolButton::clicked, this, [this](bool checked) {
|
||||
if (checked)
|
||||
m_treeView->expandAll();
|
||||
else
|
||||
@@ -505,10 +505,10 @@ void TestResultsPane::initializeFilterMenu()
|
||||
m_filterMenu->addSeparator();
|
||||
QAction *action = new QAction(Tr::tr("Check All Filters"), m_filterMenu);
|
||||
m_filterMenu->addAction(action);
|
||||
connect(action, &QAction::triggered, this, [this]() { TestResultsPane::checkAllFilter(true); });
|
||||
connect(action, &QAction::triggered, this, [this] { TestResultsPane::checkAllFilter(true); });
|
||||
action = new QAction(Tr::tr("Uncheck All Filters"), m_filterMenu);
|
||||
m_filterMenu->addAction(action);
|
||||
connect(action, &QAction::triggered, this, [this]() { TestResultsPane::checkAllFilter(false); });
|
||||
connect(action, &QAction::triggered, this, [this] { TestResultsPane::checkAllFilter(false); });
|
||||
}
|
||||
|
||||
void TestResultsPane::updateSummaryLabel()
|
||||
@@ -617,7 +617,7 @@ void TestResultsPane::onCustomContextMenuRequested(const QPoint &pos)
|
||||
QAction *action = new QAction(Tr::tr("Copy"), &menu);
|
||||
action->setShortcut(QKeySequence(QKeySequence::Copy));
|
||||
action->setEnabled(resultsAvailable && clicked);
|
||||
connect(action, &QAction::triggered, [this, clicked] () {
|
||||
connect(action, &QAction::triggered, this, [this, clicked] {
|
||||
onCopyItemTriggered(clicked);
|
||||
});
|
||||
menu.addAction(action);
|
||||
|
@@ -71,15 +71,14 @@ TestRunner::TestRunner()
|
||||
s_instance = this;
|
||||
|
||||
m_cancelTimer.setSingleShot(true);
|
||||
connect(&m_cancelTimer, &QTimer::timeout, this, [this]() { cancelCurrent(Timeout); });
|
||||
connect(&m_cancelTimer, &QTimer::timeout, this, [this] { cancelCurrent(Timeout); });
|
||||
connect(&m_futureWatcher, &QFutureWatcher<TestResultPtr>::resultReadyAt,
|
||||
this, [this](int index) { emit testResultReady(m_futureWatcher.resultAt(index)); });
|
||||
connect(&m_futureWatcher, &QFutureWatcher<TestResultPtr>::finished,
|
||||
this, &TestRunner::onFinished);
|
||||
connect(this, &TestRunner::requestStopTestRun,
|
||||
&m_futureWatcher, &QFutureWatcher<TestResultPtr>::cancel);
|
||||
connect(&m_futureWatcher, &QFutureWatcher<TestResultPtr>::canceled,
|
||||
this, [this]() {
|
||||
connect(&m_futureWatcher, &QFutureWatcher<TestResultPtr>::canceled, this, [this] {
|
||||
cancelCurrent(UserCanceled);
|
||||
reportResult(ResultType::MessageFatal, Tr::tr("Test run canceled by user."));
|
||||
});
|
||||
@@ -386,7 +385,7 @@ void TestRunner::prepareToRunTests(TestRunMode mode)
|
||||
}
|
||||
|
||||
m_targetConnect = connect(project, &Project::activeTargetChanged,
|
||||
[this]() { cancelCurrent(KitChanged); });
|
||||
this, [this] { cancelCurrent(KitChanged); });
|
||||
|
||||
if (projectExplorerSettings.buildBeforeDeploy == ProjectExplorer::Internal::BuildBeforeRunMode::Off
|
||||
|| mode == TestRunMode::DebugWithoutDeploy
|
||||
@@ -423,14 +422,14 @@ static RunConfiguration *getRunConfiguration(const QString &buildTargetKey)
|
||||
|
||||
RunConfiguration *runConfig = nullptr;
|
||||
const QList<RunConfiguration *> runConfigurations
|
||||
= Utils::filtered(target->runConfigurations(), [] (const RunConfiguration *rc) {
|
||||
= Utils::filtered(target->runConfigurations(), [](const RunConfiguration *rc) {
|
||||
return !rc->runnable().command.isEmpty();
|
||||
});
|
||||
|
||||
const ChoicePair oldChoice = AutotestPlugin::cachedChoiceFor(buildTargetKey);
|
||||
if (!oldChoice.executable.isEmpty()) {
|
||||
runConfig = Utils::findOrDefault(runConfigurations,
|
||||
[&oldChoice] (const RunConfiguration *rc) {
|
||||
[&oldChoice](const RunConfiguration *rc) {
|
||||
return oldChoice.matches(rc);
|
||||
});
|
||||
if (runConfig)
|
||||
@@ -447,7 +446,7 @@ static RunConfiguration *getRunConfiguration(const QString &buildTargetKey)
|
||||
return nullptr;
|
||||
// run configuration has been selected - fill config based on this one..
|
||||
const FilePath exe = FilePath::fromString(dialog.executable());
|
||||
runConfig = Utils::findOr(runConfigurations, nullptr, [&dName, &exe] (const RunConfiguration *rc) {
|
||||
runConfig = Utils::findOr(runConfigurations, nullptr, [&dName, &exe](const RunConfiguration *rc) {
|
||||
if (rc->displayName() != dName)
|
||||
return false;
|
||||
return rc->runnable().command.executable() == exe;
|
||||
@@ -701,7 +700,7 @@ void TestRunner::runOrDebugTests()
|
||||
if (executablesEmpty()) {
|
||||
m_skipTargetsCheck = true;
|
||||
Target * target = SessionManager::startupTarget();
|
||||
QTimer::singleShot(5000, this, [this, target = QPointer<Target>(target)]() {
|
||||
QTimer::singleShot(5000, this, [this, target = QPointer<Target>(target)] {
|
||||
if (target) {
|
||||
disconnect(target, &Target::buildSystemUpdated,
|
||||
this, &TestRunner::onBuildSystemUpdated);
|
||||
|
@@ -366,7 +366,7 @@ void TestSettingsPage::apply()
|
||||
return;
|
||||
const TestSettings newSettings = m_widget->settings();
|
||||
const QList<Utils::Id> changedIds = Utils::filtered(newSettings.frameworksGrouping.keys(),
|
||||
[newSettings, this] (const Utils::Id &id) {
|
||||
[newSettings, this](const Utils::Id &id) {
|
||||
return newSettings.frameworksGrouping[id] != m_settings->frameworksGrouping[id];
|
||||
});
|
||||
*m_settings = newSettings;
|
||||
|
@@ -70,7 +70,7 @@ void TestTreeModel::setupParsingConnections()
|
||||
m_parser->setState(TestCodeParser::Idle);
|
||||
|
||||
SessionManager *sm = SessionManager::instance();
|
||||
connect(sm, &SessionManager::startupProjectChanged, [this, sm](Project *project) {
|
||||
connect(sm, &SessionManager::startupProjectChanged, this, [this, sm](Project *project) {
|
||||
synchronizeTestFrameworks(); // we might have project settings
|
||||
m_parser->onStartupProjectChanged(project);
|
||||
removeAllTestToolItems();
|
||||
@@ -568,7 +568,7 @@ void TestTreeModel::insertItemInParent(TestTreeItem *item, TestTreeItem *root, b
|
||||
{
|
||||
TestTreeItem *parentNode = root;
|
||||
if (groupingEnabled && item->isGroupable()) {
|
||||
parentNode = root->findFirstLevelChildItem([item] (const TestTreeItem *it) {
|
||||
parentNode = root->findFirstLevelChildItem([item](const TestTreeItem *it) {
|
||||
return it->isGroupNodeFor(item);
|
||||
});
|
||||
if (!parentNode) {
|
||||
|
Reference in New Issue
Block a user