< 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:14
Uncovered lines:10
Coverable lines:24
Total lines:65
Line coverage:58.3% (14 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%8.744033.33%
OnPointerDown(...)0%6200%
OnStepStart()0%220100%
OnStepExecute()0%330100%
OnStepPlayHideAnimation()0%440100%
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;
 1513        [SerializeField] bool clickOnTooltipToFinish = true;
 14        [SerializeField] bool setMaxTimeToHide = false;
 1515        [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        {
 3024            if (!setMaxTimeToHide || !tooltipStarted)
 3025                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        {
 543            base.OnStepStart();
 44
 545            SetTooltipPosition();
 46
 547            if (tutorialController != null)
 548                tutorialController.SetTeacherPosition(teacherPositionRef.position);
 49
 550            tooltipStarted = true;
 551        }
 52
 2553        public override IEnumerator OnStepExecute() { yield return new WaitUntil(() => stepIsFinished); }
 54
 55        public override IEnumerator OnStepPlayHideAnimation()
 56        {
 557            yield return base.OnStepPlayHideAnimation();
 1058            yield return new WaitUntil(() => !isRelatedFeatureActived);
 559        }
 60
 061        protected virtual void SetTooltipPosition() { }
 62
 063        public void OverrideSetMaxTimeToHide(bool setMaxTimeToHide) { this.setMaxTimeToHide = setMaxTimeToHide; }
 64    }
 65}