< Summary

Class:DCL.Tutorial.TutorialStep_Tooltip
Assembly:Onboarding
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Tutorial/Scripts/Steps/Initial/TutorialStep_Tooltip.cs
Covered lines:2
Uncovered lines:22
Coverable lines:24
Total lines:65
Line coverage:8.3% (2 of 24)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
TutorialStep_Tooltip()0%110100%
Update()0%20400%
OnPointerDown(...)0%6200%
OnStepStart()0%6200%
OnStepExecute()0%12300%
OnStepPlayHideAnimation()0%20400%
SetTooltipPosition()0%2100%
OverrideSetMaxTimeToHide(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Tutorial/Scripts/Steps/Initial/TutorialStep_Tooltip.cs

#LineLine coverage
 1using System.Collections;
 2using UnityEngine;
 3using UnityEngine.EventSystems;
 4
 5namespace DCL.Tutorial
 6{
 7    /// <summary>
 8    /// Class that represents one of the tooltip steps included in the onboarding tutorial.
 9    /// </summary>
 10    public class TutorialStep_Tooltip : TutorialStep, IPointerDownHandler
 11    {
 12        [SerializeField] protected RectTransform tooltipTransform;
 1113        [SerializeField] bool clickOnTooltipToFinish = true;
 14        [SerializeField] bool setMaxTimeToHide = false;
 1115        [SerializeField] float maxTimeToHide = 5f;
 16
 17        private bool tooltipStarted = false;
 18        private float timeSinceWasOpened = 0f;
 19        internal bool stepIsFinished = false;
 20        internal bool isRelatedFeatureActived = false;
 21
 22        protected virtual void Update()
 23        {
 024            if (!setMaxTimeToHide || !tooltipStarted)
 025                return;
 26
 027            timeSinceWasOpened += Time.deltaTime;
 28
 029            if (timeSinceWasOpened >= maxTimeToHide)
 030                stepIsFinished = true;
 031        }
 32
 33        public virtual void OnPointerDown(PointerEventData eventData)
 34        {
 035            if (!clickOnTooltipToFinish)
 036                return;
 37
 038            stepIsFinished = true;
 039        }
 40
 41        public override void OnStepStart()
 42        {
 043            base.OnStepStart();
 44
 045            SetTooltipPosition();
 46
 047            if (tutorialController != null)
 048                tutorialController.SetTeacherPosition(teacherPositionRef.position);
 49
 050            tooltipStarted = true;
 051        }
 52
 053        public override IEnumerator OnStepExecute() { yield return new WaitUntil(() => stepIsFinished); }
 54
 55        public override IEnumerator OnStepPlayHideAnimation()
 56        {
 057            yield return base.OnStepPlayHideAnimation();
 058            yield return new WaitUntil(() => !isRelatedFeatureActived);
 059        }
 60
 061        protected virtual void SetTooltipPosition() { }
 62
 063        public void OverrideSetMaxTimeToHide(bool setMaxTimeToHide) { this.setMaxTimeToHide = setMaxTimeToHide; }
 64    }
 65}