diff --git a/plugins/perforce/kdevperforce.json b/plugins/perforce/kdevperforce.json index 8399e0d916..744fe0105f 100644 --- a/plugins/perforce/kdevperforce.json +++ b/plugins/perforce/kdevperforce.json @@ -1,63 +1,60 @@ { "KPlugin": { "Authors": [ { "Name": "Morten Danielsen Volden", "Name[x-test]": "xxMorten Danielsen Voldenxx" } ], "Category": "Version Control", "Description": "Provides Integration with Perforce Version Control System", "Description[ca@valencia]": "Proporciona integració amb el sistema de control de versions Perforce", "Description[ca]": "Proporciona integració amb el sistema de control de versions Perforce", "Description[cs]": "Poskytuje integraci Perforce Version Control System", "Description[de]": "Bietet Integration mit der Perforce-Versionsverwaltung", "Description[es]": "Proporciona integración con el sistema de control de versiones Perforce", "Description[fr]": "Fournit une intégration avec le système de contrôle de version Perforce", "Description[gl]": "Fornece integración co sistema de control de versións Perforce.", "Description[it]": "Fornisce l'integrazione con il sistema di controllo versione Perforce", "Description[nl]": "Biedt ondersteuning voor Perforce versiecontrolesysteem", "Description[pl]": "Dostarcza integrację z systemem kontroli wersji Perforce", "Description[pt]": "Oferece a integração com o Sistema de Controlo de Versões Perforce", "Description[sk]": "Poskytuje integráciu s verzionovacím systémom Perforce", "Description[sl]": "Ponuja vgradnjo sistema za nadzor različic Perforce", "Description[sv]": "Tillhandahåller integrering med Perforce versionskontrollsystem", "Description[tr]": "Perforce Sürüm Denetim Sistemi ile Bütünleşme Sağlar", "Description[uk]": "Забезпечує інтеграцію з системою керування версіями Perforce", "Description[x-test]": "xxProvides Integration with Perforce Version Control Systemxx", "Icon": "kdevelop", "Id": "kdevperforce", "License": "GPL", "Name": "Perforce Support", "Name[ca@valencia]": "Implementació del Perforce", "Name[ca]": "Implementació del Perforce", "Name[cs]": "Podpora Perforce", "Name[de]": "Perforce-Unterstützung", "Name[es]": "Implementación de Perforce", "Name[fr]": "Prise en charge de Perforce", "Name[gl]": "Compatibilidade con Perforce", "Name[it]": "Supporto per Perforce", "Name[nl]": "Ondersteuning van Perforce", "Name[pl]": "Obsługa Perforce", "Name[pt]": "Suporte para o Perforce", "Name[sk]": "Podpora Perforce", "Name[sl]": "Podpora za Perforce", "Name[sv]": "Perforce-stöd", "Name[tr]": "Perforce Desteği", "Name[uk]": "Підтримка Perforce", "Name[x-test]": "xxPerforce Supportxx", "ServiceTypes": [ "KDevelop/Plugin" ], "Version": "5.0" }, "X-KDevelop-Category": "Global", - "X-KDevelop-IRequired": [ - "org.kdevelop.IExecutePlugin" - ], "X-KDevelop-Interfaces": [ "org.kdevelop.IBasicVersionControl", "org.kdevelop.ICentralizedVersionControl" ], "X-KDevelop-Mode": "GUI" } diff --git a/plugins/perforce/tests/test_perforce.cpp b/plugins/perforce/tests/test_perforce.cpp index f45d0fca76..9d8e79583f 100644 --- a/plugins/perforce/tests/test_perforce.cpp +++ b/plugins/perforce/tests/test_perforce.cpp @@ -1,189 +1,197 @@ /*************************************************************************** * This file was inspired by KDevelop's git plugin * * Copyright 2008 Evgeniy Ivanov * * * * Adapted for Perforce * * Copyright 2011 Morten Danielsen Volden * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * ***************************************************************************/ #include "test_perforce.h" #include #include #include #include #include #include #define VERIFYJOB(j) \ QVERIFY(j); QVERIFY(j->exec()); QVERIFY((j)->status() == VcsJob::JobSucceeded) const QString tempDir = QDir::tempPath(); const QString perforceTestBaseDirNoSlash(tempDir + "/kdevPerforce_testdir"); const QString perforceTestBaseDir(tempDir + "/kdevPerforce_testdir/"); const QString perforceTestBaseDir2(tempDir + "/kdevPerforce_testdir2/"); const QString perforceConfigFileName(QStringLiteral("p4config.txt")); const QString perforceSrcDir(perforceTestBaseDir + "src/"); const QString perforceTest_FileName(QStringLiteral("testfile")); const QString perforceTest_FileName2(QStringLiteral("foo")); const QString perforceTest_FileName3(QStringLiteral("bar")); using namespace KDevelop; +void PerforcePluginTest::initTestCase() +{ + AutoTestShell::init({QStringLiteral("kdevperforce")}); + TestCore::initialize(); + m_plugin = new PerforcePlugin(TestCore::self()); +} + +void PerforcePluginTest::cleanupTestCase() +{ + delete m_plugin; + TestCore::shutdown(); +} + + void PerforcePluginTest::init() { - AutoTestShell::init({"kdevperforce"}); - m_core = new TestCore(); - m_core->initialize(); - m_plugin = new PerforcePlugin(m_core); /// During test we are setting the executable the plugin uses to our own stub m_plugin->m_perforceExecutable = P4_CLIENT_STUB_EXE; removeTempDirsIfAny(); createNewTempDirs(); } void PerforcePluginTest::createNewTempDirs() { // Now create the basic directory structure QDir tmpdir(tempDir); tmpdir.mkdir(perforceTestBaseDir); //we start it after repoInit, so we still have empty repo QFile f(perforceTestBaseDir + perforceConfigFileName); if (f.open(QIODevice::WriteOnly)) { QTextStream input(&f); input << "P4PORT=127.0.0.1:1666\n"; input << "P4USER=mvo\n"; input << "P4CLIENT=testbed\n"; } f.close(); //Put a file here because the annotate and update function will check for that QFile g(perforceTestBaseDir + perforceTest_FileName); if (g.open(QIODevice::WriteOnly)) { QTextStream input(&g); input << "HELLO WORLD"; } g.close(); tmpdir.mkdir(perforceSrcDir); tmpdir.mkdir(perforceTestBaseDir2); } void PerforcePluginTest::removeTempDirsIfAny() { QDir dir(perforceTestBaseDir); if (dir.exists() && !dir.removeRecursively()) qDebug() << "QDir::removeRecursively(" << perforceTestBaseDir << ") returned false"; QDir dir2(perforceTestBaseDir); if (dir2.exists() && !dir2.removeRecursively()) qDebug() << "QDir::removeRecursively(" << perforceTestBaseDir2 << ") returned false"; } void PerforcePluginTest::cleanup() { - m_core->cleanup(); - delete m_core; removeTempDirsIfAny(); } void PerforcePluginTest::testAdd() { VcsJob* j = m_plugin->add(QList({ QUrl::fromLocalFile(perforceTestBaseDir + perforceTest_FileName) } )); VERIFYJOB(j); } void PerforcePluginTest::testEdit() { VcsJob* j = m_plugin->edit(QList( { QUrl::fromLocalFile(perforceTestBaseDir + perforceTest_FileName) } )); VERIFYJOB(j); } void PerforcePluginTest::testEditMultipleFiles() { QList filesForEdit; filesForEdit.push_back(QUrl::fromLocalFile(perforceTestBaseDir + perforceTest_FileName)); filesForEdit.push_back(QUrl::fromLocalFile(perforceTestBaseDir + perforceTest_FileName2)); filesForEdit.push_back(QUrl::fromLocalFile(perforceTestBaseDir + perforceTest_FileName3)); VcsJob* j = m_plugin->edit(filesForEdit); VERIFYJOB(j); } void PerforcePluginTest::testStatus() { VcsJob* j = m_plugin->status(QList( { QUrl::fromLocalFile(perforceTestBaseDirNoSlash) } )); VERIFYJOB(j); } void PerforcePluginTest::testAnnotate() { VcsJob* j = m_plugin->annotate(QUrl( QUrl::fromLocalFile(perforceTestBaseDir + perforceTest_FileName) )); VERIFYJOB(j); } void PerforcePluginTest::testHistory() { VcsJob* j = m_plugin->log(QUrl( QUrl::fromLocalFile(perforceTestBaseDir + perforceTest_FileName) )); VERIFYJOB(j); } void PerforcePluginTest::testRevert() { VcsJob* j = m_plugin->revert(QList( { QUrl::fromLocalFile(perforceTestBaseDir + perforceTest_FileName) } )); VERIFYJOB(j); } void PerforcePluginTest::testUpdateFile() { VcsJob* j = m_plugin->update(QList( { QUrl::fromLocalFile(perforceTestBaseDir + perforceTest_FileName) } )); VERIFYJOB(j); } void PerforcePluginTest::testUpdateDir() { VcsJob* j = m_plugin->update(QList( { QUrl::fromLocalFile(perforceTestBaseDirNoSlash) } )); VERIFYJOB(j); } void PerforcePluginTest::testCommit() { QString commitMsg(QStringLiteral("this is the commit message")); VcsJob* j = m_plugin->commit(commitMsg, QList( { QUrl::fromLocalFile(perforceTestBaseDirNoSlash) } )); VERIFYJOB(j); } void PerforcePluginTest::testDiff() { VcsRevision srcRevision; srcRevision.setRevisionValue(QVariant(1), VcsRevision::GlobalNumber); VcsRevision dstRevision; dstRevision.setRevisionValue(QVariant(2), VcsRevision::GlobalNumber); VcsJob* j = m_plugin->diff( QUrl::fromLocalFile(perforceTestBaseDir + perforceTest_FileName), srcRevision, dstRevision); VERIFYJOB(j); } QTEST_MAIN(PerforcePluginTest) diff --git a/plugins/perforce/tests/test_perforce.h b/plugins/perforce/tests/test_perforce.h index a2a0b7062c..e3c350413e 100644 --- a/plugins/perforce/tests/test_perforce.h +++ b/plugins/perforce/tests/test_perforce.h @@ -1,58 +1,55 @@ /*************************************************************************** * This file was inspired by KDevelop's git plugin * * Copyright 2008 Evgeniy Ivanov * * * * Adapted for Perforce * * Copyright 2011 Morten Danielsen Volden * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * ***************************************************************************/ #ifndef PERFORCEPLUGIN_TEST_H #define PERFORCEPLUGIN_TEST_H #include class PerforcePlugin; -namespace KDevelop -{ -class TestCore; -} - class PerforcePluginTest : public QObject { Q_OBJECT private Q_SLOTS: + void initTestCase(); + void cleanupTestCase(); void init(); void cleanup(); + void testAdd(); void testEdit(); void testEditMultipleFiles(); void testStatus(); void testAnnotate(); void testHistory(); void testRevert(); void testUpdateFile(); void testUpdateDir(); void testCommit(); void testDiff(); private: PerforcePlugin* m_plugin; - KDevelop::TestCore* m_core; void removeTempDirsIfAny(); void createNewTempDirs(); }; #endif