< 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:1
Uncovered lines:19
Coverable lines:20
Total lines:58
Line coverage:5% (1 of 20)
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%2100%
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;
 13        [SerializeField] bool setMaxTimeToHide = false;
 714        [SerializeField] float maxTimeToHide = 5f;
 15
 16        private bool tooltipStarted = false;
 17        private float timeSinceWasOpened = 0f;
 18        protected bool stepIsFinished = false;
 19        protected bool isRelatedFeatureActived = false;
 20
 21        protected virtual void Update()
 22        {
 023            if (!setMaxTimeToHide || !tooltipStarted)
 024                return;
 25
 026            timeSinceWasOpened += Time.deltaTime;
 27
 028            if (timeSinceWasOpened >= maxTimeToHide)
 029                stepIsFinished = true;
 030        }
 31
 032        public virtual void OnPointerDown(PointerEventData eventData) { stepIsFinished = true; }
 33
 34        public override void OnStepStart()
 35        {
 036            base.OnStepStart();
 37
 038            SetTooltipPosition();
 39
 040            if (tutorialController != null)
 041                tutorialController.SetTeacherPosition(teacherPositionRef.position);
 42
 043            tooltipStarted = true;
 044        }
 45
 046        public override IEnumerator OnStepExecute() { yield return new WaitUntil(() => stepIsFinished); }
 47
 48        public override IEnumerator OnStepPlayHideAnimation()
 49        {
 050            yield return base.OnStepPlayHideAnimation();
 051            yield return new WaitUntil(() => !isRelatedFeatureActived);
 052        }
 53
 054        protected virtual void SetTooltipPosition() { }
 55
 056        public void OverrideSetMaxTimeToHide(bool setMaxTimeToHide) { this.setMaxTimeToHide = setMaxTimeToHide; }
 57    }
 58}