예제 #1
0
def test_display_with_images(device, test_images):
    (lenna, python) = test_images
    display = DeviceDisplay(device)
    # Add our main image
    display.add_image(python)
    # Add our component image
    display.add_image(lenna, subdevice=device.x)
    assert not display.image_widget.isHidden()
    # Show our subdevice and image
    display.show_subdevice(device.x.name)
    assert display.image_widget.currentWidget().filename == lenna
    # Hide all subdevices and show main image
    display.hide_subdevices()
    assert display.image_widget.currentWidget().filename == python
    return display
예제 #2
0
def test_display_with_funcs(device):
    display = DeviceDisplay(device, methods=[device.insert, device.remove])
    # The method panel is visible
    assert not display.method_panel.isHidden()
    # Assert we have all our specified functions
    assert 'insert' in display.methods
    assert 'remove' in display.methods
    return display
예제 #3
0
def test_display_with_images(device, test_images):
    (lenna, python) = test_images
    # Create a display with our image
    display = DeviceDisplay(device, image=lenna)
    assert display.image_widget.filename == lenna
    # Add our python image
    display.add_image(python)
    assert display.image_widget.filename == python
    # Add our component image
    display.add_image(lenna, subdevice=device.x)
    # Show our subdevice and image
    sub_display = display.get_subdisplay(device.x)
    assert sub_display.image_widget.filename == lenna
    # Bad input
    with pytest.raises(ValueError):
        display.add_image(lenna, subdevice=device)
    return display
예제 #4
0
def test_display(device):
    display = DeviceDisplay(device)
    # We have all our signals
    shown_read_sigs = list(display.read_panel.signals.keys())
    assert all(
        [clean_attr(sig) in shown_read_sigs for sig in device.read_attrs])
    shown_cfg_sigs = list(display.config_panel.signals.keys())
    assert all([
        clean_attr(sig) in shown_cfg_sigs for sig in device.configuration_attrs
    ])
    # We have all our subdevices
    sub_devices = [
        getattr(disp, 'device', None)
        for disp in display.ui.subdisplay.children()
    ]
    assert all(
        [getattr(device, dev) in sub_devices for dev in device._sub_devices])
    return display
예제 #5
0
def test_subdisplay(qapp, device):
    # Set display by Device component
    display = DeviceDisplay(device)
    display.show_subdisplay(device.x)
    assert not display.ui.subwindow.isHidden()
    assert display.ui.subdisplay.currentWidget().device == device.x
    # Set display by name
    display.show_subdisplay(clean_name(device.y))
    assert display.ui.subdisplay.currentWidget().device == device.y
    # Add a tool
    w = QWidget()
    # Clear other tools
    display.ui.tool_list.clear()
    display.add_tool('My Tool', w)
    # Release a model press event
    tool_item = display.ui.tool_list.item(0)
    tool_model = display.ui.tool_list.indexFromItem(tool_item)
    display.show_subdisplay(tool_model)
    assert display.ui.subdisplay.currentWidget() == w
    # Hide all our subdisplays
    display.hide_subdisplays()
    assert display.ui.subwindow.isHidden()
    assert display.ui.tool_list.selectedIndexes() == []
    assert display.ui.tool_list.selectedIndexes() == []
    return display
예제 #6
0
def test_display_with_hints(device):
    device.hints = {'fields': [device.name + '_read1']}
    display = DeviceDisplay(device)
    assert len(display.ui.hint_plot.curves) == 1
    return display