AutoTest: Add project based {en|dis}abling of test frameworks

Provide integration into the 'Project' view which allows to set
some settings on a per project base.
For now only enabling or disabling of test frameworks.

Task-number: QTCREATORBUG-16704
Change-Id: Iedd9a300164931e07a21cbb4e5a222be3266c81e
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2019-08-05 15:47:10 +02:00
committed by David Schulz
parent edcd955aad
commit 43e27f76b3
13 changed files with 476 additions and 49 deletions

View File

@@ -26,8 +26,10 @@
#include "autotestplugin.h"
#include "autotestconstants.h"
#include "autotesticons.h"
#include "projectsettingswidget.h"
#include "testcodeparser.h"
#include "testframeworkmanager.h"
#include "testprojectsettings.h"
#include "testrunner.h"
#include "testsettings.h"
#include "testsettingspage.h"
@@ -54,6 +56,7 @@
#include <projectexplorer/buildmanager.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorericons.h>
#include <projectexplorer/projectpanelfactory.h>
#include <projectexplorer/runconfiguration.h>
#include <projectexplorer/session.h>
#include <projectexplorer/target.h>
@@ -78,6 +81,7 @@ using namespace Autotest::Internal;
using namespace Core;
static AutotestPlugin *s_instance = nullptr;
static QHash<ProjectExplorer::Project *, TestProjectSettings *> s_projectSettings;
AutotestPlugin::AutotestPlugin()
: m_settings(new TestSettings)
@@ -103,6 +107,15 @@ QSharedPointer<TestSettings> AutotestPlugin::settings()
return s_instance->m_settings;
}
TestProjectSettings *AutotestPlugin::projectSettings(ProjectExplorer::Project *project)
{
auto &settings = s_projectSettings[project];
if (!settings)
settings = new TestProjectSettings(project);
return settings;
}
void AutotestPlugin::initializeMenuEntries()
{
ActionContainer *menu = ActionManager::createMenu(Constants::MENU_ID);
@@ -184,13 +197,27 @@ bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorStri
m_navigationWidgetFactory = new TestNavigationWidgetFactory;
m_resultsPane = TestResultsPane::instance();
auto panelFactory = new ProjectExplorer::ProjectPanelFactory();
panelFactory->setPriority(666);
// panelFactory->setIcon(); // TODO ?
panelFactory->setDisplayName(tr("Testing"));
panelFactory->setCreateWidgetFunction([](ProjectExplorer::Project *project) {
return new ProjectTestSettingsWidget(project);
});
ProjectExplorer::ProjectPanelFactory::registerFactory(panelFactory);
m_frameworkManager->activateFrameworksFromSettings(m_settings);
TestTreeModel::instance()->syncTestFrameworks();
TestTreeModel::instance()->scheduleTestFrameworksSync(true);
connect(ProjectExplorer::SessionManager::instance(),
&ProjectExplorer::SessionManager::startupProjectChanged, this, [this] {
m_runconfigCache.clear();
});
connect(ProjectExplorer::SessionManager::instance(),
&ProjectExplorer::SessionManager::aboutToRemoveProject,
this, [] (ProjectExplorer::Project *project) {
delete s_projectSettings.take(project);
});
return true;
}