Beispiel #1
0
    TEST_FIXTURE(InteractorTestFixture, Interactor_SelectObjectAtScreenPoint)
    {
        //as coordinates conversion is involved, the View must be rendered
        MyDoorway platform;
        LibraryScope libraryScope(cout, &platform);
        libraryScope.set_default_fonts_path(TESTLIB_FONTS_PATH);
        SpDocument spDoc( new Document(libraryScope) );
        spDoc->from_string("(lenmusdoc (vers 0.0) (content (score (vers 1.6) "
            "(instrument (musicData (clef G)(key e)(n c4 q)(r q)(barline simple))))))" );
        VerticalBookView* pView = Injector::inject_VerticalBookView(libraryScope, spDoc.get());
        SpInteractor pIntor(Injector::inject_Interactor(libraryScope, WpDocument(spDoc), pView, NULL));
        pView->set_interactor(pIntor.get());
        RenderingBuffer rbuf;
        pView->set_rendering_buffer(&rbuf);
        pView->redraw_bitmap();

        GraphicModel* pModel = pIntor->get_graphic_model();
        GmoBoxDocPage* pPage = pModel->get_page(0);     //DocPage
        GmoBox* pBDPC = pPage->get_child_box(0);        //DocPageContent
        GmoBox* pBSP = pBDPC->get_child_box(0);         //ScorePage
        GmoBox* pBSys = pBSP->get_child_box(0);         //System
        GmoBox* pBSlice = pBSys->get_child_box(0);          //Slice
        GmoBox* pBSliceInstr = pBSlice->get_child_box(0);   //SliceInsr
        GmoShape* pClef = pBSliceInstr->get_shape(0);   //Clef
        LUnits x = (pClef->get_left() + pClef->get_right()) / 2.0f;
        LUnits y = (pClef->get_top() + pClef->get_bottom()) / 2.0f;

        double vx = x;
        double vy = y;
        pIntor->model_point_to_screen(&vx, &vy, 0);

        pIntor->task_action_select_object_and_show_contextual_menu(Pixels(vx), Pixels(vy), 0);

        CHECK( pIntor->is_in_selection(pClef) == true );
    }
    TEST_FIXTURE(DocLayouterTestFixture, DocLayouter_EmptyScore_TwoInstruments)
    {
        Document doc(m_libraryScope);
        doc.from_string("(lenmusdoc (vers 0.0) (content (score (vers 1.6) "
            "(instrument (musicData )) (instrument (musicData )) )))" );
        DocLayouter dl( doc.get_im_model(), m_libraryScope);
        dl.layout_document();
        GraphicModel* pGModel = dl.get_graphic_model();
        CHECK( pGModel->get_num_pages() == 1 );
        GmoBoxDocPage* pPage = pGModel->get_page(0);
        CHECK( pPage->get_num_boxes() == 1 );
        GmoBox* pBDPC = pPage->get_child_box(0);    //DocPageContent
        CHECK( pBDPC->get_num_boxes() == 1 );
        GmoBox* pBSP = pBDPC->get_child_box(0);     //ScorePage
        CHECK( pBSP->get_num_boxes() == 1 );
        GmoBoxSystem* pBSys = dynamic_cast<GmoBoxSystem*>( pBSP->get_child_box(0) );
        CHECK( pBSys->get_num_shapes() == 2 );
        GmoShape* pShape = pBSys->get_staff_shape(0);
        CHECK( pShape != NULL );
        CHECK( pShape->is_shape_staff() == true );
        GmoShapeStaff* pSS = dynamic_cast<GmoShapeStaff*>(pShape);
        CHECK( pSS->get_num_staff() == 0 );
        pShape = pBSys->get_staff_shape(1);
        CHECK( pShape != NULL );
        CHECK( pShape->is_shape_staff() == true );
        pSS = dynamic_cast<GmoShapeStaff*>(pShape);
        CHECK( pSS->get_num_staff() == 0 );
        CHECK( pBSys->get_num_boxes() == 0 );

        delete pGModel;
    }
 TEST_FIXTURE(DocLayouterTestFixture, DocLayouter_BoxSystemHasStaffShape)
 {
     Document doc(m_libraryScope);
     doc.from_string("(lenmusdoc (vers 0.0) "
         "(pageLayout (pageSize 24000 35700)(pageMargins 1000 1500 3000 2500 4000) landscape) "
         "(content (score (vers 1.6) "
         "(instrument (musicData (clef G)(key e)(n c4 q)(r q)(barline simple))))))" );
     DocLayouter dl( doc.get_im_model(), m_libraryScope);
     dl.layout_document();
     GraphicModel* pGModel = dl.get_graphic_model();
     GmoBoxDocPage* pPage = pGModel->get_page(0);
     GmoBox* pBDPC = pPage->get_child_box(0);    //DocPageContent
     GmoBox* pBSP = pBDPC->get_child_box(0);     //ScorePage
     GmoBox* pBSys = pBSP->get_child_box(0);     //System
     GmoShape* pShape = pBSys->get_shape(0);     //ShapeStaff
     CHECK( pShape != NULL );
     CHECK( pShape->is_shape_staff() == true );
     //CHECK( pShape->get_width() == 16000.0f );
     delete pGModel;
 }
