Skip to content
Snippets Groups Projects
test_simulation_gui.py 1.41 KiB
Newer Older
  • Learn to ignore specific revisions
  • Oscar Gustafsson's avatar
    Oscar Gustafsson committed
    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")
    
    
    
    @pytest.mark.filterwarnings("ignore:No artists with labels found to put in legend")
    
    Oscar Gustafsson's avatar
    Oscar Gustafsson committed
    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
    
    Oscar Gustafsson's avatar
    Oscar Gustafsson committed
        assert len(widget._plot_axes.lines) == 1
    
    
    
    @pytest.mark.filterwarnings("ignore:No artists with labels found to put in legend")
    
    Oscar Gustafsson's avatar
    Oscar Gustafsson committed
    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
    
    Oscar Gustafsson's avatar
    Oscar Gustafsson committed
        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