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_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();

View File

@@ -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 &macros = parts.at(0)->projectMacros;
auto found = std::find_if(
macros.cbegin(),
macros.cend(),
[] (const ProjectExplorer::Macro &macro) { return macro.key == "QUICK_TEST_SOURCE_DIR"; });
auto found = std::find_if(macros.cbegin(), macros.cend(),
[](const ProjectExplorer::Macro &macro) {
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);

View File

@@ -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)

View File

@@ -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);

View File

@@ -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);

View File

@@ -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
@@ -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);

View File

@@ -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();