Beispiel #4
0
    TEST_FIXTURE(InteractorTestFixture, Interactor_SelectObject)
    {
        SpDocument spDoc( new Document(m_libraryScope) );
        spDoc->from_string("(lenmusdoc (vers 0.0) (content (score (vers 1.6) "
            "(instrument (musicData (clef G)(key e)(n c4 q)(r q)(barline simple))))))" );
        View* pView = Injector::inject_View(m_libraryScope, ViewFactory::k_view_simple,
                                            spDoc.get());
        SpInteractor pIntor(Injector::inject_Interactor(m_libraryScope, WpDocument(spDoc), pView, NULL));
        pView->set_interactor(pIntor.get());
        GraphicModel* pModel = pIntor->get_graphic_model();
        GmoBoxDocPage* pPage = pModel->get_page(0);     //DocPage
        GmoBox* pBDPC = pPage->get_child_box(0);        //DocPageContent
        GmoBox* pBSP = pBDPC->get_child_box(0);         //ScorePage
        GmoBox* pBSys = pBSP->get_child_box(0);         //System
        GmoBox* pBSlice = pBSys->get_child_box(0);          //Slice
        GmoBox* pBSliceInstr = pBSlice->get_child_box(0);   //SliceInsr
        GmoShape* pClef = pBSliceInstr->get_shape(0);      //Clef

        pIntor->select_object(pClef);

        CHECK( pIntor->is_in_selection(pClef) == true );
    }
    TEST_FIXTURE(DocLayouterTestFixture, DocLayouter_BoxesPositionAndMargins)
    {
        Document doc(m_libraryScope);
        doc.from_string("(lenmusdoc (vers 0.0) "
            "(content (score (vers 1.6) "
            "(instrument (musicData (clef G) )) )))" );
        DocLayouter dl( doc.get_im_model(), m_libraryScope);
        dl.layout_document();
        GraphicModel* pGModel = dl.get_graphic_model();
        CHECK( pGModel->get_num_pages() == 1 );
        GmoBoxDocPage* pPage = pGModel->get_page(0);
        CHECK( pPage->get_num_boxes() == 1 );
        GmoBox* pBDPC = pPage->get_child_box(0);    //DocPageContent
        CHECK( pBDPC->get_num_boxes() == 1 );
        GmoBox* pBSP = pBDPC->get_child_box(0);     //ScorePage
        CHECK( pBSP->get_num_boxes() == 1 );
        GmoBoxSystem* pBSys = dynamic_cast<GmoBoxSystem*>( pBSP->get_child_box(0) );
        CHECK( pBSys->get_top_margin() == 0.0f );
        CHECK( pBSys->get_bottom_margin() == 0.0f );

        CHECK( pBSys->get_num_boxes() == 1 );
        GmoBox* pBSlice = pBSys->get_child_box(0);     //Slice
        CHECK( pBSlice->get_top_margin() == 0.0f );
        CHECK( pBSlice->get_bottom_margin() == 0.0f );
        CHECK( pBSlice->get_left_margin() == 0.0f );
        CHECK( pBSlice->get_right_margin() == 0.0f );
        CHECK( pBSlice->get_top() == pBSys->get_top() );

        CHECK( pBSlice->get_num_boxes() == 1 );
        GmoBox* pBSliceInstr = pBSlice->get_child_box(0);     //SliceInsr
        CHECK( pBSliceInstr->get_num_boxes() == 0 );
        CHECK( pBSliceInstr->get_top_margin() == 0.0f );
        CHECK( pBSliceInstr->get_bottom_margin() == 0.0f );
        CHECK( pBSliceInstr->get_left_margin() == 0.0f );
        CHECK( pBSliceInstr->get_right_margin() == 0.0f );
        CHECK( pBSliceInstr->get_top() == pBSlice->get_top() );

        delete pGModel;
    }
    TEST_FIXTURE(DocLayouterTestFixture, DocLayouter_BoxScoreHasBoxSystem)
    {
        Document doc(m_libraryScope);
        doc.from_string("(lenmusdoc (vers 0.0) "
            "(pageLayout (pageSize 24000 35700)(pageMargins 1000 1500 3000 2500 4000) landscape) "
            "(content (score (vers 1.6) "
            "(instrument (musicData (clef G)(key e)(n c4 q)(r q)(barline simple))))))" );
        DocLayouter dl( doc.get_im_model(), m_libraryScope);
        dl.layout_document();
        GraphicModel* pGModel = dl.get_graphic_model();
//        pGModel->dump_page(0, cout);
        GmoBoxDocPage* pPage = pGModel->get_page(0);
        GmoBox* pBDPC = pPage->get_child_box(0);     //DocPageContent
        GmoBox* pBSP = pBDPC->get_child_box(0);      //ScorePage
        GmoBox* pBox = pBSP->get_child_box(0);       //System
        CHECK( pBox != NULL );
        CHECK( pBox->is_box_system() == true );
        //CHECK( pBox->get_width() == 16000.0f );
        //CHECK( pBox->get_height() == 735.0f );
        //CHECK( pBox->get_left() == 1000.0f );
        //CHECK( pBox->get_top() == 1500.0f );
        delete pGModel;
    }