Esempio n. 1
0
def test_pulse_view(windows, workbench, process_and_sleep):
    """Test the view of the Pulse class.

    """
    from ecpy.testing.util import show_widget
    with enaml.imports():
        from ecpy_pulses.pulses.sequences.views.base_sequences_views\
            import RootSequenceView

    pulse = Pulse(root=RootSequence(context=TestContext()))
    pulse.kind = 'Analogical'
    root = pulse.root
    root.add_child_item(0, pulse)
    core = workbench.get_plugin('enaml.workbench.core')
    root_view = RootSequenceView(item=root, core=core)
    pulse_view = root_view.view_for(pulse)
    show_widget(root_view)
    process_and_sleep()

    # Test selecting a slope shape
    shape_select = pulse_view.widgets()[-1].widgets()[-1]
    shape_select.selected = 'ecpy_pulses.SlopeShape'
    process_and_sleep()

    shape_view = pulse_view.widgets()[-1]
    sv_widgets = shape_view.split_items()[0].split_widget().widgets()

    for mode in ('Start/Stop', 'Start/Slope', 'Slope/Stop'):
        sv_widgets[1].selected = mode
        process_and_sleep()
        assert sv_widgets[2].text == mode.split('/')[0]
        assert sv_widgets[4].text == mode.split('/')[1]
Esempio n. 2
0
def test_pulse_view(windows, workbench, pulse, process_and_sleep):
    """Test the view of the Pulse class.

    """
    import enaml
    from ecpy.testing.util import show_widget
    with enaml.imports():
        from ecpy_pulses.pulses.sequences.views.base_sequences_views\
            import RootSequenceView

    pulse.kind = 'Analogical'
    root = pulse.root
    root.add_child_item(0, pulse)
    core = workbench.get_plugin('enaml.workbench.core')
    root_view = RootSequenceView(item=root, core=core)
    pulse_view = root_view.view_for(pulse)
    show_widget(root_view)
    process_and_sleep()

    # Test swithcing between logical and analogical
    widgets_num = len(pulse_view.widgets())
    pulse.kind = 'Logical'
    process_and_sleep()
    process_and_sleep()
    assert widgets_num - 1 == len(pulse_view.widgets())
    pulse.kind = 'Analogical'
    process_and_sleep()
    assert widgets_num == len(pulse_view.widgets())

    # Test selecting a shape
    shape_select = pulse_view.widgets()[-1].widgets()[-1]
    shape_select.selected = 'ecpy_pulses.SquareShape'
    process_and_sleep()
    assert widgets_num + 1 == len(pulse_view.widgets())
    shape_select.selected = ''
    process_and_sleep()
    assert widgets_num == len(pulse_view.widgets())

    # Test adding a modulation
    mod_check = pulse_view.widgets()[-1].widgets()[0]
    mod_check.checked = True
    process_and_sleep()
    assert widgets_num + 1 == len(pulse_view.widgets())
    mod_check.checked = False
    process_and_sleep()
    assert widgets_num == len(pulse_view.widgets())
Esempio n. 3
0
def test_pulse_view(windows, workbench, pulse, process_and_sleep):
    """Test the view of the Pulse class.

    """
    import enaml
    from ecpy.testing.util import show_widget
    with enaml.imports():
        from ecpy_pulses.pulses.sequences.views.base_sequences_views\
            import RootSequenceView

    pulse.kind = 'Analogical'
    root = pulse.root
    root.add_child_item(0, pulse)
    core = workbench.get_plugin('enaml.workbench.core')
    root_view = RootSequenceView(item=root, core=core)
    pulse_view = root_view.view_for(pulse)
    show_widget(root_view)
    process_and_sleep()

    # Test swithcing between logical and analogical
    widgets_num = len(pulse_view.widgets())
    pulse.kind = 'Logical'
    process_and_sleep()
    process_and_sleep()
    assert widgets_num - 1 == len(pulse_view.widgets())
    pulse.kind = 'Analogical'
    process_and_sleep()
    assert widgets_num == len(pulse_view.widgets())

    # Test selecting a shape
    shape_select = pulse_view.widgets()[-1].widgets()[-1]
    shape_select.selected = 'ecpy_pulses.SquareShape'
    process_and_sleep()
    assert widgets_num + 1 == len(pulse_view.widgets())
    shape_select.selected = ''
    process_and_sleep()
    assert widgets_num == len(pulse_view.widgets())

    # Test adding a modulation
    mod_check = pulse_view.widgets()[-1].widgets()[0]
    mod_check.checked = True
    process_and_sleep()
    assert widgets_num + 1 == len(pulse_view.widgets())
    mod_check.checked = False
    process_and_sleep()
    assert widgets_num == len(pulse_view.widgets())
Esempio n. 4
0
def test_root_sequence_view(windows, workbench):
    """Test the root sequence view.

    """
    core = workbench.get_plugin('enaml.workbench.core')
    view = RootSequenceView(item=RootSequence(), core=core)

    show_widget(view)
    seq = BaseSequence()
    view.item.add_child_item(0, seq)
    assert seq in view._cache
    view.item.remove_child_item(0)
    assert seq not in view._cache

    but = view.widgets()[-1].pages()[1].page_widget().widgets()[0]
    with handle_dialog('reject'):
        but.clicked = True
Esempio n. 5
0
def test_root_sequence_view(windows, workbench):
    """Test the root sequence view.

    """
    core = workbench.get_plugin('enaml.workbench.core')
    view = RootSequenceView(item=RootSequence(),
                            core=core)

    show_widget(view)
    seq = BaseSequence()
    view.item.add_child_item(0, seq)
    assert seq in view._cache
    view.item.remove_child_item(0)
    assert seq not in view._cache

    but = view.widgets()[-1].pages()[1].page_widget().widgets()[0]
    with handle_dialog('reject'):
        but.clicked = True
Esempio n. 6
0
def test_conditional_sequence_view(windows, workbench, root,
                                   process_and_sleep):
    """Test the view of the Pulse class.

    """
    import enaml
    from ecpy.testing.util import show_and_close_widget
    with enaml.imports():
        from ecpy_pulses.pulses.sequences.views.base_sequences_views\
            import RootSequenceView

    core = workbench.get_plugin('enaml.workbench.core')
    root.add_child_item(0, ConditionalSequence())
    show_and_close_widget(RootSequenceView(item=root, core=core))
Esempio n. 7
0
def test_pulse_view2(windows, workbench, pulse):
    """Test showing a pulse logical at the start.

    """
    import enaml
    from ecpy.testing.util import show_and_close_widget
    with enaml.imports():
        from ecpy_pulses.pulses.sequences.views.base_sequences_views\
            import RootSequenceView

    pulse.kind = 'Logical'
    root = pulse.root
    root.add_child_item(0, pulse)
    core = workbench.get_plugin('enaml.workbench.core')
    root_view = RootSequenceView(item=root, core=core)
    show_and_close_widget(root_view)