Пример #1
0
void TestShapeAt::testShadow()
{
    QRectF bbox(20, 30, 50, 70);
    
    MockShape shape;
    shape.setPosition(bbox.topLeft());
    shape.setSize(bbox.size());
    QCOMPARE(shape.boundingRect(), bbox);

    KoLineBorder *border = new KoLineBorder();
    border->setLineWidth(20); // which means the shape grows 10 in all directions.
    shape.setBorder(border);
    KoInsets borderInsets;
    border->borderInsets(&shape, borderInsets);
    bbox.adjust(-borderInsets.left, -borderInsets.top, borderInsets.right, borderInsets.bottom);
    QCOMPARE(shape.boundingRect(), bbox);

    KoShapeShadow *shadow = new KoShapeShadow();
    shadow->setOffset(QPointF(5, 9));
    shape.setShadow(shadow);
    KoInsets shadowInsets;
    shadow->insets(&shape, shadowInsets);
    bbox.adjust(-shadowInsets.left, -shadowInsets.top, shadowInsets.right, shadowInsets.bottom);
    QCOMPARE(shape.boundingRect(), bbox);
}