|
22 | 22 |
|
23 | 23 | import pytest |
24 | 24 |
|
| 25 | +from action_plugins import response_curve |
| 26 | +from action_plugins import root |
25 | 27 | from action_plugins import map_to_io |
26 | 28 | import dill |
| 29 | +from gremlin.ui import backend |
27 | 30 | from gremlin import event_handler |
| 31 | +from gremlin import intermediate_output |
| 32 | +from gremlin import plugin_manager |
28 | 33 | from gremlin import profile |
| 34 | +from gremlin import shared_state |
29 | 35 | from gremlin import types |
30 | 36 | from gremlin import mode_manager |
31 | 37 | from test.integration import app_tester |
32 | 38 |
|
| 39 | +_INPUT_IO_AXIS_LABEL = "InputAxis1" |
| 40 | +_OUTPUT_IO_AXIS_LABEL = "OutputAxis1" |
33 | 41 |
|
34 | | -@pytest.fixture(scope="module", autouse=True) |
35 | | -def profile_name() -> str: |
36 | | - return "action_response_curve.xml" |
| 42 | + |
| 43 | +@pytest.fixture(scope="module") |
| 44 | +def profile_setup() -> None: |
| 45 | + # This is important for locally-run tests where the last used profile could |
| 46 | + # get loaded, if present in configuration. |
| 47 | + backend.Backend().profile = pr = profile.Profile() |
| 48 | + shared_state.current_profile = pr |
| 49 | + |
| 50 | + # Create intermediate output axis for both input and output. |
| 51 | + io = intermediate_output.IntermediateOutput() |
| 52 | + io.reset() |
| 53 | + io.create(types.InputType.JoystickAxis, label=_INPUT_IO_AXIS_LABEL) |
| 54 | + io.create(types.InputType.JoystickAxis, label=_OUTPUT_IO_AXIS_LABEL) |
| 55 | + |
| 56 | + p_manager = plugin_manager.PluginManager() |
| 57 | + # Create response curve action. |
| 58 | + response_curve_action = p_manager.create_instance( |
| 59 | + response_curve.ResponseCurveData.name, |
| 60 | + types.InputType.JoystickAxis |
| 61 | + ) |
| 62 | + |
| 63 | + # Create intermediate output mapping action. |
| 64 | + map_to_io_action = p_manager.create_instance( |
| 65 | + map_to_io.MapToIOData.name, |
| 66 | + types.InputType.JoystickAxis |
| 67 | + ) |
| 68 | + map_to_io_action.io_input_guid = io[_OUTPUT_IO_AXIS_LABEL].guid |
| 69 | + |
| 70 | + # Add actions to profile. |
| 71 | + root_action = p_manager.create_instance(root.RootData.name, types.InputType.JoystickAxis) |
| 72 | + root_action.insert_action(response_curve_action, "children") |
| 73 | + root_action.insert_action(map_to_io_action, "children") |
| 74 | + # Add input item and its binding. |
| 75 | + input_item = profile.InputItem(pr.library) |
| 76 | + input_item.device_id = dill.UUID_IntermediateOutput |
| 77 | + input_item.input_id = io[_INPUT_IO_AXIS_LABEL].guid |
| 78 | + input_item.input_type = types.InputType.JoystickAxis |
| 79 | + input_item.mode = mode_manager.ModeManager().current.name |
| 80 | + input_item_binding = profile.InputItemBinding(input_item) |
| 81 | + input_item_binding.root_action = root_action |
| 82 | + input_item_binding.behavior = types.InputType.JoystickAxis |
| 83 | + input_item.action_sequences.append(input_item_binding) |
| 84 | + pr.inputs.setdefault(dill.UUID_IntermediateOutput, []).append(input_item) |
37 | 85 |
|
38 | 86 |
|
39 | 87 | @pytest.fixture |
40 | | -def input_axis_uuid(loaded_profile: profile.Profile) -> uuid.UUID: |
41 | | - return loaded_profile.inputs[dill.UUID_IntermediateOutput][0].input_id |
| 88 | +def input_axis_uuid() -> uuid.UUID: |
| 89 | + return intermediate_output.IntermediateOutput()[_INPUT_IO_AXIS_LABEL].guid |
42 | 90 |
|
43 | 91 |
|
44 | 92 | @pytest.fixture |
45 | | -def output_axis_uuid(loaded_profile: profile.Profile) -> uuid.UUID: |
46 | | - return loaded_profile.library.actions_by_type(map_to_io.MapToIOData)[ |
47 | | - 0 |
48 | | - ].io_input_guid |
| 93 | +def output_axis_uuid() -> uuid.UUID: |
| 94 | + return intermediate_output.IntermediateOutput()[_OUTPUT_IO_AXIS_LABEL].guid |
49 | 95 |
|
50 | 96 |
|
51 | 97 | class TestResponseCurve: |
|
0 commit comments