Commit 1ab5e806 authored by Milian Wolff's avatar Milian Wolff

Enable QStandardPaths test mode in all tests

Among other things this ensures that we don't load plugins that
we don't need in some of our tests, as we no longer check the
user's configuration for which plugin is enabled.
parent 51c038da
......@@ -22,6 +22,7 @@
#include "test_stringhelpers.h"
#include <QTest>
#include <QStandardPaths>
#include <language/duchain/stringhelpers.h>
......@@ -29,6 +30,11 @@ QTEST_MAIN(TestDUChain)
using namespace KDevelop;
void TestDUChain::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
}
void TestDUChain::testFormatComment_data()
{
QTest::addColumn<QByteArray>("input");
......
......@@ -30,6 +30,8 @@ class TestDUChain
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void testFormatComment_data();
void testFormatComment();
......
......@@ -21,6 +21,7 @@
#include <QObject>
#include <QTest>
#include <QStandardPaths>
#include <vector>
#include <algorithm>
......@@ -60,6 +61,8 @@ class TestKDevHash
Q_OBJECT
private Q_SLOTS:
void initTestCase() { QStandardPaths::setTestModeEnabled(true); }
void benchHash_int()
{
runBench<int>();
......
......@@ -23,6 +23,8 @@
#include <outputview/filtereditem.h>
#include <util/path.h>
#include <QStandardPaths>
using namespace KDevelop;
QTEST_GUILESS_MAIN(TestFilteringStrategy)
......@@ -69,6 +71,11 @@ inline QTestData& newRowForPathType(const char *dataTag, TestPathType pathType)
}
void TestFilteringStrategy::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
}
void TestFilteringStrategy::testNoFilterStrategy_data()
{
QTest::addColumn<QString>("line");
......
......@@ -27,6 +27,7 @@ class TestFilteringStrategy : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void testNoFilterStrategy_data();
void testNoFilterStrategy();
void testCompilerFilterStrategy_data();
......
......@@ -21,6 +21,7 @@
#include "../outputmodel.h"
#include <QTest>
#include <QStandardPaths>
QTEST_MAIN(KDevelop::TestOutputModel)
......@@ -29,6 +30,7 @@ namespace KDevelop
TestOutputModel::TestOutputModel(QObject* parent): QObject(parent)
{
QStandardPaths::setTestModeEnabled(true);
}
QStringList generateLines()
......
......@@ -27,6 +27,7 @@
#include <algorithm>
#include <random>
#include <QTest>
#include <QStandardPaths>
QTEST_GUILESS_MAIN(BenchItemRepository)
......@@ -111,6 +112,7 @@ using TestDataRepository = ItemRepository<TestData, TestDataRepositoryItemReques
void BenchItemRepository::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
ItemRepositoryRegistry::initialize(m_repositoryPath);
}
......
......@@ -25,6 +25,7 @@
#include <serialization/itemrepositoryregistry.h>
#include <serialization/indexedstring.h>
#include <QTest>
#include <QStandardPaths>
#include <utility>
......@@ -34,6 +35,7 @@ using namespace KDevelop;
void TestIndexedString::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
ItemRepositoryRegistry::initialize(m_repositoryPath);
}
......
#include <QObject>
#include <QTest>
#include <QStandardPaths>
#include <serialization/itemrepository.h>
#include <serialization/indexedstring.h>
#include <cstdlib>
......@@ -118,6 +119,7 @@ class TestItemRepository
private Q_SLOTS:
void initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
ItemRepositoryRegistry::initialize(m_repositoryPath);
}
void cleanupTestCase()
......
......@@ -19,6 +19,7 @@
#include <QTest>
#include <QSignalSpy>
#include <QStandardPaths>
#include <shell/checkerstatus.h>
#include <KLocalizedString>
......@@ -56,6 +57,7 @@ TestCheckerStatus::TestCheckerStatus()
void TestCheckerStatus::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
m_status.reset(new CheckerStatus());
}
......
......@@ -18,6 +18,7 @@
*/
#include <QTest>
#include <QStandardPaths>
#include <shell/problemstorenode.h>
#include <shell/problem.h>
......@@ -42,6 +43,7 @@ private:
void TestProblemStoreNode::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
m_root.reset(new ProblemStoreNode());
}
......
......@@ -30,9 +30,15 @@
#include <QTest>
#include <QStandardItem>
#include <QStandardItemModel>
#include <QStandardPaths>
using namespace Sublime;
void TestAggregateModel::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
}
void TestAggregateModel::modelAggregationInASingleView()
{
auto *model = new AggregateModel(this);
......
......@@ -26,6 +26,7 @@ class QStandardItemModel;
class TestAggregateModel: public QObject {
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void modelAggregationInASingleView();
private:
......
......@@ -50,6 +50,11 @@ struct ViewCounter {
int count = 0;
};
void TestAreaOperation::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
}
void TestAreaOperation::init()
{
m_controller = new Controller(this);
......
......@@ -31,6 +31,7 @@ namespace Sublime {
class TestAreaOperation: public QObject {
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
......
......@@ -20,6 +20,7 @@
#include <QStringList>
#include <QTest>
#include <QStandardPaths>
#include <sublime/area.h>
#include <sublime/view.h>
......@@ -52,6 +53,11 @@ struct AreaStopper {
QString m_stopAt;
};
void TestAreaWalker::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
}
void TestAreaWalker::viewWalkerModes()
{
auto *controller = new Controller(this);
......
......@@ -23,6 +23,7 @@
class TestAreaWalker: public QObject {
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void viewWalkerModes();
void toolViewWalkerModes();
};
......
......@@ -21,6 +21,7 @@
#include <QTextEdit>
#include <QTest>
#include <QDebug>
#include <QStandardPaths>
#include <sublime/controller.h>
#include <sublime/tooldocument.h>
......@@ -29,6 +30,11 @@
using namespace Sublime;
void TestController::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
}
void TestController::documentDeletion()
{
Controller controller;
......
......@@ -24,6 +24,7 @@
class TestController: public QObject {
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void documentDeletion();
void areaDeletion();
void namedAreas();
......
......@@ -20,6 +20,7 @@
#include <QTextEdit>
#include <QTest>
#include <QStandardPaths>
#include <sublime/controller.h>
#include <sublime/tooldocument.h>
......@@ -27,6 +28,11 @@
using namespace Sublime;
void TestDocument::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
}
void TestDocument::viewDeletion()
{
Controller controller;
......
......@@ -24,6 +24,7 @@
class TestDocument: public QObject {
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void viewDeletion();
};
......
......@@ -25,6 +25,7 @@
#include <QTextEdit>
#include <QToolBar>
#include <QStandardPaths>
#include <sublime/view.h>
#include <sublime/area.h>
......@@ -57,6 +58,11 @@ private:
QList<QAction*> actionList;
};
void TestToolViewToolBar::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
}
void TestToolViewToolBar::init()
{
// this is starting to become a GeneralFixture
......
......@@ -35,6 +35,7 @@ class TestToolViewToolBar : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
......
......@@ -20,6 +20,7 @@
#include <QTextEdit>
#include <QTest>
#include <QStandardPaths>
#include <sublime/controller.h>
#include <sublime/tooldocument.h>
......@@ -60,6 +61,11 @@ protected:
View *newView(Document *doc) override { return new Test(doc); }
};
void TestView::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
}
void TestView::viewReimplementation()
{
Controller controller;
......
......@@ -24,6 +24,7 @@
class TestView: public QObject {
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void widgetDeletion();
void viewReimplementation();
};
......
......@@ -25,6 +25,7 @@
#include <QTextEdit>
#include <QDockWidget>
#include <QFocusEvent>
#include <QStandardPaths>
#include <sublime/view.h>
#include <sublime/area.h>
......@@ -51,6 +52,7 @@ public:
void TestViewActivation::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
qRegisterMetaType<View*>("View*");
}
......
......@@ -19,6 +19,8 @@
#include "autotestshell.h"
#include <QStandardPaths>
using namespace KDevelop;
AutoTestShell::~AutoTestShell() = default;
......@@ -31,6 +33,8 @@ void AutoTestShell::init(const QStringList& plugins)
#endif
qputenv("CLEAR_DUCHAIN_DIR", "1"); // Always clear duchain dir (also to avoid popups asking the user to clear it)
QStandardPaths::setTestModeEnabled(true);
static auto instance = AutoTestShell();
instance.m_plugins = plugins;
s_instance = &instance;
......
......@@ -25,11 +25,17 @@
#include <QTest>
#include <QProcessEnvironment>
#include <QStandardPaths>
QTEST_MAIN(TestEnvironment)
using ProcEnv = QMap<QString, QString>;
void TestEnvironment::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
}
void TestEnvironment::testExpandVariables_data()
{
QTest::addColumn<ProcEnv>("env");
......
......@@ -28,6 +28,8 @@ class TestEnvironment : public QObject
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void testExpandVariables_data();
void testExpandVariables();
};
......
......@@ -23,6 +23,7 @@
#include <QTest>
#include <QSignalSpy>
#include <QStandardPaths>
#include <util/executecompositejob.h>
......@@ -40,6 +41,11 @@ struct JobSpy
QSignalSpy result;
};
void TestExecuteCompositeJob::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
}
void TestExecuteCompositeJob::runOneJob()
{
QPointer<TestJob> slave(new TestJob);
......
......@@ -50,6 +50,8 @@ class TestExecuteCompositeJob : public QObject
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void runOneJob();
void runTwoJobs();
};
......
......@@ -19,7 +19,7 @@
#include "test_foregroundlock.h"
#include <QTest>
#include <QStandardPaths>
#include <QThread>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
#include <QRandomGenerator>
......@@ -60,6 +60,11 @@ public:
}
};
void TestForegroundLock::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
}
void TestForegroundLock::testTryLock_data()
{
QTest::addColumn<int>("numThreads");
......
......@@ -27,6 +27,8 @@ class TestForegroundLock : public QObject
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void testTryLock_data();
void testTryLock();
};
......
......@@ -25,11 +25,17 @@
#include <QString>
#include <QTest>
#include <QStandardPaths>
QTEST_MAIN(TestFormattingHelpers)
using namespace KDevelop;
void TestFormattingHelpers::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
}
void TestFormattingHelpers::testFuzzyMatching()
{
QFETCH(QString, formattedMergedText);
......
......@@ -28,6 +28,8 @@ class TestFormattingHelpers : public QObject
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void testFuzzyMatching();
void testFuzzyMatching_data();
};
......@@ -31,6 +31,7 @@
#include <QStringList>
#include <QTemporaryDir>
#include <QTextStream>
#include <QStandardPaths>
#include <vector>
......@@ -67,6 +68,11 @@ TestKdevFormatSource::~TestKdevFormatSource()
{
}
void TestKdevFormatSource::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
}
void TestKdevFormatSource::testNotFound_data()
{
static const QStringList formatFileData = {};
......
......@@ -41,6 +41,8 @@ public:
~TestKdevFormatSource() override;
private Q_SLOTS:
void initTestCase();
void testNotFound();
void testNotFound_data();
......
......@@ -18,7 +18,7 @@
#include <QObject>
#include <QTest>
#include <QStandardPaths>
#include <QDebug>
#include "../kdevvarlengtharray.h"
......@@ -43,6 +43,8 @@ class TestKDevVarLengthArray : public QObject
Q_OBJECT
private Q_SLOTS:
void initTestCase() { QStandardPaths::setTestModeEnabled(true); }
/**
* Make sure that valgrind does not report any warnings here
* about uninitialized member variables.
......
......@@ -24,11 +24,17 @@
#include "objectlist.h"
#include <QTest>
#include <QStandardPaths>
QTEST_MAIN(TestObjectList)
using namespace KDevelop;
void TestObjectList::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
}
void TestObjectList::testBasicInterface()
{
ObjectList<QObject> list;
......
......@@ -29,6 +29,8 @@ class TestObjectList : public QObject
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void testBasicInterface();
void testDeleteAll();
void testBehaviorOnDestruction();
......