modelmanagertesthelper.h 3.34 KB
Newer Older
1 2
/****************************************************************************
**
Eike Ziller's avatar
Eike Ziller committed
3 4
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
5 6 7 8 9 10 11
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
Eike Ziller's avatar
Eike Ziller committed
12 13
** a written agreement between you and The Qt Company.  For licensing terms and
** conditions see http://www.qt.io/terms-conditions.  For further information
Eike Ziller's avatar
Eike Ziller committed
14
** use the contact form at http://www.qt.io/contact-us.
15 16 17
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
Eike Ziller's avatar
Eike Ziller committed
18 19 20 21 22 23
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file.  Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
**
Eike Ziller's avatar
Eike Ziller committed
25 26
** In addition, as a special exception, The Qt Company gives you certain additional
** rights.  These rights are described in The Qt Company LGPL Exception
27 28 29 30 31 32 33
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/

#ifndef CPPTOOLS_INTERNAL_MODELMANAGERTESTHELPER_H
#define CPPTOOLS_INTERNAL_MODELMANAGERTESTHELPER_H

34
#include "cpptools_global.h"
35 36
#include "cppmodelmanager.h"

37 38
#include <projectexplorer/project.h>

39 40 41
#include <QObject>

namespace CppTools {
42
namespace Tests {
43

44
class CPPTOOLS_EXPORT TestProject: public ProjectExplorer::Project
45 46 47 48 49
{
    Q_OBJECT

public:
    TestProject(const QString &name, QObject *parent);
50
    ~TestProject() override;
51

52 53 54 55
    QString displayName() const override { return m_name; }
    Core::IDocument *document() const override { return 0; }
    ProjectExplorer::IProjectManager *projectManager() const override { return 0; }
    ProjectExplorer::ProjectNode *rootProjectNode() const override { return 0; }
56

57
    QStringList files(FilesMode fileMode) const override { Q_UNUSED(fileMode); return QStringList(); }
58 59 60 61 62

private:
    QString m_name;
};

63
class CPPTOOLS_EXPORT ModelManagerTestHelper: public QObject
64 65 66 67 68 69
{
    Q_OBJECT

public:
    typedef ProjectExplorer::Project Project;

70 71
    explicit ModelManagerTestHelper(QObject *parent = 0,
                                    bool testOnlyForCleanedProjects = true);
72
    ~ModelManagerTestHelper() override;
73 74 75 76 77

    void cleanup();

    Project *createProject(const QString &name);

78 79
    QSet<QString> updateProjectInfo(const ProjectInfo &projectInfo);

80
    void resetRefreshedSourceFiles();
81
    QSet<QString> waitForRefreshedSourceFiles();
82
    void waitForFinishedGc();
83

84 85 86
signals:
    void aboutToRemoveProject(ProjectExplorer::Project *project);
    void projectAdded(ProjectExplorer::Project*);
87 88

public slots:
89
    void sourceFilesRefreshed(const QSet<QString> &files);
90
    void gcFinished();
91 92

private:
93
    bool m_gcFinished;
94
    bool m_refreshHappened;
95
    bool m_testOnlyForCleanedProjects;
96
    QSet<QString> m_lastRefreshedSourceFiles;
97 98
};

99
} // namespace Tests
100 101 102
} // namespace CppTools

#endif // CPPTOOLS_INTERNAL_MODELMANAGERTESTHELPER_H