Commit aaf94aac authored by hjk's avatar hjk

ClangStaticAnalyzer: Use common pattern to access SessionManager

Change-Id: I335b4ffedd679cb14e9502c98513409859e34c8f
Reviewed-by: Nikolai Kosjar's avatarNikolai Kosjar <nikolai.kosjar@qt.io>
parent cb8d0f06
......@@ -69,12 +69,11 @@ static bool processEventsUntil(const std::function<bool()> condition, int timeOu
class WaitForParsedProjects : public QObject
{
public:
WaitForParsedProjects(ProjectExplorer::SessionManager &sessionManager,
const QStringList &projects)
: m_sessionManager(sessionManager)
, m_projectsToWaitFor(projects)
WaitForParsedProjects(const QStringList &projects)
: m_projectsToWaitFor(projects)
{
connect(&m_sessionManager, &ProjectExplorer::SessionManager::projectFinishedParsing,
connect(SessionManager::instance(),
&ProjectExplorer::SessionManager::projectFinishedParsing,
this, &WaitForParsedProjects::onProjectFinishedParsing);
}
......@@ -91,7 +90,6 @@ public:
}
private:
ProjectExplorer::SessionManager &m_sessionManager;
QStringList m_projectsToWaitFor;
};
......@@ -102,7 +100,6 @@ ClangStaticAnalyzerPreconfiguredSessionTests::ClangStaticAnalyzerPreconfiguredSe
ClangStaticAnalyzerTool *analyzerTool,
QObject *parent)
: QObject(parent)
, m_sessionManager(*ProjectExplorer::SessionManager::instance())
, m_analyzerTool(*analyzerTool)
{
}
......@@ -110,16 +107,16 @@ ClangStaticAnalyzerPreconfiguredSessionTests::ClangStaticAnalyzerPreconfiguredSe
void ClangStaticAnalyzerPreconfiguredSessionTests::initTestCase()
{
const QString preconfiguredSessionName = QLatin1String("ClangStaticAnalyzerPreconfiguredSession");
if (!m_sessionManager.sessions().contains(preconfiguredSessionName))
if (!SessionManager::sessions().contains(preconfiguredSessionName))
QSKIP("Manually preconfigured session 'ClangStaticAnalyzerPreconfiguredSession' needed.");
if (m_sessionManager.activeSession() == preconfiguredSessionName)
if (SessionManager::activeSession() == preconfiguredSessionName)
QSKIP("Session must not be already active.");
// Load session
const QStringList projects = m_sessionManager.projectsForSessionName(preconfiguredSessionName);
WaitForParsedProjects waitForParsedProjects(m_sessionManager, projects);
QVERIFY(m_sessionManager.loadSession(preconfiguredSessionName));
const QStringList projects = SessionManager::projectsForSessionName(preconfiguredSessionName);
WaitForParsedProjects waitForParsedProjects(projects);
QVERIFY(SessionManager::loadSession(preconfiguredSessionName));
QVERIFY(waitForParsedProjects.wait());
}
......@@ -206,7 +203,7 @@ void ClangStaticAnalyzerPreconfiguredSessionTests::testPreconfiguredSession_data
bool hasAddedTestData = false;
foreach (Project *project, validProjects(m_sessionManager.projects())) {
foreach (Project *project, validProjects(SessionManager::projects())) {
foreach (Target *target, validTargets(project)) {
hasAddedTestData = true;
QTest::newRow(dataTagName(project, target)) << project << target;
......@@ -220,17 +217,17 @@ void ClangStaticAnalyzerPreconfiguredSessionTests::testPreconfiguredSession_data
bool ClangStaticAnalyzerPreconfiguredSessionTests::switchToProjectAndTarget(Project *project,
Target *target)
{
Project * const activeProject = m_sessionManager.startupProject();
Project * const activeProject = SessionManager::startupProject();
if (project == activeProject && target == activeProject->activeTarget())
return true; // OK, desired project/target already active.
if (project != activeProject)
m_sessionManager.setStartupProject(project);
SessionManager::setStartupProject(project);
if (target != project->activeTarget()) {
QSignalSpy spyFinishedParsing(ProjectExplorer::SessionManager::instance(),
&ProjectExplorer::SessionManager::projectFinishedParsing);
m_sessionManager.setActiveTarget(project, target, ProjectExplorer::SetActive::NoCascade);
SessionManager::setActiveTarget(project, target, ProjectExplorer::SetActive::NoCascade);
QTC_ASSERT(spyFinishedParsing.wait(30000), return false);
const QVariant projectArgument = spyFinishedParsing.takeFirst().takeFirst();
......
......@@ -31,7 +31,6 @@
namespace ProjectExplorer {
class Project;
class Target;
class SessionManager;
}
namespace ClangStaticAnalyzer {
......@@ -56,7 +55,6 @@ private:
bool switchToProjectAndTarget(ProjectExplorer::Project *project,
ProjectExplorer::Target *target);
ProjectExplorer::SessionManager &m_sessionManager;
ClangStaticAnalyzerTool &m_analyzerTool;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment