Esempio n. 1
0
TEST(CmnModuleTest, TestTieMembership) {
    MeiDocument* doc = createMeiDocument();

    MeiElement* layer = doc->getElementById("id-layer");
    MeiElement* measure = doc->getElementById("id-measure");

    Note* n1 = new Note();
    Note* n2 = new Note();
    Note* n3 = new Note();
    Note* n4 = new Note();

    layer->addChild(n1);
    layer->addChild(n2);
    layer->addChild(n3);
    layer->addChild(n4);

    Tie* t1 = new Tie();
    measure->addChild(t1);

    t1->m_Startid.setStartid(n1->getId());
    t1->m_Startendid.setEndid(n4->getId());
    t1->m_Staffident.setStaff("staffname");
    
    vector<MeiElement*> members = t1->getMembers();
    ASSERT_EQ(4, members.size());
}
Esempio n. 2
0
// after adding a root to a document, you can find an element
TEST(TestMeiDocument, ElementById) {
    Mei *mei = new Mei();
    Music *mus = new Music();
    Body *body = new Body();
    Staff *staff = new Staff();
    Staff *s2 = new Staff();
    Note *n1 = new Note();
    string wantedId = n1->getId();
    Note *n2 = new Note();
    Note *n3 = new Note();
    Note *n4 = new Note();
    MeiDocument *doc = new MeiDocument();

    ASSERT_EQ(NULL, doc->getElementById(wantedId));

    mei->addChild(mus);
    mus->addChild(body);
    body->addChild(staff);
    body->addChild(s2);
    staff->addChild(n1);
    staff->addChild(n2);
    staff->addChild(n3);
    s2->addChild(n4);

    doc->setRootElement(mei);

    ASSERT_EQ(n1, doc->getElementById(wantedId));

    ASSERT_EQ(NULL, doc->getElementById("some-unknown-id"));

    // After adding the root element, making a new element works
    Note *n5 = new Note();
    string newid = n5->getId();
    s2->addChild(n5);
    ASSERT_EQ(n5, doc->getElementById(newid));

    // removing the element from the document, clear from document map
    s2->removeChild(n5);
    ASSERT_EQ(NULL, doc->getElementById(newid));
}