Skip to content
Draft

Large diffs are not rendered by default.

Original file line numberDiff line numberDiff line change
Expand Up@@ -58,7 +58,11 @@ public IEnumerator Test_AccessibilityLabel()
AccessibilityNode axObject = ButtonAXObject();
UnityEngine.Assertions.Assert.AreEqual(axObject.AccessibilityLabel, "Button");

#if UNITY_6000_4_OR_NEWER
bool succeeded = AccessibilityTests.RuniOSSideUnitTestWithKeyPathExpectingStringResult(EntityId.ToULong(axObject.gameObject.GetEntityId()), "accessibilityLabel", "Button");
#else
bool succeeded = AccessibilityTests.RuniOSSideUnitTestWithKeyPathExpectingStringResult(axObject.gameObject.GetInstanceID(), "accessibilityLabel", "Button");
#endif
UnityEngine.Assertions.Assert.IsTrue(succeeded);

yield return null;
Expand All@@ -75,7 +79,11 @@ public IEnumerator Test_AccessibilityValue()
AccessibilityNode axObject = ButtonAXObject();
UnityEngine.Assertions.Assert.AreEqual(axObject.AccessibilityValue, "ButtonValue");

#if UNITY_6000_4_OR_NEWER
bool succeeded = AccessibilityTests.RuniOSSideUnitTestWithKeyPathExpectingStringResult(EntityId.ToULong(axObject.gameObject.GetEntityId()), "accessibilityValue", "ButtonValue");
#else
bool succeeded = AccessibilityTests.RuniOSSideUnitTestWithKeyPathExpectingStringResult(axObject.gameObject.GetInstanceID(), "accessibilityValue", "ButtonValue");
#endif
UnityEngine.Assertions.Assert.IsTrue(succeeded);

yield return null;
Expand All@@ -92,7 +100,11 @@ public IEnumerator Test_AccessibilityHint()
AccessibilityNode axObject = ButtonAXObject();
UnityEngine.Assertions.Assert.AreEqual(axObject.AccessibilityHint, "ButtonHint");

#if UNITY_6000_4_OR_NEWER
bool succeeded = AccessibilityTests.RuniOSSideUnitTestWithKeyPathExpectingStringResult(EntityId.ToULong(axObject.gameObject.GetEntityId()), "accessibilityHint", "ButtonHint");
#else
bool succeeded = AccessibilityTests.RuniOSSideUnitTestWithKeyPathExpectingStringResult(axObject.gameObject.GetInstanceID(), "accessibilityHint", "ButtonHint");
#endif
UnityEngine.Assertions.Assert.IsTrue(succeeded);

yield return null;
Expand DownExpand Up@@ -135,7 +147,11 @@ public IEnumerator Test_PerformMagicTap()
return true;
};

#if UNITY_6000_4_OR_NEWER
bool tapSucceeded = AccessibilityRuntime._UnityAX_AccessibilityPerformMagicTap(EntityId.ToULong(axObject.gameObject.GetEntityId()));
#else
bool tapSucceeded = AccessibilityRuntime._UnityAX_AccessibilityPerformMagicTap(axObject.gameObject.GetInstanceID());
#endif
expectedMagicTapCount += 1;
UnityEngine.Assertions.Assert.AreEqual(magicTapCount, expectedMagicTapCount);
UnityEngine.Assertions.Assert.IsTrue(tapSucceeded);
Expand All@@ -156,7 +172,11 @@ public IEnumerator Test_PerformMagicTap()
return false;
};

#if UNITY_6000_4_OR_NEWER
tapSucceeded = AccessibilityRuntime._UnityAX_AccessibilityPerformMagicTap(EntityId.ToULong(axObject.gameObject.GetEntityId()));
#else
tapSucceeded = AccessibilityRuntime._UnityAX_AccessibilityPerformMagicTap(axObject.gameObject.GetInstanceID());
#endif
expectedMagicTapCount += 1;
UnityEngine.Assertions.Assert.AreEqual(magicTapCount, expectedMagicTapCount);
UnityEngine.Assertions.Assert.IsFalse(tapSucceeded);
Expand All@@ -171,7 +191,12 @@ public IEnumerator Test_PerformMagicTap()
//Unimplemented tap
axObject.onAccessibilityPerformMagicTap = null;

