diff options
| author | Brianna Rainey | 2026-01-29 14:50:29 -0500 |
|---|---|---|
| committer | GitHub | 2026-01-29 14:50:29 -0500 |
| commit | 71a22c6a121d1294a05ef35020c525fa70cae2fd (patch) | |
| tree | 025dd2329c214a5fe5ac78c7f2e8342e2bfde14d | |
| parent | f66eb99465c61232a7f649e66bee59504bb0e52c (diff) | |
v2.2.2 - fix flaky tests, fix UnboundLocalError in MainWindow.createNewProject (#94)
* search more than one filename for compName
* remove extra QVBoxLayout
* insert default components using name instead of index
* bump version 2.2.1 to 2.2.2
* tests do not use `.config` for settings
Core.storeSettings() is no longer called as a side effect any time avp.core is imported. Thus the tests use a new `initCore` method and the normal user path now relies on entering via `cli.py`. This means certain toolkit functions (e.g., ones using `FFMPEG_BIN`) no longer work if imported from a different python script, unless they call Core.storeSettings() themselves to initialize the settings.ini file
* fix UnboundLocalError in createNewProject
27 files changed, 997 insertions, 931 deletions
@@ -9,6 +9,9 @@ prof/ .venv/ .env/ .vscode/ +tests/data/log/ +tests/data/settings.ini +tests/data/autosave.avp *.mkv *.mp4 *.wav diff --git a/pyproject.toml b/pyproject.toml index 2f0647c..ea27839 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "uv_build" name = "audio-visualizer-python" description = "Create audio visualization videos from a GUI or commandline" readme = "README.md" -version = "2.2.1" +version = "2.2.2" requires-python = ">= 3.12" license = "MIT" classifiers=[ diff --git a/src/avp/__init__.py b/src/avp/__init__.py index a88bf10..9de9f93 100644 --- a/src/avp/__init__.py +++ b/src/avp/__init__.py @@ -3,7 +3,7 @@ import os import logging -__version__ = "2.2.1" +__version__ = "2.2.2" class Logger(logging.getLoggerClass()): diff --git a/src/avp/cli.py b/src/avp/cli.py index 02ceee6..0176f76 100644 --- a/src/avp/cli.py +++ b/src/avp/cli.py @@ -5,6 +5,11 @@ import re import string +from .core import Core + +# Core class must store settings as class variables +# before we can use many things in AVP +Core.storeSettings() log = logging.getLogger("AVP.Main") diff --git a/src/avp/command.py b/src/avp/command.py index 7a77848..870391b 100644 --- a/src/avp/command.py +++ b/src/avp/command.py @@ -256,7 +256,6 @@ class Command(QtCore.QObject): for i, compFileName in enumerate(compFileNames): if name.lower() in compFileName: return self.core.compNames[i] - return return None diff --git a/src/avp/components/spectrum.ui b/src/avp/components/spectrum.ui index c6a8a15..3bde075 100644 --- a/src/avp/components/spectrum.ui +++ b/src/avp/components/spectrum.ui @@ -27,909 +27,899 @@ </property> <layout class="QVBoxLayout" name="verticalLayout_2"> <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="leftMargin"> - <number>4</number> - </property> + <layout class="QHBoxLayout" name="horizontalLayout_8"> <item> - <layout class="QHBoxLayout" name="horizontalLayout_5"/> + <widget class="QLabel" name="label_4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Type</string> + </property> + </widget> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout_8"> - <item> - <widget class="QLabel" name="label_4"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Type</string> - </property> - </widget> - </item> + <widget class="QComboBox" name="comboBox_filterType"> <item> - <widget class="QComboBox" name="comboBox_filterType"> - <item> - <property name="text"> - <string>Spectrum</string> - </property> - </item> - <item> - <property name="text"> - <string>Histogram</string> - </property> - </item> - <item> - <property name="text"> - <string>Vector Scope</string> - </property> - </item> - <item> - <property name="text"> - <string>Musical Scale</string> - </property> - </item> - <item> - <property name="text"> - <string>Phase</string> - </property> - </item> - </widget> + <property name="text"> + <string>Spectrum</string> + </property> </item> <item> - <spacer name="horizontalSpacer_9"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>5</width> - <height>20</height> - </size> - </property> - </spacer> + <property name="text"> + <string>Histogram</string> + </property> </item> <item> - <widget class="QLabel" name="label_xTitleAlign"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>X</string> - </property> - </widget> + <property name="text"> + <string>Vector Scope</string> + </property> </item> <item> - <widget class="QSpinBox" name="spinBox_x"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximumSize"> - <size> - <width>80</width> - <height>16777215</height> - </size> - </property> - <property name="minimum"> - <number>-10000</number> - </property> - <property name="maximum"> - <number>10000</number> - </property> - </widget> + <property name="text"> + <string>Musical Scale</string> + </property> </item> <item> - <widget class="QLabel" name="label_yTitleAlign"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Y</string> - </property> - </widget> + <property name="text"> + <string>Phase</string> + </property> </item> - <item> - <widget class="QSpinBox" name="spinBox_y"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximumSize"> - <size> - <width>80</width> - <height>16777215</height> - </size> - </property> - <property name="baseSize"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="minimum"> - <number>-10000</number> - </property> - <property name="maximum"> - <number>10000</number> - </property> - <property name="value"> - <number>0</number> - </property> - </widget> - </item> - </layout> + </widget> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout_10"> - <item> - <widget class="QCheckBox" name="checkBox_compress"> - <property name="text"> - <string>Compress</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="checkBox_mono"> - <property name="text"> - <string>Mono</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="checkBox_mirror"> - <property name="text"> - <string>Mirror</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="label_11"> - <property name="text"> - <string>Hue</string> - </property> - <property name="margin"> - <number>4</number> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spinBox_hue"> - <property name="suffix"> - <string>° </string> - </property> - <property name="maximum"> - <number>359</number> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Scale</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spinBox_scale"> - <property name="buttonSymbols"> - <enum>QAbstractSpinBox::UpDownArrows</enum> - </property> - <property name="suffix"> - <string>%</string> - </property> - <property name="minimum"> - <number>10</number> - </property> - <property name="maximum"> - <number>400</number> - </property> - <property name="value"> - <number>100</number> - </property> - </widget> - </item> - </layout> + <spacer name="horizontalSpacer_9"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Policy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>5</width> + <height>20</height> + </size> + </property> + </spacer> </item> <item> - <widget class="QStackedWidget" name="stackedWidget"> + <widget class="QLabel" name="label_xTitleAlign"> <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="autoFillBackground"> - <bool>false</bool> + <property name="text"> + <string>X</string> </property> - <property name="frameShape"> - <enum>QFrame::NoFrame</enum> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBox_x"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>80</width> + <height>16777215</height> + </size> + </property> + <property name="minimum"> + <number>-10000</number> + </property> + <property name="maximum"> + <number>10000</number> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_yTitleAlign"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> - <property name="frameShadow"> - <enum>QFrame::Plain</enum> + <property name="text"> + <string>Y</string> </property> - <property name="currentIndex"> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBox_y"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>80</width> + <height>16777215</height> + </size> + </property> + <property name="baseSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="minimum"> + <number>-10000</number> + </property> + <property name="maximum"> + <number>10000</number> + </property> + <property name="value"> <number>0</number> </property> - <widget class="QWidget" name="page"> - <widget class="QWidget" name="verticalLayoutWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>561</width> - <height>66</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout_3"> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_10"> + <item> + <widget class="QCheckBox" name="checkBox_compress"> + <property name="text"> + <string>Compress</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_mono"> + <property name="text"> + <string>Mono</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_mirror"> + <property name="text"> + <string>Mirror</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="label_11"> + <property name="text"> + <string>Hue</string> + </property> + <property name="margin"> + <number>4</number> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBox_hue"> + <property name="suffix"> + <string>° </string> + </property> + <property name="maximum"> + <number>359</number> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Scale</string> + </property> + <property name="alignment"> + <set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBox_scale"> + <property name="buttonSymbols"> + <enum>QAbstractSpinBox::ButtonSymbols::UpDownArrows</enum> + </property> + <property name="suffix"> + <string>%</string> + </property> + <property name="minimum"> + <number>10</number> + </property> + <property name="maximum"> + <number>400</number> + </property> + <property name="value"> + <number>100</number> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QStackedWidget" name="stackedWidget"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="frameShape"> + <enum>QFrame::Shape::NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Shadow::Plain</enum> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="page"> + <widget class="QWidget" name="verticalLayoutWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>561</width> + <height>76</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <property name="sizeConstraint"> + <enum>QLayout::SizeConstraint::SetMaximumSize</enum> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_9"> <property name="sizeConstraint"> - <enum>QLayout::SetMaximumSize</enum> - </property> - <property name="rightMargin"> - <number>0</number> + <enum>QLayout::SizeConstraint::SetDefaultConstraint</enum> </property> <item> - <layout class="QHBoxLayout" name="horizontalLayout_9"> - <property name="sizeConstraint"> - <enum>QLayout::SetDefaultConstraint</enum> - </property> - <item> - <widget class="QLabel" name="label_textColor"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>31</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string>Window</string> - </property> - <property name="margin"> - <number>4</number> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboBox_window"> - <item> - <property name="text"> - <string>hann</string> - </property> - </item> - <item> - <property name="text"> - <string>gauss</string> - </property> - </item> - <item> - <property name="text"> - <string>tukey</string> - </property> - </item> - <item> - <property name="text"> - <string>dolph</string> - </property> - </item> - <item> - <property name="text"> - <string>cauchy</string> - </property> - </item> - <item> - <property name="text"> - <string>parzen</string> - </property> - </item> - <item> - <property name="text"> - <string>poisson</string> - </property> - </item> - <item> - <property name="text"> - <string>rect</string> - </property> - </item> - <item> - <property name="text"> - <string>bartlett</string> - </property> - </item> - <item> - <property name="text"> - <string>hanning</string> - </property> - </item> - <item> - <property name="text"> - <string>hamming</string> - </property> - </item> - <item> - <property name="text"> - <string>blackman</string> - </property> - </item> - <item> - <property name="text"> - <string>welch</string> - </property> - </item> - <item> - <property name="text"> - <string>flattop</string> - </property> - </item> - <item> - <property name="text"> - <string>bharris</string> - </property> - </item> - <item> - <property name="text"> - <string>bnuttall</string> - </property> - </item> - <item> - <property name="text"> - <string>lanczos</string> - </property> - </item> - </widget> - </item> - <item> - <widget class="QLabel" name="label_3"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Amplitude</string> - </property> - <property name="margin"> - <number>4</number> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboBox_amplitude0"> - <item> - <property name="text"> - <string>Square root</string> - </property> - </item> - <item> - <property name="text"> - <string>Cubic root</string> - </property> - </item> - <item> - <property name="text"> - <string>4thrt</string> - </property> - </item> - <item> - <property name="text"> - <string>5thrt</string> - </property> - </item> - <item> - <property name="text"> - <string>Linear</string> - </property> - </item> - <item> - <property name="text"> - <string>Logarithmic</string> - </property> - </item> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_4"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::MinimumExpanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>10</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> + <widget class="QLabel" name="label_textColor"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>31</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>Window</string> + </property> + <property name="margin"> + <number>4</number> + </property> + </widget> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLabel" name="label_2"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Color </string> - </property> - <property name="margin"> - <number>4</number> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboBox_color"> - <item> - <property name="text"> - <string>Channel</string> - </property> - </item> - <item> - <property name="text"> - <string>Intensity</string> - </property> - </item> - <item> - <property name="text"> - <string>Rainbow</string> - </property> - </item> - <item> - <property name="text"> - <string>Moreland</string> - </property> - </item> - <item> - <property name="text"> - <string>Nebulae</string> - </property> - </item> - <item> - <property name="text"> - <string>Fire</string> - </property> - </item> - <item> - <property name="text"> - <string>Fiery</string> - </property> - </item> - <item> - <property name="text"> - <string>Fruit</string> - </property> - </item> - <item> - <property name="text"> - <string>Cool</string> - </property> - </item> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_3"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::MinimumExpanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>10</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> + <widget class="QComboBox" name="comboBox_window"> + <item> + <property name="text"> + <string>hann</string> + </property> + </item> + <item> + <property name="text"> + <string>gauss</string> + </property> + </item> + <item> + <property name="text"> + <string>tukey</string> + </property> + </item> + <item> + <property name="text"> + <string>dolph</string> + </property> + </item> + <item> + <property name="text"> + <string>cauchy</string> + </property> + </item> + <item> + <property name="text"> + <string>parzen</string> + </property> + </item> + <item> + <property name="text"> + <string>poisson</string> + </property> + </item> + <item> + <property name="text"> + <string>rect</string> + </property> + </item> + <item> + <property name="text"> + <string>bartlett</string> + </property> + </item> + <item> + <property name="text"> + <string>hanning</string> + </property> + </item> + <item> + <property name="text"> + <string>hamming</string> + </property> + </item> + <item> + <property name="text"> + <string>blackman</string> + </property> + </item> + <item> + <property name="text"> + <string>welch</string> + </property> + </item> + <item> + <property name="text"> + <string>flattop</string> + </property> + </item> + <item> + <property name="text"> + <string>bharris</string> + </property> + </item> + <item> + <property name="text"> + <string>bnuttall</string> + </property> + </item> + <item> + <property name="text"> + <string>lanczos</string> + </property> + </item> + </widget> + </item> + <item> + <widget class="QLabel" name="label_3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Amplitude</string> + </property> + <property name="margin"> + <number>4</number> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="comboBox_amplitude0"> + <item> + <property name="text"> + <string>Square root</string> + </property> + </item> + <item> + <property name="text"> + <string>Cubic root</string> + </property> + </item> + <item> + <property name="text"> + <string>4thrt</string> + </property> + </item> + <item> + <property name="text"> + <string>5thrt</string> + </property> + </item> + <item> + <property name="text"> + <string>Linear</string> + </property> + </item> + <item> + <property name="text"> + <string>Logarithmic</string> + </property> + </item> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_4"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Policy::MinimumExpanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>10</width> + <height>20</height> + </size> + </property> + </spacer> </item> </layout> - </widget> - </widget> - <widget class="QWidget" name="page_2"> - <widget class="QWidget" name="verticalLayoutWidget_2"> - <property name="geometry"> - <rect> - <x>-1</x> - <y>-1</y> - <width>561</width> - <height>31</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout_4"> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QLabel" name="label_6"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Display Scale</string> - </property> - <property name="margin"> - <number>4</number> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboBox_display"> - <item> - <property name="text"> - <string>Logarithmic</string> - </property> - </item> - <item> - <property name="text"> - <string>Square root</string> - </property> - </item> - <item> - <property name="text"> - <string>Cubic root</string> - </property> - </item> - <item> - <property name="text"> - <string>Linear</string> - </property> - </item> - <item> - <property name="text"> - <string>Reverse Log</string> - </property> - </item> - </widget> - </item> - <item> - <widget class="QLabel" name="label_5"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Amplitude</string> - </property> - <property name="margin"> - <number>4</number> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboBox_amplitude1"> - <item> - <property name="text"> - <string>Logarithmic</string> - </property> - </item> - <item> - <property name="text"> - <string>Linear</string> - </property> - </item> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Minimum</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> + <widget class="QLabel" name="label_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Color </string> + </property> + <property name="margin"> + <number>4</number> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="comboBox_color"> + <item> + <property name="text"> + <string>Channel</string> + </property> + </item> + <item> + <property name="text"> + <string>Intensity</string> + </property> + </item> + <item> + <property name="text"> + <string>Rainbow</string> + </property> + </item> + <item> + <property name="text"> + <string>Moreland</string> + </property> + </item> + <item> + <property name="text"> + <string>Nebulae</string> + </property> + </item> + <item> + <property name="text"> + <string>Fire</string> + </property> + </item> + <item> + <property name="text"> + <string>Fiery</string> + </property> + </item> + <item> + <property name="text"> + <string>Fruit</string> + </property> + </item> + <item> + <property name="text"> + <string>Cool</string> + </property> + </item> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Policy::MinimumExpanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>10</width> + <height>20</height> + </size> + </property> + </spacer> </item> </layout> - </widget> - </widget> - <widget class="QWidget" name="page_3"> - <widget class="QWidget" name="verticalLayoutWidget_3"> - <property name="geometry"> - <rect> - <x>-1</x> - <y>-1</y> - <width>585</width> - <height>64</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout_5"> + </item> + </layout> + </widget> + </widget> + <widget class="QWidget" name="page_2"> + <widget class="QWidget" name="verticalLayoutWidget_2"> + <property name="geometry"> + <rect> + <x>-1</x> + <y>-1</y> + <width>561</width> + <height>36</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QLabel" name="label_9"> - <property name="text"> - <string>Mode</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboBox_mode"> - <item> - <property name="text"> - <string>lissajous</string> - </property> - </item> - <item> - <property name="text"> - <string>lissajous_xy</string> - </property> - </item> - <item> - <property name="text"> - <string>polar</string> - </property> - </item> - </widget> - </item> - <item> - <widget class="QLabel" name="label_7"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Amplitude</string> - </property> - <property name="margin"> - <number>4</number> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboBox_amplitude2"> - <item> - <property name="text"> - <string>Linear</string> - </property> - </item> - <item> - <property name="text"> - <string>Square root</string> - </property> - </item> - <item> - <property name="text"> - <string>Cubic root</string> - </property> - </item> - <item> - <property name="text"> - <string>Logarithmic</string> - </property> - </item> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_5"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> + <widget class="QLabel" name="label_6"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Display Scale</string> + </property> + <property name="margin"> + <number>4</number> + </property> + </widget> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout_6"> - <item> - <widget class="QLabel" name="label_8"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Zoom</string> - </property> - <property name="margin"> - <number>4</number> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spinBox_zoom"> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>10</number> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="checkBox_draw"> - <property name="text"> - <string>Line</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_6"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> + <widget class="QComboBox" name="comboBox_display"> + <item> + <property name="text"> + <string>Logarithmic</string> + </property> + </item> + <item> + <property name="text"> + <string>Square root</string> + </property> + </item> + <item> + <property name="text"> + <string>Cubic root</string> + </property> + </item> + <item> + <property name="text"> + <string>Linear</string> + </property> + </item> + <item> + <property name="text"> + <string>Reverse Log</string> + </property> + </item> + </widget> + </item> + <item> + <widget class="QLabel" name="label_5"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Amplitude</string> + </property> + <property name="margin"> + <number>4</number> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="comboBox_amplitude1"> + <item> + <property name="text"> + <string>Logarithmic</string> + </property> + </item> + <item> + <property name="text"> + <string>Linear</string> + </property> + </item> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Policy::Minimum</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + </widget> + <widget class="QWidget" name="page_3"> + <widget class="QWidget" name="verticalLayoutWidget_3"> + <property name="geometry"> + <rect> + <x>-1</x> + <y>-1</y> + <width>585</width> + <height>76</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout_5"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QLabel" name="label_9"> + <property name="text"> + <string>Mode</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="comboBox_mode"> + <item> + <property name="text"> + <string>lissajous</string> + </property> + </item> + <item> + <property name="text"> + <string>lissajous_xy</string> + </property> + </item> + <item> + <property name="text"> + <string>polar</string> + </property> + </item> + </widget> + </item> + <item> + <widget class="QLabel" name="label_7"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Amplitude</string> + </property> + <property name="margin"> + <number>4</number> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="comboBox_amplitude2"> + <item> + <property name="text"> + <string>Linear</string> + </property> + </item> + <item> + <property name="text"> + <string>Square root</string> + </property> + </item> + <item> + <property name="text"> + <string>Cubic root</string> + </property> + </item> + <item> + <property name="text"> + <string>Logarithmic</string> + </property> + </item> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_5"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> </item> </layout> - </widget> - </widget> - <widget class="QWidget" name="page_4"> - <widget class="QWidget" name="verticalLayoutWidget_4"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>561</width> - <height>31</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout_6"> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <item> + <widget class="QLabel" name="label_8"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Zoom</string> + </property> + <property name="margin"> + <number>4</number> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBox_zoom"> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>10</number> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_draw"> + <property name="text"> + <string>Line</string> + </property> + </widget> + </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout_7"> - <item> - <widget class="QLabel" name="label_10"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Timeclamp</string> - </property> - <property name="margin"> - <number>4</number> - </property> - </widget> - </item> - <item> - <widget class="QDoubleSpinBox" name="spinBox_tc"> - <property name="suffix"> - <string>s</string> - </property> - <property name="decimals"> - <number>3</number> - </property> - <property name="minimum"> - <double>0.002000000000000</double> - </property> - <property name="maximum"> - <double>1.000000000000000</double> - </property> - <property name="singleStep"> - <double>0.010000000000000</double> - </property> - <property name="value"> - <double>0.017000000000000</double> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_7"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> + <spacer name="horizontalSpacer_6"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> </item> </layout> - </widget> - </widget> - <widget class="QWidget" name="page_5"> - <widget class="QWidget" name="verticalLayoutWidget_5"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>551</width> - <height>31</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout_7"> + </item> + </layout> + </widget> + </widget> + <widget class="QWidget" name="page_4"> + <widget class="QWidget" name="verticalLayoutWidget_4"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>561</width> + <height>36</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout_6"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_7"> <item> - <layout class="QHBoxLayout" name="horizontalLayout_11"/> + <widget class="QLabel" name="label_10"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Timeclamp</string> + </property> + <property name="margin"> + <number>4</number> + </property> + </widget> + </item> + <item> + <widget class="QDoubleSpinBox" name="spinBox_tc"> + <property name="suffix"> + <string>s</string> + </property> + <property name="decimals"> + <number>3</number> + </property> + <property name="minimum"> + <double>0.002000000000000</double> + </property> + <property name="maximum"> + <double>1.000000000000000</double> + </property> + <property name="singleStep"> + <double>0.010000000000000</double> + </property> + <property name="value"> + <double>0.017000000000000</double> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_7"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> </item> </layout> - </widget> - </widget> + </item> + </layout> </widget> - </item> - </layout> + </widget> + <widget class="QWidget" name="page_5"> + <widget class="QWidget" name="verticalLayoutWidget_5"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>551</width> + <height>31</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout_7"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_11"/> + </item> + </layout> + </widget> + </widget> + </widget> </item> <item> <spacer name="verticalSpacer"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> + <enum>QSizePolicy::Policy::Fixed</enum> </property> <property name="sizeHint" stdset="0"> <size> diff --git a/src/avp/core.py b/src/avp/core.py index 099b0b4..1e9a9c3 100644 --- a/src/avp/core.py +++ b/src/avp/core.py @@ -420,14 +420,18 @@ class Core: Core.canceled = False @classmethod - def storeSettings(cls): + def storeSettings(cls, dataDir=None): """Store settings/paths to directories as class variables""" from .__init__ import wd from .toolkit.ffmpeg import findFfmpeg cls.wd = wd - dataDir = QtCore.QStandardPaths.writableLocation( - QtCore.QStandardPaths.StandardLocation.AppConfigLocation + dataDir = ( + QtCore.QStandardPaths.writableLocation( + QtCore.QStandardPaths.StandardLocation.AppConfigLocation + ) + if dataDir is None + else dataDir ) # Windows: C:/Users/<USER>/AppData/Local/audio-visualizer # macOS: ~/Library/Preferences/audio-visualizer @@ -589,7 +593,3 @@ class Core: libLog.addHandler(libLogFile) # lowest level must be explicitly set on the root Logger libLog.setLevel(0) - - -# always store settings in class variables even if a Core object is not created -Core.storeSettings() diff --git a/src/avp/gui/mainwindow.py b/src/avp/gui/mainwindow.py index 5a051fd..3221783 100644 --- a/src/avp/gui/mainwindow.py +++ b/src/avp/gui/mainwindow.py @@ -414,8 +414,10 @@ class MainWindow(QtWidgets.QMainWindow): # Add initial components if none are in the list if not self.core.selectedComponents: - self.core.insertComponent(0, 0, self) - self.core.insertComponent(1, 1, self) + self.core.insertComponent( + 0, self.core.moduleIndexFor("Classic Visualizer"), self + ) + self.core.insertComponent(1, self.core.moduleIndexFor("Color"), self) # set colors to white and black to match classic appearance of program self.core.selectedComponents[0].page.lineEdit_visColor.setText( "255,255,255" @@ -900,8 +902,8 @@ class MainWindow(QtWidgets.QMainWindow): def createNewProject(self, prompt=True): if prompt: ch = self.openSaveChangesDialog("starting a new project") - if ch is None: - return + if ch is None: + return self.clear() self.currentProject = None diff --git a/tests/__init__.py b/tests/__init__.py index b615681..df08c7c 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,8 +1,9 @@ import os import numpy -# core always has to be imported first -import avp.core +from avp.core import Core +from avp.command import Command +from avp.gui.mainwindow import MainWindow from avp.toolkit.ffmpeg import readAudioFile from pytest import fixture @@ -10,16 +11,47 @@ from pytest import fixture @fixture def audioData(): """Fixture that gives a tuple of (completeAudioArray, duration)""" - soundFile = getTestDataPath("test.ogg") + # Core.storeSettings() needed to store ffmpeg bin location + initCore() + soundFile = getTestDataPath("inputfiles/test.ogg") yield readAudioFile(soundFile, MockVideoWorker()) -def getTestDataPath(filename): +@fixture +def command(qtbot): + initCore() + command = Command() + command.quit = lambda _: None + yield command + + +@fixture +def window(qtbot): + initCore() + window = MainWindow(None, None) + window.clear() + qtbot.addWidget(window) + window.settings.setValue("outputWidth", 1920) + window.settings.setValue("outputHeight", 1080) + yield window + + +def getTestDataPath(filename=""): """Get path to a file in the ./data directory""" tests_dir = os.path.dirname(os.path.abspath(__file__)) return os.path.join(tests_dir, "data", filename) +def initCore(): + testDataDir = getTestDataPath() + unwanted = ["autosave.avp", "settings.ini"] + for file in unwanted: + filename = os.path.join(testDataDir, "autosave.avp") + if os.path.exists(filename): + os.remove(filename) + Core.storeSettings(testDataDir) + + class MockSignal: """Pretends to be a pyqtSignal""" diff --git a/tests/data/test.jpg b/tests/data/inputfiles/test.jpg Binary files differindex 86266d9..86266d9 100644 --- a/tests/data/test.jpg +++ b/tests/data/inputfiles/test.jpg diff --git a/tests/data/test.ogg b/tests/data/inputfiles/test.ogg Binary files differindex 46af76c..46af76c 100644 --- a/tests/data/test.ogg +++ b/tests/data/inputfiles/test.ogg diff --git a/tests/data/test.png b/tests/data/inputfiles/test.png Binary files differindex f1ffd4a..f1ffd4a 100644 --- a/tests/data/test.png +++ b/tests/data/inputfiles/test.png diff --git a/tests/data/projects/testproject.avp b/tests/data/projects/testproject.avp new file mode 100644 index 0000000..fd6b6eb --- /dev/null +++ b/tests/data/projects/testproject.avp @@ -0,0 +1,17 @@ +[Components] +Classic Visualizer +1 +OrderedDict({'bars': 63, 'layout': 0, 'preset': None, 'scale': 20, 'smooth': 0, 'visColor': (255, 255, 255), 'y': 0.0}) +Color +1 +OrderedDict({'LG_end': 0.0, 'LG_start': 0.0, 'RG_centre': 0.0015625, 'RG_end': 0.0, 'RG_start': 0.0, 'color1': (0, 0, 0), 'color2': (133, 133, 133), 'fillType': 0, 'height': 1.0, 'preset': None, 'spread': 0, 'stretch': False, 'trans': False, 'width': 1.0, 'x': 0.0, 'y': 0.0}) + +[Settings] +componentDir=tests/data/inputfiles +inputDir=tests/data/inputfiles +presetDir=tests/data/presets +projectDir=tests/data/projects + +[WindowFields] +lineEdit_audioFile=tests/data/test.ogg +lineEdit_outputFile= diff --git a/tests/test_commandline_export.py b/tests/test_commandline_export.py index 05ead77..6d7f068 100644 --- a/tests/test_commandline_export.py +++ b/tests/test_commandline_export.py @@ -1,14 +1,13 @@ import sys import os import tempfile -from avp.command import Command -from . import getTestDataPath +from . import command, getTestDataPath, MockSignal from pytestqt import qtbot -def test_commandline_classic_export(qtbot): +def test_commandline_classic_export(qtbot, command): """Run Qt event loop and create a video in the system /tmp or /temp""" - soundFile = getTestDataPath("test.ogg") + soundFile = getTestDataPath("inputfiles/test.ogg") outputDir = tempfile.mkdtemp(prefix="avp-test-") outputFilename = os.path.join(outputDir, "output.mp4") sys.argv = [ @@ -21,9 +20,6 @@ def test_commandline_classic_export(qtbot): "-o", outputFilename, ] - - command = Command() - command.quit = lambda _: None command.parseArgs() # Command object now has a video_thread Worker which is exporting the video diff --git a/tests/test_commandline_parser.py b/tests/test_commandline_parser.py index 77836ce..186c602 100644 --- a/tests/test_commandline_parser.py +++ b/tests/test_commandline_parser.py @@ -1,39 +1,34 @@ import sys import pytest -from avp.command import Command from pytestqt import qtbot +from . import command -def test_commandline_help(qtbot): - command = Command() +def test_commandline_help(qtbot, command): sys.argv = ["", "--help"] with pytest.raises(SystemExit): command.parseArgs() -def test_commandline_help_if_bad_args(qtbot): - command = Command() +def test_commandline_help_if_bad_args(qtbot, command): sys.argv = ["", "--junk"] with pytest.raises(SystemExit): command.parseArgs() -def test_commandline_launches_gui_if_verbose(qtbot): - command = Command() +def test_commandline_launches_gui_if_verbose(qtbot, command): sys.argv = ["", "--verbose"] mode = command.parseArgs() assert mode == "GUI" -def test_commandline_launches_gui_if_verbose_with_project(qtbot): - command = Command() +def test_commandline_launches_gui_if_verbose_with_project(qtbot, command): sys.argv = ["", "test", "--verbose"] mode = command.parseArgs() assert mode == "GUI" -def test_commandline_tries_to_export(qtbot): - command = Command() +def test_commandline_tries_to_export(qtbot, command): didCallFunction = False def captureFunction(*args): @@ -46,16 +41,13 @@ def test_commandline_tries_to_export(qtbot): assert didCallFunction -def test_commandline_parses_classic_by_alias(qtbot): - command = Command() +def test_commandline_parses_classic_by_alias(qtbot, command): assert command.parseCompName("original") == "Classic Visualizer" -def test_commandline_parses_conway_by_short_name(qtbot): - command = Command() +def test_commandline_parses_conway_by_short_name(qtbot, command): assert command.parseCompName("conway") == "Conway's Game of Life" -def test_commandline_parses_image_by_name(qtbot): - command = Command() +def test_commandline_parses_image_by_name(qtbot, command): assert command.parseCompName("image") == "Image" diff --git a/tests/test_comp_color.py b/tests/test_comp_color.py index 6b82e4c..48b07ff 100644 --- a/tests/test_comp_color.py +++ b/tests/test_comp_color.py @@ -1,13 +1,12 @@ from avp.command import Command from pytestqt import qtbot from pytest import fixture -from . import imageDataSum +from . import imageDataSum, command @fixture -def coreWithColorComp(qtbot): +def coreWithColorComp(qtbot, command): """Fixture providing a Command object with Color component added""" - command = Command() command.settings.setValue("outputHeight", 1080) command.settings.setValue("outputWidth", 1920) command.core.insertComponent(0, command.core.moduleIndexFor("Color"), command) diff --git a/tests/test_comp_image.py b/tests/test_comp_image.py index a4f05e1..c580d5a 100644 --- a/tests/test_comp_image.py +++ b/tests/test_comp_image.py @@ -1,16 +1,15 @@ from avp.command import Command from pytestqt import qtbot from pytest import fixture -from . import audioData, MockSignal, imageDataSum, getTestDataPath +from . import audioData, command, MockSignal, imageDataSum, getTestDataPath sampleSize = 1470 # 44100 / 30 = 1470 @fixture -def coreWithImageComp(qtbot): +def coreWithImageComp(qtbot, command): """Fixture providing a Command object with Image component added""" - command = Command() command.settings.setValue("outputHeight", 1080) command.settings.setValue("outputWidth", 1920) command.core.insertComponent(0, command.core.moduleIndexFor("Image"), command) @@ -20,7 +19,7 @@ def coreWithImageComp(qtbot): def test_comp_image_set_path(coreWithImageComp): "Set imagePath of Image component" comp = coreWithImageComp.selectedComponents[0] - comp.imagePath = getTestDataPath("test.jpg") + comp.imagePath = getTestDataPath("inputfiles/test.jpg") image = comp.previewRender() assert imageDataSum(image) == 463711601 @@ -28,7 +27,7 @@ def test_comp_image_set_path(coreWithImageComp): def test_comp_image_scale_50_1080p(coreWithImageComp): """Image component stretches image to 50% at 1080p""" comp = coreWithImageComp.selectedComponents[0] - comp.imagePath = getTestDataPath("test.jpg") + comp.imagePath = getTestDataPath("inputfiles/test.jpg") image = comp.previewRender() sum = imageDataSum(image) comp.page.spinBox_scale.setValue(50) @@ -38,7 +37,7 @@ def test_comp_image_scale_50_1080p(coreWithImageComp): def test_comp_image_scale_50_720p(coreWithImageComp): """Image component stretches image to 50% at 720p""" comp = coreWithImageComp.selectedComponents[0] - comp.imagePath = getTestDataPath("test.jpg") + comp.imagePath = getTestDataPath("inputfiles/test.jpg") comp.page.spinBox_scale.setValue(50) image = comp.previewRender() sum = imageDataSum(image) diff --git a/tests/test_comp_life.py b/tests/test_comp_life.py index ad78e52..3c02117 100644 --- a/tests/test_comp_life.py +++ b/tests/test_comp_life.py @@ -1,13 +1,12 @@ from avp.command import Command from pytestqt import qtbot from pytest import fixture -from . import imageDataSum +from . import imageDataSum, command @fixture -def coreWithLifeComp(qtbot): +def coreWithLifeComp(qtbot, command): """Fixture providing a Command object with Waveform component added""" - command = Command() command.settings.setValue("outputHeight", 1080) command.settings.setValue("outputWidth", 1920) command.core.insertComponent( diff --git a/tests/test_comp_original.py b/tests/test_comp_original.py index 6264644..8cd00a4 100644 --- a/tests/test_comp_original.py +++ b/tests/test_comp_original.py @@ -2,16 +2,15 @@ from avp.command import Command from avp.toolkit.visualizer import transformData from pytestqt import qtbot from pytest import fixture -from . import audioData, MockSignal, imageDataSum +from . import audioData, command, MockSignal, imageDataSum sampleSize = 1470 # 44100 / 30 = 1470 @fixture -def coreWithClassicComp(qtbot): +def coreWithClassicComp(qtbot, command): """Fixture providing a Command object with Classic Visualizer component added""" - command = Command() command.core.insertComponent( 0, command.core.moduleIndexFor("Classic Visualizer"), command ) diff --git a/tests/test_comp_spectrum.py b/tests/test_comp_spectrum.py index 44fb257..870185c 100644 --- a/tests/test_comp_spectrum.py +++ b/tests/test_comp_spectrum.py @@ -1,13 +1,12 @@ from avp.command import Command from pytestqt import qtbot from pytest import fixture -from . import imageDataSum +from . import imageDataSum, command @fixture -def coreWithSpectrumComp(qtbot): +def coreWithSpectrumComp(qtbot, command): """Fixture providing a Command object with Spectrum component added""" - command = Command() command.settings.setValue("outputHeight", 1080) command.settings.setValue("outputWidth", 1920) command.core.insertComponent(0, command.core.moduleIndexFor("Spectrum"), command) diff --git a/tests/test_comp_text.py b/tests/test_comp_text.py index e389ff9..20b202d 100644 --- a/tests/test_comp_text.py +++ b/tests/test_comp_text.py @@ -2,13 +2,12 @@ from avp.command import Command from PyQt6.QtGui import QFont from pytestqt import qtbot from pytest import fixture, mark -from . import audioData, MockSignal, imageDataSum +from . import audioData, command, MockSignal, imageDataSum @fixture -def coreWithTextComp(qtbot): +def coreWithTextComp(qtbot, command): """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 diff --git a/tests/test_comp_waveform.py b/tests/test_comp_waveform.py index a71040b..eb5800d 100644 --- a/tests/test_comp_waveform.py +++ b/tests/test_comp_waveform.py @@ -1,12 +1,11 @@ -from avp.command import Command from pytestqt import qtbot from pytest import fixture +from . import command @fixture -def coreWithWaveformComp(qtbot): +def coreWithWaveformComp(qtbot, command): """Fixture providing a Command object with Waveform component added""" - command = Command() command.core.insertComponent(0, command.core.moduleIndexFor("Waveform"), command) yield command.core diff --git a/tests/test_mainwindow_projects.py b/tests/test_mainwindow_projects.py new file mode 100644 index 0000000..8ad491a --- /dev/null +++ b/tests/test_mainwindow_projects.py @@ -0,0 +1,40 @@ +from pytest import fixture +from pytestqt import qtbot +from . import getTestDataPath, window + + +def test_mainwindow_clear(qtbot, window): + """MainWindow.clear() gives us a clean slate""" + assert len(window.core.selectedComponents) == 0 + + +def test_mainwindow_openProject(qtbot, window): + """Open testproject.avp using MainWindow.openProject()""" + window.openProject(getTestDataPath("projects/testproject.avp"), prompt=False) + assert len(window.core.selectedComponents) == 2 + + +def test_mainwindow_newProject_without_unsaved_changes(qtbot, window): + """Starting new project without unsaved changes""" + didCallFunction = False + + def captureFunction(*args, **kwargs): + nonlocal didCallFunction + didCallFunction = True + + window.createNewProject(prompt=False) + assert not didCallFunction + assert len(window.core.selectedComponents) == 0 + + +def test_mainwindow_newProject_with_unsaved_changes(qtbot, window): + """Starting new project with unsaved changes""" + didCallFunction = False + + def captureFunction(*args, **kwargs): + nonlocal didCallFunction + didCallFunction = True + + window.openSaveChangesDialog = captureFunction + window.createNewProject(prompt=True) + assert didCallFunction diff --git a/tests/test_mainwindow_undostack.py b/tests/test_mainwindow_undostack.py index 1eec1ef..ceaf87e 100644 --- a/tests/test_mainwindow_undostack.py +++ b/tests/test_mainwindow_undostack.py @@ -1,16 +1,7 @@ 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 +from . import getTestDataPath, window def test_undo_classic_visualizer_sensitivity(window, qtbot): @@ -20,7 +11,7 @@ def test_undo_classic_visualizer_sensitivity(window, qtbot): 0, window.core.moduleIndexFor("Classic Visualizer"), window ) comp = window.core.selectedComponents[0] - comp.imagePath = getTestDataPath("test.jpg") + comp.imagePath = getTestDataPath("inputfiles/test.jpg") for i in range(1, 100): comp.page.spinBox_scale.setValue(i) assert comp.scale == 99 @@ -32,7 +23,7 @@ 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.imagePath = getTestDataPath("inputfiles/test.jpg") comp.page.spinBox_scale.setValue(100) for i in range(10, 401): comp.page.spinBox_scale.setValue(i) diff --git a/tests/test_toolkit_common.py b/tests/test_toolkit_common.py index 8e9dca2..b20ae53 100644 --- a/tests/test_toolkit_common.py +++ b/tests/test_toolkit_common.py @@ -2,20 +2,25 @@ from pytest import fixture from pytestqt import qtbot from avp.command import Command from avp.toolkit import blockSignals, rgbFromString +from . import command @fixture def gotWarning(): """Check if a function called log.warning""" import avp.toolkit.common as tk + warning = False + def gotWarning(): nonlocal warning return warning + class log: def warning(self, *args): nonlocal warning warning = True + oldLog = tk.log tk.log = log() try: @@ -24,8 +29,7 @@ def gotWarning(): tk.log = oldLog -def test_blockSignals(qtbot): - command = Command() +def test_blockSignals(qtbot, command): command.core.insertComponent(0, 0, command) comp = command.core.selectedComponents[0] assert comp.page.spinBox_scale.signalsBlocked() == False @@ -41,4 +45,4 @@ def test_rgbFromString(gotWarning): def test_rgbFromString_error(gotWarning): assert rgbFromString("255,255,256") == (255, 255, 255) - assert gotWarning()
\ No newline at end of file + assert gotWarning() diff --git a/tests/test_toolkit_ffmpeg.py b/tests/test_toolkit_ffmpeg.py index b015470..363eba1 100644 --- a/tests/test_toolkit_ffmpeg.py +++ b/tests/test_toolkit_ffmpeg.py @@ -1,7 +1,8 @@ import pytest +from avp.core import Core from avp.command import Command from avp.toolkit.ffmpeg import createFfmpegCommand -from . import audioData +from . import audioData, getTestDataPath, initCore def test_readAudioFile_data(audioData): @@ -14,6 +15,7 @@ def test_readAudioFile_duration(audioData): @pytest.mark.parametrize("width, height", ((1920, 1080), (1280, 720))) def test_createFfmpegCommand(width, height): + initCore() command = Command() command.settings.setValue("outputWidth", width) command.settings.setValue("outputHeight", height) @@ -4,7 +4,7 @@ requires-python = ">=3.12" [[package]] name = "audio-visualizer-python" -version = "2.2.1" +version = "2.2.2" source = { editable = "." } dependencies = [ { name = "numpy" }, |
