From: adv Date: Thu, 12 Sep 2013 06:57:27 +0000 (+0000) Subject: Teste of operators factory corrected accordingly with changes for Feature #6. X-Git-Tag: BR_hydro_v_0_1~37 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=44f4c6114effd982fe0fca95779e3e5d0ef4f391;p=modules%2Fhydro.git Teste of operators factory corrected accordingly with changes for Feature #6. --- diff --git a/src/HYDROData/test_HYDROOperations_Factory.cxx b/src/HYDROData/test_HYDROOperations_Factory.cxx index 0695cc33..f09794d4 100644 --- a/src/HYDROData/test_HYDROOperations_Factory.cxx +++ b/src/HYDROData/test_HYDROOperations_Factory.cxx @@ -2,11 +2,13 @@ #include #include +#include #include -#include #include +#include + void test_HYDROOperations_Factory::testCreate() { Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); @@ -34,28 +36,51 @@ static QImage TestImage() { void test_HYDROOperations_Factory::testCrop() { - Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 ); HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory(); - Handle(HYDROData_Image) anImage = aFactory->CreateImage(aDoc, NULL); + // prepare the original image and crop-path - QImage aPic = TestImage(); - anImage->SetImage(aPic); - QPainterPath aPath(QPointF(25, 0)); - aPath.lineTo(0, 20); - aPath.lineTo(25, 40); - aPath.lineTo(50, 20); - aPath.closeSubpath(); + Handle(HYDROData_Image) anOriImage = + Handle(HYDROData_Image)::DownCast( aDoc->CreateObject( KIND_IMAGE ) ); + + QImage aTestImage = TestImage(); + anOriImage->SetImage( aTestImage ); + + Handle(HYDROData_Polyline) aCropPolyline = + Handle(HYDROData_Polyline)::DownCast( aDoc->CreateObject( KIND_POLYLINE ) ); + + HYDROData_Polyline::PolylineData aPolylineData; + + PolylineSection aPolylineSect; + + aPolylineSect.myCoords << 25 << 0 << 0; + aPolylineSect.myCoords << 0 << 20 << 0; + aPolylineSect.myCoords << 25 << 40 << 0; + aPolylineSect.myCoords << 50 << 20 << 0; + + aPolylineData << aPolylineSect; + + aCropPolyline->setPolylineData( aPolylineData ); + // prepare Composer Operation - ImageComposer_CropOperator aCropOp; - aCropOp.setArgs(Qt::red, aPath); + ImageComposer_Operator* aCropOp = + aFactory->Operator( ImageComposer_CropOperator::Type() ); + + CPPUNIT_ASSERT( aCropOp ); + + aCropOp->setArgs( Qt::red ); + // create crop - image - Handle(HYDROData_Image) aCrop = aFactory->CreateImage(aDoc, &aCropOp); - CPPUNIT_ASSERT(!aCrop.IsNull()); - aCrop->AppendReference(anImage); - aFactory->UpdateImage(aDoc, aCrop); + Handle(HYDROData_Image) aCropImage = aFactory->CreateImage( aDoc, aCropOp ); + CPPUNIT_ASSERT( !aCropImage.IsNull() ); + + aCropImage->AppendReference( anOriImage ); + aCropImage->AppendReference( aCropPolyline ); + aCropImage->Update(); + // check crop operation was performed - CPPUNIT_ASSERT(!aCrop->Image().isNull()); - CPPUNIT_ASSERT(aCrop->Image() != aPic); + CPPUNIT_ASSERT( !aCropImage->Image().isNull() ); + CPPUNIT_ASSERT( aCropImage->Image() != aTestImage ); aDoc->Close(); }