Skip to content

Commit 651526e

Browse files
committed
Added more tests, code cleanup, refactored QA script to QA asset folder.
1 parent 0dbc8f5 commit 651526e

11 files changed

+539
-246
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using UnityEngine;
5+
using UnityEngine.InputSystem;
6+
7+
internal static class DumpInputActionReferences
8+
{
9+
private static void DumpReferences(StringBuilder sb, string prefix, InputActionReference[] references)
10+
{
11+
sb.Append(prefix + ":\n");
12+
foreach (var reference in references)
13+
{
14+
var s = reference.action != null ? "Yes" : "No";
15+
sb.Append($"- {reference.name} (Resolved: {s}, Asset: {reference.asset})\n");
16+
}
17+
}
18+
19+
private static void DumpReferences()
20+
{
21+
var sb = new StringBuilder();
22+
DumpReferences(sb, "Loaded objects", Object.FindObjectsByType<InputActionReference>(
23+
FindObjectsInactive.Include, FindObjectsSortMode.InstanceID));
24+
DumpReferences(sb, "All objects:", Resources.FindObjectsOfTypeAll<InputActionReference>());
25+
Debug.Log(sb.ToString());
26+
}
27+
28+
[UnityEditor.MenuItem("QA Tools/Dump Input Action References to Console", false, 100)]
29+
private static void Dump()
30+
{
31+
DumpReferences();
32+
}
33+
}

Assets/Editor/DumpInputActionReferences.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Tests/InputSystem.Editor/EditorPrefsTestUtils.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,36 @@ public static void SaveEditorPrefs()
2525
/// <summary>
2626
/// Call this from a tests TearDown routine to restore editor preferences to the state it had before the test.
2727
/// </summary>
28+
/// <remarks>Note that if domain reloads have not been disabled and you have a domain reload mid-test,
29+
/// this utility will fail to restore editor preferences since the saved data will be lost.</remarks>
2830
public static void RestoreEditorPrefs()
2931
{
3032
EditorPrefs.SetBool(EnterPlayModeOptionsEnabledKey, _savedEnterPlayModeOptionsEnabled);
3133
EditorPrefs.SetInt(EnterPlayModeOptionsKey, _savedEnterPlayModeOptions);
3234
}
3335

36+
/// <summary>
37+
/// Returns whether domain reloads are disabled.
38+
/// </summary>
39+
/// <returns>true if domain reloads have been disabled, else false.</returns>
40+
public static bool IsDomainReloadsDisabled()
41+
{
42+
return EditorPrefs.GetBool(EnterPlayModeOptionsEnabledKey, false) &&
43+
(EditorPrefs.GetInt(EnterPlayModeOptionsKey, (int)EnterPlayModeOptions.None) &
44+
(int)EnterPlayModeOptions.DisableDomainReload) != 0;
45+
}
46+
47+
/// <summary>
48+
/// Returns whether scene reloads are disabled.
49+
/// </summary>
50+
/// <returns>true if scene reloads have been disabled, else false.</returns>
51+
public static bool IsSceneReloadsDisabled()
52+
{
53+
return EditorPrefs.GetBool(EnterPlayModeOptionsEnabledKey, false) &&
54+
(EditorPrefs.GetInt(EnterPlayModeOptionsKey, (int)EnterPlayModeOptions.None) &
55+
(int)EnterPlayModeOptions.DisableSceneReload) != 0;
56+
}
57+
3458
/// <summary>
3559
/// Call this from within a test to temporarily enable domain reload.
3660
/// </summary>
@@ -44,9 +68,9 @@ public static void EnableDomainReload()
4468
/// </summary>
4569
public static void DisableDomainReload()
4670
{
47-
EditorPrefs.SetBool(EnterPlayModeOptionsEnabledKey, true);
4871
EditorPrefs.SetInt(EnterPlayModeOptionsKey, (int)(EnterPlayModeOptions.DisableDomainReload |
4972
EnterPlayModeOptions.DisableSceneReload));
73+
EditorPrefs.SetBool(EnterPlayModeOptionsEnabledKey, true);
5074
}
5175
}
5276
}

0 commit comments

Comments
 (0)