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_mainwindow_undostack.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_mainwindow_undostack.py')
| -rw-r--r-- | tests/test_mainwindow_undostack.py | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/test_mainwindow_undostack.py b/tests/test_mainwindow_undostack.py new file mode 100644 index 0000000..1eec1ef --- /dev/null +++ b/tests/test_mainwindow_undostack.py @@ -0,0 +1,73 @@ +from pytest import fixture +from pytestqt import qtbot +from avp.gui.mainwindow import MainWindow +from . import getTestDataPath + + +@fixture +def window(qtbot): + window = MainWindow(None, None) + qtbot.addWidget(window) + window.settings.setValue("outputWidth", 1920) + window.settings.setValue("outputHeight", 1080) + yield window + + +def test_undo_classic_visualizer_sensitivity(window, qtbot): + """Undo Classic Visualizer component sensitivity setting + should undo multiple merged actions.""" + window.core.insertComponent( + 0, window.core.moduleIndexFor("Classic Visualizer"), window + ) + comp = window.core.selectedComponents[0] + comp.imagePath = getTestDataPath("test.jpg") + for i in range(1, 100): + comp.page.spinBox_scale.setValue(i) + assert comp.scale == 99 + window.undoStack.undo() + assert comp.scale == 20 + + +def test_undo_image_scale(window, qtbot): + """Undo Image component scale setting should undo multiple merged actions.""" + window.core.insertComponent(0, window.core.moduleIndexFor("Image"), window) + comp = window.core.selectedComponents[0] + comp.imagePath = getTestDataPath("test.jpg") + comp.page.spinBox_scale.setValue(100) + for i in range(10, 401): + comp.page.spinBox_scale.setValue(i) + assert comp.scale == 400 + window.undoStack.undo() + assert comp.scale == 10 + window.undoStack.undo() + assert comp.scale == 100 + + +def test_undo_image_resizeMode(window, qtbot): + window.core.insertComponent(0, window.core.moduleIndexFor("Image"), window) + comp = window.core.selectedComponents[0] + comp.page.comboBox_resizeMode.setCurrentIndex(1) + assert not comp.page.spinBox_scale.isEnabled() + window.undoStack.undo() + assert comp.page.spinBox_scale.isEnabled() + + +def test_undo_title_text_merged(window, qtbot): + """Undoing title text change should undo all recent changes.""" + window.core.insertComponent(0, window.core.moduleIndexFor("Title Text"), window) + comp = window.core.selectedComponents[0] + comp.page.lineEdit_title.setText("avp") + comp.page.lineEdit_title.setText("test") + window.undoStack.undo() + assert comp.title == "Text" + + +def test_undo_title_text_not_merged(window, qtbot): + """Undoing title text change should undo up to previous different action""" + window.core.insertComponent(0, window.core.moduleIndexFor("Title Text"), window) + comp = window.core.selectedComponents[0] + comp.page.lineEdit_title.setText("avp") + comp.page.spinBox_xTextAlign.setValue(0) + comp.page.lineEdit_title.setText("test") + window.undoStack.undo() + assert comp.title == "avp" |
