Skip to content

Commit b11fcc6

Browse files
committed
Move InputSystemTestHooks out of InputSystem partial class
1 parent 5617d64 commit b11fcc6

5 files changed

Lines changed: 23 additions & 24 deletions

File tree

Assets/Tests/InputSystem/CoreTests_Editor.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public void Editor_DomainReload_PreservesUsagesOnDevices()
220220
var device = InputSystem.AddDevice<Gamepad>();
221221
InputSystem.SetDeviceUsage(device, CommonUsages.LeftHand);
222222

223-
InputSystem.TestHook_SimulateDomainReload(runtime);
223+
InputSystemTestHooks.TestHook_SimulateDomainReload(runtime);
224224

225225
var newDevice = InputSystem.devices[0];
226226

@@ -240,7 +240,7 @@ public void Editor_DomainReload_PreservesEnabledState()
240240

241241
Assert.That(device.enabled, Is.False);
242242

243-
InputSystem.TestHook_SimulateDomainReload(runtime);
243+
InputSystemTestHooks.TestHook_SimulateDomainReload(runtime);
244244

245245
var newDevice = InputSystem.devices[0];
246246

@@ -253,7 +253,7 @@ public void Editor_DomainReload_InputSystemInitializationCausesDevicesToBeRecrea
253253
{
254254
InputSystem.AddDevice<Gamepad>();
255255

256-
InputSystem.TestHook_SimulateDomainReload(runtime);
256+
InputSystemTestHooks.TestHook_SimulateDomainReload(runtime);
257257

258258
Assert.That(InputSystem.devices, Has.Count.EqualTo(1));
259259
Assert.That(InputSystem.devices[0], Is.TypeOf<Gamepad>());
@@ -290,7 +290,7 @@ public void Editor_DomainReload_CustomDevicesAreRestoredAsLayoutsBecomeAvailable
290290
InputSystem.RegisterLayout(kLayout);
291291
InputSystem.AddDevice("CustomDevice");
292292

293-
InputSystem.TestHook_SimulateDomainReload(runtime);
293+
InputSystemTestHooks.TestHook_SimulateDomainReload(runtime);
294294

295295
Assert.That(InputSystem.devices, Is.Empty);
296296

@@ -311,7 +311,7 @@ public void Editor_DomainReload_RetainsUnsupportedDevices()
311311
});
312312
InputSystem.Update();
313313

314-
InputSystem.TestHook_SimulateDomainReload(runtime);
314+
InputSystemTestHooks.TestHook_SimulateDomainReload(runtime);
315315

316316
Assert.That(InputSystem.GetUnsupportedDevices(), Has.Count.EqualTo(1));
317317
Assert.That(InputSystem.GetUnsupportedDevices()[0].interfaceName, Is.EqualTo("SomethingUnknown"));

Assets/Tests/InputSystem/CoreTests_Remoting.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,12 +498,12 @@ public FakeRemote()
498498

499499
public void SwitchToRemoteState()
500500
{
501-
InputSystem.TestHook_SwitchToDifferentInputManager(remoteManager);
501+
InputSystemTestHooks.TestHook_SwitchToDifferentInputManager(remoteManager);
502502
}
503503

504504
public void SwitchToLocalState()
505505
{
506-
InputSystem.TestHook_SwitchToDifferentInputManager(localManager);
506+
InputSystemTestHooks.TestHook_SwitchToDifferentInputManager(localManager);
507507
}
508508

509509
public void Dispose()

Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemEditorInitializer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,11 @@ private static void RegisterAssemblyReloadHooks()
341341

342342
private static void RegisterTestHooks()
343343
{
344-
InputSystem.s_TestHookInitializeForPlayModeTests = TestHook_InitializeForPlayModeTests;
344+
InputSystemTestHooks.s_TestHookInitializeForPlayModeTests = TestHook_InitializeForPlayModeTests;
345345
#if !ENABLE_CORECLR
346-
InputSystem.s_TestHookSimulateDomainReload = TestHook_SimulateDomainReload;
346+
InputSystemTestHooks.s_TestHookSimulateDomainReload = TestHook_SimulateDomainReload;
347347
#endif
348-
InputSystem.s_TestHookEditorCleanup = TestHook_EditorCleanup;
348+
InputSystemTestHooks.s_TestHookEditorCleanup = TestHook_EditorCleanup;
349349
}
350350

