def test_all_generic_libraries_in_a_row(gui): gui(initialize_global_variables) with pytest.warns(log.RAFCONDeprecationWarning) as deprecations_warnings: execute_all_generic_libraries_with_keyboard_only(gui) assert len([ record for record in deprecations_warnings if record.category is log.RAFCONDeprecationWarning ]) == 4
def test_preemption_of_all_state_machines_at_once(gui): gui(initialize_global_variables) with pytest.warns(log.RAFCONDeprecationWarning) as deprecations_warnings: from rafcon.core.singleton import state_machine_execution_engine, state_machine_manager import rafcon.gui.singleton as gui_singleton menubar_ctrl = gui_singleton.main_window_controller.get_controller( 'menu_bar_controller') gui( menubar_ctrl.on_open_activate, None, None, testing_utils.get_test_sm_path( os.path.join("unit_test_state_machines", "all_dialogs_parallel_preempted"))) gui(menubar_ctrl.on_start_activate, None, None) duration_waited = 0. period = 0.1 while not state_machine_execution_engine.finished_or_stopped(): time.sleep(period) duration_waited += period if duration_waited > 3.: gui(menubar_ctrl.on_stop_activate, None, None) raise RuntimeError( "The state machine should finish in less then {0}".format( duration_waited)) print( "Run duration of execute_preemption_of_all_state_machines_at_once was: {0}" .format(duration_waited)) assert len([ record for record in deprecations_warnings if record.category is log.RAFCONDeprecationWarning ]) == 4
def test_user_input_gaphas(gui): menubar_ctrl = gui.singletons.main_window_controller.menu_bar_controller sm_ctrls = gui.singletons.main_window_controller.state_machines_editor_ctrl gui(menubar_ctrl.on_new_activate, None) graphical_editor_controller = sm_ctrls.get_controller(1) # get first state machine page in state machines notebook sm_page = list(sm_ctrls.tabs.items())[0][1]['page'] sm_model = list(sm_ctrls.tabs.items())[0][1]['state_machine_m'] state_view_for_root_state = graphical_editor_controller.canvas.get_view_for_model( sm_model.root_state) x, y = south_east_coordinates_of_model(state_view_for_root_state) # print x, y gui(resize_state, sm_model, sm_page, graphical_editor_controller) # wait_for_gui() # graphical_editor_controller.canvas.update() new_x, new_y = south_east_coordinates_of_model(state_view_for_root_state) sleep_time = 0.01 max_counter = 10.0 / 0.01 counter = 0 while new_x == x and new_y == y: new_x, new_y = south_east_coordinates_of_model( state_view_for_root_state) counter += 1 if counter > max_counter: break time.sleep(sleep_time) # print new_x, new_y assert x < new_x assert y < new_y
def execute_all_generic_libraries_with_keyboard_only(gui): menubar_ctrl = gui.singletons.main_window_controller.menu_bar_controller gui( menubar_ctrl.on_open_activate, None, None, testing_utils.get_test_sm_path( os.path.join("unit_test_state_machines", "all_generic_libraries"))) testing_utils.wait_for_gui() gui(menubar_ctrl.on_start_activate, None, None) import time from pykeyboard import PyKeyboard time.sleep(0.5) k = PyKeyboard() k.tap_key('Return', 7, 0.5) k.tap_key('Tab', 2, 0.5) k.tap_key('Return', 5, 0.5) gui(menubar_ctrl.on_stop_activate, None, None)