Commit fcd1ccd6 authored by Nicolas Carion's avatar Nicolas Carion

[FuzzBug2] Stricter checking when creating AVSplit group

parent 7b495c3d
...@@ -103,6 +103,31 @@ int GroupsModel::groupItems(const std::unordered_set<int> &ids, Fun &undo, Fun & ...@@ -103,6 +103,31 @@ int GroupsModel::groupItems(const std::unordered_set<int> &ids, Fun &undo, Fun &
// We do not create a group with only one element. Instead, we return the id of that element // We do not create a group with only one element. Instead, we return the id of that element
return *(roots.begin()); return *(roots.begin());
} }
if (type == GroupType::AVSplit && !force) {
// additional checks for AVSplit
if (roots.size() != 2) {
// must group exactly two items
return -1;
}
auto it = roots.begin();
int cid1 = *it;
++it;
int cid2 = *it;
auto ptr = m_parent.lock();
if (!ptr) Q_ASSERT(false);
if (cid1 == cid2 || !ptr->isClip(cid1) || !ptr->isClip(cid2)) {
// invalid: we must get two different clips
return -1;
}
int tid1 = ptr->getClipTrackId(cid1);
bool isAudio1 = ptr->getTrackById(tid1)->isAudioTrack();
int tid2 = ptr->getClipTrackId(cid2);
bool isAudio2 = ptr->getTrackById(tid2)->isAudioTrack();
if (isAudio1 == isAudio2) {
// invalid: we must insert one in video the other in audio
return -1;
}
}
int gid = TimelineModel::getNextId(); int gid = TimelineModel::getNextId();
auto operation = groupItems_lambda(gid, roots, type); auto operation = groupItems_lambda(gid, roots, type);
if (operation()) { if (operation()) {
......
...@@ -551,3 +551,83 @@ TEST_CASE("FuzzBug1") ...@@ -551,3 +551,83 @@ TEST_CASE("FuzzBug1")
} }
pCore->m_projectManager = nullptr; pCore->m_projectManager = nullptr;
} }
TEST_CASE("FuzzBug2")
{
auto binModel = pCore->projectItemModel();
std::shared_ptr<DocUndoStack> undoStack = std::make_shared<DocUndoStack>(nullptr);
std::shared_ptr<MarkerListModel> guideModel = std::make_shared<MarkerListModel>(undoStack);
TimelineModel::next_id = 0;
{
Mock<ProjectManager> pmMock;
When(Method(pmMock, undoStack)).AlwaysReturn(undoStack);
ProjectManager &mocked = pmMock.get();
pCore->m_projectManager = &mocked;
TimelineItemModel tim_0(&reg_profile, undoStack);
Mock<TimelineItemModel> timMock_0(tim_0);
auto timeline_0 = std::shared_ptr<TimelineItemModel>(&timMock_0.get(), [](...) {});
TimelineItemModel::finishConstruct(timeline_0, guideModel);
Fake(Method(timMock_0, adjustAssetRange));
REQUIRE(timeline_0->checkConsistency());
undoStack->undo();
REQUIRE(timeline_0->checkConsistency());
undoStack->redo();
REQUIRE(timeline_0->checkConsistency());
{
int dummy_1;
bool res = timeline_0->requestTrackInsertion(-1, dummy_1, "$", false);
REQUIRE(res == true);
}
REQUIRE(timeline_0->checkConsistency());
undoStack->undo();
REQUIRE(timeline_0->checkConsistency());
undoStack->redo();
REQUIRE(timeline_0->checkConsistency());
createProducer(reg_profile, "d", binModel, 0, true);
REQUIRE(timeline_0->checkConsistency());
undoStack->undo();
REQUIRE(timeline_0->checkConsistency());
undoStack->redo();
REQUIRE(timeline_0->checkConsistency());
{
int dummy_3;
bool res = timeline_0->requestClipInsertion("2", 1, 0, dummy_3, true, false, true);
REQUIRE(res == true);
}
REQUIRE(timeline_0->checkConsistency());
undoStack->undo();
REQUIRE(timeline_0->checkConsistency());
undoStack->redo();
REQUIRE(timeline_0->checkConsistency());
{
int dummy_3;
bool res = timeline_0->requestClipInsertion("2", 1, 30, dummy_3, true, false, true);
REQUIRE(res == true);
}
REQUIRE(timeline_0->checkConsistency());
undoStack->undo();
REQUIRE(timeline_0->checkConsistency());
undoStack->redo();
REQUIRE(timeline_0->checkConsistency());
{
int dummy_3;
bool res = timeline_0->requestClipInsertion("2", 1, 60, dummy_3, true, false, true);
REQUIRE(res == true);
}
REQUIRE(timeline_0->checkConsistency());
undoStack->undo();
REQUIRE(timeline_0->checkConsistency());
undoStack->redo();
REQUIRE(timeline_0->checkConsistency());
{
int res = timeline_0->requestClipsGroup({3, 2}, true, GroupType::AVSplit);
REQUIRE(res == -1);
}
REQUIRE(timeline_0->checkConsistency());
undoStack->undo();
REQUIRE(timeline_0->checkConsistency());
undoStack->redo();
REQUIRE(timeline_0->checkConsistency());
}
pCore->m_projectManager = nullptr;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment