2014-10-07 12:30:54 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2014-10-07 12:30:54 +02:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** This file is part of Qt Creator.
|
2014-10-07 12:30:54 +02:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
2014-10-07 12:30:54 +02:00
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-22 10:37:55 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2014-10-07 12:30:54 +02:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2014-10-07 12:30:54 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "autotestplugin.h"
|
|
|
|
|
#include "autotestconstants.h"
|
2017-12-04 10:11:19 +01:00
|
|
|
#include "autotesticons.h"
|
2015-02-16 13:17:53 +01:00
|
|
|
#include "testcodeparser.h"
|
2016-06-01 16:22:50 +02:00
|
|
|
#include "testframeworkmanager.h"
|
2014-10-07 15:51:02 +02:00
|
|
|
#include "testrunner.h"
|
2014-12-04 14:05:19 +01:00
|
|
|
#include "testsettings.h"
|
|
|
|
|
#include "testsettingspage.h"
|
2015-02-13 15:44:18 +01:00
|
|
|
#include "testtreeitem.h"
|
2014-10-07 12:30:54 +02:00
|
|
|
#include "testtreeview.h"
|
|
|
|
|
#include "testtreemodel.h"
|
2014-10-07 15:51:02 +02:00
|
|
|
#include "testresultspane.h"
|
2014-12-18 15:02:07 +01:00
|
|
|
#include "testnavigationwidget.h"
|
2014-10-07 12:30:54 +02:00
|
|
|
|
2016-06-01 16:22:50 +02:00
|
|
|
#include "qtest/qttestframework.h"
|
|
|
|
|
#include "quick/quicktestframework.h"
|
|
|
|
|
#include "gtest/gtestframework.h"
|
|
|
|
|
|
2014-10-07 12:30:54 +02:00
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/icontext.h>
|
2017-12-04 10:11:19 +01:00
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
2014-10-07 12:30:54 +02:00
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
#include <coreplugin/actionmanager/command.h>
|
|
|
|
|
#include <coreplugin/coreconstants.h>
|
2018-02-16 17:57:37 +01:00
|
|
|
#include <coreplugin/messagemanager.h>
|
|
|
|
|
#include <cppeditor/cppeditorconstants.h>
|
2014-10-28 13:02:34 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2017-06-15 10:43:44 +02:00
|
|
|
#include <projectexplorer/buildmanager.h>
|
2017-12-04 10:11:19 +01:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2018-02-16 17:57:37 +01:00
|
|
|
#include <projectexplorer/projectexplorericons.h>
|
2018-08-08 12:40:03 +02:00
|
|
|
#include <projectexplorer/runconfiguration.h>
|
2018-04-06 09:24:48 +02:00
|
|
|
#include <projectexplorer/session.h>
|
|
|
|
|
#include <projectexplorer/target.h>
|
2018-02-16 17:57:37 +01:00
|
|
|
#include <texteditor/texteditor.h>
|
|
|
|
|
#include <utils/textutils.h>
|
2017-12-04 10:11:19 +01:00
|
|
|
#include <utils/utilsicons.h>
|
2014-10-28 13:02:34 +01:00
|
|
|
|
2014-10-07 12:30:54 +02:00
|
|
|
#include <QAction>
|
2018-02-16 17:57:37 +01:00
|
|
|
#include <QList>
|
2014-10-07 12:30:54 +02:00
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
|
#include <QMenu>
|
2018-02-16 17:57:37 +01:00
|
|
|
#include <QTextCursor>
|
2014-10-07 12:30:54 +02:00
|
|
|
#include <QtPlugin>
|
|
|
|
|
|
2015-02-10 14:20:43 +01:00
|
|
|
#ifdef WITH_TESTS
|
|
|
|
|
#include "autotestunittests.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-10-07 12:30:54 +02:00
|
|
|
using namespace Autotest::Internal;
|
2015-03-30 07:47:07 +02:00
|
|
|
using namespace Core;
|
2014-10-07 12:30:54 +02:00
|
|
|
|
2017-02-13 10:05:06 +01:00
|
|
|
static AutotestPlugin *s_instance = nullptr;
|
2014-12-04 14:05:19 +01:00
|
|
|
|
2014-10-07 12:30:54 +02:00
|
|
|
AutotestPlugin::AutotestPlugin()
|
2014-12-04 14:05:19 +01:00
|
|
|
: m_settings(new TestSettings)
|
2014-10-07 12:30:54 +02:00
|
|
|
{
|
2015-01-08 12:51:01 +01:00
|
|
|
// needed to be used in QueuedConnection connects
|
|
|
|
|
qRegisterMetaType<TestResult>();
|
2015-09-07 14:44:45 +02:00
|
|
|
qRegisterMetaType<TestTreeItem *>();
|
2015-02-13 15:44:18 +01:00
|
|
|
qRegisterMetaType<TestCodeLocationAndType>();
|
|
|
|
|
|
2017-02-13 10:05:06 +01:00
|
|
|
s_instance = this;
|
2014-10-07 12:30:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AutotestPlugin::~AutotestPlugin()
|
|
|
|
|
{
|
2018-02-01 09:17:56 +01:00
|
|
|
delete m_navigationWidgetFactory;
|
|
|
|
|
delete m_resultsPane;
|
|
|
|
|
delete m_testSettingPage;
|
2016-06-01 16:22:50 +02:00
|
|
|
delete m_frameworkManager;
|
2014-10-07 12:30:54 +02:00
|
|
|
}
|
|
|
|
|
|
2018-02-01 09:17:56 +01:00
|
|
|
QSharedPointer<TestSettings> AutotestPlugin::settings()
|
2014-12-04 14:05:19 +01:00
|
|
|
{
|
2018-02-01 09:17:56 +01:00
|
|
|
return s_instance->m_settings;
|
2015-01-06 15:24:31 +01:00
|
|
|
}
|
|
|
|
|
|
2014-12-19 11:25:05 +01:00
|
|
|
void AutotestPlugin::initializeMenuEntries()
|
|
|
|
|
{
|
2015-03-30 07:47:07 +02:00
|
|
|
ActionContainer *menu = ActionManager::createMenu(Constants::MENU_ID);
|
2016-01-24 09:03:45 +02:00
|
|
|
menu->menu()->setTitle(tr("&Tests"));
|
2016-10-25 14:30:51 +02:00
|
|
|
menu->setOnAllDisabledBehavior(ActionContainer::Show);
|
2015-03-30 07:47:07 +02:00
|
|
|
|
|
|
|
|
QAction *action = new QAction(tr("Run &All Tests"), this);
|
2017-12-04 10:11:19 +01:00
|
|
|
action->setIcon(Utils::Icons::RUN_SMALL_TOOLBAR.icon());
|
|
|
|
|
action->setToolTip(tr("Run All Tests"));
|
2015-03-30 07:47:07 +02:00
|
|
|
Command *command = ActionManager::registerAction(action, Constants::ACTION_RUN_ALL_ID);
|
2018-08-20 12:44:52 +02:00
|
|
|
command->setDefaultKeySequence(
|
|
|
|
|
QKeySequence(useMacShortcuts ? tr("Ctrl+Meta+T, Ctrl+Meta+A") : tr("Alt+Shift+T,Alt+A")));
|
2017-12-04 10:11:19 +01:00
|
|
|
connect(action, &QAction::triggered, this, &AutotestPlugin::onRunAllTriggered);
|
2017-06-15 10:43:44 +02:00
|
|
|
action->setEnabled(false);
|
2015-03-30 07:47:07 +02:00
|
|
|
menu->addAction(command);
|
|
|
|
|
|
|
|
|
|
action = new QAction(tr("&Run Selected Tests"), this);
|
2017-12-04 10:11:19 +01:00
|
|
|
Utils::Icon runSelectedIcon = Utils::Icons::RUN_SMALL_TOOLBAR;
|
|
|
|
|
for (const Utils::IconMaskAndColor &maskAndColor : Icons::RUN_SELECTED_OVERLAY)
|
|
|
|
|
runSelectedIcon.append(maskAndColor);
|
|
|
|
|
action->setIcon(runSelectedIcon.icon());
|
|
|
|
|
action->setToolTip(tr("Run Selected Tests"));
|
2015-03-30 07:47:07 +02:00
|
|
|
command = ActionManager::registerAction(action, Constants::ACTION_RUN_SELECTED_ID);
|
2018-08-20 12:44:52 +02:00
|
|
|
command->setDefaultKeySequence(
|
|
|
|
|
QKeySequence(useMacShortcuts ? tr("Ctrl+Meta+T, Ctrl+Meta+R") : tr("Alt+Shift+T,Alt+R")));
|
2017-12-04 10:11:19 +01:00
|
|
|
connect(action, &QAction::triggered, this, &AutotestPlugin::onRunSelectedTriggered);
|
2017-06-15 10:43:44 +02:00
|
|
|
action->setEnabled(false);
|
2015-03-30 07:47:07 +02:00
|
|
|
menu->addAction(command);
|
|
|
|
|
|
2018-05-05 22:28:55 +03:00
|
|
|
action = new QAction(tr("Run Tests for Current &File"), this);
|
|
|
|
|
Utils::Icon runFileIcon = Utils::Icons::RUN_SMALL_TOOLBAR;
|
|
|
|
|
for (const Utils::IconMaskAndColor &maskAndColor : Icons::RUN_FILE_OVERLAY)
|
|
|
|
|
runFileIcon.append(maskAndColor);
|
|
|
|
|
action->setIcon(runFileIcon.icon());
|
|
|
|
|
action->setToolTip(tr("Run Tests for Current File"));
|
|
|
|
|
command = ActionManager::registerAction(action, Constants::ACTION_RUN_FILE_ID);
|
2018-08-20 12:44:52 +02:00
|
|
|
command->setDefaultKeySequence(
|
|
|
|
|
QKeySequence(useMacShortcuts ? tr("Ctrl+Meta+T, Ctrl+Meta+F") : tr("Alt+Shift+T,Alt+F")));
|
2018-05-05 22:28:55 +03:00
|
|
|
connect(action, &QAction::triggered, this, &AutotestPlugin::onRunFileTriggered);
|
|
|
|
|
action->setEnabled(false);
|
|
|
|
|
menu->addAction(command);
|
|
|
|
|
|
2015-03-30 07:47:07 +02:00
|
|
|
action = new QAction(tr("Re&scan Tests"), this);
|
|
|
|
|
command = ActionManager::registerAction(action, Constants::ACTION_SCAN_ID);
|
2018-08-20 12:44:52 +02:00
|
|
|
command->setDefaultKeySequence(
|
|
|
|
|
QKeySequence(useMacShortcuts ? tr("Ctrl+Meta+T, Ctrl+Meta+S") : tr("Alt+Shift+T,Alt+S")));
|
|
|
|
|
connect(action, &QAction::triggered, this, []() {
|
2017-03-06 15:24:16 +01:00
|
|
|
TestTreeModel::instance()->parser()->updateTestTree();
|
|
|
|
|
});
|
2014-12-19 11:25:05 +01:00
|
|
|
menu->addAction(command);
|
2015-03-30 07:47:07 +02:00
|
|
|
|
2015-04-14 15:24:31 +02:00
|
|
|
ActionContainer *toolsMenu = ActionManager::actionContainer(Core::Constants::M_TOOLS);
|
|
|
|
|
toolsMenu->addMenu(menu);
|
2017-06-15 10:43:44 +02:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
connect(BuildManager::instance(), &BuildManager::buildStateChanged,
|
|
|
|
|
this, &AutotestPlugin::updateMenuItemsEnabledState);
|
|
|
|
|
connect(BuildManager::instance(), &BuildManager::buildQueueFinished,
|
|
|
|
|
this, &AutotestPlugin::updateMenuItemsEnabledState);
|
2017-12-04 10:11:19 +01:00
|
|
|
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions,
|
|
|
|
|
this, &AutotestPlugin::updateMenuItemsEnabledState);
|
2017-06-15 10:43:44 +02:00
|
|
|
connect(TestTreeModel::instance(), &TestTreeModel::testTreeModelChanged,
|
2015-04-14 15:24:31 +02:00
|
|
|
this, &AutotestPlugin::updateMenuItemsEnabledState);
|
2014-12-19 11:25:05 +01:00
|
|
|
}
|
|
|
|
|
|
2014-10-07 12:30:54 +02:00
|
|
|
bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorString)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(arguments)
|
|
|
|
|
Q_UNUSED(errorString)
|
|
|
|
|
|
2016-06-01 16:22:50 +02:00
|
|
|
m_frameworkManager = TestFrameworkManager::instance();
|
2017-12-04 10:11:19 +01:00
|
|
|
initializeMenuEntries();
|
2016-06-01 16:22:50 +02:00
|
|
|
m_frameworkManager->registerTestFramework(new QtTestFramework);
|
|
|
|
|
m_frameworkManager->registerTestFramework(new QuickTestFramework);
|
|
|
|
|
m_frameworkManager->registerTestFramework(new GTestFramework);
|
|
|
|
|
|
2016-10-05 12:39:23 +02:00
|
|
|
m_frameworkManager->synchronizeSettings(ICore::settings());
|
2018-02-01 09:17:56 +01:00
|
|
|
m_testSettingPage = new TestSettingsPage(m_settings);
|
|
|
|
|
m_navigationWidgetFactory = new TestNavigationWidgetFactory;
|
|
|
|
|
m_resultsPane = TestResultsPane::instance();
|
2014-10-07 12:30:54 +02:00
|
|
|
|
2016-06-06 15:35:00 +02:00
|
|
|
m_frameworkManager->activateFrameworksFromSettings(m_settings);
|
|
|
|
|
TestTreeModel::instance()->syncTestFrameworks();
|
2016-02-01 15:12:10 +01:00
|
|
|
|
2018-08-08 12:40:03 +02:00
|
|
|
connect(ProjectExplorer::SessionManager::instance(),
|
|
|
|
|
&ProjectExplorer::SessionManager::startupProjectChanged, this, [this] {
|
|
|
|
|
m_runconfigCache.clear();
|
|
|
|
|
});
|
2014-10-07 12:30:54 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AutotestPlugin::extensionsInitialized()
|
|
|
|
|
{
|
2018-02-16 17:57:37 +01:00
|
|
|
ActionContainer *contextMenu = ActionManager::actionContainer(CppEditor::Constants::M_CONTEXT);
|
2018-05-23 13:24:04 +02:00
|
|
|
if (!contextMenu) // if QC is started without CppEditor plugin
|
|
|
|
|
return;
|
2018-02-16 17:57:37 +01:00
|
|
|
|
|
|
|
|
QAction *action = new QAction(tr("&Run Test Under Cursor"), this);
|
|
|
|
|
action->setEnabled(false);
|
|
|
|
|
action->setIcon(Utils::Icons::RUN_SMALL_TOOLBAR.icon());
|
|
|
|
|
|
|
|
|
|
Command *command = ActionManager::registerAction(action, Constants::ACTION_RUN_UCURSOR);
|
|
|
|
|
connect(action, &QAction::triggered, std::bind(&AutotestPlugin::onRunUnderCursorTriggered, this,
|
|
|
|
|
TestRunMode::Run));
|
|
|
|
|
contextMenu->addSeparator();
|
|
|
|
|
contextMenu->addAction(command);
|
|
|
|
|
|
|
|
|
|
action = new QAction(tr("&Debug Test Under Cursor"), this);;
|
|
|
|
|
action->setEnabled(false);
|
|
|
|
|
action->setIcon(ProjectExplorer::Icons::DEBUG_START_SMALL.icon());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
command = ActionManager::registerAction(action, Constants::ACTION_RUN_DBG_UCURSOR);
|
|
|
|
|
connect(action, &QAction::triggered, std::bind(&AutotestPlugin::onRunUnderCursorTriggered, this,
|
|
|
|
|
TestRunMode::Debug));
|
|
|
|
|
contextMenu->addAction(command);
|
|
|
|
|
contextMenu->addSeparator();
|
2014-10-07 12:30:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExtensionSystem::IPlugin::ShutdownFlag AutotestPlugin::aboutToShutdown()
|
|
|
|
|
{
|
2016-07-08 12:53:57 +02:00
|
|
|
TestTreeModel::instance()->parser()->aboutToShutdown();
|
2014-10-07 12:30:54 +02:00
|
|
|
return SynchronousShutdown;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-30 07:47:07 +02:00
|
|
|
void AutotestPlugin::onRunAllTriggered()
|
|
|
|
|
{
|
|
|
|
|
TestRunner *runner = TestRunner::instance();
|
|
|
|
|
TestTreeModel *model = TestTreeModel::instance();
|
|
|
|
|
runner->setSelectedTests(model->getAllTestCases());
|
2017-09-05 13:57:22 +02:00
|
|
|
runner->prepareToRunTests(TestRunMode::Run);
|
2015-03-30 07:47:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AutotestPlugin::onRunSelectedTriggered()
|
|
|
|
|
{
|
|
|
|
|
TestRunner *runner = TestRunner::instance();
|
|
|
|
|
TestTreeModel *model = TestTreeModel::instance();
|
|
|
|
|
runner->setSelectedTests(model->getSelectedTests());
|
2017-09-05 13:57:22 +02:00
|
|
|
runner->prepareToRunTests(TestRunMode::Run);
|
2015-03-30 07:47:07 +02:00
|
|
|
}
|
|
|
|
|
|
2018-05-05 22:28:55 +03:00
|
|
|
void AutotestPlugin::onRunFileTriggered()
|
|
|
|
|
{
|
|
|
|
|
const IDocument *document = EditorManager::currentDocument();
|
|
|
|
|
if (!document)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const Utils::FileName &fileName = document->filePath();
|
|
|
|
|
if (fileName.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
TestTreeModel *model = TestTreeModel::instance();
|
|
|
|
|
const QList<TestConfiguration *> tests = model->getTestsForFile(fileName);
|
|
|
|
|
if (tests.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
TestRunner *runner = TestRunner::instance();
|
|
|
|
|
runner->setSelectedTests(tests);
|
|
|
|
|
runner->prepareToRunTests(TestRunMode::Run);
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-16 17:57:37 +01:00
|
|
|
void AutotestPlugin::onRunUnderCursorTriggered(TestRunMode mode)
|
|
|
|
|
{
|
|
|
|
|
QTextCursor cursor = Utils::Text::wordStartCursor(
|
|
|
|
|
TextEditor::BaseTextEditor::currentTextEditor()->editorWidget()->textCursor());
|
|
|
|
|
cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
|
|
|
|
|
const QString text = cursor.selectedText();
|
|
|
|
|
if (text.isEmpty())
|
|
|
|
|
return; // Do not trigger when no name under cursor
|
|
|
|
|
|
|
|
|
|
const QList<TestTreeItem *> testsItems = TestTreeModel::instance()->testItemsByName(text);
|
|
|
|
|
if (testsItems.isEmpty())
|
|
|
|
|
return; // Wrong location triggered
|
|
|
|
|
|
|
|
|
|
QList<TestConfiguration *> testsToRun;
|
|
|
|
|
for (const TestTreeItem * item : testsItems){
|
|
|
|
|
if (TestConfiguration *cfg = item->asConfiguration(mode))
|
|
|
|
|
testsToRun << cfg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (testsToRun.isEmpty()) {
|
|
|
|
|
MessageManager::write(tr("Selected test was not found (%1).").arg(text), MessageManager::Flash);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto runner = TestRunner::instance();
|
|
|
|
|
runner->setSelectedTests(testsToRun);
|
|
|
|
|
runner->prepareToRunTests(mode);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-30 07:47:07 +02:00
|
|
|
void AutotestPlugin::updateMenuItemsEnabledState()
|
|
|
|
|
{
|
2018-04-06 09:24:48 +02:00
|
|
|
const ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
|
|
|
|
|
const ProjectExplorer::Target *target = project ? project->activeTarget() : nullptr;
|
2018-02-28 13:08:05 +01:00
|
|
|
const bool canScan = !TestRunner::instance()->isTestRunning()
|
|
|
|
|
&& TestTreeModel::instance()->parser()->state() == TestCodeParser::Idle;
|
|
|
|
|
const bool hasTests = TestTreeModel::instance()->hasTests();
|
2018-04-06 09:24:48 +02:00
|
|
|
// avoid expensive call to PE::canRunStartupProject() - limit to minimum necessary checks
|
2018-02-28 13:08:05 +01:00
|
|
|
const bool canRun = hasTests && canScan
|
2018-04-06 09:24:48 +02:00
|
|
|
&& project && !project->needsConfiguration()
|
|
|
|
|
&& target && target->activeRunConfiguration()
|
|
|
|
|
&& !ProjectExplorer::BuildManager::isBuilding();
|
2015-03-30 07:47:07 +02:00
|
|
|
|
2018-02-28 13:08:05 +01:00
|
|
|
ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action()->setEnabled(canRun);
|
|
|
|
|
ActionManager::command(Constants::ACTION_RUN_SELECTED_ID)->action()->setEnabled(canRun);
|
2018-05-05 22:28:55 +03:00
|
|
|
ActionManager::command(Constants::ACTION_RUN_FILE_ID)->action()->setEnabled(canRun);
|
2018-02-28 13:08:05 +01:00
|
|
|
ActionManager::command(Constants::ACTION_SCAN_ID)->action()->setEnabled(canScan);
|
2018-02-16 17:57:37 +01:00
|
|
|
|
|
|
|
|
ActionContainer *contextMenu = ActionManager::actionContainer(CppEditor::Constants::M_CONTEXT);
|
|
|
|
|
if (!contextMenu)
|
|
|
|
|
return; // When no context menu, actions do not exists
|
|
|
|
|
|
|
|
|
|
ActionManager::command(Constants::ACTION_RUN_UCURSOR)->action()->setEnabled(canRun);
|
|
|
|
|
ActionManager::command(Constants::ACTION_RUN_DBG_UCURSOR)->action()->setEnabled(canRun);
|
2015-03-30 07:47:07 +02:00
|
|
|
}
|
|
|
|
|
|
2018-08-08 12:40:03 +02:00
|
|
|
void AutotestPlugin::cacheRunConfigChoice(const QString &buildTargetKey, const ChoicePair &choice)
|
|
|
|
|
{
|
|
|
|
|
if (s_instance)
|
|
|
|
|
s_instance->m_runconfigCache.insert(buildTargetKey, choice);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ChoicePair AutotestPlugin::cachedChoiceFor(const QString &buildTargetKey)
|
|
|
|
|
{
|
|
|
|
|
return s_instance ? s_instance->m_runconfigCache.value(buildTargetKey) : ChoicePair();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AutotestPlugin::clearChoiceCache()
|
|
|
|
|
{
|
|
|
|
|
if (s_instance)
|
|
|
|
|
s_instance->m_runconfigCache.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-10 14:20:43 +01:00
|
|
|
QList<QObject *> AutotestPlugin::createTestObjects() const
|
|
|
|
|
{
|
|
|
|
|
QList<QObject *> tests;
|
|
|
|
|
#ifdef WITH_TESTS
|
|
|
|
|
tests << new AutoTestUnitTests(TestTreeModel::instance());
|
|
|
|
|
#endif
|
|
|
|
|
return tests;
|
|
|
|
|
}
|
2018-08-08 12:40:03 +02:00
|
|
|
|
|
|
|
|
bool ChoicePair::matches(const ProjectExplorer::RunConfiguration *rc) const
|
|
|
|
|
{
|
|
|
|
|
return rc ? (rc->displayName() == displayName && rc->runnable().executable == executable)
|
|
|
|
|
: false;
|
|
|
|
|
}
|