Beispiel #1
0
def test_moveLayer(qApp):
    document = Document()
    model = LayerModel()
    layer0 = Layer(name='Layer 0')
    layer1 = Layer(name='Layer 1')
    layer2 = Layer(name='Layer 2')
    document.addItems(layer0, layer1, layer2)
    model.document = document

    assert layer0.order() == 0
    assert layer1.order() == 1
    assert layer2.order() == 2

    model.moveLayer(2, 1)
    assert layer0.order() == 0
    assert layer1.order() == 2
    assert layer2.order() == 1

    model.moveLayer(0, 2)
    assert layer0.order() == 2
    assert layer1.order() == 1
    assert layer2.order() == 0
    assert document.layers() == [layer2, layer1, layer0]

    # test reload file after reordering layers

    data = {}
    document.write(data)
    document2 = Document()
    document2.read(data)

    _layer0 = document2.query1(name='Layer 0')
    _layer1 = document2.query1(name='Layer 1')
    _layer2 = document2.query1(name='Layer 2')
    assert _layer0.order() == 2
    assert _layer1.order() == 1
    assert _layer2.order() == 0
    assert document2.layers() == [_layer2, _layer1, _layer0]
Beispiel #2
0
def test_read_write_layered_props(qApp):
    """ Item.write was not explicitly requesting non-layered prop values. """
    document = Document()
    person = Person()
    layer = Layer(name='Layer 1', active=True)
    document.addItems(person, layer)
    person.setItemPos(QPointF(10, 10))
    person.setColor('#ff0000')
    #
    data = {}
    document.write(data)
    document = Document()
    document.read(data)
    assert document.people()[0].pos() == QPointF(10, 10)
    assert document.people()[0].color() == '#ff0000'
    assert document.people()[0].pen().color().name() == '#ff0000'
    
    document.layers()[0].setActive(False)
    assert document.people()[0].color() == None
    assert document.people()[0].pen().color().name() == util.PEN.color().name()
    
    document.layers()[0].setActive(True)
    assert document.people()[0].color() == '#ff0000'
    assert document.people()[0].pen().color().name() == '#ff0000'