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_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