def test_pane_positions(caplog): testing_utils.run_gui(gui_config={ 'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False }, runtime_config={ 'LEFT_BAR_DOCKED_POS': 500, 'RIGHT_BAR_DOCKED_POS': 950, 'CONSOLE_DOCKED_POS': 700, 'LEFT_BAR_WINDOW_UNDOCKED': False, 'RIGHT_BAR_WINDOW_UNDOCKED': False, 'CONSOLE_WINDOW_UNDOCKED': False }) from rafcon.gui.runtime_config import global_runtime_config original_runtime_config = global_runtime_config.as_dict() try: check_pane_positions() finally: for key, value in original_runtime_config.iteritems(): call_gui_callback(global_runtime_config.set_config_value, key, value) testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog)
def test_drag_and_drop_test(caplog): testing_utils.run_gui( gui_config={ 'AUTO_BACKUP_ENABLED': False, 'HISTORY_ENABLED': False }, runtime_config={ 'MAIN_WINDOW_MAXIMIZED': False, 'MAIN_WINDOW_SIZE': (1500, 800), 'MAIN_WINDOW_POS': (0, 0), 'LEFT_BAR_WINDOW_UNDOCKED': False, 'RIGHT_BAR_WINDOW_UNDOCKED': False, 'CONSOLE_WINDOW_UNDOCKED': False, 'LEFT_BAR_HIDDEN': True, 'RIGHT_BAR_HIDDEN': True, 'CONSOLE_HIDDEN': True, }, libraries={ "unit_test_state_machines": testing_utils.get_test_sm_path("unit_test_state_machines") }) import rafcon.core.singleton call_gui_callback(create_models) try: trigger_drag_and_drop_tests( rafcon.gui.singleton.state_machine_manager_model, rafcon.gui.singleton.main_window_controller) finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog, expected_warnings=1, expected_errors=0)
def test_gui(caplog): from os.path import join change_in_gui_config = { 'AUTO_BACKUP_ENABLED': False, 'HISTORY_ENABLED': False } libraries = { "ros": join(testing_utils.EXAMPLES_PATH, "libraries", "ros_libraries"), "turtle_libraries": join(testing_utils.EXAMPLES_PATH, "libraries", "turtle_libraries"), "generic": join(testing_utils.LIBRARY_SM_PATH, "generic") } testing_utils.run_gui(gui_config=change_in_gui_config, libraries=libraries) try: trigger_gui_signals() finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog, expected_warnings=0, expected_errors=1)
def test_semantic_data(caplog): testing_utils.run_gui(gui_config={'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False}) try: change_semantic_data_values() finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog)
def test_copy_delete_bug(caplog): from os.path import join libraries = { "ros": join(testing_utils.EXAMPLES_PATH, "libraries", "ros_libraries"), "turtle_libraries": join(testing_utils.EXAMPLES_PATH, "libraries", "turtle_libraries"), "generic": join(testing_utils.LIBRARY_SM_PATH, "generic") } change_in_gui_config = { 'AUTO_BACKUP_ENABLED': False, 'HISTORY_ENABLED': False } testing_utils.run_gui( gui_config=change_in_gui_config, libraries=libraries, ) try: trigger_copy_delete_bug_signals() finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog)
def test_recent_opened_state_machine_list(caplog): change_in_gui_config = { 'AUTO_BACKUP_ENABLED': True, 'HISTORY_ENABLED': False } libraries = { "ros": join(testing_utils.EXAMPLES_PATH, "libraries", "ros_libraries"), "turtle_libraries": join(testing_utils.EXAMPLES_PATH, "libraries", "turtle_libraries"), "generic": join(testing_utils.LIBRARY_SM_PATH, "generic") } testing_utils.run_gui(gui_config=change_in_gui_config, libraries=libraries) # , patch_threading=False) call_gui_callback(patch_backup_threading) try: trigger_gui_signals() except: raise finally: call_gui_callback(unpatch_backup_threading) testing_utils.close_gui() testing_utils.shutdown_environment( caplog=caplog, expected_warnings=0, expected_errors=1) # , unpatch_threading=False)
def test_storage_with_gui(with_gui, caplog): print("test storage with gui", with_gui) testing_utils.dummy_gui(None) if with_gui: testing_utils.run_gui(gui_config={ 'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False }) else: testing_utils.initialize_environment(gui_config={ 'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False }, gui_already_started=False) e = None try: save_state_machine(with_gui) except Exception as e: pass finally: if with_gui: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog) else: testing_utils.shutdown_environment(caplog=caplog, unpatch_threading=False) if e: raise e print("test storage with gui {0} finished".format(with_gui))
def test_pane_positions(caplog): testing_utils.run_gui(core_config=None, gui_config={'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False}, runtime_config={ 'MAIN_WINDOW_MAXIMIZED': False, 'MAIN_WINDOW_SIZE': (1500, 800), 'MAIN_WINDOW_POS': (0, 0), 'LEFT_BAR_DOCKED_POS': 400, 'RIGHT_BAR_DOCKED_POS': 800, 'CONSOLE_DOCKED_POS': 600, 'LEFT_BAR_WINDOW_UNDOCKED': False, 'RIGHT_BAR_WINDOW_UNDOCKED': False, 'CONSOLE_WINDOW_UNDOCKED': False, 'LEFT_BAR_HIDDEN': False, 'RIGHT_BAR_HIDDEN': False, 'CONSOLE_HIDDEN': False, }) from rafcon.gui.runtime_config import global_runtime_config original_runtime_config = global_runtime_config.as_dict() try: check_pane_positions() finally: for key, value in original_runtime_config.items(): call_gui_callback(global_runtime_config.set_config_value, key, value) testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog)
def test_gui(caplog): testing_utils.run_gui( gui_config={ 'AUTO_BACKUP_ENABLED': False, 'CHECK_PYTHON_FILES_WITH_PYLINT': False, 'PREFER_EXTERNAL_EDITOR': False }) # queue = Queue.Queue() # TODO think about to use this to get call_back methods return value by a generic scheme # thread = threading.Thread(target=lambda q, arg1: q.put(trigger_source_editor_signals(arg1)), args=(queue, main_window_controller)) errors = 1 try: result = trigger_source_editor_signals() if not result: logger.error( "!The editor required in this test was not found on this machine. Test was aborted!" ) errors = 2 except: raise finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog, expected_warnings=0, expected_errors=errors)
def test_backward_compatibility_storage(caplog): """This test ensures that old state machines storage formats can still be opened with the current RAFCON version""" path = testing_utils.get_test_sm_path( os.path.join("unit_test_state_machines", "backward_compatibility")) run_gui(gui_config={ 'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False }, libraries={ 'unit_test_state_machines': testing_utils.get_test_sm_path("unit_test_state_machines") }) try: run_backward_compatibility_state_machines(path) except Exception: raise finally: # two warning per minor version lower than the current RAFCON version state_machines = len([ filename for filename in os.listdir(path) if os.path.isdir(os.path.join(path, filename)) ]) testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog, expected_warnings=0)
def test_window_positions(caplog): testing_utils.run_gui(core_config=None, runtime_config={ 'LEFT_BAR_WINDOW_SIZE': (800, 800), 'RIGHT_BAR_WINDOW_SIZE': (800, 800), 'CONSOLE_WINDOW_SIZE': (800, 800), 'LEFT_BAR_WINDOW_POS': (10, 10), 'RIGHT_BAR_WINDOW_POS': (10, 10), 'CONSOLE_WINDOW_POS': (10, 10), 'LEFT_BAR_WINDOW_UNDOCKED': False, 'RIGHT_BAR_WINDOW_UNDOCKED': False, 'CONSOLE_WINDOW_UNDOCKED': False }, gui_config={ 'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False }) from rafcon.gui.runtime_config import global_runtime_config original_runtime_config = global_runtime_config.as_dict() try: undock_sidebars() finally: for key, value in original_runtime_config.iteritems(): call_gui_callback(global_runtime_config.set_config_value, key, value) testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog)
def test_backward_stepping_preemptive_state(caplog): testing_utils.run_gui(gui_config={'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False}) call_gui_callback(initialize_global_variables) try: execute_preemptive_state_forwards_backwards() finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog)
def test_simple_state_size_resize(state_path, recursive, rel_size, caplog, monkeypatch): testing_utils.run_gui(gui_config={'HISTORY_ENABLED': True}) try: from rafcon.gui.helpers.meta_data import check_gaphas_state_meta_data_consistency sm_m, canvas, view = open_test_state_machine() state_m = sm_m.get_state_model_by_path(state_path) state_v = canvas.get_view_for_model(state_m) orig_state_size = state_m.get_meta_data_editor()["size"] check_gaphas_state_meta_data_consistency(state_m, canvas, recursive=True) print "\ninitial:" print_state_sizes(state_m, canvas, ["C"]) view_rel_size = transform_size_v2i(view, state_v, rel_size) resize_state(view, state_v, rel_size, 3, recursive, monkeypatch) new_state_size = add_vectors(orig_state_size, view_rel_size) print "\nfirst resize:" print_state_sizes(state_m, canvas, ["C"]) assert_state_size_and_meta_data_consistency(state_m, state_v, new_state_size, canvas) rel_size = (-rel_size[0], -rel_size[1]) view_rel_size = transform_size_v2i(view, state_v, rel_size) resize_state(view, state_v, rel_size, 3, recursive, monkeypatch) print "\nsecond resize:" print_state_sizes(state_m, canvas, ["C"]) assert_state_size_and_meta_data_consistency(state_m, state_v, orig_state_size, canvas) call_gui_callback(sm_m.history.undo) print "\nfirst undo:" print_state_sizes(state_m, canvas, ["C"]) assert_state_size_and_meta_data_consistency(state_m, state_v, new_state_size, canvas) call_gui_callback(sm_m.history.undo) print "\nsecond undo:" print_state_sizes(state_m, canvas, ["C"]) assert_state_size_and_meta_data_consistency(state_m, state_v, orig_state_size, canvas) call_gui_callback(sm_m.history.redo) assert_state_size_and_meta_data_consistency(state_m, state_v, new_state_size, canvas) call_gui_callback(sm_m.history.redo) assert_state_size_and_meta_data_consistency(state_m, state_v, orig_state_size, canvas) finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog)
def test_backward_stepping_barrier_state(caplog): testing_utils.run_gui(gui_config={ 'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False }) call_gui_callback(initialize_global_variables) try: execute_barrier_state_forwards_backwards() except Exception, e: raise
def test_state_type_change_test(caplog): testing_utils.run_gui(gui_config={ 'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False }) try: trigger_state_type_change_tests(with_gui=True) finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog)
def test_bug_issue_586(caplog): testing_utils.run_gui(gui_config={ 'AUTO_BACKUP_ENABLED': False, 'HISTORY_ENABLED': True }, libraries={}) try: trigger_issue_586_reproduction_sequence() finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog)
def test_notification_debugging_example(caplog): testing_utils.run_gui(gui_config={ 'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False }) try: patch_notifications() finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog, expected_warnings=0, expected_errors=0)
def test_dynamic_state_insertion(caplog): testing_utils.run_gui( gui_config={'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False}, libraries={'unit_test_state_machines': testing_utils.get_test_sm_path("unit_test_state_machines")} ) try: execute_dynamic_state_insertion() except Exception: raise finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog)
def test_repetitive_ungroup_state_and_group_states(caplog): """Check if repetitive group and ungroup works""" libraries = {"unit_test_state_machines": testing_utils.get_test_sm_path("unit_test_state_machines")} testing_utils.run_gui(gui_config={'HISTORY_ENABLED': True}, libraries=libraries) try: trigger_repetitive_group_ungroup() except Exception: raise finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog, expected_warnings=0, expected_errors=1) pass
def test_state_machine_baking(caplog): testing_utils.dummy_gui(caplog) testing_utils.run_gui( gui_config={'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False}, libraries={'unit_test_state_machines': testing_utils.get_test_sm_path("unit_test_state_machines")} ) try: trigger_baking_commands() finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog)
def test_user_input_gaphas(caplog): run_gui(gui_config={ 'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False }, libraries={ 'unit_test_state_machines': testing_utils.get_test_sm_path("unit_test_state_machines") }) try: create_and_resize_state() except Exception, e: raise
def test_thread_observer_creation_list(caplog): # TODO use the patch/unpatch support of py.test testing_utils.run_gui() try: run_create() except: raise finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog, expected_warnings=0, expected_errors=0)
def test_gui_tests(monkeypatch, caplog): # let the gui thread create the gui singletons by opening and closing an empty gui testing_utils.run_gui(gui_config={ 'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False }) try: pass except: raise finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog)
def test_backward_stepping_library_state(caplog): testing_utils.run_gui(gui_config={'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False}, libraries={'unit_test': os.path.join(testing_utils.TESTS_PATH, 'assets', 'unit_test_state_machines', 'backward_step_library_execution_test', 'test_library') } ) call_gui_callback(initialize_global_variables) try: execute_library_state_forwards_backwards() except Exception: raise finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog)
def test_gui(caplog): testing_utils.run_gui(gui_config={ 'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False }) try: trigger_gvm_signals() except: raise finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog, expected_warnings=0, expected_errors=1)
def test_dialog_test(caplog): testing_utils.run_gui(gui_config={ 'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False }) logger.debug("Dialog test started.") try: trigger_dialog_tests() except Exception: raise finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog, expected_warnings=0, expected_errors=0)
def test_user_input_gaphas(caplog): run_gui(gui_config={ 'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False }, libraries={ 'unit_test_state_machines': testing_utils.get_test_sm_path("unit_test_state_machines") }) try: create_and_resize_state() except Exception as e: raise finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog)
def test_backward_compatibility_storage(caplog): """This test ensures that old state machines storage formats can still be opened with the current RAFCON version""" path = get_backward_compatibility_state_machines_path() if not os.path.exists(path): logger.info( "test_backward_compatibility_storage: the current python interpreter version is not supported" ) return run_gui(gui_config={ 'HISTORY_ENABLED': False, 'AUTO_BACKUP_ENABLED': False }, libraries={ 'unit_test_state_machines': testing_utils.get_test_sm_path("unit_test_state_machines") }) try: logger.info("Run backward compatibility state machine for own version") run_backward_compatibility_state_machines(path) logger.info( "Run backward compatibility state machine for other versions") all_versions_path = testing_utils.get_test_sm_path( os.path.join("unit_test_state_machines", "backward_compatibility")) for python_version_folder in os.listdir(all_versions_path): full_python_version_path = os.path.join(all_versions_path, python_version_folder) if os.path.isdir(full_python_version_path): if full_python_version_path == path: pass else: run_backward_compatibility_state_machines( full_python_version_path) except Exception: raise finally: # two warning per minor version lower than the current RAFCON version state_machines = len([ filename for filename in os.listdir(path) if os.path.isdir(os.path.join(path, filename)) ]) testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog, expected_warnings=0)
def test_thread_observer_creation_list(caplog): # The side bars have been hidden in the state_resize test; here we show them again testing_utils.run_gui( runtime_config={ 'LEFT_BAR_HIDDEN': False, 'RIGHT_BAR_HIDDEN': False, 'CONSOLE_HIDDEN': False, }) try: run_create() except: raise finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog, expected_warnings=0, expected_errors=0)
def test_logging_view_widget(caplog): from os.path import join change_in_gui_config = {'AUTO_BACKUP_ENABLED': False, 'HISTORY_ENABLED': False, "CONSOLE_FOLLOW_LOGGING": False, "LOGGING_SHOW_VERBOSE": True, "LOGGING_SHOW_DEBUG": True, "LOGGING_SHOW_WARNING": True, "LOGGING_SHOW_ERROR": True} libraries = {"ros": join(testing_utils.EXAMPLES_PATH, "libraries", "ros_libraries"), "turtle_libraries": join(testing_utils.EXAMPLES_PATH, "libraries", "turtle_libraries"), "generic": join(testing_utils.LIBRARY_SM_PATH, "generic")} testing_utils.run_gui(gui_config=change_in_gui_config, libraries=libraries) try: trigger_logging_view_gui_signals() finally: testing_utils.close_gui() testing_utils.shutdown_environment(caplog=caplog, expected_warnings=0, expected_errors=0)