#if UNITY_6000_4_OR_NEWER
EntityId.ToULong(axObject.gameObject.GetEntityId())
tapSucceeded = AccessibilityRuntime._UnityAX_AccessibilityPerformMagicTap(EntityId.ToULong(axObject.gameObject.GetEntityId()));
#else
tapSucceeded = AccessibilityRuntime._UnityAX_AccessibilityPerformMagicTap(axObject.gameObject.GetInstanceID());
#endif
UnityEngine.Assertions.Assert.AreEqual(magicTapCount, expectedMagicTapCount);
UnityEngine.Assertions.Assert.IsFalse(tapSucceeded);
#if UNITY_IOS && !UNITY_EDITOR
Expand DownExpand Up@@ -205,7 +230,11 @@ public IEnumerator Test_PerformEscape()
return true;
};

#if UNITY_6000_4_OR_NEWER
bool tapSucceeded = AccessibilityRuntime._UnityAX_AccessibilityPerformEscape(EntityId.ToULong(axObject.gameObject.GetEntityId()));
#else
bool tapSucceeded = AccessibilityRuntime._UnityAX_AccessibilityPerformEscape(axObject.gameObject.GetInstanceID());
#endif
expectedEscapeCount += 1;
UnityEngine.Assertions.Assert.AreEqual(EscapeCount, expectedEscapeCount);
UnityEngine.Assertions.Assert.IsTrue(tapSucceeded);
Expand All@@ -226,7 +255,11 @@ public IEnumerator Test_PerformEscape()
return false;
};

#if UNITY_6000_4_OR_NEWER
tapSucceeded = AccessibilityRuntime._UnityAX_AccessibilityPerformEscape(EntityId.ToULong(axObject.gameObject.GetEntityId()));
#else
tapSucceeded = AccessibilityRuntime._UnityAX_AccessibilityPerformEscape(axObject.gameObject.GetInstanceID());
#endif
expectedEscapeCount += 1;
UnityEngine.Assertions.Assert.AreEqual(EscapeCount, expectedEscapeCount);
UnityEngine.Assertions.Assert.IsFalse(tapSucceeded);
Expand All@@ -241,7 +274,11 @@ public IEnumerator Test_PerformEscape()
//Unimplemented tap
axObject.onAccessibilityPerformEscape = null;

#if UNITY_6000_4_OR_NEWER
tapSucceeded = AccessibilityRuntime._UnityAX_AccessibilityPerformEscape(EntityId.ToULong(axObject.gameObject.GetEntityId()));
#else
tapSucceeded = AccessibilityRuntime._UnityAX_AccessibilityPerformEscape(axObject.gameObject.GetInstanceID());
#endif
UnityEngine.Assertions.Assert.AreEqual(EscapeCount, expectedEscapeCount);
UnityEngine.Assertions.Assert.IsFalse(tapSucceeded);
#if UNITY_IOS && !UNITY_EDITOR
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,21 +6,35 @@ namespace Apple.Accessibility.UnitTests
public class AccessibilityTests : MonoBehaviour
{
[DllImport("__Internal")]
private static extern bool _UnityAX_RuniOSSideUnitTestWithName(string name);

private static extern bool _UnityAX_RuniOSSideUnitTestWithName(string name);

#if UNITY_6000_4_OR_NEWER
[DllImport("__Internal")]
private static extern bool _UnityAX_RuniOSSideUnitTestWithKeyPathExpectingStringResult(int identifier, string keyPath, string expected);

private static extern bool _UnityAX_RuniOSSideUnitTestWithKeyPathExpectingStringResult2(ulong identifier, string keyPath, string expected);
#else
[DllImport("__Internal")]
private static extern bool _UnityAX_RuniOSSideUnitTestWithKeyPathExpectingStringResult(int identifier, string keyPath, string expected);
#endif

public static bool RuniOSUnitTestWithName(string name)
{
#if (UNITY_IOS || UNITY_TVOS) && !UNITY_EDITOR
return _UnityAX_RuniOSSideUnitTestWithName(name);
#else
return true;
#endif
}

#if UNITY_6000_4_OR_NEWER
public static bool RuniOSSideUnitTestWithKeyPathExpectingStringResult(ulong identifier, string keyPath, string expected)
{
#if (UNITY_IOS || UNITY_TVOS) && !UNITY_EDITOR
return _UnityAX_RuniOSSideUnitTestWithKeyPathExpectingStringResult2(identifier, keyPath, expected);
#else
return true;
#endif
}

#else
public static bool RuniOSSideUnitTestWithKeyPathExpectingStringResult(int identifier, string keyPath, string expected)
{
#if (UNITY_IOS || UNITY_TVOS) && !UNITY_EDITOR
Expand All@@ -29,7 +43,8 @@ public static bool RuniOSSideUnitTestWithKeyPathExpectingStringResult(int identi
return true;
#endif
}

#endif

[DllImport("__Internal")]
private static extern void _UnityAX_PostFeatureEnabledNotification(string name, bool enabled);

Expand Down
Loading