351351
private static void SetUpEditorRemoting()

Packages/com.unity.inputsystem/InputSystem/Runtime/InputSystemTestHooks.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
using System;
2-
using System.Collections.Generic;
32
using UnityEngine.InputSystem.LowLevel;
43

54
#if UNITY_EDITOR || UNITY_INCLUDE_TESTS
65

76
namespace UnityEngine.InputSystem
87
{
98
/// <summary>
10-
/// Extension of class to provide test-specific functionality.
11-
/// Editor-specific operations are handled via callbacks set by the Editor assembly.
9+
/// Test-only helpers that access InputSystem internals.
10+
/// Editor-specific operations are registered as delegates by the Editor assembly.
1211
/// </summary>
13-
public static partial class InputSystem
12+
internal static class InputSystemTestHooks
1413
{
1514
#if UNITY_EDITOR
1615
internal static Action<bool, IInputRuntime> s_TestHookInitializeForPlayModeTests;
@@ -36,26 +35,26 @@ internal static void TestHook_SimulateDomainReload(IInputRuntime runtime)
3635
internal static void TestHook_DestroyAndReset()
3736
{
3837
InputSystem.s_Manager?.Dispose();
39-
if (InputSystem.s_RemoteConnection != null)
40-
Object.DestroyImmediate(InputSystem.s_RemoteConnection);
38+
if (InputSystem.remoteConnection != null)
39+
Object.DestroyImmediate(InputSystem.remoteConnection);
4140

4241
s_TestHookEditorCleanup?.Invoke();
4342

4443
InputSystem.s_Manager = null;
45-
InputSystem.s_RemoteConnection = null;
44+
InputSystem.remoteConnection = null;
4645
InputSystem.s_Remote = null;
4746
}
4847

4948
internal static void TestHook_RestoreFromSavedState(InputManager manager, InputRemoting remote, RemoteInputPlayerConnection remoteConnection)
5049
{
51-
s_Manager = manager;
52-
s_Remote = remote;
53-
s_RemoteConnection = remoteConnection;
50+
InputSystem.s_Manager = manager;
51+
InputSystem.s_Remote = remote;
52+
InputSystem.remoteConnection = remoteConnection;
5453
}
5554

5655
internal static void TestHook_SwitchToDifferentInputManager(InputManager otherManager)
5756
{
58-
s_Manager = otherManager;
57+
InputSystem.s_Manager = otherManager;
5958
InputStateBuffers.SwitchTo(otherManager.m_StateBuffers, otherManager.defaultUpdateType);
6059
}
6160
}

Packages/com.unity.inputsystem/Tests/TestFixture/InputTestStateManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void Reset(bool enableRemoting, IInputRuntime runtime)
8484

8585
#if UNITY_EDITOR
8686
// Perform special initialization for running Editor tests
87-
InputSystem.TestHook_InitializeForPlayModeTests(enableRemoting, runtime);
87+
InputSystemTestHooks.TestHook_InitializeForPlayModeTests(enableRemoting, runtime);
8888
#else
8989
// For Player tests we can use the normal initialization
9090
InputSystem.InitializeInPlayer(runtime, false);
@@ -116,13 +116,13 @@ public void Restore()
116116
state.touchState.StaticDisposeCurrentState();
117117
state.inputActionState.StaticDisposeCurrentState();
118118

119-
InputSystem.TestHook_DestroyAndReset();
119+
InputSystemTestHooks.TestHook_DestroyAndReset();
120120

121121
state.inputUserState.RestoreSavedState();
122122
state.touchState.RestoreSavedState();
123123
state.inputActionState.RestoreSavedState();
124124

125-
InputSystem.TestHook_RestoreFromSavedState(state.manager, state.remote, state.remoteConnection);
125+
InputSystemTestHooks.TestHook_RestoreFromSavedState(state.manager, state.remote, state.remoteConnection);
126126
InputUpdate.Restore(state.managerState.updateState);
127127

128128
InputSystem.manager.InstallRuntime(InputSystem.manager.runtime);

0 commit comments

Comments
 (0)