aboutsummaryrefslogtreecommitdiff
path: root/tests/test_comp_classic.py
diff options
context:
space:
mode:
authorBrianna Rainey2026-02-12 15:38:54 -0500
committerGitHub2026-02-12 15:38:54 -0500
commitf03a3a686c7304588dd434322c73506531e53595 (patch)
treeee41d920873e9a77c41f4a65857af019e71a4754 /tests/test_comp_classic.py
parent48a9105eab94e64101470402427564203e1d8970 (diff)
v2.2.4 - Quiet FFmpeg; add "invert" option to Classic Vis; fix CLI parsing for Image component (#96)
* change noisiness of terminal output ffmpeg no longer prints everything into the terminal unless we're in `--verbose` mode. percentage progress text stays on one line while not in verbose mode. * Added hint to run `avp --verbose` if `avp --log` is run with no avp_debug.log file present * Classic Visualizer: add invert option * Image component: fix path commandline option * Image component: restrict file formats in CLI to match GUI * Color component: add tooltip to color2 picker (second color of gradients) * change tests to work with pytest-xdist avp core stores its config (location of `settings.ini`) in temp directories if using multiple workers to run tests, so they don't interfere with each other. when using a single worker, the `tests/data/config` directory is still used * check alt comp names when parsing cmdline * rename `original.py` to `classic.py` * move `component.py` into subpackage * rename comp_original to comp_classic * show traceback if renderFrame() raises exception * do not try to insert non-existent components from project files * add "composite" property for components if a component returns "composite" then it will receive a frame to draw on during calls to previewRender and frameRender * more tests of projects, actions, waveform, spectrum, image, color, classic * do not change presetDir to "projects" within PresetManager
Diffstat (limited to 'tests/test_comp_classic.py')
-rw-r--r--tests/test_comp_classic.py103
1 files changed, 103 insertions, 0 deletions
diff --git a/tests/test_comp_classic.py b/tests/test_comp_classic.py
new file mode 100644
index 0000000..a942d89
--- /dev/null
+++ b/tests/test_comp_classic.py
@@ -0,0 +1,103 @@
+from avp.toolkit.visualizer import transformData
+from pytestqt import qtbot
+from pytest import fixture, mark
+from . import audioData, command, imageDataSum, preFrameRender
+
+
+sampleSize = 1470 # 44100 / 30 = 1470
+
+
+def createSpectrumArray(audioData):
+ """Creates enough `spectrumArray` for one call to Component.drawBars()"""
+ spectrumArray = {0: transformData(0, audioData[0], sampleSize, 0.08, 0.8, None, 20)}
+ for i in range(sampleSize, len(audioData[0]), sampleSize):
+ spectrumArray[i] = transformData(
+ i,
+ audioData[0],
+ sampleSize,
+ 0.08,
+ 0.8,
+ spectrumArray[i - sampleSize].copy(),
+ 20,
+ )
+ return spectrumArray
+
+
+@fixture
+def coreWithClassicComp(qtbot, command):
+ """Fixture providing a Command object with Classic Visualizer component added"""
+ command.core.insertComponent(
+ 0, command.core.moduleIndexFor("Classic Visualizer"), command
+ )
+ yield command.core
+
+
+def test_comp_classic_added(coreWithClassicComp):
+ """Add Classic Visualizer to core"""
+ assert len(coreWithClassicComp.selectedComponents) == 1
+
+
+def test_comp_classic_removed(coreWithClassicComp):
+ """Remove Classic Visualizer from core"""
+ coreWithClassicComp.removeComponent(0)
+ assert len(coreWithClassicComp.selectedComponents) == 0
+
+
+@mark.parametrize("layout", (0, 1, 2, 3))
+def test_comp_classic_drawBars(coreWithClassicComp, audioData, layout):
+ """Call drawBars after creating audio spectrum data manually."""
+ spectrumArray = createSpectrumArray(audioData)
+ comp = coreWithClassicComp.selectedComponents[0]
+ image = comp.drawBars(
+ 1920, 1080, spectrumArray[sampleSize * 4], (0, 0, 0), layout, None
+ )
+ imageSize = 37872316
+ assert imageDataSum(image) == imageSize if layout < 2 else imageSize / 2
+
+
+def test_comp_classic_drawBars_using_preFrameRender(coreWithClassicComp, audioData):
+ """Call drawBars after creating audio spectrum data using preFrameRender."""
+ comp = coreWithClassicComp.selectedComponents[0]
+ preFrameRender(audioData, comp)
+ image = comp.drawBars(
+ 1920,
+ 1080,
+ coreWithClassicComp.selectedComponents[0].spectrumArray[sampleSize * 4],
+ (0, 0, 0),
+ 0,
+ None,
+ )
+ assert imageDataSum(image) == 37872316
+
+
+def test_comp_classic_command_layout(coreWithClassicComp):
+ comp = coreWithClassicComp.selectedComponents[0]
+ comp.command("layout=top")
+ assert comp.layout == 3
+
+
+def test_comp_classic_command_color(coreWithClassicComp):
+ comp = coreWithClassicComp.selectedComponents[0]
+ comp.command("color=111,111,111")
+ assert comp.visColor == (111, 111, 111)
+
+
+def test_comp_classic_command_preset(coreWithClassicComp):
+ comp = coreWithClassicComp.selectedComponents[0]
+ saveValueStore = comp.savePreset()
+ saveValueStore["preset"] = "testPreset"
+ coreWithClassicComp.createPresetFile(
+ comp.name, comp.version, "testPreset", saveValueStore
+ )
+ comp.command("preset=testPreset")
+ assert comp.currentPreset == "testPreset"
+
+
+def test_comp_classic_loadPreset(coreWithClassicComp):
+ comp = coreWithClassicComp.selectedComponents[0]
+ comp.scale = 99
+ saveValueStore = comp.savePreset()
+ saveValueStore["preset"] = "testPreset"
+ comp.scale = 20
+ comp.loadPreset(saveValueStore, "testPreset")
+ assert comp.scale == 99