Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import pytest
from qtpy import QtCore
try:
from b_asic.gui_utils.plot_window import PlotWindow
except ImportError:
pytestmark = pytest.mark.skip("Qt not setup")
def test_start(qtbot):
widget = PlotWindow({})
qtbot.addWidget(widget)
def test_start_with_data(qtbot):
sim_res = {
'0': [0.5, 0.5, 0, 0],
'add1': [0.5, 0.5, 0, 0],
'cmul1': [0, 0.5, 0, 0],
'cmul2': [0.5, 0, 0, 0],
'in1': [1, 0, 0, 0],
't1': [0, 1, 0, 0],
}
widget = PlotWindow(sim_res)
qtbot.addWidget(widget)
assert widget.checklist.count() == 6
assert len(widget._plot_axes.lines) == 1
def test_click_buttons(qtbot):
sim_res = {
'0': [0.5, 0.5, 0, 0],
'add1': [0.5, 0.5, 0, 0],
'cmul1': [0, 0.5, 0, 0],
'cmul2': [0.5, 0, 0, 0],
'in1': [1, 0, 0, 0],
't1': [0, 1, 0, 0],
}
widget = PlotWindow(sim_res)
qtbot.addWidget(widget)
assert widget.checklist.count() == 6
assert len(widget._plot_axes.lines) == 1
qtbot.mouseClick(widget._button_all, QtCore.Qt.MouseButton.LeftButton)
assert len(widget._plot_axes.lines) == 6
qtbot.mouseClick(widget._button_none, QtCore.Qt.MouseButton.LeftButton)
assert len(widget._plot_axes.lines) == 0