def show_widget(widget): """Show a widget in a window """ win = Window() win.insert_children(None, [widget]) win.show() process_app_events() return win
def show_widget(qtbot, widget): """Show a widget in a window """ win = Window() win.insert_children(None, [widget]) win.show() wait_for_window_displayed(qtbot, win) return win
def test_auto_view(self): with traits_enaml.imports(): from enaml.widgets.api import Window model = AllTypes() window = Window() window.insert_children(None, (auto_view(model=model),)) with self.event_loop(): window.show() self.check_component_counts(window) self.check_label_text(window)
def test_workspace_lifecycle(workspace): """Test the workspace life cycle. """ process_app_events() workbench = workspace.plugin.workbench log = workbench.get_plugin('ecpy.app.logging') # Check UI creation assert workspace.content assert workspace.dock_area assert workbench.get_manifest('ecpy.measure.workspace.menus') # Check log handling assert 'ecpy.measure.workspace' in log.handler_ids # Check engine handling engine = workbench.get_manifest('test.measure').find('dummy_engine') assert engine.workspace_contributing # Check measure creation assert len(workspace.plugin.edited_measures.measures) == 1 assert workspace.plugin.edited_measures.measures[0].monitors # Check observance of engine selection. workspace.plugin.selected_engine = '' assert not engine.workspace_contributing workspace.plugin.selected_engine = 'dummy' assert engine.workspace_contributing # Test stopping the workspace core = workbench.get_plugin('enaml.workbench.core') cmd = 'enaml.workbench.ui.close_workspace' core.invoke_command(cmd, {'workspace': 'ecpy.measure.workspace'}) assert workspace.plugin.workspace is None assert not engine.workspace_contributing assert workbench.get_manifest('ecpy.measure.workspace.menus') is None assert 'ecpy.measure.workspace' not in log.handler_ids # Test restarting now that we have one edited measure. cmd = 'enaml.workbench.ui.select_workspace' core.invoke_command(cmd, {'workspace': 'ecpy.measure.workspace'}) assert len(workspace.plugin.edited_measures.measures) == 1 # Create a false monitors_window workspace.plugin.processor.monitors_window = Window() workspace.plugin.processor.monitors_window.show() process_app_events() # Stop again core = workbench.get_plugin('enaml.workbench.core') cmd = 'enaml.workbench.ui.close_workspace' core.invoke_command(cmd, {'workspace': 'ecpy.measure.workspace'}) process_app_events() assert not workspace.plugin.processor.monitors_window.visible
def test_auto_view(self): with traits_enaml.imports(): from enaml.widgets.api import Window model = AllTypes() window = Window() window.insert_children(None, (auto_view(model=model), )) with self.event_loop(): window.show() self.check_component_counts(window) self.check_label_text(window)
def test_workspace_lifecycle(exopy_qtbot, workspace, tmpdir): """Test the workspace life cycle. """ workbench = workspace.plugin.workbench log = workbench.get_plugin('exopy.app.logging') # Check UI creation def assert_ui(): assert workspace._selection_tracker._thread assert workspace.last_selected_measurement assert workspace.content assert workspace.dock_area assert workbench.get_manifest('exopy.measurement.workspace.menus') exopy_qtbot.wait_until(assert_ui) # Check log handling assert 'exopy.measurement.workspace' in log.handler_ids # Check engine handling engine = workbench.get_manifest('test.measurement').find('dummy_engine') assert engine.workspace_contributing # Check measurement creation assert len(workspace.plugin.edited_measurements.measurements) == 1 assert workspace.plugin.edited_measurements.measurements[0].monitors # Create a new measurement and enqueue it workspace.new_measurement() def assert_measurement_created(): assert len(workspace.plugin.edited_measurements.measurements) == 2 exopy_qtbot.wait_until(assert_measurement_created) m = workspace.plugin.edited_measurements.measurements[1] m.root_task.default_path = str(tmpdir) assert workspace.enqueue_measurement(m) exopy_qtbot.wait(10) # Create a tool edition window for d in workspace.dock_area.dock_items(): if d.name == 'meas_0': edition_view = d ed = edition_view.dock_widget().widgets()[0] btn = ed.widgets()[4] btn.clicked = True exopy_qtbot.wait(10) # Check observance of engine selection. workspace.plugin.selected_engine = '' assert not engine.workspace_contributing workspace.plugin.selected_engine = 'dummy' def assert_contrib(): assert engine.workspace_contributing exopy_qtbot.wait_until(assert_contrib) # Test stopping the workspace core = workbench.get_plugin('enaml.workbench.core') cmd = 'enaml.workbench.ui.close_workspace' core.invoke_command(cmd, {'workspace': 'exopy.measurement.workspace'}) assert workspace.plugin.workspace is None assert not engine.workspace_contributing assert workbench.get_manifest('exopy.measurement.workspace.menus') is None assert 'exopy.measurement.workspace' not in log.handler_ids assert not workspace._selection_tracker._thread.is_alive() # Test restarting now that we have two edited measurement. cmd = 'enaml.workbench.ui.select_workspace' core.invoke_command(cmd, {'workspace': 'exopy.measurement.workspace'}) assert len(workspace.plugin.edited_measurements.measurements) == 2 # Check that all dock items have been restored. names = [d.name for d in workspace.dock_area.dock_items()] for n in ('meas_0', 'meas_1', 'meas_0_tools'): assert n in names # Create a false monitors_window workspace.plugin.processor.monitors_window = Window() workspace.plugin.processor.monitors_window.show() exopy_qtbot.wait(10) # Stop again core = workbench.get_plugin('enaml.workbench.core') cmd = 'enaml.workbench.ui.close_workspace' core.invoke_command(cmd, {'workspace': 'exopy.measurement.workspace'}) def assert_not_visible(): assert not workspace.plugin.processor.monitors_window.visible exopy_qtbot.wait_until(assert_not_visible)