public IEnumerator DontCompleteWhenSnappedWrongOnActivation() { // Setup object with mocked grabbed property and activate SnappablePropertyMock mockedProperty = CreateSnappablePropertyMock(); SnapZoneProperty snapZoneProperty = CreateSnapZoneProperty(); SnapZoneProperty wrongSnapZoneProperty = CreateSnapZoneProperty(); mockedProperty.SetSnapZone(wrongSnapZoneProperty); yield return(null); SnappedCondition condition = new SnappedCondition(mockedProperty, snapZoneProperty); condition.LifeCycle.Activate(); int frameCountEnd = Time.frameCount + 5; while (Time.frameCount <= frameCountEnd) { yield return(null); condition.Update(); } // Assert that condition is not completed Assert.IsFalse(condition.IsCompleted, "SnappedCondition should not be complete!"); }
public IEnumerator CompleteOnTargetedSnapZone() { // Setup object with mocked grabbed property and activate SnappablePropertyMock mockedProperty = CreateSnappablePropertyMock(); SnapZoneProperty snapZoneProperty = CreateSnapZoneProperty(); yield return(null); SnappedCondition condition = new SnappedCondition(mockedProperty, snapZoneProperty); condition.LifeCycle.Activate(); while (condition.LifeCycle.Stage != Stage.Active) { yield return(null); condition.Update(); } // Emit grabbed event mockedProperty.SetSnapZone(snapZoneProperty); mockedProperty.EmitSnapped(snapZoneProperty); while (condition.IsCompleted == false) { yield return(null); condition.Update(); } // Assert that condition is now completed Assert.IsTrue(condition.IsCompleted); }
public IEnumerator HighlightObjectNotShown() { // Given a snappable property with a snapzone highlight deactivated parameter active. DynamicRuntimeConfiguration testRuntimeConfiguration = new DynamicRuntimeConfiguration(); testRuntimeConfiguration.SetAvailableModes(new List <IMode> { new Mode("Test", new WhitelistTypeRule <IOptional>(), new Dictionary <string, object> { { "ShowSnapzoneHighlightObject", false } }), }); RuntimeConfigurator.Configuration = testRuntimeConfiguration; SnappablePropertyMock mockedProperty = CreateSnappablePropertyMock(); SnapZoneProperty snapZoneProperty = CreateSnapZoneProperty(); SnapZone zone = snapZoneProperty.SnapZone; mockedProperty.SetSnapZone(snapZoneProperty); yield return(null); SnappedCondition condition = new SnappedCondition(mockedProperty, snapZoneProperty); condition.Configure(RuntimeConfigurator.Configuration.Modes.CurrentMode); yield return(null); condition.Update(); // When activated condition.LifeCycle.Activate(); while (condition.LifeCycle.Stage != Stage.Active) { yield return(null); condition.Update(); } // Then the highlight is still inactive. Assert.IsFalse(snapZoneProperty.SnapZone.ShowHighlightObject); }
public IEnumerator HighlightColorCanBeChanged() { // Given a snappable property with a highlight color changed DynamicRuntimeConfiguration testRuntimeConfiguration = new DynamicRuntimeConfiguration(); testRuntimeConfiguration.SetAvailableModes(new List <IMode> { new Mode("Test", new WhitelistTypeRule <IOptional>(), new Dictionary <string, object> { { "HighlightColor", Color.yellow } }), }); RuntimeConfigurator.Configuration = testRuntimeConfiguration; SnappablePropertyMock mockedProperty = CreateSnappablePropertyMock(); SnapZoneProperty snapZoneProperty = CreateSnapZoneProperty(); SnapZone zone = snapZoneProperty.SnapZone; mockedProperty.SetSnapZone(snapZoneProperty); yield return(null); SnappedCondition condition = new SnappedCondition(mockedProperty, snapZoneProperty); condition.Configure(RuntimeConfigurator.Configuration.Modes.CurrentMode); yield return(null); condition.Update(); // When activated condition.LifeCycle.Activate(); while (condition.LifeCycle.Stage != Stage.Active) { yield return(null); condition.Update(); } // Then the highlight color changed properly Assert.AreEqual(Color.yellow, snapZoneProperty.SnapZone.ShownHighlightObjectColor); }
public IEnumerator HoverMeshShown() { // Given a snappable property with an AlwaysShowSnapzoneHighlight parameter set to false. DynamicRuntimeConfiguration testRuntimeConfiguration = new DynamicRuntimeConfiguration(); testRuntimeConfiguration.SetAvailableModes(new List <IMode> { new Mode("Test", new WhitelistTypeRule <IOptional>(), new Dictionary <string, object> { { "ShowSnapzoneHoverMeshes", true } }), }); RuntimeConfigurator.Configuration = testRuntimeConfiguration; SnappablePropertyMock mockedProperty = CreateSnappablePropertyMock(); SnapZoneProperty snapZoneProperty = CreateSnapZoneProperty(); SnapZone zone = snapZoneProperty.SnapZone; mockedProperty.SetSnapZone(snapZoneProperty); yield return(null); SnappedCondition condition = new SnappedCondition(mockedProperty, snapZoneProperty); condition.Configure(RuntimeConfigurator.Configuration.Modes.CurrentMode); // When activated condition.LifeCycle.Activate(); while (condition.LifeCycle.Stage != Stage.Active) { yield return(null); condition.Update(); } // Then the highlightAlwaysActive variable should be false Assert.IsTrue(snapZoneProperty.SnapZone.showInteractableHoverMeshes); }