add test for conflicted files

This commit is contained in:
Martin Marmsoler 2022-12-29 16:59:31 +01:00
parent fad1f45252
commit 774285d606
2 changed files with 38 additions and 1 deletions

View File

@ -30,6 +30,7 @@ private slots:
void discardFiles();
void fileMergeCrash();
void dirtySubmoduleAndStagedSubmodule();
void conflictedAndStagedFile();
private:
};
@ -267,7 +268,6 @@ void TestTreeView::dirtySubmoduleAndStagedSubmodule() {
auto doubleTree = repoView->findChild<DoubleTreeWidget *>();
QVERIFY(doubleTree);
doubleTree->fileCountExpansionThreshold = 5;
auto stagedTree = doubleTree->findChild<TreeView *>("Staged");
QVERIFY(stagedTree);
auto unstagedTree = doubleTree->findChild<TreeView *>("Unstaged");
@ -300,6 +300,43 @@ void TestTreeView::dirtySubmoduleAndStagedSubmodule() {
}
}
void TestTreeView::conflictedAndStagedFile() {
INIT_REPO("ConflictedAndStagedFile.zip", false);
auto doubleTree = repoView->findChild<DoubleTreeWidget *>();
QVERIFY(doubleTree);
auto stagedTree = doubleTree->findChild<TreeView *>("Staged");
QVERIFY(stagedTree);
auto unstagedTree = doubleTree->findChild<TreeView *>("Unstaged");
QVERIFY(unstagedTree);
{
QAbstractItemModel *stagedModel = stagedTree->model();
QCOMPARE(stagedModel->rowCount(), 1);
QModelIndex index = stagedModel->index(0, 0); // "folder" folder
QVERIFY(index.isValid());
QCOMPARE(index.data(), "folder");
QCOMPARE(stagedModel->rowCount(index), 1);
index = stagedModel->index(0, 0, index);
QVERIFY(index.isValid());
QCOMPARE(index.data(), "NotConflictedFile.txt");
}
{
QAbstractItemModel *unstagedModel = unstagedTree->model();
QCOMPARE(unstagedModel->rowCount(), 1);
QModelIndex index = unstagedModel->index(0, 0); // "folder" folder
QVERIFY(index.isValid());
QCOMPARE(index.data(), "folder");
QCOMPARE(unstagedModel->rowCount(index), 1);
index = unstagedModel->index(0, 0, index);
QVERIFY(index.isValid());
QCOMPARE(index.data(), "conflictedFile.txt");
}
}
TEST_MAIN(TestTreeView)
#include "TreeView.moc"

Binary file not shown.