Skip to content
Snippets Groups Projects
Commit 64fdf6c6 authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Even more test coverage

parent 37f0f376
No related branches found
No related tags found
No related merge requests found
Pipeline #88136 passed
from qtpy import QtCore
import pytest import pytest
try: try:
...@@ -35,7 +38,6 @@ def test_flip(qtbot, datadir): ...@@ -35,7 +38,6 @@ def test_flip(qtbot, datadir):
assert not dragbutton.is_flipped() assert not dragbutton.is_flipped()
dragbutton._flip() dragbutton._flip()
assert dragbutton.is_flipped() assert dragbutton.is_flipped()
widget.exit_app() widget.exit_app()
...@@ -52,3 +54,51 @@ def test_sfg_invalidated_by_remove_of_operation(qtbot, datadir): ...@@ -52,3 +54,51 @@ def test_sfg_invalidated_by_remove_of_operation(qtbot, datadir):
assert ops_before_remove -1 == len(widget.operationDragDict) assert ops_before_remove -1 == len(widget.operationDragDict)
widget.exit_app() widget.exit_app()
def test_select_operation(qtbot, datadir):
widget = GUI.MainWindow()
qtbot.addWidget(widget)
widget._load_from_file(datadir.join('twotapfir.py'))
sfg = widget.sfg_dict['twotapfir']
op = sfg.find_by_name("cmul2")[0]
dragbutton = widget.operationDragDict[op]
assert not dragbutton.pressed
assert not widget.pressed_operations
# Click
qtbot.mouseClick(dragbutton, QtCore.Qt.MouseButton.LeftButton)
assert dragbutton.pressed
assert len(widget.pressed_operations) == 1
# Click again, should unselect
qtbot.mouseClick(dragbutton, QtCore.Qt.MouseButton.LeftButton)
# Currently failing
# assert not dragbutton.pressed
# assert not widget.pressed_operations
# Select another operation
op2 = sfg.find_by_name("add1")[0]
dragbutton2 = widget.operationDragDict[op2]
assert not dragbutton2.pressed
# Click
qtbot.mouseClick(dragbutton2, QtCore.Qt.MouseButton.LeftButton)
assert dragbutton2.pressed
# Unselect previous
assert not dragbutton.pressed
assert len(widget.pressed_operations) == 1
# Control-click first
qtbot.mouseClick(dragbutton, QtCore.Qt.MouseButton.LeftButton, QtCore.Qt.KeyboardModifier.ControlModifier)
assert dragbutton2.pressed
assert dragbutton.pressed
assert len(widget.pressed_operations) == 2
# Control-click second
qtbot.mouseClick(dragbutton2, QtCore.Qt.MouseButton.LeftButton, QtCore.Qt.KeyboardModifier.ControlModifier)
assert not dragbutton2.pressed
assert dragbutton.pressed
assert len(widget.pressed_operations) == 1
widget.exit_app()
...@@ -14,7 +14,7 @@ out1 = Output(name="") ...@@ -14,7 +14,7 @@ out1 = Output(name="")
# Operations: # Operations:
t1 = Delay(initial_value=0, name="") t1 = Delay(initial_value=0, name="")
cmul1 = ConstantMultiplication(value=0.5, name="cmul2", latency_offsets={'in0': None, 'out0': None}) cmul1 = ConstantMultiplication(value=0.5, name="cmul2", latency_offsets={'in0': None, 'out0': None})
add1 = Addition(name="", latency_offsets={'in0': None, 'in1': None, 'out0': None}) add1 = Addition(name="add1", latency_offsets={'in0': None, 'in1': None, 'out0': None})
cmul2 = ConstantMultiplication(value=0.5, name="cmul", latency_offsets={'in0': None, 'out0': None}) cmul2 = ConstantMultiplication(value=0.5, name="cmul", latency_offsets={'in0': None, 'out0': None})
# Signals: # Signals:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment