Dissolve RunControl::setRunnable

Change-Id: I52aea3bea0c4ea90a448f5a77bfa01414bc56702
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2022-05-25 16:26:10 +02:00
parent 3ad82a66f9
commit bc3c4d7453
7 changed files with 66 additions and 40 deletions

View File

@@ -36,6 +36,9 @@
#include <QtTest>
#include <QTcpServer>
using namespace ProjectExplorer;
using namespace Utils;
namespace QmlProfiler {
namespace Internal {
@@ -45,9 +48,8 @@ LocalQmlProfilerRunnerTest::LocalQmlProfilerRunnerTest(QObject *parent) : QObjec
void LocalQmlProfilerRunnerTest::testRunner()
{
QPointer<ProjectExplorer::RunControl> runControl;
QPointer<RunControl> runControl;
QPointer<LocalQmlProfilerSupport> profiler;
ProjectExplorer::Runnable debuggee;
QUrl serverUrl;
bool running = false;
@@ -56,37 +58,35 @@ void LocalQmlProfilerRunnerTest::testRunner()
int runCount = 0;
int stopCount = 0;
debuggee.command.setExecutable("\\-/|\\-/");
debuggee.environment = Utils::Environment::systemEnvironment();
// should not be used anywhere but cannot be empty
serverUrl.setScheme(Utils::urlSocketScheme());
serverUrl.setPath("invalid");
runControl = new ProjectExplorer::RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
runControl->setRunnable(debuggee);
runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
runControl->setCommandLine({"\\-/|\\-/", {}});
profiler = new LocalQmlProfilerSupport(runControl, serverUrl);
auto connectRunner = [&]() {
connect(runControl, &ProjectExplorer::RunControl::aboutToStart, this, [&]() {
connect(runControl, &RunControl::aboutToStart, this, [&] {
QVERIFY(!started);
QVERIFY(!running);
++startCount;
started = true;
});
connect(runControl, &ProjectExplorer::RunControl::started, this, [&]() {
connect(runControl, &RunControl::started, this, [&] {
QVERIFY(started);
QVERIFY(!running);
++runCount;
running = true;
});
connect(runControl, &ProjectExplorer::RunControl::stopped, this, [&]() {
connect(runControl, &RunControl::stopped, this, [&] {
QVERIFY(started);
++stopCount;
running = false;
started = false;
});
connect(runControl, &ProjectExplorer::RunControl::finished, this, [&]() {
connect(runControl, &RunControl::finished, this, [&]{
running = false;
started = false;
});
@@ -110,10 +110,10 @@ void LocalQmlProfilerRunnerTest::testRunner()
serverUrl = Utils::urlFromLocalSocket();
// comma is used to specify a test function. In this case, an invalid one.
debuggee.command = Utils::CommandLine(Utils::FilePath::fromString(QCoreApplication::applicationFilePath()),
{"-test", "QmlProfiler,"});
runControl = new ProjectExplorer::RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
runControl->setRunnable(debuggee);
runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
const FilePath app = FilePath::fromString(QCoreApplication::applicationFilePath());
runControl->setCommandLine({app, {"-test", "QmlProfiler,"}});
profiler = new LocalQmlProfilerSupport(runControl, serverUrl);
connectRunner();
runControl->initiateStart();
@@ -128,11 +128,10 @@ void LocalQmlProfilerRunnerTest::testRunner()
QTRY_VERIFY(runControl.isNull());
QVERIFY(profiler.isNull());
debuggee.command.setArguments({});
serverUrl.clear();
serverUrl = Utils::urlFromLocalHostAndFreePort();
runControl = new ProjectExplorer::RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
runControl->setRunnable(debuggee);
runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
runControl->setCommandLine({app, {}});
profiler = new LocalQmlProfilerSupport(runControl, serverUrl);
connectRunner();
runControl->initiateStart();
@@ -148,7 +147,6 @@ void LocalQmlProfilerRunnerTest::testRunner()
QTRY_VERIFY(runControl.isNull());
QVERIFY(profiler.isNull());
debuggee.command.setArguments("-test QmlProfiler,");
serverUrl.setScheme(Utils::urlSocketScheme());
{
Utils::TemporaryFile file("file with spaces");
@@ -156,8 +154,8 @@ void LocalQmlProfilerRunnerTest::testRunner()
serverUrl.setPath(file.fileName());
}
runControl = new ProjectExplorer::RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
runControl->setRunnable(debuggee);
runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
runControl->setCommandLine({app, {"-test", "QmlProfiler,"}});
profiler = new LocalQmlProfilerSupport(runControl, serverUrl);
connectRunner();
runControl->initiateStart();