diff options
| author | Brianna Rainey | 2026-01-22 16:29:46 -0500 |
|---|---|---|
| committer | GitHub | 2026-01-22 16:29:46 -0500 |
| commit | a12be862e22bdec6a243a3f0b5f4f28d69084a2a (patch) | |
| tree | 7f2b21f58cf54deb81bfe77d7ef45358c80454f0 /tests/test_classic_visualizer.py | |
| parent | 36760579a0ae604074034c4b78cda2e3f3b001de (diff) | |
fix #89 with Image component v2.0 + 23 tests (#90)
* qtbot is needed in any test that uses a QObject
previously these tests would fail if they ran before qtbot was initialized by another test. I'm now running tests in a random order
* add tests for drawBars, readAudioFile, BlankFrame
* replace numpy.seterr with numpy.errstate
* fix incorrect comment
* add MockVideoWorker and imageDataSum
* test further into visualization (less likely to be a false positive)
* test FloodFrame function
* add failing test for Image component
one step towards fixing #89
* test component name CLI parsing
* prevent log warning when 1 setting changed
* correct tests to use widgets when needed
* test undo and blockSignals
* remove stretch_scale (use scale only)
* image ignores scale if stretch checkbox checked
fixes #89
* test Title Text component, ffmpeg command
* Image v2: replace stretched setting with resizeMode
3 resize modes are scale, cover, and stretch. Scale only applies when resizeMode is set to scale. Cover uses ImageOps.fit() to stretch while maintaining aspect ratio. Also, spinBox_scale was moved to be underneath comboBox_resizeMode.
* change transformData into staticmethod
the purpose is to allow easier reuse in other components
* add respondToAudio option to Image component
this causes the image to scale up and down slightly based on the input audio file
* cache static portion of image when animating
increases rendering speed of a 1-minute video by 12 seconds (based on two manual tests anyway)
Diffstat (limited to 'tests/test_classic_visualizer.py')
| -rw-r--r-- | tests/test_classic_visualizer.py | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/test_classic_visualizer.py b/tests/test_classic_visualizer.py new file mode 100644 index 0000000..e301263 --- /dev/null +++ b/tests/test_classic_visualizer.py @@ -0,0 +1,71 @@ +from avp.command import Command +from pytestqt import qtbot +from pytest import fixture +from . import audioData, MockSignal, imageDataSum + + +sampleSize = 1470 # 44100 / 30 = 1470 + + +@fixture +def coreWithClassicComp(qtbot): + """Fixture providing a Command object with Classic Visualizer component added""" + command = Command() + 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 + + +def test_comp_classic_drawBars(coreWithClassicComp, audioData): + """Call drawBars after creating audio spectrum data manually.""" + + spectrumArray = { + 0: coreWithClassicComp.selectedComponents[0].transformData( + 0, audioData[0], sampleSize, 0.08, 0.8, None, 20 + ) + } + for i in range(sampleSize, len(audioData[0]), sampleSize): + spectrumArray[i] = coreWithClassicComp.selectedComponents[0].transformData( + i, + audioData[0], + sampleSize, + 0.08, + 0.8, + spectrumArray[i - sampleSize].copy(), + 20, + ) + image = coreWithClassicComp.selectedComponents[0].drawBars( + 1920, 1080, spectrumArray[sampleSize * 4], (0, 0, 0), 0 + ) + assert imageDataSum(image) == 37872316 + + +def test_comp_classic_drawBars_using_preFrameRender(coreWithClassicComp, audioData): + """Call drawBars after creating audio spectrum data using preFrameRender.""" + comp = coreWithClassicComp.selectedComponents[0] + comp.preFrameRender( + completeAudioArray=audioData[0], + sampleSize=sampleSize, + progressBarSetText=MockSignal(), + progressBarUpdate=MockSignal(), + ) + image = comp.drawBars( + 1920, + 1080, + coreWithClassicComp.selectedComponents[0].spectrumArray[sampleSize * 4], + (0, 0, 0), + 0, + ) + assert imageDataSum(image) == 37872316 |
