static void Check(XrResult result) { if (result != XrResult.XR_SUCCESS) { throw new Exception(result.ToString()); } }
private static void AfterFunctionCallback(string function, XrResult result) { var callback = GetAfterFunctionCallback(function); if (null == callback) { return; } callback(function, result); }
public IEnumerator BeginSessionSuccessWithValues([ValueSource("beginSessionSuccessResults")] XrResult successResult) { var states = new List <XrSessionState>(); MockRuntime.Instance.TestCallback = (methodName, param) => { if (methodName == nameof(OpenXRFeature.OnSessionStateChange)) { var newState = (XrSessionState)((MockRuntime.XrSessionStateChangedParams)param).NewState; states.Add(newState); } return(true); }; MockRuntime.SetFunctionCallback("xrBeginSession", (name) => successResult); base.InitializeAndStart(); yield return(null); Assert.IsTrue(base.IsRunning <XRDisplaySubsystem>()); switch (successResult) { case XrResult.Success: Assert.IsTrue(states.Contains(XrSessionState.Ready)); Assert.IsTrue(states.Contains(XrSessionState.Synchronized)); Assert.IsTrue(states.Contains(XrSessionState.Visible)); Assert.IsTrue(states.Contains(XrSessionState.Focused)); break; case XrResult.LossPending: Assert.IsTrue(states.Contains(XrSessionState.Ready)); Assert.IsFalse(states.Contains(XrSessionState.Synchronized)); Assert.IsFalse(states.Contains(XrSessionState.Visible)); Assert.IsFalse(states.Contains(XrSessionState.Focused)); break; } }
internal static extern void SetReturnCodeForFunction([MarshalAs(UnmanagedType.LPStr)] string functionName, XrResult result);