forked from qt-creator/qt-creator
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 <david.schulz@qt.io>
This commit is contained in:
@@ -26,45 +26,24 @@
|
|||||||
namespace Squish {
|
namespace Squish {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
static QString stateName(SquishPerspective::State state)
|
enum class IconType { StopRecord, Play, Pause, StepIn, StepOver, StepReturn, Stop };
|
||||||
{
|
|
||||||
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 };
|
|
||||||
|
|
||||||
static QIcon iconForType(IconType type)
|
static QIcon iconForType(IconType type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case StopRecord:
|
case IconType::StopRecord:
|
||||||
return QIcon();
|
return QIcon();
|
||||||
case Play:
|
case IconType::Play:
|
||||||
return Debugger::Icons::DEBUG_CONTINUE_SMALL_TOOLBAR.icon();
|
return Debugger::Icons::DEBUG_CONTINUE_SMALL_TOOLBAR.icon();
|
||||||
case Pause:
|
case IconType::Pause:
|
||||||
return Utils::Icons::INTERRUPT_SMALL.icon();
|
return Utils::Icons::INTERRUPT_SMALL.icon();
|
||||||
case StepIn:
|
case IconType::StepIn:
|
||||||
return Debugger::Icons::STEP_INTO_TOOLBAR.icon();
|
return Debugger::Icons::STEP_INTO_TOOLBAR.icon();
|
||||||
case StepOver:
|
case IconType::StepOver:
|
||||||
return Debugger::Icons::STEP_OVER_TOOLBAR.icon();
|
return Debugger::Icons::STEP_OVER_TOOLBAR.icon();
|
||||||
case StepReturn:
|
case IconType::StepReturn:
|
||||||
return Debugger::Icons::STEP_OUT_TOOLBAR.icon();
|
return Debugger::Icons::STEP_OUT_TOOLBAR.icon();
|
||||||
case Stop:
|
case IconType::Stop:
|
||||||
return Utils::Icons::STOP_SMALL.icon();
|
return Utils::Icons::STOP_SMALL.icon();
|
||||||
}
|
}
|
||||||
return QIcon();
|
return QIcon();
|
||||||
@@ -202,19 +181,19 @@ SquishPerspective::SquishPerspective()
|
|||||||
void SquishPerspective::initPerspective()
|
void SquishPerspective::initPerspective()
|
||||||
{
|
{
|
||||||
m_pausePlayAction = new QAction(this);
|
m_pausePlayAction = new QAction(this);
|
||||||
m_pausePlayAction->setIcon(iconForType(Pause));
|
m_pausePlayAction->setIcon(iconForType(IconType::Pause));
|
||||||
m_pausePlayAction->setToolTip(Tr::tr("Interrupt"));
|
m_pausePlayAction->setToolTip(Tr::tr("Interrupt"));
|
||||||
m_pausePlayAction->setEnabled(false);
|
m_pausePlayAction->setEnabled(false);
|
||||||
m_stepInAction = new QAction(this);
|
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->setToolTip(Tr::tr("Step Into"));
|
||||||
m_stepInAction->setEnabled(false);
|
m_stepInAction->setEnabled(false);
|
||||||
m_stepOverAction = new QAction(this);
|
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->setToolTip(Tr::tr("Step Over"));
|
||||||
m_stepOverAction->setEnabled(false);
|
m_stepOverAction->setEnabled(false);
|
||||||
m_stepOutAction = new QAction(this);
|
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->setToolTip(Tr::tr("Step Out"));
|
||||||
m_stepOutAction->setEnabled(false);
|
m_stepOutAction->setEnabled(false);
|
||||||
m_stopAction = Debugger::createStopAction();
|
m_stopAction = Debugger::createStopAction();
|
||||||
@@ -248,15 +227,9 @@ void SquishPerspective::initPerspective()
|
|||||||
addWindow(mainWidget, Perspective::AddToTab, nullptr, true, Qt::RightDockWidgetArea);
|
addWindow(mainWidget, Perspective::AddToTab, nullptr, true, Qt::RightDockWidgetArea);
|
||||||
|
|
||||||
connect(m_pausePlayAction, &QAction::triggered, this, &SquishPerspective::onPausePlayTriggered);
|
connect(m_pausePlayAction, &QAction::triggered, this, &SquishPerspective::onPausePlayTriggered);
|
||||||
connect(m_stepInAction, &QAction::triggered, this, [this] {
|
connect(m_stepInAction, &QAction::triggered, this, [this] { emit runRequested(StepIn); });
|
||||||
setState(State::StepInRequested);
|
connect(m_stepOverAction, &QAction::triggered, this, [this] { emit runRequested(StepOver); });
|
||||||
});
|
connect(m_stepOutAction, &QAction::triggered, this, [this] { emit runRequested(StepOut); });
|
||||||
connect(m_stepOverAction, &QAction::triggered, this, [this] {
|
|
||||||
setState(State::StepOverRequested);
|
|
||||||
});
|
|
||||||
connect(m_stepOutAction, &QAction::triggered, this, [this] {
|
|
||||||
setState(State::StepReturnRequested);
|
|
||||||
});
|
|
||||||
connect(m_stopAction, &QAction::triggered, this, &SquishPerspective::onStopTriggered);
|
connect(m_stopAction, &QAction::triggered, this, &SquishPerspective::onStopTriggered);
|
||||||
|
|
||||||
connect(SquishTools::instance(), &SquishTools::localsUpdated,
|
connect(SquishTools::instance(), &SquishTools::localsUpdated,
|
||||||
@@ -278,18 +251,17 @@ void SquishPerspective::onStopTriggered()
|
|||||||
{
|
{
|
||||||
m_pausePlayAction->setEnabled(false);
|
m_pausePlayAction->setEnabled(false);
|
||||||
m_stopAction->setEnabled(false);
|
m_stopAction->setEnabled(false);
|
||||||
setState(m_state == State::Interrupted ? State::CancelRequestedWhileInterrupted
|
emit stopRequested();
|
||||||
: State::CancelRequested);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SquishPerspective::onPausePlayTriggered()
|
void SquishPerspective::onPausePlayTriggered()
|
||||||
{
|
{
|
||||||
if (m_state == State::Interrupted)
|
if (m_mode == Interrupted)
|
||||||
setState(State::RunRequested);
|
emit runRequested(Continue);
|
||||||
else if (m_state == State::Running)
|
else if (m_mode == Running)
|
||||||
setState(State::InterruptRequested);
|
emit interruptRequested();
|
||||||
else
|
else
|
||||||
qDebug() << "###state: " << stateName(m_state);
|
qDebug() << "###state: " << m_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SquishPerspective::onLocalsUpdated(const QString &output)
|
void SquishPerspective::onLocalsUpdated(const QString &output)
|
||||||
@@ -358,100 +330,46 @@ void SquishPerspective::destroyControlBar()
|
|||||||
m_controlBar = nullptr;
|
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;
|
return;
|
||||||
|
|
||||||
if (!isStateTransitionValid(state)) {
|
m_mode = mode;
|
||||||
qDebug() << "Illegal state transition" << stateName(m_state) << "->" << stateName(state);
|
switch (m_mode) {
|
||||||
return;
|
case Running:
|
||||||
}
|
|
||||||
|
|
||||||
m_state = state;
|
|
||||||
m_localsModel.clear();
|
|
||||||
emit stateChanged(state);
|
|
||||||
|
|
||||||
switch (m_state) {
|
|
||||||
case State::Running:
|
|
||||||
case State::Interrupted:
|
|
||||||
m_pausePlayAction->setEnabled(true);
|
m_pausePlayAction->setEnabled(true);
|
||||||
if (m_state == State::Interrupted) {
|
m_pausePlayAction->setIcon(iconForType(IconType::Pause));
|
||||||
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_pausePlayAction->setToolTip(Tr::tr("Interrupt"));
|
||||||
m_stepInAction->setEnabled(false);
|
m_stepInAction->setEnabled(false);
|
||||||
m_stepOverAction->setEnabled(false);
|
m_stepOverAction->setEnabled(false);
|
||||||
m_stepOutAction->setEnabled(false);
|
m_stepOutAction->setEnabled(false);
|
||||||
}
|
|
||||||
m_stopAction->setEnabled(true);
|
m_stopAction->setEnabled(true);
|
||||||
break;
|
break;
|
||||||
case State::RunRequested:
|
case Interrupted:
|
||||||
case State::Starting:
|
m_pausePlayAction->setEnabled(true);
|
||||||
case State::StepInRequested:
|
m_pausePlayAction->setIcon(iconForType(IconType::Play));
|
||||||
case State::StepOverRequested:
|
m_pausePlayAction->setToolTip(Tr::tr("Continue"));
|
||||||
case State::StepReturnRequested:
|
m_stepInAction->setEnabled(true);
|
||||||
case State::InterruptRequested:
|
m_stepOverAction->setEnabled(true);
|
||||||
case State::CancelRequested:
|
m_stepOutAction->setEnabled(true);
|
||||||
case State::CancelRequestedWhileInterrupted:
|
m_stopAction->setEnabled(true);
|
||||||
case State::Canceled:
|
break;
|
||||||
case State::Finished:
|
case Querying:
|
||||||
m_pausePlayAction->setIcon(iconForType(Pause));
|
case NoMode:
|
||||||
|
m_pausePlayAction->setIcon(iconForType(IconType::Pause));
|
||||||
m_pausePlayAction->setToolTip(Tr::tr("Interrupt"));
|
m_pausePlayAction->setToolTip(Tr::tr("Interrupt"));
|
||||||
m_pausePlayAction->setEnabled(false);
|
m_pausePlayAction->setEnabled(false);
|
||||||
m_stepInAction->setEnabled(false);
|
m_stepInAction->setEnabled(false);
|
||||||
m_stepOverAction->setEnabled(false);
|
m_stepOverAction->setEnabled(false);
|
||||||
m_stepOutAction->setEnabled(false);
|
m_stepOutAction->setEnabled(false);
|
||||||
m_stopAction->setEnabled(false);
|
m_stopAction->setEnabled(false);
|
||||||
|
m_localsModel.clear();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
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 Internal
|
||||||
} // namespace Squish
|
} // namespace Squish
|
||||||
|
|||||||
@@ -28,41 +28,28 @@ class SquishPerspective : public Utils::Perspective
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum class State {
|
enum PerspectiveMode { NoMode, Interrupted, Running, Querying };
|
||||||
None,
|
enum StepMode { Continue, StepIn, StepOver, StepOut };
|
||||||
Starting,
|
|
||||||
Running,
|
|
||||||
RunRequested,
|
|
||||||
StepInRequested,
|
|
||||||
StepOverRequested,
|
|
||||||
StepReturnRequested,
|
|
||||||
Interrupted,
|
|
||||||
InterruptRequested,
|
|
||||||
Canceling,
|
|
||||||
Canceled,
|
|
||||||
CancelRequested,
|
|
||||||
CancelRequestedWhileInterrupted,
|
|
||||||
Finished
|
|
||||||
};
|
|
||||||
|
|
||||||
SquishPerspective();
|
SquishPerspective();
|
||||||
void initPerspective();
|
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 updateStatus(const QString &status);
|
||||||
|
|
||||||
void showControlBar(SquishXmlOutputHandler *xmlOutputHandler);
|
void showControlBar(SquishXmlOutputHandler *xmlOutputHandler);
|
||||||
void destroyControlBar();
|
void destroyControlBar();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void stateChanged(State state);
|
void stopRequested();
|
||||||
|
void interruptRequested();
|
||||||
|
void runRequested(SquishPerspective::StepMode mode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onStopTriggered();
|
void onStopTriggered();
|
||||||
void onPausePlayTriggered();
|
void onPausePlayTriggered();
|
||||||
void onLocalsUpdated(const QString &output);
|
void onLocalsUpdated(const QString &output);
|
||||||
bool isStateTransitionValid(State newState) const;
|
|
||||||
|
|
||||||
QAction *m_pausePlayAction = nullptr;
|
QAction *m_pausePlayAction = nullptr;
|
||||||
QAction *m_stepInAction = nullptr;
|
QAction *m_stepInAction = nullptr;
|
||||||
@@ -72,7 +59,7 @@ private:
|
|||||||
QLabel *m_status = nullptr;
|
QLabel *m_status = nullptr;
|
||||||
class SquishControlBar *m_controlBar = nullptr;
|
class SquishControlBar *m_controlBar = nullptr;
|
||||||
Utils::TreeModel<LocalsItem> m_localsModel;
|
Utils::TreeModel<LocalsItem> m_localsModel;
|
||||||
State m_state = State::None;
|
PerspectiveMode m_mode = NoMode;
|
||||||
|
|
||||||
friend class SquishControlBar;
|
friend class SquishControlBar;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -36,6 +36,25 @@ using namespace Utils;
|
|||||||
namespace Squish {
|
namespace Squish {
|
||||||
namespace Internal {
|
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
|
class SquishLocationMark : public TextEditor::TextMark
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -50,7 +69,6 @@ public:
|
|||||||
// make this configurable?
|
// make this configurable?
|
||||||
static const QString resultsDirectory = QFileInfo(QDir::home(), ".squishQC/Test Results")
|
static const QString resultsDirectory = QFileInfo(QDir::home(), ".squishQC/Test Results")
|
||||||
.absoluteFilePath();
|
.absoluteFilePath();
|
||||||
|
|
||||||
static SquishTools *s_instance = nullptr;
|
static SquishTools *s_instance = nullptr;
|
||||||
|
|
||||||
SquishTools::SquishTools(QObject *parent)
|
SquishTools::SquishTools(QObject *parent)
|
||||||
@@ -82,8 +100,24 @@ SquishTools::SquishTools(QObject *parent)
|
|||||||
this, &SquishTools::onServerFinished);
|
this, &SquishTools::onServerFinished);
|
||||||
s_instance = this;
|
s_instance = this;
|
||||||
m_perspective.initPerspective();
|
m_perspective.initPerspective();
|
||||||
connect(&m_perspective, &SquishPerspective::stateChanged,
|
connect(&m_perspective, &SquishPerspective::interruptRequested,
|
||||||
this, &SquishTools::onPerspectiveStateChanged);
|
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()
|
SquishTools::~SquishTools()
|
||||||
@@ -184,7 +218,7 @@ void SquishTools::runTestCases(const QString &suitePath,
|
|||||||
connect(m_xmlOutputHandler.get(), &SquishXmlOutputHandler::updateStatus,
|
connect(m_xmlOutputHandler.get(), &SquishXmlOutputHandler::updateStatus,
|
||||||
&m_perspective, &SquishPerspective::updateStatus);
|
&m_perspective, &SquishPerspective::updateStatus);
|
||||||
|
|
||||||
m_squishRunnerMode = TestingMode;
|
m_perspective.setPerspectiveMode(SquishPerspective::Running);
|
||||||
emit squishTestRunStarted();
|
emit squishTestRunStarted();
|
||||||
startSquishServer(RunTestRequested);
|
startSquishServer(RunTestRequested);
|
||||||
}
|
}
|
||||||
@@ -201,7 +235,7 @@ void SquishTools::queryServerSettings()
|
|||||||
.arg(m_state));
|
.arg(m_state));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_squishRunnerMode = QueryMode;
|
m_perspective.setPerspectiveMode(SquishPerspective::Querying);
|
||||||
m_fullRunnerOutput.clear();
|
m_fullRunnerOutput.clear();
|
||||||
startSquishServer(RunnerQueryRequested);
|
startSquishServer(RunnerQueryRequested);
|
||||||
}
|
}
|
||||||
@@ -225,7 +259,6 @@ void SquishTools::setState(SquishTools::State state)
|
|||||||
{
|
{
|
||||||
// TODO check whether state transition is legal
|
// TODO check whether state transition is legal
|
||||||
m_state = state;
|
m_state = state;
|
||||||
|
|
||||||
switch (m_state) {
|
switch (m_state) {
|
||||||
case Idle:
|
case Idle:
|
||||||
m_request = None;
|
m_request = None;
|
||||||
@@ -235,7 +268,7 @@ void SquishTools::setState(SquishTools::State state)
|
|||||||
m_reportFiles.clear();
|
m_reportFiles.clear();
|
||||||
m_additionalRunnerArguments.clear();
|
m_additionalRunnerArguments.clear();
|
||||||
m_additionalServerArguments.clear();
|
m_additionalServerArguments.clear();
|
||||||
m_squishRunnerMode = NoMode;
|
m_perspective.setPerspectiveMode(SquishPerspective::NoMode);
|
||||||
m_currentResultsDirectory.clear();
|
m_currentResultsDirectory.clear();
|
||||||
m_lastTopLevelWindows.clear();
|
m_lastTopLevelWindows.clear();
|
||||||
break;
|
break;
|
||||||
@@ -252,11 +285,11 @@ void SquishTools::setState(SquishTools::State state)
|
|||||||
break;
|
break;
|
||||||
case ServerStartFailed:
|
case ServerStartFailed:
|
||||||
m_state = Idle;
|
m_state = Idle;
|
||||||
m_request = None;
|
if (m_request == RunTestRequested) {
|
||||||
if (m_squishRunnerMode == TestingMode) {
|
|
||||||
emit squishTestRunFinished();
|
emit squishTestRunFinished();
|
||||||
m_squishRunnerMode = NoMode;
|
m_perspective.setPerspectiveMode(SquishPerspective::NoMode);
|
||||||
}
|
}
|
||||||
|
m_request = None;
|
||||||
if (toolsSettings.minimizeIDE)
|
if (toolsSettings.minimizeIDE)
|
||||||
restoreQtCreatorWindows();
|
restoreQtCreatorWindows();
|
||||||
m_perspective.destroyControlBar();
|
m_perspective.destroyControlBar();
|
||||||
@@ -277,9 +310,9 @@ void SquishTools::setState(SquishTools::State state)
|
|||||||
emit configChangesWritten();
|
emit configChangesWritten();
|
||||||
} else if (m_request == ServerStopRequested) {
|
} else if (m_request == ServerStopRequested) {
|
||||||
m_request = None;
|
m_request = None;
|
||||||
if (m_squishRunnerMode == TestingMode) {
|
if (m_perspective.perspectiveMode() == SquishPerspective::Running) {
|
||||||
emit squishTestRunFinished();
|
emit squishTestRunFinished();
|
||||||
m_squishRunnerMode = NoMode;
|
m_perspective.setPerspectiveMode(SquishPerspective::NoMode);
|
||||||
}
|
}
|
||||||
if (toolsSettings.minimizeIDE)
|
if (toolsSettings.minimizeIDE)
|
||||||
restoreQtCreatorWindows();
|
restoreQtCreatorWindows();
|
||||||
@@ -303,11 +336,10 @@ void SquishTools::setState(SquishTools::State state)
|
|||||||
break;
|
break;
|
||||||
case RunnerStartFailed:
|
case RunnerStartFailed:
|
||||||
case RunnerStopped:
|
case RunnerStopped:
|
||||||
if (m_squishRunnerMode == QueryMode) {
|
if (m_request == RunnerQueryRequested) {
|
||||||
m_request = ServerStopRequested;
|
m_request = ServerStopRequested;
|
||||||
stopSquishServer();
|
stopSquishServer();
|
||||||
} else if (m_testCases.isEmpty()
|
} else if (m_testCases.isEmpty() || (m_squishRunnerState == RunnerState::Canceled)) {
|
||||||
|| (m_perspective.state() == SquishPerspective::State::Canceled)) {
|
|
||||||
m_request = ServerStopRequested;
|
m_request = ServerStopRequested;
|
||||||
stopSquishServer();
|
stopSquishServer();
|
||||||
QString error;
|
QString error;
|
||||||
@@ -320,7 +352,7 @@ void SquishTools::setState(SquishTools::State state)
|
|||||||
logrotateTestResults();
|
logrotateTestResults();
|
||||||
} else {
|
} else {
|
||||||
m_xmlOutputHandler->clearForNextRun();
|
m_xmlOutputHandler->clearForNextRun();
|
||||||
m_perspective.setState(SquishPerspective::State::Starting);
|
m_squishRunnerState = RunnerState::Starting;
|
||||||
startSquishRunner();
|
startSquishRunner();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -333,6 +365,7 @@ void SquishTools::startSquishServer(Request request)
|
|||||||
{
|
{
|
||||||
if (m_shutdownInitiated)
|
if (m_shutdownInitiated)
|
||||||
return;
|
return;
|
||||||
|
QTC_ASSERT(m_perspective.perspectiveMode() != SquishPerspective::NoMode, return);
|
||||||
m_request = request;
|
m_request = request;
|
||||||
if (m_serverProcess.state() != QProcess::NotRunning) {
|
if (m_serverProcess.state() != QProcess::NotRunning) {
|
||||||
handleSquishServerAlreadyRunning();
|
handleSquishServerAlreadyRunning();
|
||||||
@@ -355,7 +388,7 @@ void SquishTools::startSquishServer(Request request)
|
|||||||
}
|
}
|
||||||
toolsSettings.serverPath = squishServer;
|
toolsSettings.serverPath = squishServer;
|
||||||
|
|
||||||
if (m_squishRunnerMode == TestingMode) {
|
if (m_request == RunTestRequested) {
|
||||||
if (toolsSettings.minimizeIDE)
|
if (toolsSettings.minimizeIDE)
|
||||||
minimizeQtCreatorWindows();
|
minimizeQtCreatorWindows();
|
||||||
else
|
else
|
||||||
@@ -364,7 +397,7 @@ void SquishTools::startSquishServer(Request request)
|
|||||||
m_perspective.showControlBar(m_xmlOutputHandler.get());
|
m_perspective.showControlBar(m_xmlOutputHandler.get());
|
||||||
|
|
||||||
m_perspective.select();
|
m_perspective.select();
|
||||||
m_perspective.setState(SquishPerspective::State::Starting);
|
m_squishRunnerState = RunnerState::Starting;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringList arguments = serverArgumentsFromSettings();
|
const QStringList arguments = serverArgumentsFromSettings();
|
||||||
@@ -460,7 +493,7 @@ void SquishTools::onServerFinished()
|
|||||||
|
|
||||||
void SquishTools::onRunnerFinished()
|
void SquishTools::onRunnerFinished()
|
||||||
{
|
{
|
||||||
if (m_squishRunnerMode == QueryMode) {
|
if (m_request == RunnerQueryRequested) {
|
||||||
emit queryFinished(m_fullRunnerOutput);
|
emit queryFinished(m_fullRunnerOutput);
|
||||||
setState(RunnerStopped);
|
setState(RunnerStopped);
|
||||||
m_fullRunnerOutput.clear();
|
m_fullRunnerOutput.clear();
|
||||||
@@ -468,8 +501,9 @@ void SquishTools::onRunnerFinished()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!m_shutdownInitiated) {
|
if (!m_shutdownInitiated) {
|
||||||
m_perspective.setState(SquishPerspective::State::Finished);
|
m_squishRunnerState = RunnerState::Finished;
|
||||||
m_perspective.updateStatus(Tr::tr("Test run finished."));
|
m_perspective.updateStatus(Tr::tr("Test run finished."));
|
||||||
|
m_perspective.setPerspectiveMode(SquishPerspective::NoMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_resultsFileWatcher) {
|
if (m_resultsFileWatcher) {
|
||||||
@@ -619,8 +653,10 @@ void SquishTools::onRunnerErrorOutput()
|
|||||||
emit logOutputReceived("Runner: " + QLatin1String(trimmed));
|
emit logOutputReceived("Runner: " + QLatin1String(trimmed));
|
||||||
if (trimmed.startsWith("QSocketNotifier: Invalid socket")) {
|
if (trimmed.startsWith("QSocketNotifier: Invalid socket")) {
|
||||||
// we've lost connection to the AUT - if Interrupted, try to cancel the runner
|
// we've lost connection to the AUT - if Interrupted, try to cancel the runner
|
||||||
if (m_perspective.state() == SquishPerspective::State::Interrupted)
|
if (m_squishRunnerState == RunnerState::Interrupted) {
|
||||||
m_perspective.setState(SquishPerspective::State::CancelRequestedWhileInterrupted);
|
m_squishRunnerState = RunnerState::CancelRequestedWhileInterrupted;
|
||||||
|
handlePrompt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -705,49 +741,28 @@ void SquishTools::setBreakpoints()
|
|||||||
|
|
||||||
void SquishTools::handlePrompt(const QString &fileName, int line, int column)
|
void SquishTools::handlePrompt(const QString &fileName, int line, int column)
|
||||||
{
|
{
|
||||||
const SquishPerspective::State state = m_perspective.state();
|
switch (m_squishRunnerState) {
|
||||||
switch (state) {
|
case RunnerState::Starting:
|
||||||
case SquishPerspective::State::Starting:
|
|
||||||
setBreakpoints();
|
setBreakpoints();
|
||||||
m_perspective.setState(SquishPerspective::State::RunRequested);
|
onRunnerRunRequested(SquishPerspective::Continue);
|
||||||
break;
|
break;
|
||||||
case SquishPerspective::State::RunRequested:
|
case RunnerState::CancelRequested:
|
||||||
case SquishPerspective::State::StepInRequested:
|
case RunnerState::CancelRequestedWhileInterrupted:
|
||||||
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:
|
|
||||||
m_runnerProcess.write("exit\n");
|
m_runnerProcess.write("exit\n");
|
||||||
clearLocationMarker();
|
clearLocationMarker();
|
||||||
m_perspective.setState(SquishPerspective::State::Canceling);
|
m_squishRunnerState = RunnerState::Canceling;
|
||||||
break;
|
break;
|
||||||
case SquishPerspective::State::Canceling:
|
case RunnerState::Canceling:
|
||||||
m_runnerProcess.write("quit\n");
|
m_runnerProcess.write("quit\n");
|
||||||
m_perspective.setState(SquishPerspective::State::Canceled);
|
m_squishRunnerState = RunnerState::Canceled;
|
||||||
break;
|
break;
|
||||||
case SquishPerspective::State::Canceled:
|
case RunnerState::Canceled:
|
||||||
QTC_CHECK(false);
|
QTC_CHECK(false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (line != -1 && column != -1) {
|
if (line != -1 && column != -1) {
|
||||||
m_perspective.setState(SquishPerspective::State::Interrupted);
|
m_perspective.setPerspectiveMode(SquishPerspective::Interrupted);
|
||||||
|
m_squishRunnerState = RunnerState::Interrupted;
|
||||||
restoreQtCreatorWindows();
|
restoreQtCreatorWindows();
|
||||||
// if we're returning from a function we might end up without a file information
|
// if we're returning from a function we might end up without a file information
|
||||||
if (fileName.isEmpty()) {
|
if (fileName.isEmpty()) {
|
||||||
@@ -760,7 +775,7 @@ void SquishTools::handlePrompt(const QString &fileName, int line, int column)
|
|||||||
updateLocationMarker(filePath, line);
|
updateLocationMarker(filePath, line);
|
||||||
}
|
}
|
||||||
} else { // it's just some output coming from the server
|
} 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
|
// FIXME: this should be easier, but when interrupted and AUT is closed
|
||||||
// runner does not get notified until continued/canceled
|
// runner does not get notified until continued/canceled
|
||||||
m_requestVarsTimer = new QTimer(this);
|
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)
|
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");
|
m_runnerProcess.write("print variables +" + name + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -879,27 +894,28 @@ void SquishTools::clearLocationMarker()
|
|||||||
m_locationMarker = nullptr;
|
m_locationMarker = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SquishTools::onPerspectiveStateChanged(SquishPerspective::State state)
|
void SquishTools::onRunnerRunRequested(SquishPerspective::StepMode step)
|
||||||
{
|
{
|
||||||
switch (state) {
|
if (m_requestVarsTimer) {
|
||||||
case SquishPerspective::State::InterruptRequested:
|
delete m_requestVarsTimer;
|
||||||
if (m_runnerProcess.processId() != -1)
|
m_requestVarsTimer = nullptr;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
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()
|
void SquishTools::interruptRunner()
|
||||||
|
|||||||
@@ -45,6 +45,20 @@ public:
|
|||||||
RunnerStopped
|
RunnerStopped
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class RunnerState {
|
||||||
|
None,
|
||||||
|
Starting,
|
||||||
|
Running,
|
||||||
|
RunRequested,
|
||||||
|
Interrupted,
|
||||||
|
InterruptRequested,
|
||||||
|
Canceling,
|
||||||
|
Canceled,
|
||||||
|
CancelRequested,
|
||||||
|
CancelRequestedWhileInterrupted,
|
||||||
|
Finished
|
||||||
|
};
|
||||||
|
|
||||||
State state() const { return m_state; }
|
State state() const { return m_state; }
|
||||||
void runTestCases(const QString &suitePath,
|
void runTestCases(const QString &suitePath,
|
||||||
const QStringList &testCases = QStringList(),
|
const QStringList &testCases = QStringList(),
|
||||||
@@ -102,7 +116,7 @@ private:
|
|||||||
void restoreQtCreatorWindows();
|
void restoreQtCreatorWindows();
|
||||||
void updateLocationMarker(const Utils::FilePath &file, int line);
|
void updateLocationMarker(const Utils::FilePath &file, int line);
|
||||||
void clearLocationMarker();
|
void clearLocationMarker();
|
||||||
void onPerspectiveStateChanged(SquishPerspective::State state);
|
void onRunnerRunRequested(SquishPerspective::StepMode step);
|
||||||
void interruptRunner();
|
void interruptRunner();
|
||||||
void terminateRunner();
|
void terminateRunner();
|
||||||
bool isValidToStartRunner();
|
bool isValidToStartRunner();
|
||||||
@@ -120,6 +134,7 @@ private:
|
|||||||
QString m_serverHost;
|
QString m_serverHost;
|
||||||
Request m_request = None;
|
Request m_request = None;
|
||||||
State m_state = Idle;
|
State m_state = Idle;
|
||||||
|
RunnerState m_squishRunnerState = RunnerState::None;
|
||||||
QString m_suitePath;
|
QString m_suitePath;
|
||||||
QStringList m_testCases;
|
QStringList m_testCases;
|
||||||
QStringList m_reportFiles;
|
QStringList m_reportFiles;
|
||||||
@@ -134,7 +149,6 @@ private:
|
|||||||
QWindowList m_lastTopLevelWindows;
|
QWindowList m_lastTopLevelWindows;
|
||||||
class SquishLocationMark *m_locationMarker = nullptr;
|
class SquishLocationMark *m_locationMarker = nullptr;
|
||||||
QTimer *m_requestVarsTimer = nullptr;
|
QTimer *m_requestVarsTimer = nullptr;
|
||||||
enum RunnerMode { NoMode, TestingMode, QueryMode} m_squishRunnerMode = NoMode;
|
|
||||||
qint64 m_readResultsCount;
|
qint64 m_readResultsCount;
|
||||||
bool m_shutdownInitiated = false;
|
bool m_shutdownInitiated = false;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user