aboutsummaryrefslogtreecommitdiff
path: root/tests/test_comp_text.py
blob: e389ff9ce6948760191d569213c4bdd483fe2a77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from avp.command import Command
from PyQt6.QtGui import QFont
from pytestqt import qtbot
from pytest import fixture, mark
from . import audioData, MockSignal, imageDataSum


@fixture
def coreWithTextComp(qtbot):
    """Fixture providing a Command object with Title Text component added"""
    command = Command()
    command.core.insertComponent(0, command.core.moduleIndexFor("Title Text"), command)
    yield command.core


def setTextSettings(comp):
    comp.page.spinBox_fontSize.setValue(40)
    comp.page.checkBox_shadow.setChecked(True)
    comp.page.spinBox_shadBlur.setValue(0)
    comp.page.spinBox_shadX.setValue(2)
    comp.page.spinBox_shadY.setValue(-2)
    comp.page.fontComboBox_titleFont.setCurrentFont(QFont("Noto Sans"))
    comp.page.lineEdit_textColor.setText("255,255,255")


@mark.parametrize(
    "width, height",
    ((1920, 1080), (1280, 720)),
)
def test_comp_text_renderFrame(coreWithTextComp, width, height):
    """Call renderFrame of Title Text component added to Command object."""
    comp = coreWithTextComp.selectedComponents[0]
    comp.parent.settings.setValue("outputWidth", width)
    comp.parent.settings.setValue("outputHeight", height)
    setTextSettings(comp)
    comp.centerXY()
    image = comp.frameRender(0)
    assert comp.titleFont.family() == "Noto Sans"
    assert comp.xPosition == width / 2
    assert image.width == width
    assert comp.fontSize == 40
    assert comp.shadX == 2
    assert comp.shadY == -2
    assert comp.shadBlur == 0
    assert imageDataSum(image) == 727403 or 738586