def test_navigation_in_tools_editor(measure, windows, dialog_sleep): """Test navigating among the different measure tools and accessing their editors. """ item = ToolsEditorDockItem(measure=measure) window = DockItemTestingWindow(widget=item) window.show() window.maximize() process_app_events() sleep(dialog_sleep) nb = item.dock_widget().widgets()[0] pages = nb.pages() nb.selected_tab = pages[1].name process_app_events() sleep(dialog_sleep) nb.selected_tab = pages[2].name process_app_events() sleep(dialog_sleep) nb.selected_tab = pages[0].name process_app_events() sleep(dialog_sleep)
def test_text_monitor_item(text_monitor_workbench, monitor, dialog_sleep): """Test that the dock item of the text monitor does display the right entries. """ # Check only displayed entries are indeed shown. monitor.handle_database_change(('added', 'root/test', 0)) monitor.handle_database_change(('added', 'root/simp/test', 0)) monitor.handle_database_change(('added', 'root/comp/index', 0)) monitor.move_entries('displayed', 'undisplayed', [monitor.displayed_entries[0]]) w = DockItemTestingWindow(widget=TextMonitorItem(monitor=monitor)) w.show() process_app_events() f = w.widget.dock_widget() assert (sorted([l.text for l in f.widgets()[::2]]) == sorted([e.name for e in monitor.displayed_entries])) sleep(dialog_sleep) e = sorted(monitor.displayed_entries, key=attrgetter('path'))[0] e.name = 'new' e.value = '1' process_app_events() assert f.widgets()[0].text == 'new' assert f.widgets()[1].text == '1'
def test_ending_with_no_tools(measure, windows, dialog_sleep): """Test adding/moving/removing tools. """ for m in list(measure.monitors): measure.remove_tool('monitor', m) item = ToolsEditorDockItem(measure=measure) window = DockItemTestingWindow(widget=item) window.show() window.maximize() process_app_events() sleep(dialog_sleep) nb = item.dock_widget().widgets()[0] mon_ed = nb.pages()[1].page_widget().widgets()[0] # Add a tool def add_tool_1(dial): widgets = dial.central_widget().widgets() widgets[0].selected_item = 'Dummy' process_app_events() sleep(dialog_sleep) with handle_dialog('accept', custom=add_tool_1): mon_ed.widgets()[-4].clicked = True assert 'dummy' in measure.monitors # Move up and then down mon_ed.selected_id = 'dummy' assert not mon_ed.widgets()[-2].enabled assert not mon_ed.widgets()[-1].enabled # Remove dummy mon_ed.widgets()[-3].clicked = True process_app_events() sleep(dialog_sleep) assert 'dummy' not in measure.monitors
def test_manipulating_tools(measure, windows, dialog_sleep): """Test adding/moving/removing tools. """ item = ToolsEditorDockItem(measure=measure) window = DockItemTestingWindow(widget=item) window.show() window.maximize() process_app_events() sleep(dialog_sleep) nb = item.dock_widget().widgets()[0] pre_hook_ed = nb.pages()[0].page_widget().widgets()[0] # Add a tool def add_tool_1(dial): widgets = dial.central_widget().widgets() widgets[0].selected_item = 'Dummy' process_app_events() sleep(dialog_sleep) widgets[-2].clicked = True with handle_dialog(custom=add_tool_1): pre_hook_ed.widgets()[-4].clicked = True assert 'dummy' in measure.pre_hooks pre_hook_len = len(measure.pre_hooks) # Start to add a tool but cancel. with handle_dialog('reject'): pre_hook_ed.widgets()[-4].clicked = True assert len(measure.pre_hooks) == pre_hook_len # Add a tool using wrong id (in principle impossible) # TODO : fix this test second dialog never closes # def add_tool_2(dial): # pl = dial.measure.plugin # dial.selected_decl = pl.get_declarations('pre-hook', # ['dummy2'])['dummy2'] # dial.selected_decl.id = '__' # # with enaml.imports(): # from ecpy.app.errors.widgets import ErrorsDialog # # with handle_dialog(cls=ErrorsDialog): # with handle_dialog(custom=add_tool_2): # pre_hook_ed.widgets()[-4].clicked = True # Move up and then down pre_hook_ed.selected_id = 'Dummy' pre_hook_ed.widgets()[-2].clicked = True process_app_events() sleep(dialog_sleep) assert measure.pre_hooks.keys()[-2] == 'dummy' pre_hook_ed.widgets()[-1].clicked = True process_app_events() sleep(dialog_sleep) assert measure.pre_hooks.keys()[-1] == 'dummy' # Remove dummy pre_hook_ed.widgets()[-3].clicked = True process_app_events() sleep(dialog_sleep) assert 'dummy' not in measure.pre_hooks
def test_manipulating_tools(measure, windows, dialog_sleep): """Test adding/moving/removing tools. """ item = ToolsEditorDockItem(measure=measure) window = DockItemTestingWindow(widget=item) window.show() window.maximize() process_app_events() sleep(dialog_sleep) nb = item.dock_widget().widgets()[0] pre_hook_ed = nb.pages()[0].page_widget().widgets()[0] # Add a tool def add_tool_1(dial): widgets = dial.central_widget().widgets() widgets[0].selected_item = 'Dummy' process_app_events() sleep(dialog_sleep) with handle_dialog(custom=add_tool_1): pre_hook_ed.widgets()[-4].clicked = True assert 'dummy' in measure.pre_hooks pre_hook_len = len(measure.pre_hooks) # Start to add a tool but cancel. with handle_dialog('reject'): pre_hook_ed.widgets()[-4].clicked = True assert len(measure.pre_hooks) == pre_hook_len # Add a tool using wrong id (in principle impossible) # TODO : fix this test second dialog never closes # def add_tool_2(dial): # pl = dial.measure.plugin # dial.selected_decl = pl.get_declarations('pre-hook', # ['dummy2'])['dummy2'] # dial.selected_decl.id = '__' # # with enaml.imports(): # from ecpy.app.errors.widgets import ErrorsDialog # # with handle_dialog(cls=ErrorsDialog): # with handle_dialog(custom=add_tool_2): # pre_hook_ed.widgets()[-4].clicked = True # Move up and then down pre_hook_ed.selected_id = 'Dummy' pre_hook_ed.widgets()[-2].clicked = True process_app_events() sleep(dialog_sleep) assert list(measure.pre_hooks)[-2] == 'dummy' pre_hook_ed.widgets()[-1].clicked = True process_app_events() sleep(dialog_sleep) assert list(measure.pre_hooks)[-1] == 'dummy' # Remove dummy pre_hook_ed.widgets()[-3].clicked = True process_app_events() sleep(dialog_sleep) assert 'dummy' not in measure.pre_hooks