Changeset View
Changeset View
Standalone View
Standalone View
tests/test_mercurial.cpp
Show All 21 Lines | |||||
22 | */ | 22 | */ | ||
23 | 23 | | |||
24 | #include "test_mercurial.h" | 24 | #include "test_mercurial.h" | ||
25 | 25 | | |||
26 | #include <QtTest/QtTest> | 26 | #include <QtTest/QtTest> | ||
27 | #include <tests/testcore.h> | 27 | #include <tests/testcore.h> | ||
28 | #include <tests/autotestshell.h> | 28 | #include <tests/autotestshell.h> | ||
29 | 29 | | |||
30 | #include <QScopedPointer> | ||||
30 | #include <QUrl> | 31 | #include <QUrl> | ||
31 | 32 | | |||
32 | #include <KIO/DeleteJob> | 33 | #include <KIO/DeleteJob> | ||
33 | 34 | | |||
34 | #include <vcs/dvcs/dvcsjob.h> | 35 | #include <vcs/dvcs/dvcsjob.h> | ||
35 | #include <vcs/vcsannotation.h> | 36 | #include <vcs/vcsannotation.h> | ||
36 | 37 | | |||
37 | #include "../mercurialplugin.h" | 38 | #include "../mercurialplugin.h" | ||
38 | #include "../mercurialannotatejob.h" | 39 | #include "../mercurialannotatejob.h" | ||
40 | #include "../models/mercurialheadsmodel.h" | ||||
39 | #include "debug.h" | 41 | #include "debug.h" | ||
40 | 42 | | |||
41 | using namespace KDevelop; | 43 | using namespace KDevelop; | ||
42 | 44 | | |||
43 | namespace | 45 | namespace | ||
44 | { | 46 | { | ||
45 | const QString tempDir = QDir::tempPath(); | 47 | const QString tempDir = QDir::tempPath(); | ||
46 | const QString MercurialTestDir1("kdevMercurial_testdir"); | 48 | const QString MercurialTestDir1("kdevMercurial_testdir"); | ||
▲ Show 20 Lines • Show All 309 Lines • ▼ Show 20 Line(s) | 342 | { | |||
356 | }; | 358 | }; | ||
357 | verifyAnnotateJobFailed(MercurialAnnotateJob::TestCase::Status); | 359 | verifyAnnotateJobFailed(MercurialAnnotateJob::TestCase::Status); | ||
358 | //verifyAnnotateJobFailed(MercurialAnnotateJob::TestCase::Commit); | 360 | //verifyAnnotateJobFailed(MercurialAnnotateJob::TestCase::Commit); | ||
359 | verifyAnnotateJobFailed(MercurialAnnotateJob::TestCase::Annotate); | 361 | verifyAnnotateJobFailed(MercurialAnnotateJob::TestCase::Annotate); | ||
360 | verifyAnnotateJobFailed(MercurialAnnotateJob::TestCase::Log); | 362 | verifyAnnotateJobFailed(MercurialAnnotateJob::TestCase::Log); | ||
361 | //verifyAnnotateJobFailed(MercurialAnnotateJob::TestCase::Strip); | 363 | //verifyAnnotateJobFailed(MercurialAnnotateJob::TestCase::Strip); | ||
362 | } | 364 | } | ||
363 | 365 | | |||
366 | void MercurialTest::testHeads() | ||||
367 | { | ||||
368 | repoInit(); | ||||
369 | addFiles(); | ||||
370 | commitFiles(); | ||||
371 | | ||||
372 | VcsRevision revision; | ||||
373 | revision.setRevisionValue(0, KDevelop::VcsRevision::GlobalNumber); | ||||
374 | auto job = m_proxy->checkoutHead(QUrl::fromLocalFile(mercurialTest_BaseDir), revision); | ||||
375 | verifyJobSucceed(job); | ||||
376 | | ||||
377 | writeToFile(mercurialTest_BaseDir + mercurialTest_FileName, "new head content", QIODevice::Append); | ||||
378 | | ||||
379 | auto j = m_proxy->commit(QString("new head"), {QUrl::fromLocalFile(mercurialTest_BaseDir)}, KDevelop::IBasicVersionControl::Recursive); | ||||
380 | verifyJobSucceed(j); | ||||
381 | | ||||
382 | QScopedPointer<MercurialHeadsModel> headsModel(new MercurialHeadsModel(m_proxy, QUrl::fromLocalFile(mercurialTest_BaseDir), nullptr)); | ||||
383 | headsModel->update(); | ||||
384 | | ||||
385 | QSignalSpy waiter(headsModel.data(), &MercurialHeadsModel::updateComplete); | ||||
386 | QVERIFY(waiter.wait()); | ||||
387 | QVERIFY(waiter.count() == 1); | ||||
388 | | ||||
389 | QCOMPARE(headsModel->rowCount(), 2); | ||||
390 | auto rev2 = headsModel->data(headsModel->index(0, VcsBasicEventModel::RevisionColumn)).toLongLong(); | ||||
391 | auto rev1 = headsModel->data(headsModel->index(1, VcsBasicEventModel::RevisionColumn)).toLongLong(); | ||||
392 | QCOMPARE(rev2, 2); | ||||
393 | QCOMPARE(rev1, 1); | ||||
394 | } | ||||
395 | | ||||
364 | QTEST_MAIN(MercurialTest) | 396 | QTEST_MAIN(MercurialTest) |