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:
Jarek Kobus
2022-12-07 14:45:43 +01:00
parent f6913ce791
commit 9e571931d0
13 changed files with 48 additions and 55 deletions

View File

@@ -86,8 +86,7 @@ ProjectTestSettingsWidget::ProjectTestSettingsWidget(ProjectExplorer::Project *p
m_projectSettings->setRunAfterBuild(RunAfterBuildMode(index)); m_projectSettings->setRunAfterBuild(RunAfterBuildMode(index));
}); });
m_syncTimer.setSingleShot(true); m_syncTimer.setSingleShot(true);
connect(&m_syncTimer, &QTimer::timeout, connect(&m_syncTimer, &QTimer::timeout, this, [this] {
[this]() {
auto testTreeModel = TestTreeModel::instance(); auto testTreeModel = TestTreeModel::instance();
if (m_syncType & ITestBase::Framework) if (m_syncType & ITestBase::Framework)
testTreeModel->synchronizeTestFrameworks(); testTreeModel->synchronizeTestFrameworks();

View File

@@ -83,10 +83,10 @@ static QString quickTestSrcDir(const CppEditor::CppModelManager *cppMM,
const QList<CppEditor::ProjectPart::ConstPtr> parts = cppMM->projectPart(fileName); const QList<CppEditor::ProjectPart::ConstPtr> parts = cppMM->projectPart(fileName);
if (parts.size() > 0) { if (parts.size() > 0) {
const ProjectExplorer::Macros &macros = parts.at(0)->projectMacros; const ProjectExplorer::Macros &macros = parts.at(0)->projectMacros;
auto found = std::find_if( auto found = std::find_if(macros.cbegin(), macros.cend(),
macros.cbegin(), [](const ProjectExplorer::Macro &macro) {
macros.cend(), return macro.key == "QUICK_TEST_SOURCE_DIR";
[] (const ProjectExplorer::Macro &macro) { return macro.key == "QUICK_TEST_SOURCE_DIR"; }); });
if (found != macros.cend()) { if (found != macros.cend()) {
QByteArray result = found->value; QByteArray result = found->value;
if (result.startsWith('"')) if (result.startsWith('"'))
@@ -96,7 +96,7 @@ static QString quickTestSrcDir(const CppEditor::CppModelManager *cppMM,
return QLatin1String(result); return QLatin1String(result);
} }
} }
return QString(); return {};
} }
QString QuickTestParser::quickTestName(const CPlusPlus::Document::Ptr &doc) const QString QuickTestParser::quickTestName(const CPlusPlus::Document::Ptr &doc) const
@@ -326,7 +326,7 @@ QuickTestParser::QuickTestParser(ITestFramework *framework)
: CppParser(framework) : CppParser(framework)
{ {
connect(ProjectExplorer::SessionManager::instance(), connect(ProjectExplorer::SessionManager::instance(),
&ProjectExplorer::SessionManager::startupProjectChanged, [this] { &ProjectExplorer::SessionManager::startupProjectChanged, this, [this] {
const QStringList &dirs = m_directoryWatcher.directories(); const QStringList &dirs = m_directoryWatcher.directories();
if (!dirs.isEmpty()) if (!dirs.isEmpty())
m_directoryWatcher.removePaths(dirs); m_directoryWatcher.removePaths(dirs);

View File

@@ -112,7 +112,7 @@ void TestCodeParser::emitUpdateTestTree(ITestParser *parser)
qCDebug(LOG) << "adding singleShot"; qCDebug(LOG) << "adding singleShot";
m_singleShotScheduled = true; 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) void TestCodeParser::updateTestTree(const QSet<ITestParser *> &parsers)

View File

@@ -84,8 +84,7 @@ TestNavigationWidget::TestNavigationWidget(QWidget *parent) :
this, &TestNavigationWidget::onParsingFinished); this, &TestNavigationWidget::onParsingFinished);
connect(m_model->parser(), &TestCodeParser::parsingFailed, connect(m_model->parser(), &TestCodeParser::parsingFailed,
this, &TestNavigationWidget::onParsingFinished); this, &TestNavigationWidget::onParsingFinished);
connect(m_model, &TestTreeModel::updatedActiveFrameworks, connect(m_model, &TestTreeModel::updatedActiveFrameworks, this, [this](int numberOfActive) {
this, [this] (int numberOfActive) {
m_missingFrameworksWidget->setVisible(numberOfActive == 0); m_missingFrameworksWidget->setVisible(numberOfActive == 0);
}); });
ProjectExplorer::SessionManager *sm = ProjectExplorer::SessionManager::instance(); ProjectExplorer::SessionManager *sm = ProjectExplorer::SessionManager::instance();
@@ -122,14 +121,12 @@ void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
if (item->canProvideTestConfiguration()) { if (item->canProvideTestConfiguration()) {
runThisTest = new QAction(Tr::tr("Run This Test"), &menu); runThisTest = new QAction(Tr::tr("Run This Test"), &menu);
runThisTest->setEnabled(enabled); runThisTest->setEnabled(enabled);
connect(runThisTest, &QAction::triggered, connect(runThisTest, &QAction::triggered, this, [this] {
this, [this] () {
onRunThisTestTriggered(TestRunMode::Run); onRunThisTestTriggered(TestRunMode::Run);
}); });
runWithoutDeploy = new QAction(Tr::tr("Run Without Deployment"), &menu); runWithoutDeploy = new QAction(Tr::tr("Run Without Deployment"), &menu);
runWithoutDeploy->setEnabled(enabled); runWithoutDeploy->setEnabled(enabled);
connect(runWithoutDeploy, &QAction::triggered, connect(runWithoutDeploy, &QAction::triggered, this, [this] {
this, [this] () {
onRunThisTestTriggered(TestRunMode::RunWithoutDeploy); onRunThisTestTriggered(TestRunMode::RunWithoutDeploy);
}); });
} }
@@ -139,14 +136,12 @@ void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
if (ttitem && ttitem->canProvideDebugConfiguration()) { if (ttitem && ttitem->canProvideDebugConfiguration()) {
debugThisTest = new QAction(Tr::tr("Debug This Test"), &menu); debugThisTest = new QAction(Tr::tr("Debug This Test"), &menu);
debugThisTest->setEnabled(enabled); debugThisTest->setEnabled(enabled);
connect(debugThisTest, &QAction::triggered, connect(debugThisTest, &QAction::triggered, this, [this] {
this, [this] () {
onRunThisTestTriggered(TestRunMode::Debug); onRunThisTestTriggered(TestRunMode::Debug);
}); });
debugWithoutDeploy = new QAction(Tr::tr("Debug Without Deployment"), &menu); debugWithoutDeploy = new QAction(Tr::tr("Debug Without Deployment"), &menu);
debugWithoutDeploy->setEnabled(enabled); debugWithoutDeploy->setEnabled(enabled);
connect(debugWithoutDeploy, &QAction::triggered, connect(debugWithoutDeploy, &QAction::triggered, this, [this] {
this, [this] () {
onRunThisTestTriggered(TestRunMode::DebugWithoutDeploy); onRunThisTestTriggered(TestRunMode::DebugWithoutDeploy);
}); });
} }
@@ -216,13 +211,13 @@ QList<QToolButton *> TestNavigationWidget::createToolButtons()
collapse->setIcon(Utils::Icons::COLLAPSE_TOOLBAR.icon()); collapse->setIcon(Utils::Icons::COLLAPSE_TOOLBAR.icon());
collapse->setToolTip(Tr::tr("Collapse All")); 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->blockSignals(true);
m_view->expandAll(); m_view->expandAll();
m_view->blockSignals(false); m_view->blockSignals(false);
updateExpandedStateCache(); updateExpandedStateCache();
}); });
connect(collapse, &QToolButton::clicked, m_view, [this]() { connect(collapse, &QToolButton::clicked, m_view, [this] {
m_view->blockSignals(true); m_view->blockSignals(true);
m_view->collapseAll(); m_view->collapseAll();
m_view->blockSignals(false); m_view->blockSignals(false);

View File

@@ -135,10 +135,10 @@ TestResultsPane::TestResultsPane(QObject *parent) :
trd, &TestResultDelegate::currentChanged); trd, &TestResultDelegate::currentChanged);
connect(m_treeView, &Utils::TreeView::customContextMenuRequested, connect(m_treeView, &Utils::TreeView::customContextMenuRequested,
this, &TestResultsPane::onCustomContextMenuRequested); this, &TestResultsPane::onCustomContextMenuRequested);
connect(m_treeView, &ResultsTreeView::copyShortcutTriggered, [this] () { connect(m_treeView, &ResultsTreeView::copyShortcutTriggered, this, [this] {
onCopyItemTriggered(getTestResult(m_treeView->currentIndex())); 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)); m_treeView->expand(m_filterModel->mapFromSource(idx));
}); });
connect(TestRunner::instance(), &TestRunner::testRunStarted, connect(TestRunner::instance(), &TestRunner::testRunStarted,
@@ -159,7 +159,7 @@ void TestResultsPane::createToolButtons()
m_expandCollapse->setToolTip(Tr::tr("Expand All")); m_expandCollapse->setToolTip(Tr::tr("Expand All"));
m_expandCollapse->setCheckable(true); m_expandCollapse->setCheckable(true);
m_expandCollapse->setChecked(false); m_expandCollapse->setChecked(false);
connect(m_expandCollapse, &QToolButton::clicked, [this] (bool checked) { connect(m_expandCollapse, &QToolButton::clicked, this, [this](bool checked) {
if (checked) if (checked)
m_treeView->expandAll(); m_treeView->expandAll();
else else
@@ -505,10 +505,10 @@ void TestResultsPane::initializeFilterMenu()
m_filterMenu->addSeparator(); m_filterMenu->addSeparator();
QAction *action = new QAction(Tr::tr("Check All Filters"), m_filterMenu); QAction *action = new QAction(Tr::tr("Check All Filters"), m_filterMenu);
m_filterMenu->addAction(action); 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); action = new QAction(Tr::tr("Uncheck All Filters"), m_filterMenu);
m_filterMenu->addAction(action); 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() void TestResultsPane::updateSummaryLabel()
@@ -617,7 +617,7 @@ void TestResultsPane::onCustomContextMenuRequested(const QPoint &pos)
QAction *action = new QAction(Tr::tr("Copy"), &menu); QAction *action = new QAction(Tr::tr("Copy"), &menu);
action->setShortcut(QKeySequence(QKeySequence::Copy)); action->setShortcut(QKeySequence(QKeySequence::Copy));
action->setEnabled(resultsAvailable && clicked); action->setEnabled(resultsAvailable && clicked);
connect(action, &QAction::triggered, [this, clicked] () { connect(action, &QAction::triggered, this, [this, clicked] {
onCopyItemTriggered(clicked); onCopyItemTriggered(clicked);
}); });
menu.addAction(action); menu.addAction(action);

View File

@@ -71,15 +71,14 @@ TestRunner::TestRunner()
s_instance = this; s_instance = this;
m_cancelTimer.setSingleShot(true); 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, connect(&m_futureWatcher, &QFutureWatcher<TestResultPtr>::resultReadyAt,
this, [this](int index) { emit testResultReady(m_futureWatcher.resultAt(index)); }); this, [this](int index) { emit testResultReady(m_futureWatcher.resultAt(index)); });
connect(&m_futureWatcher, &QFutureWatcher<TestResultPtr>::finished, connect(&m_futureWatcher, &QFutureWatcher<TestResultPtr>::finished,
this, &TestRunner::onFinished); this, &TestRunner::onFinished);
connect(this, &TestRunner::requestStopTestRun, connect(this, &TestRunner::requestStopTestRun,
&m_futureWatcher, &QFutureWatcher<TestResultPtr>::cancel); &m_futureWatcher, &QFutureWatcher<TestResultPtr>::cancel);
connect(&m_futureWatcher, &QFutureWatcher<TestResultPtr>::canceled, connect(&m_futureWatcher, &QFutureWatcher<TestResultPtr>::canceled, this, [this] {
this, [this]() {
cancelCurrent(UserCanceled); cancelCurrent(UserCanceled);
reportResult(ResultType::MessageFatal, Tr::tr("Test run canceled by user.")); 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, m_targetConnect = connect(project, &Project::activeTargetChanged,
[this]() { cancelCurrent(KitChanged); }); this, [this] { cancelCurrent(KitChanged); });
if (projectExplorerSettings.buildBeforeDeploy == ProjectExplorer::Internal::BuildBeforeRunMode::Off if (projectExplorerSettings.buildBeforeDeploy == ProjectExplorer::Internal::BuildBeforeRunMode::Off
|| mode == TestRunMode::DebugWithoutDeploy || mode == TestRunMode::DebugWithoutDeploy
@@ -701,7 +700,7 @@ void TestRunner::runOrDebugTests()
if (executablesEmpty()) { if (executablesEmpty()) {
m_skipTargetsCheck = true; m_skipTargetsCheck = true;
Target * target = SessionManager::startupTarget(); Target * target = SessionManager::startupTarget();
QTimer::singleShot(5000, this, [this, target = QPointer<Target>(target)]() { QTimer::singleShot(5000, this, [this, target = QPointer<Target>(target)] {
if (target) { if (target) {
disconnect(target, &Target::buildSystemUpdated, disconnect(target, &Target::buildSystemUpdated,
this, &TestRunner::onBuildSystemUpdated); this, &TestRunner::onBuildSystemUpdated);

View File

@@ -70,7 +70,7 @@ void TestTreeModel::setupParsingConnections()
m_parser->setState(TestCodeParser::Idle); m_parser->setState(TestCodeParser::Idle);
SessionManager *sm = SessionManager::instance(); 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 synchronizeTestFrameworks(); // we might have project settings
m_parser->onStartupProjectChanged(project); m_parser->onStartupProjectChanged(project);
removeAllTestToolItems(); removeAllTestToolItems();