using System.Collections;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.TestTools;
using UnityEngine.UI;
using UnityEngine.XR.Interaction.Toolkit;
using UnityEngine.XR.Interaction.Toolkit.Inputs.Readers;
using UnityEngine.XR.Interaction.Toolkit.Interactors;
using UnityEngine.XR.Interaction.Toolkit.UI;
namespace jeanf.universalplayer.tests
{
///
/// Verifies VR UI interaction without a headset: an XRRayInteractor pointing at a
/// world-space canvas (TrackedDeviceGraphicRaycaster) must hit UI, and a manually
/// queued press (XRI's ManualValue input mode — same trick the Hands Test Bench
/// uses) must produce a real Button click through XRUIInputModule.
///
public class UiInteractionTests
{
private GameObject _eventSystemGo;
private GameObject _managerGo;
private GameObject _interactorGo;
private GameObject _canvasGo;
private GameObject _cameraGo;
private XRRayInteractor _rayInteractor;
private Button _button;
private int _clickCount;
[UnitySetUp]
public IEnumerator SetUp()
{
_clickCount = 0;
// UI event pipeline: EventSystem + XRI's input module (created before the
// interactor so the interactor can register with it on enable)
// fully qualified: inside the jeanf.* namespace, "EventSystem" resolves to the
// jeanf.EventSystem namespace instead of the UGUI component
_eventSystemGo = new GameObject("EventSystem", typeof(UnityEngine.EventSystems.EventSystem), typeof(XRUIInputModule));
_managerGo = new GameObject("XRInteractionManager", typeof(XRInteractionManager));
_cameraGo = new GameObject("TestCamera", typeof(Camera));
// world-space canvas with the same raycaster the package's UI prefabs use
_canvasGo = new GameObject("Canvas", typeof(Canvas), typeof(TrackedDeviceGraphicRaycaster));
var canvas = _canvasGo.GetComponent