forked from qt-creator/qt-creator
Autotest: Add more "without deployment" actions
When debugging tests, if there was no change in code, user should be able to just rerun tests of his choice. However, currently there are not so many options to just rerun tests without the build. This patch adds more options to run tests without deployment, which can speed up development in some environments Change-Id: I9f998fee90f2e61a1623bd0840a9d5ddf8eb58d7 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -32,11 +32,15 @@ namespace Constants {
|
||||
|
||||
const char ACTION_SCAN_ID[] = "AutoTest.ScanAction";
|
||||
const char ACTION_RUN_ALL_ID[] = "AutoTest.RunAll";
|
||||
const char ACTION_RUN_ALL_NODEPLOY_ID[] = "AutoTest.RunAllNoDeploy";
|
||||
const char ACTION_RUN_SELECTED_ID[] = "AutoTest.RunSelected";
|
||||
const char ACTION_RUN_SELECTED_NODEPLOY_ID[] = "AutoTest.RunSelectedNoDeploy";
|
||||
const char ACTION_RUN_FAILED_ID[] = "AutoTest.RunFailed";
|
||||
const char ACTION_RUN_FILE_ID[] = "AutoTest.RunFile";
|
||||
const char ACTION_RUN_UCURSOR[] = "AutoTest.RunUnderCursor";
|
||||
const char ACTION_RUN_UCURSOR_NODEPLOY[] = "AutoTest.RunUnderCursorNoDeploy";
|
||||
const char ACTION_RUN_DBG_UCURSOR[] = "AutoTest.RunDebugUnderCursor";
|
||||
const char ACTION_RUN_DBG_UCURSOR_NODEPLOY[] = "AutoTest.RunDebugUnderCursorNoDeploy";
|
||||
const char MENU_ID[] = "AutoTest.Menu";
|
||||
const char AUTOTEST_ID[] = "AutoTest.ATP";
|
||||
const char AUTOTEST_CONTEXT[] = "Auto Tests";
|
||||
|
||||
@@ -99,8 +99,8 @@ public:
|
||||
QMap<QString, ChoicePair> m_runconfigCache;
|
||||
|
||||
void initializeMenuEntries();
|
||||
void onRunAllTriggered();
|
||||
void onRunSelectedTriggered();
|
||||
void onRunAllTriggered(TestRunMode mode);
|
||||
void onRunSelectedTriggered(TestRunMode mode);
|
||||
void onRunFailedTriggered();
|
||||
void onRunFileTriggered();
|
||||
void onRunUnderCursorTriggered(TestRunMode mode);
|
||||
@@ -214,7 +214,19 @@ void AutotestPluginPrivate::initializeMenuEntries()
|
||||
Command *command = ActionManager::registerAction(action, Constants::ACTION_RUN_ALL_ID);
|
||||
command->setDefaultKeySequence(
|
||||
QKeySequence(useMacShortcuts ? tr("Ctrl+Meta+T, Ctrl+Meta+A") : tr("Alt+Shift+T,Alt+A")));
|
||||
connect(action, &QAction::triggered, this, &AutotestPluginPrivate::onRunAllTriggered);
|
||||
connect(action, &QAction::triggered,
|
||||
std::bind(&AutotestPluginPrivate::onRunAllTriggered, this, TestRunMode::Run));
|
||||
action->setEnabled(false);
|
||||
menu->addAction(command);
|
||||
|
||||
action = new QAction(tr("Run All Tests Without Deployment"), this);
|
||||
action->setIcon(Utils::Icons::RUN_SMALL.icon());
|
||||
action->setToolTip(tr("Run All Tests Without Deployment"));
|
||||
command = ActionManager::registerAction(action, Constants::ACTION_RUN_ALL_NODEPLOY_ID);
|
||||
command->setDefaultKeySequence(
|
||||
QKeySequence(useMacShortcuts ? tr("Ctrl+Meta+T, Ctrl+Meta+E") : tr("Alt+Shift+T,Alt+E")));
|
||||
connect(action, &QAction::triggered,
|
||||
std::bind(&AutotestPluginPrivate::onRunAllTriggered, this, TestRunMode::RunWithoutDeploy));
|
||||
action->setEnabled(false);
|
||||
menu->addAction(command);
|
||||
|
||||
@@ -224,7 +236,19 @@ void AutotestPluginPrivate::initializeMenuEntries()
|
||||
command = ActionManager::registerAction(action, Constants::ACTION_RUN_SELECTED_ID);
|
||||
command->setDefaultKeySequence(
|
||||
QKeySequence(useMacShortcuts ? tr("Ctrl+Meta+T, Ctrl+Meta+R") : tr("Alt+Shift+T,Alt+R")));
|
||||
connect(action, &QAction::triggered, this, &AutotestPluginPrivate::onRunSelectedTriggered);
|
||||
connect(action, &QAction::triggered,
|
||||
std::bind(&AutotestPluginPrivate::onRunSelectedTriggered, this, TestRunMode::Run));
|
||||
action->setEnabled(false);
|
||||
menu->addAction(command);
|
||||
|
||||
action = new QAction(tr("&Run Selected Tests Without Deployment"), this);
|
||||
action->setIcon(Utils::Icons::RUN_SELECTED.icon());
|
||||
action->setToolTip(tr("Run Selected Tests"));
|
||||
command = ActionManager::registerAction(action, Constants::ACTION_RUN_SELECTED_NODEPLOY_ID);
|
||||
command->setDefaultKeySequence(
|
||||
QKeySequence(useMacShortcuts ? tr("Ctrl+Meta+T, Ctrl+Meta+W") : tr("Alt+Shift+T,Alt+W")));
|
||||
connect(action, &QAction::triggered,
|
||||
std::bind(&AutotestPluginPrivate::onRunSelectedTriggered, this, TestRunMode::RunWithoutDeploy));
|
||||
action->setEnabled(false);
|
||||
menu->addAction(command);
|
||||
|
||||
@@ -300,6 +324,15 @@ void AutotestPlugin::extensionsInitialized()
|
||||
contextMenu->addSeparator();
|
||||
contextMenu->addAction(command);
|
||||
|
||||
action = new QAction(tr("Run Test Under Cursor Without Deployment"), this);
|
||||
action->setEnabled(false);
|
||||
action->setIcon(Utils::Icons::RUN_SMALL.icon());
|
||||
|
||||
command = ActionManager::registerAction(action, Constants::ACTION_RUN_UCURSOR_NODEPLOY);
|
||||
connect(action, &QAction::triggered,
|
||||
std::bind(&AutotestPluginPrivate::onRunUnderCursorTriggered, dd, TestRunMode::RunWithoutDeploy));
|
||||
contextMenu->addAction(command);
|
||||
|
||||
action = new QAction(tr("&Debug Test Under Cursor"), this);
|
||||
action->setEnabled(false);
|
||||
action->setIcon(ProjectExplorer::Icons::DEBUG_START_SMALL.icon());
|
||||
@@ -308,6 +341,15 @@ void AutotestPlugin::extensionsInitialized()
|
||||
connect(action, &QAction::triggered,
|
||||
std::bind(&AutotestPluginPrivate::onRunUnderCursorTriggered, dd, TestRunMode::Debug));
|
||||
contextMenu->addAction(command);
|
||||
|
||||
action = new QAction(tr("Debug Test Under Cursor Without Deployment"), this);
|
||||
action->setEnabled(false);
|
||||
action->setIcon(ProjectExplorer::Icons::DEBUG_START_SMALL.icon());
|
||||
|
||||
command = ActionManager::registerAction(action, Constants::ACTION_RUN_DBG_UCURSOR_NODEPLOY);
|
||||
connect(action, &QAction::triggered,
|
||||
std::bind(&AutotestPluginPrivate::onRunUnderCursorTriggered, dd, TestRunMode::DebugWithoutDeploy));
|
||||
contextMenu->addAction(command);
|
||||
contextMenu->addSeparator();
|
||||
}
|
||||
|
||||
@@ -318,16 +360,16 @@ ExtensionSystem::IPlugin::ShutdownFlag AutotestPlugin::aboutToShutdown()
|
||||
return SynchronousShutdown;
|
||||
}
|
||||
|
||||
void AutotestPluginPrivate::onRunAllTriggered()
|
||||
void AutotestPluginPrivate::onRunAllTriggered(TestRunMode mode)
|
||||
{
|
||||
m_testRunner.setSelectedTests(m_testTreeModel.getAllTestCases());
|
||||
m_testRunner.prepareToRunTests(TestRunMode::Run);
|
||||
m_testRunner.prepareToRunTests(mode);
|
||||
}
|
||||
|
||||
void AutotestPluginPrivate::onRunSelectedTriggered()
|
||||
void AutotestPluginPrivate::onRunSelectedTriggered(TestRunMode mode)
|
||||
{
|
||||
m_testRunner.setSelectedTests(m_testTreeModel.getSelectedTests());
|
||||
m_testRunner.prepareToRunTests(TestRunMode::Run);
|
||||
m_testRunner.prepareToRunTests(mode);
|
||||
}
|
||||
|
||||
void AutotestPluginPrivate::onRunFailedTriggered()
|
||||
@@ -416,6 +458,8 @@ void AutotestPlugin::updateMenuItemsEnabledState()
|
||||
|
||||
ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action()->setEnabled(canRun);
|
||||
ActionManager::command(Constants::ACTION_RUN_SELECTED_ID)->action()->setEnabled(canRun);
|
||||
ActionManager::command(Constants::ACTION_RUN_ALL_NODEPLOY_ID)->action()->setEnabled(canRun);
|
||||
ActionManager::command(Constants::ACTION_RUN_SELECTED_NODEPLOY_ID)->action()->setEnabled(canRun);
|
||||
ActionManager::command(Constants::ACTION_RUN_FAILED_ID)->action()->setEnabled(canRunFailed);
|
||||
ActionManager::command(Constants::ACTION_RUN_FILE_ID)->action()->setEnabled(canRun);
|
||||
ActionManager::command(Constants::ACTION_SCAN_ID)->action()->setEnabled(canScan);
|
||||
@@ -425,7 +469,9 @@ void AutotestPlugin::updateMenuItemsEnabledState()
|
||||
return; // When no context menu, actions do not exists
|
||||
|
||||
ActionManager::command(Constants::ACTION_RUN_UCURSOR)->action()->setEnabled(canRun);
|
||||
ActionManager::command(Constants::ACTION_RUN_UCURSOR_NODEPLOY)->action()->setEnabled(canRun);
|
||||
ActionManager::command(Constants::ACTION_RUN_DBG_UCURSOR)->action()->setEnabled(canRun);
|
||||
ActionManager::command(Constants::ACTION_RUN_DBG_UCURSOR_NODEPLOY)->action()->setEnabled(canRun);
|
||||
}
|
||||
|
||||
void AutotestPlugin::cacheRunConfigChoice(const QString &buildTargetKey, const ChoicePair &choice)
|
||||
|
||||
@@ -176,6 +176,8 @@ void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||
|
||||
QAction *runAll = Core::ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action();
|
||||
QAction *runSelected = Core::ActionManager::command(Constants::ACTION_RUN_SELECTED_ID)->action();
|
||||
QAction *runAllNoDeploy = Core::ActionManager::command(Constants::ACTION_RUN_ALL_NODEPLOY_ID)->action();
|
||||
QAction *runSelectedNoDeploy = Core::ActionManager::command(Constants::ACTION_RUN_SELECTED_NODEPLOY_ID)->action();
|
||||
QAction *selectAll = new QAction(tr("Select All"), &menu);
|
||||
QAction *deselectAll = new QAction(tr("Deselect All"), &menu);
|
||||
// TODO remove?
|
||||
@@ -196,7 +198,9 @@ void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||
menu.addSeparator();
|
||||
|
||||
menu.addAction(runAll);
|
||||
menu.addAction(runAllNoDeploy);
|
||||
menu.addAction(runSelected);
|
||||
menu.addAction(runSelectedNoDeploy);
|
||||
menu.addSeparator();
|
||||
menu.addAction(selectAll);
|
||||
menu.addAction(deselectAll);
|
||||
|
||||
@@ -648,6 +648,13 @@ void TestResultsPane::onCustomContextMenuRequested(const QPoint &pos)
|
||||
});
|
||||
menu.addAction(action);
|
||||
|
||||
action = new QAction(tr("Run This Test Without Deployment"), &menu);
|
||||
action->setEnabled(correlatingItem && correlatingItem->canProvideTestConfiguration());
|
||||
connect(action, &QAction::triggered, this, [this, clicked] {
|
||||
onRunThisTestTriggered(TestRunMode::RunWithoutDeploy, clicked);
|
||||
});
|
||||
menu.addAction(action);
|
||||
|
||||
action = new QAction(tr("Debug This Test"), &menu);
|
||||
bool debugEnabled = false;
|
||||
if (correlatingItem) {
|
||||
@@ -662,6 +669,13 @@ void TestResultsPane::onCustomContextMenuRequested(const QPoint &pos)
|
||||
});
|
||||
menu.addAction(action);
|
||||
|
||||
action = new QAction(tr("Debug This Test Without Deployment"), &menu);
|
||||
action->setEnabled(debugEnabled);
|
||||
connect(action, &QAction::triggered, this, [this, clicked] {
|
||||
onRunThisTestTriggered(TestRunMode::DebugWithoutDeploy, clicked);
|
||||
});
|
||||
menu.addAction(action);
|
||||
|
||||
menu.exec(m_treeView->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user