From 4e88a8a6f7021f93feac8486f3fa2976b9d13a1b Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Fri, 2 Sep 2022 14:57:14 +0200 Subject: [PATCH] Squish: Redo state handling Separate states and modes according to their use. Remove state handling from perspective, let tools switch the perspective mode, and reflect perspective mode immediately on the perspective. Change-Id: Ibb0338974b90fcc099517c13d685f800d9774a7d Reviewed-by: David Schulz --- src/plugins/squish/squishperspective.cpp | 170 ++++++----------------- src/plugins/squish/squishperspective.h | 29 ++-- src/plugins/squish/squishtools.cpp | 166 ++++++++++++---------- src/plugins/squish/squishtools.h | 18 ++- 4 files changed, 159 insertions(+), 224 deletions(-) diff --git a/src/plugins/squish/squishperspective.cpp b/src/plugins/squish/squishperspective.cpp index c8a4338cc18..a4e80aa280e 100644 --- a/src/plugins/squish/squishperspective.cpp +++ b/src/plugins/squish/squishperspective.cpp @@ -26,45 +26,24 @@ namespace Squish { namespace Internal { -static QString stateName(SquishPerspective::State state) -{ - switch (state) { - case SquishPerspective::State::None: return "None"; - case SquishPerspective::State::Starting: return "Starting"; - case SquishPerspective::State::Running: return "Running"; - case SquishPerspective::State::RunRequested: return "RunRequested"; - case SquishPerspective::State::StepInRequested: return "StepInRequested"; - case SquishPerspective::State::StepOverRequested: return "StepOverRequested"; - case SquishPerspective::State::StepReturnRequested: return "StepReturnRequested"; - case SquishPerspective::State::Interrupted: return "Interrupted"; - case SquishPerspective::State::InterruptRequested: return "InterruptedRequested"; - case SquishPerspective::State::Canceling: return "Canceling"; - case SquishPerspective::State::Canceled: return "Canceled"; - case SquishPerspective::State::CancelRequested: return "CancelRequested"; - case SquishPerspective::State::CancelRequestedWhileInterrupted: return "CancelRequestedWhileInterrupted"; - case SquishPerspective::State::Finished: return "Finished"; - } - return "ThouShallNotBeHere"; -} - -enum IconType { StopRecord, Play, Pause, StepIn, StepOver, StepReturn, Stop }; +enum class IconType { StopRecord, Play, Pause, StepIn, StepOver, StepReturn, Stop }; static QIcon iconForType(IconType type) { switch (type) { - case StopRecord: + case IconType::StopRecord: return QIcon(); - case Play: + case IconType::Play: return Debugger::Icons::DEBUG_CONTINUE_SMALL_TOOLBAR.icon(); - case Pause: + case IconType::Pause: return Utils::Icons::INTERRUPT_SMALL.icon(); - case StepIn: + case IconType::StepIn: return Debugger::Icons::STEP_INTO_TOOLBAR.icon(); - case StepOver: + case IconType::StepOver: return Debugger::Icons::STEP_OVER_TOOLBAR.icon(); - case StepReturn: + case IconType::StepReturn: return Debugger::Icons::STEP_OUT_TOOLBAR.icon(); - case Stop: + case IconType::Stop: return Utils::Icons::STOP_SMALL.icon(); } return QIcon(); @@ -202,19 +181,19 @@ SquishPerspective::SquishPerspective() void SquishPerspective::initPerspective() { m_pausePlayAction = new QAction(this); - m_pausePlayAction->setIcon(iconForType(Pause)); + m_pausePlayAction->setIcon(iconForType(IconType::Pause)); m_pausePlayAction->setToolTip(Tr::tr("Interrupt")); m_pausePlayAction->setEnabled(false); m_stepInAction = new QAction(this); - m_stepInAction->setIcon(iconForType(StepIn)); + m_stepInAction->setIcon(iconForType(IconType::StepIn)); m_stepInAction->setToolTip(Tr::tr("Step Into")); m_stepInAction->setEnabled(false); m_stepOverAction = new QAction(this); - m_stepOverAction->setIcon(iconForType(StepOver)); + m_stepOverAction->setIcon(iconForType(IconType::StepOver)); m_stepOverAction->setToolTip(Tr::tr("Step Over")); m_stepOverAction->setEnabled(false); m_stepOutAction = new QAction(this); - m_stepOutAction->setIcon(iconForType(StepReturn)); + m_stepOutAction->setIcon(iconForType(IconType::StepReturn)); m_stepOutAction->setToolTip(Tr::tr("Step Out")); m_stepOutAction->setEnabled(false); m_stopAction = Debugger::createStopAction(); @@ -248,15 +227,9 @@ void SquishPerspective::initPerspective() addWindow(mainWidget, Perspective::AddToTab, nullptr, true, Qt::RightDockWidgetArea); connect(m_pausePlayAction, &QAction::triggered, this, &SquishPerspective::onPausePlayTriggered); - connect(m_stepInAction, &QAction::triggered, this, [this] { - setState(State::StepInRequested); - }); - connect(m_stepOverAction, &QAction::triggered, this, [this] { - setState(State::StepOverRequested); - }); - connect(m_stepOutAction, &QAction::triggered, this, [this] { - setState(State::StepReturnRequested); - }); + connect(m_stepInAction, &QAction::triggered, this, [this] { emit runRequested(StepIn); }); + connect(m_stepOverAction, &QAction::triggered, this, [this] { emit runRequested(StepOver); }); + connect(m_stepOutAction, &QAction::triggered, this, [this] { emit runRequested(StepOut); }); connect(m_stopAction, &QAction::triggered, this, &SquishPerspective::onStopTriggered); connect(SquishTools::instance(), &SquishTools::localsUpdated, @@ -278,18 +251,17 @@ void SquishPerspective::onStopTriggered() { m_pausePlayAction->setEnabled(false); m_stopAction->setEnabled(false); - setState(m_state == State::Interrupted ? State::CancelRequestedWhileInterrupted - : State::CancelRequested); + emit stopRequested(); } void SquishPerspective::onPausePlayTriggered() { - if (m_state == State::Interrupted) - setState(State::RunRequested); - else if (m_state == State::Running) - setState(State::InterruptRequested); + if (m_mode == Interrupted) + emit runRequested(Continue); + else if (m_mode == Running) + emit interruptRequested(); else - qDebug() << "###state: " << stateName(m_state); + qDebug() << "###state: " << m_mode; } void SquishPerspective::onLocalsUpdated(const QString &output) @@ -358,100 +330,46 @@ void SquishPerspective::destroyControlBar() m_controlBar = nullptr; } -void SquishPerspective::setState(State state) +void SquishPerspective::setPerspectiveMode(PerspectiveMode mode) { - if (m_state == state) // ignore triggering the state again + if (m_mode == mode) // ignore return; - if (!isStateTransitionValid(state)) { - qDebug() << "Illegal state transition" << stateName(m_state) << "->" << stateName(state); - return; - } - - m_state = state; - m_localsModel.clear(); - emit stateChanged(state); - - switch (m_state) { - case State::Running: - case State::Interrupted: + m_mode = mode; + switch (m_mode) { + case Running: m_pausePlayAction->setEnabled(true); - if (m_state == State::Interrupted) { - m_pausePlayAction->setIcon(iconForType(Play)); - m_pausePlayAction->setToolTip(Tr::tr("Continue")); - m_stepInAction->setEnabled(true); - m_stepOverAction->setEnabled(true); - m_stepOutAction->setEnabled(true); - } else { - m_pausePlayAction->setIcon(iconForType(Pause)); - m_pausePlayAction->setToolTip(Tr::tr("Interrupt")); - m_stepInAction->setEnabled(false); - m_stepOverAction->setEnabled(false); - m_stepOutAction->setEnabled(false); - } + m_pausePlayAction->setIcon(iconForType(IconType::Pause)); + m_pausePlayAction->setToolTip(Tr::tr("Interrupt")); + m_stepInAction->setEnabled(false); + m_stepOverAction->setEnabled(false); + m_stepOutAction->setEnabled(false); m_stopAction->setEnabled(true); break; - case State::RunRequested: - case State::Starting: - case State::StepInRequested: - case State::StepOverRequested: - case State::StepReturnRequested: - case State::InterruptRequested: - case State::CancelRequested: - case State::CancelRequestedWhileInterrupted: - case State::Canceled: - case State::Finished: - m_pausePlayAction->setIcon(iconForType(Pause)); + case Interrupted: + m_pausePlayAction->setEnabled(true); + m_pausePlayAction->setIcon(iconForType(IconType::Play)); + m_pausePlayAction->setToolTip(Tr::tr("Continue")); + m_stepInAction->setEnabled(true); + m_stepOverAction->setEnabled(true); + m_stepOutAction->setEnabled(true); + m_stopAction->setEnabled(true); + break; + case Querying: + case NoMode: + m_pausePlayAction->setIcon(iconForType(IconType::Pause)); m_pausePlayAction->setToolTip(Tr::tr("Interrupt")); m_pausePlayAction->setEnabled(false); m_stepInAction->setEnabled(false); m_stepOverAction->setEnabled(false); m_stepOutAction->setEnabled(false); m_stopAction->setEnabled(false); + m_localsModel.clear(); break; default: break; } } -bool SquishPerspective::isStateTransitionValid(State newState) const -{ - if (newState == State::Finished || newState == State::CancelRequested) - return true; - - switch (m_state) { - case State::None: - return newState == State::Starting; - case State::Starting: - return newState == State::RunRequested; - case State::Running: - return newState == State::Interrupted - || newState == State::InterruptRequested; - case State::RunRequested: - case State::StepInRequested: - case State::StepOverRequested: - case State::StepReturnRequested: - return newState == State::Running; - case State::Interrupted: - return newState == State::RunRequested - || newState == State::StepInRequested - || newState == State::StepOverRequested - || newState == State::StepReturnRequested - || newState == State::CancelRequestedWhileInterrupted; - case State::InterruptRequested: - return newState == State::Interrupted; - case State::Canceling: - return newState == State::Canceled; - case State::Canceled: - return newState == State::None; - case State::CancelRequested: - case State::CancelRequestedWhileInterrupted: - return newState == State::Canceling; - case State::Finished: - return newState == State::Starting; - } - return false; -} - } // namespace Internal } // namespace Squish diff --git a/src/plugins/squish/squishperspective.h b/src/plugins/squish/squishperspective.h index e432413fe0f..8cc4569360c 100644 --- a/src/plugins/squish/squishperspective.h +++ b/src/plugins/squish/squishperspective.h @@ -28,41 +28,28 @@ class SquishPerspective : public Utils::Perspective { Q_OBJECT public: - enum class State { - None, - Starting, - Running, - RunRequested, - StepInRequested, - StepOverRequested, - StepReturnRequested, - Interrupted, - InterruptRequested, - Canceling, - Canceled, - CancelRequested, - CancelRequestedWhileInterrupted, - Finished - }; + enum PerspectiveMode { NoMode, Interrupted, Running, Querying }; + enum StepMode { Continue, StepIn, StepOver, StepOut }; SquishPerspective(); void initPerspective(); + void setPerspectiveMode(PerspectiveMode mode); + PerspectiveMode perspectiveMode() const { return m_mode; } - State state() const { return m_state; } - void setState(State state); void updateStatus(const QString &status); void showControlBar(SquishXmlOutputHandler *xmlOutputHandler); void destroyControlBar(); signals: - void stateChanged(State state); + void stopRequested(); + void interruptRequested(); + void runRequested(SquishPerspective::StepMode mode); private: void onStopTriggered(); void onPausePlayTriggered(); void onLocalsUpdated(const QString &output); - bool isStateTransitionValid(State newState) const; QAction *m_pausePlayAction = nullptr; QAction *m_stepInAction = nullptr; @@ -72,7 +59,7 @@ private: QLabel *m_status = nullptr; class SquishControlBar *m_controlBar = nullptr; Utils::TreeModel m_localsModel; - State m_state = State::None; + PerspectiveMode m_mode = NoMode; friend class SquishControlBar; }; diff --git a/src/plugins/squish/squishtools.cpp b/src/plugins/squish/squishtools.cpp index 62fcc227d02..0f299595da0 100644 --- a/src/plugins/squish/squishtools.cpp +++ b/src/plugins/squish/squishtools.cpp @@ -36,6 +36,25 @@ using namespace Utils; namespace Squish { namespace Internal { + +static QString runnerStateName(SquishTools::RunnerState state) +{ + switch (state) { + case SquishTools::RunnerState::None: return "None"; + case SquishTools::RunnerState::Starting: return "Starting"; + case SquishTools::RunnerState::Running: return "Running"; + case SquishTools::RunnerState::RunRequested: return "RunRequested"; + case SquishTools::RunnerState::Interrupted: return "Interrupted"; + case SquishTools::RunnerState::InterruptRequested: return "InterruptedRequested"; + case SquishTools::RunnerState::Canceling: return "Canceling"; + case SquishTools::RunnerState::Canceled: return "Canceled"; + case SquishTools::RunnerState::CancelRequested: return "CancelRequested"; + case SquishTools::RunnerState::CancelRequestedWhileInterrupted: return "CancelRequestedWhileInterrupted"; + case SquishTools::RunnerState::Finished: return "Finished"; + } + return "ThouShallNotBeHere"; +} + class SquishLocationMark : public TextEditor::TextMark { public: @@ -50,7 +69,6 @@ public: // make this configurable? static const QString resultsDirectory = QFileInfo(QDir::home(), ".squishQC/Test Results") .absoluteFilePath(); - static SquishTools *s_instance = nullptr; SquishTools::SquishTools(QObject *parent) @@ -82,8 +100,24 @@ SquishTools::SquishTools(QObject *parent) this, &SquishTools::onServerFinished); s_instance = this; m_perspective.initPerspective(); - connect(&m_perspective, &SquishPerspective::stateChanged, - this, &SquishTools::onPerspectiveStateChanged); + connect(&m_perspective, &SquishPerspective::interruptRequested, + this, [this] { + m_squishRunnerState = RunnerState::InterruptRequested; + if (m_runnerProcess.processId() != -1) + interruptRunner(); + }); + connect(&m_perspective, &SquishPerspective::stopRequested, + this, [this] () { + bool interrupted = m_squishRunnerState == RunnerState::Interrupted; + m_squishRunnerState = interrupted ? RunnerState::CancelRequestedWhileInterrupted + : RunnerState::CancelRequested; + if (interrupted) + handlePrompt(); + else if (m_runnerProcess.processId() != -1) + terminateRunner(); + }); + connect(&m_perspective, &SquishPerspective::runRequested, + this, &SquishTools::onRunnerRunRequested); } SquishTools::~SquishTools() @@ -184,7 +218,7 @@ void SquishTools::runTestCases(const QString &suitePath, connect(m_xmlOutputHandler.get(), &SquishXmlOutputHandler::updateStatus, &m_perspective, &SquishPerspective::updateStatus); - m_squishRunnerMode = TestingMode; + m_perspective.setPerspectiveMode(SquishPerspective::Running); emit squishTestRunStarted(); startSquishServer(RunTestRequested); } @@ -201,7 +235,7 @@ void SquishTools::queryServerSettings() .arg(m_state)); return; } - m_squishRunnerMode = QueryMode; + m_perspective.setPerspectiveMode(SquishPerspective::Querying); m_fullRunnerOutput.clear(); startSquishServer(RunnerQueryRequested); } @@ -225,7 +259,6 @@ void SquishTools::setState(SquishTools::State state) { // TODO check whether state transition is legal m_state = state; - switch (m_state) { case Idle: m_request = None; @@ -235,7 +268,7 @@ void SquishTools::setState(SquishTools::State state) m_reportFiles.clear(); m_additionalRunnerArguments.clear(); m_additionalServerArguments.clear(); - m_squishRunnerMode = NoMode; + m_perspective.setPerspectiveMode(SquishPerspective::NoMode); m_currentResultsDirectory.clear(); m_lastTopLevelWindows.clear(); break; @@ -252,11 +285,11 @@ void SquishTools::setState(SquishTools::State state) break; case ServerStartFailed: m_state = Idle; - m_request = None; - if (m_squishRunnerMode == TestingMode) { + if (m_request == RunTestRequested) { emit squishTestRunFinished(); - m_squishRunnerMode = NoMode; + m_perspective.setPerspectiveMode(SquishPerspective::NoMode); } + m_request = None; if (toolsSettings.minimizeIDE) restoreQtCreatorWindows(); m_perspective.destroyControlBar(); @@ -277,9 +310,9 @@ void SquishTools::setState(SquishTools::State state) emit configChangesWritten(); } else if (m_request == ServerStopRequested) { m_request = None; - if (m_squishRunnerMode == TestingMode) { + if (m_perspective.perspectiveMode() == SquishPerspective::Running) { emit squishTestRunFinished(); - m_squishRunnerMode = NoMode; + m_perspective.setPerspectiveMode(SquishPerspective::NoMode); } if (toolsSettings.minimizeIDE) restoreQtCreatorWindows(); @@ -303,11 +336,10 @@ void SquishTools::setState(SquishTools::State state) break; case RunnerStartFailed: case RunnerStopped: - if (m_squishRunnerMode == QueryMode) { + if (m_request == RunnerQueryRequested) { m_request = ServerStopRequested; stopSquishServer(); - } else if (m_testCases.isEmpty() - || (m_perspective.state() == SquishPerspective::State::Canceled)) { + } else if (m_testCases.isEmpty() || (m_squishRunnerState == RunnerState::Canceled)) { m_request = ServerStopRequested; stopSquishServer(); QString error; @@ -320,7 +352,7 @@ void SquishTools::setState(SquishTools::State state) logrotateTestResults(); } else { m_xmlOutputHandler->clearForNextRun(); - m_perspective.setState(SquishPerspective::State::Starting); + m_squishRunnerState = RunnerState::Starting; startSquishRunner(); } break; @@ -333,6 +365,7 @@ void SquishTools::startSquishServer(Request request) { if (m_shutdownInitiated) return; + QTC_ASSERT(m_perspective.perspectiveMode() != SquishPerspective::NoMode, return); m_request = request; if (m_serverProcess.state() != QProcess::NotRunning) { handleSquishServerAlreadyRunning(); @@ -355,7 +388,7 @@ void SquishTools::startSquishServer(Request request) } toolsSettings.serverPath = squishServer; - if (m_squishRunnerMode == TestingMode) { + if (m_request == RunTestRequested) { if (toolsSettings.minimizeIDE) minimizeQtCreatorWindows(); else @@ -364,7 +397,7 @@ void SquishTools::startSquishServer(Request request) m_perspective.showControlBar(m_xmlOutputHandler.get()); m_perspective.select(); - m_perspective.setState(SquishPerspective::State::Starting); + m_squishRunnerState = RunnerState::Starting; } const QStringList arguments = serverArgumentsFromSettings(); @@ -460,7 +493,7 @@ void SquishTools::onServerFinished() void SquishTools::onRunnerFinished() { - if (m_squishRunnerMode == QueryMode) { + if (m_request == RunnerQueryRequested) { emit queryFinished(m_fullRunnerOutput); setState(RunnerStopped); m_fullRunnerOutput.clear(); @@ -468,8 +501,9 @@ void SquishTools::onRunnerFinished() } if (!m_shutdownInitiated) { - m_perspective.setState(SquishPerspective::State::Finished); + m_squishRunnerState = RunnerState::Finished; m_perspective.updateStatus(Tr::tr("Test run finished.")); + m_perspective.setPerspectiveMode(SquishPerspective::NoMode); } if (m_resultsFileWatcher) { @@ -619,8 +653,10 @@ void SquishTools::onRunnerErrorOutput() emit logOutputReceived("Runner: " + QLatin1String(trimmed)); if (trimmed.startsWith("QSocketNotifier: Invalid socket")) { // we've lost connection to the AUT - if Interrupted, try to cancel the runner - if (m_perspective.state() == SquishPerspective::State::Interrupted) - m_perspective.setState(SquishPerspective::State::CancelRequestedWhileInterrupted); + if (m_squishRunnerState == RunnerState::Interrupted) { + m_squishRunnerState = RunnerState::CancelRequestedWhileInterrupted; + handlePrompt(); + } } } } @@ -705,49 +741,28 @@ void SquishTools::setBreakpoints() void SquishTools::handlePrompt(const QString &fileName, int line, int column) { - const SquishPerspective::State state = m_perspective.state(); - switch (state) { - case SquishPerspective::State::Starting: + switch (m_squishRunnerState) { + case RunnerState::Starting: setBreakpoints(); - m_perspective.setState(SquishPerspective::State::RunRequested); + onRunnerRunRequested(SquishPerspective::Continue); break; - case SquishPerspective::State::RunRequested: - case SquishPerspective::State::StepInRequested: - case SquishPerspective::State::StepOverRequested: - case SquishPerspective::State::StepReturnRequested: - if (m_requestVarsTimer) { - delete m_requestVarsTimer; - m_requestVarsTimer = nullptr; - } - if (state == SquishPerspective::State::RunRequested) - m_runnerProcess.write("continue\n"); - else if (state == SquishPerspective::State::StepInRequested) - m_runnerProcess.write("step\n"); - else if (state == SquishPerspective::State::StepOverRequested) - m_runnerProcess.write("next\n"); - else // SquishPerspective::State::StepReturnRequested - m_runnerProcess.write("return\n"); - clearLocationMarker(); - if (state == SquishPerspective::State::RunRequested && toolsSettings.minimizeIDE) - minimizeQtCreatorWindows(); - m_perspective.setState(SquishPerspective::State::Running); - break; - case SquishPerspective::State::CancelRequested: - case SquishPerspective::State::CancelRequestedWhileInterrupted: + case RunnerState::CancelRequested: + case RunnerState::CancelRequestedWhileInterrupted: m_runnerProcess.write("exit\n"); clearLocationMarker(); - m_perspective.setState(SquishPerspective::State::Canceling); + m_squishRunnerState = RunnerState::Canceling; break; - case SquishPerspective::State::Canceling: + case RunnerState::Canceling: m_runnerProcess.write("quit\n"); - m_perspective.setState(SquishPerspective::State::Canceled); + m_squishRunnerState = RunnerState::Canceled; break; - case SquishPerspective::State::Canceled: + case RunnerState::Canceled: QTC_CHECK(false); break; default: if (line != -1 && column != -1) { - m_perspective.setState(SquishPerspective::State::Interrupted); + m_perspective.setPerspectiveMode(SquishPerspective::Interrupted); + m_squishRunnerState = RunnerState::Interrupted; restoreQtCreatorWindows(); // if we're returning from a function we might end up without a file information if (fileName.isEmpty()) { @@ -760,7 +775,7 @@ void SquishTools::handlePrompt(const QString &fileName, int line, int column) updateLocationMarker(filePath, line); } } else { // it's just some output coming from the server - if (m_perspective.state() == SquishPerspective::State::Interrupted && !m_requestVarsTimer) { + if (m_squishRunnerState == RunnerState::Interrupted && !m_requestVarsTimer) { // FIXME: this should be easier, but when interrupted and AUT is closed // runner does not get notified until continued/canceled m_requestVarsTimer = new QTimer(this); @@ -777,7 +792,7 @@ void SquishTools::handlePrompt(const QString &fileName, int line, int column) void SquishTools::requestExpansion(const QString &name) { - QTC_ASSERT(m_perspective.state() == SquishPerspective::State::Interrupted, return); + QTC_ASSERT(m_squishRunnerState == RunnerState::Interrupted, return); m_runnerProcess.write("print variables +" + name + "\n"); } @@ -879,27 +894,28 @@ void SquishTools::clearLocationMarker() m_locationMarker = nullptr; } -void SquishTools::onPerspectiveStateChanged(SquishPerspective::State state) +void SquishTools::onRunnerRunRequested(SquishPerspective::StepMode step) { - switch (state) { - case SquishPerspective::State::InterruptRequested: - if (m_runnerProcess.processId() != -1) - interruptRunner(); - break; - case SquishPerspective::State::CancelRequested: - if (m_runnerProcess.processId() != -1) - terminateRunner(); - break; - case SquishPerspective::State::RunRequested: - case SquishPerspective::State::StepInRequested: - case SquishPerspective::State::StepOverRequested: - case SquishPerspective::State::StepReturnRequested: - case SquishPerspective::State::CancelRequestedWhileInterrupted: - handlePrompt(); - break; - default: - break; + if (m_requestVarsTimer) { + delete m_requestVarsTimer; + m_requestVarsTimer = nullptr; } + m_squishRunnerState = RunnerState::RunRequested; + + if (step == SquishPerspective::Continue) + m_runnerProcess.write("continue\n"); + else if (step == SquishPerspective::StepIn) + m_runnerProcess.write("step\n"); + else if (step == SquishPerspective::StepOver) + m_runnerProcess.write("next\n"); + else if (step == SquishPerspective::StepOut) + m_runnerProcess.write("return\n"); + + clearLocationMarker(); + if (toolsSettings.minimizeIDE) + minimizeQtCreatorWindows(); + m_perspective.setPerspectiveMode(SquishPerspective::Running); + m_squishRunnerState = RunnerState::Running; } void SquishTools::interruptRunner() diff --git a/src/plugins/squish/squishtools.h b/src/plugins/squish/squishtools.h index e26e1c754fa..1a64a01fc36 100644 --- a/src/plugins/squish/squishtools.h +++ b/src/plugins/squish/squishtools.h @@ -45,6 +45,20 @@ public: RunnerStopped }; + enum class RunnerState { + None, + Starting, + Running, + RunRequested, + Interrupted, + InterruptRequested, + Canceling, + Canceled, + CancelRequested, + CancelRequestedWhileInterrupted, + Finished + }; + State state() const { return m_state; } void runTestCases(const QString &suitePath, const QStringList &testCases = QStringList(), @@ -102,7 +116,7 @@ private: void restoreQtCreatorWindows(); void updateLocationMarker(const Utils::FilePath &file, int line); void clearLocationMarker(); - void onPerspectiveStateChanged(SquishPerspective::State state); + void onRunnerRunRequested(SquishPerspective::StepMode step); void interruptRunner(); void terminateRunner(); bool isValidToStartRunner(); @@ -120,6 +134,7 @@ private: QString m_serverHost; Request m_request = None; State m_state = Idle; + RunnerState m_squishRunnerState = RunnerState::None; QString m_suitePath; QStringList m_testCases; QStringList m_reportFiles; @@ -134,7 +149,6 @@ private: QWindowList m_lastTopLevelWindows; class SquishLocationMark *m_locationMarker = nullptr; QTimer *m_requestVarsTimer = nullptr; - enum RunnerMode { NoMode, TestingMode, QueryMode} m_squishRunnerMode = NoMode; qint64 m_readResultsCount; bool m_shutdownInitiated = false; };