Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/engraving/tests/chordsymbol_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@
#include "engraving/dom/part.h"
#include "engraving/dom/score.h"
#include "engraving/dom/segment.h"
#include "engraving/editing/editdata.h"
#include "engraving/editing/transpose.h"

#include "utils/scorerw.h"
#include "utils/scorecomp.h"

using namespace mu::engraving;

static constexpr double POSITION_ERROR = 1e-6;

static const String CHORDSYMBOL_DATA_DIR("chordsymbol_data/");

class Engraving_ChordSymbolTests : public ::testing::Test
Expand Down Expand Up @@ -140,6 +143,43 @@ TEST_F(Engraving_ChordSymbolTests, testAddLink)
test_post(score, u"add-link");
}

TEST_F(Engraving_ChordSymbolTests, harmonyEditKeepsDisplayPosition)
{
MasterScore* score = test_pre(u"add-link");
ASSERT_TRUE(score);

Segment* seg = score->firstSegment(SegmentType::ChordRest);
ASSERT_TRUE(seg);
ChordRest* cr = seg->cr(0);
ASSERT_TRUE(cr);

Harmony* harmony = new Harmony(cr->segment());
harmony->setHarmony(u"C");
harmony->setTrack(cr->track());
harmony->setParent(cr->segment());
score->undoAddElement(harmony);
score->doLayout();

const double x = harmony->canvasPos().x();
const double y = harmony->canvasPos().y();

EditData ed;
harmony->startEdit(ed);

EXPECT_NEAR(harmony->canvasPos().x(), x, POSITION_ERROR);
EXPECT_NEAR(harmony->canvasPos().y(), y, POSITION_ERROR);

ed.s = String(u"7");
harmony->cursor()->moveCursorToEnd();
harmony->edit(ed);

EXPECT_NEAR(harmony->canvasPos().x(), x, POSITION_ERROR);
EXPECT_NEAR(harmony->canvasPos().y(), y, POSITION_ERROR);

harmony->endEdit(ed);
delete score;
}

TEST_F(Engraving_ChordSymbolTests, testAddPart)
{
MasterScore* score = test_pre(u"add-part");
Expand Down
Loading