Browse Source

Random bug fixes.

preloaded
Ben Niemann 3 years ago
parent
commit
4bb8ea6d2f
  1. 4
      noisicaa/builtin_nodes/pianoroll/processor_messages.py
  2. 1
      noisicaa/ui/editor_app_test.py
  3. 3
      noisicaa/ui/graph/base_node_test.py
  4. 13
      noisicaa/ui/track_list/editor_test.py
  5. 6
      noisidev/qttest.py
  6. 13
      noisidev/uitest.py

4
noisicaa/builtin_nodes/pianoroll/processor_messages.py

@ -20,14 +20,14 @@
#
# @end:license
from typing import Interable
from typing import Iterable
from noisicaa import audioproc
from noisicaa.builtin_nodes import processor_message_registry_pb2
from . import processor_messages_pb2
def emit_events(node_id: str, midi: Interable[bytes]) -> audioproc.ProcessorMessage:
def emit_events(node_id: str, midi: Iterable[bytes]) -> audioproc.ProcessorMessage:
msg = audioproc.ProcessorMessage(node_id=node_id)
pb = msg.Extensions[processor_message_registry_pb2.pianoroll_emit_events]
pb.midi.extend(midi)

1
noisicaa/ui/editor_app_test.py

@ -79,6 +79,7 @@ class EditorAppTest(unittest_mixins.ProcessManagerMixin, qttest.QtTestCase):
async def cleanup_testcase(self):
if self.app is not None:
await self.app.cleanup()
self.app = None
if self.process is not None:
await self.process.cleanup()

3
noisicaa/ui/graph/base_node_test.py

@ -27,7 +27,7 @@ from noisicaa import value_types
from . import base_node
class NoteTest(uitest.ProjectMixin, uitest.UITestCase):
class NodeTest(uitest.ProjectMixin, uitest.UITestCase):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@ -46,6 +46,7 @@ class NoteTest(uitest.ProjectMixin, uitest.UITestCase):
async def cleanup_testcase(self):
if self.nitem is not None:
self.nitem.cleanup()
self.nitem = None
def _scaledSize(self, zoom):
return QtCore.QSize(

13
noisicaa/ui/track_list/editor_test.py

@ -38,23 +38,14 @@ class TrackEditorItemTestMixin(uitest.ProjectMixin, uitest.UITestCase):
player_state=self.player_state,
context=self.context)
self.editor.resize(800, 400)
self.setWidgetUnderTest(self.editor)
async def cleanup_testcase(self):
if self.editor is not None:
self.editor.cleanup()
def _render(self):
img = QtGui.QPixmap(self.editor.size())
painter = QtGui.QPainter(img)
try:
self.editor.render(painter)
finally:
painter.end()
painter = None # QPainter must be destroyed before QImage.
img = None
def test_add_track(self):
with self.project.apply_mutations('test'):
self.project.create_node('builtin://pianoroll-track')
self._render()
self.renderWidget()

6
noisidev/qttest.py

@ -21,6 +21,7 @@
# @end:license
import asyncio
import concurrent.futures
import logging
from PyQt5 import QtWidgets
@ -45,7 +46,10 @@ class QtTestCase(unittest.AsyncTestCase):
cls.qt_app = QtWidgets.QApplication(['unittest'])
cls.qt_app.setQuitOnLastWindowClosed(False)
asyncio.set_event_loop(quamash.QEventLoop(cls.qt_app))
event_loop = quamash.QEventLoop(cls.qt_app)
asyncio.set_event_loop(event_loop)
executor = concurrent.futures.ThreadPoolExecutor(max_workers=10)
event_loop.set_default_executor(executor)
def setup_testcase(self):
if not constants.TEST_OPTS.ALLOW_UI:

13
noisidev/uitest.py

@ -396,7 +396,6 @@ class UITestCase(unittest_mixins.ProcessManagerMixin, qttest.QtTestCase):
async def setup_testcase(self):
self.hid_state = HIDState()
self.widget = None
self.setup_node_db_process(inline=True)
self.setup_urid_mapper_process(inline=True)
@ -447,6 +446,11 @@ class UITestCase(unittest_mixins.ProcessManagerMixin, qttest.QtTestCase):
if self.process is not None:
await self.process.cleanup()
self.app = None
self.context = None
self.widget_under_test = None
self.selection_set = None
def setWidgetUnderTest(self, widget):
self.widget_under_test = widget
@ -455,12 +459,7 @@ class UITestCase(unittest_mixins.ProcessManagerMixin, qttest.QtTestCase):
def renderWidget(self):
pixmap = QtGui.QPixmap(self.widget_under_test.size())
painter = QtGui.QPainter(pixmap)
try:
self.widget_under_test.render(painter)
finally:
painter.end()
painter = None # QPainter must be destroyed before QPixmap.
self.widget_under_test.render(pixmap)
return pixmap
def replayEvents(self, *events):

Loading…
Cancel
Save