Skip to content

Commit 2915104

Browse files
committed
Move test back to in Editor only tests
1 parent 5511859 commit 2915104

File tree

2 files changed

+34
-31
lines changed

2 files changed

+34
-31
lines changed

Assets/Tests/InputSystem/CoreTests_Editor.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2905,6 +2905,39 @@ private static void DisableProjectWideActions()
29052905
#endif
29062906
}
29072907

2908+
[Test]
2909+
[Category("Editor")]
2910+
public void Editor_InitializeInEditor_EnablesProjectWideActions()
2911+
{
2912+
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
2913+
if (InputSystem.actions != null)
2914+
{
2915+
// Asserts that project wide actions are enabled by default.
2916+
// Before the test is run, InputSystem.Reset() is called which will enable them.
2917+
// It can be interpreted as a mock of the behavior that happens when `InitializeInEditor()` is called.
2918+
Assert.That(InputSystem.actions.enabled, Is.True);
2919+
2920+
// Calling exit play mode callbacks will disable them
2921+
InputSystem.OnPlayModeChange(PlayModeStateChange.ExitingPlayMode);
2922+
InputSystem.OnPlayModeChange(PlayModeStateChange.EnteredEditMode);
2923+
2924+
Assert.That(InputSystem.actions.enabled, Is.False);
2925+
2926+
// Calling enter play mode callbacks will not re-enable them per default. They are only
2927+
// enabled when `InputSystem.InitializeInEditor()` is called, which happens before these callbacks.
2928+
// Note: Project-wide actions are disabled at this point. These next lines are added to make sure we
2929+
// establish behavior that project-wide actions should be enabled only once
2930+
// `InputSystem.InitializeInEditor()` is called. Before this test was introduced, project-wide actions were
2931+
// enabled after entering play mode again which would lead to a different behavior than Player
2932+
// builds.
2933+
InputSystem.OnPlayModeChange(PlayModeStateChange.ExitingEditMode);
2934+
InputSystem.OnPlayModeChange(PlayModeStateChange.EnteredPlayMode);
2935+
2936+
Assert.That(InputSystem.actions.enabled, Is.False);
2937+
}
2938+
#endif
2939+
}
2940+
29082941
[Test]
29092942
[Category("Editor")]
29102943
public void Editor_LeavingPlayMode_DestroysAllActionStates()
@@ -2920,6 +2953,7 @@ public void Editor_LeavingPlayMode_DestroysAllActionStates()
29202953
InputSystem.OnPlayModeChange(PlayModeStateChange.ExitingEditMode);
29212954

29222955
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
2956+
29232957
// This simulates enabling project-wide actions, which is done before just before entering play mode,
29242958
// called from InputSystem.InitializeInEditor().
29252959
if (InputSystem.actions)

Assets/Tests/InputSystem/CoreTests_ProjectWideActions.cs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -196,37 +196,6 @@ public void ProjectWideActions_CanEnableCurrentActionMapOfPlayerInput(string act
196196
//NOTE: Asset actions are considered enabled even if a single action map is enabled
197197
Assert.That(playerInput.actions.enabled, Is.EqualTo(expectedResult));
198198
}
199-
200-
[Test]
201-
[Category("Editor")]
202-
public void ProjectWideActions_InitializeInEditorEnablesProjectWideActions()
203-
{
204-
if (InputSystem.actions != null)
205-
{
206-
// Asserts that project wide actions are enabled by default.
207-
// Before the test is run, InputSystem.Reset() is called which will enable them.
208-
// It can be interpreted as a mock of the behavior that happens when `InitializeInEditor()` is called.
209-
Assert.That(InputSystem.actions.enabled, Is.True);
210-
211-
// Calling exit play mode callbacks will disable them
212-
InputSystem.OnPlayModeChange(PlayModeStateChange.ExitingPlayMode);
213-
InputSystem.OnPlayModeChange(PlayModeStateChange.EnteredEditMode);
214-
215-
Assert.That(InputSystem.actions.enabled, Is.False);
216-
217-
// Calling enter play mode callbacks will not re-enable them per default. They are only
218-
// enabled when `InputSystem.InitializeInEditor()` is called, which happens before these callbacks.
219-
// Note: Project-wide actions are disabled at this point. These next lines are added to make sure we
220-
// establish behavior that project-wide actions should be enabled only once
221-
// `InputSystem.InitializeInEditor()` is called. Before this test was introduced, project-wide actions were
222-
// enabled after entering play mode again which would lead to a different behavior than Player
223-
// builds.
224-
InputSystem.OnPlayModeChange(PlayModeStateChange.ExitingEditMode);
225-
InputSystem.OnPlayModeChange(PlayModeStateChange.EnteredPlayMode);
226-
227-
Assert.That(InputSystem.actions.enabled, Is.False);
228-
}
229-
}
230199
}
231200

232201
#endif

0 commit comments

Comments
 (0)