< Summary

Class:HoseController
Assembly:Test
File(s):D:/--UnityProject/VR/_____ISSTA 26/vr-firefighter-simulator/Assets/Test/HoseController.cs
Covered lines:49
Uncovered lines:0
Coverable lines:49
Total lines:86
Line coverage:100% (49 of 49)
Covered branches:0
Total branches:0
Covered methods:9
Total methods:9
Method coverage:100% (9 of 9)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
HoseController()0%000100%
Awake()0%000100%
Update()0%000100%
IsValidChange()0%000100%
HandleHoseAudio()0%000100%
StartHoseAudio()0%000100%
EndHoseAudio()0%000100%
HandleHoseWaterWithDelay()0%000100%
HandleHoseWater()0%000100%

File(s)

D:/--UnityProject/VR/_____ISSTA 26/vr-firefighter-simulator/Assets/Test/HoseController.cs

#LineLine coverage
 1using System.Collections;
 2using UnityEngine;
 3
 4public class HoseController : MonoBehaviour
 5{
 6    public HoseHandleMovement hoseHandle;
 7    public ParticleSystem hoseWaterPs;
 8    public AudioSource audioSource;
 9    public AudioClip hoseAudioStart;
 10    public AudioClip hoseAudioDuring;
 11    public float waterDelayTime;
 12    public float changeStateInterval;
 13
 214    private float lastChangeState = 10f;
 15    private bool hoseIsOn;
 16
 17    // Start is called before the first frame update
 18    void Awake()
 119    {
 120        this.hoseHandle = GameObject.FindGameObjectWithTag("HoseHandle").GetComponent<HoseHandleMovement>();
 121        this.audioSource = this.GetComponent<AudioSource>();
 122        this.hoseIsOn = false;
 123        this.HandleHoseWater();
 124    }
 25
 26    // Update is called once per frame
 27    void Update()
 1160928    {
 1160929        if (this.IsValidChange() && !this.hoseHandle.getIsTurning() && ActionMapper.GetDevicesTrigger())
 32230        {
 32231            this.hoseIsOn = !this.hoseIsOn;
 32232            this.hoseHandle.ActivateHandleMovement(this.hoseIsOn);
 32233            this.HandleHoseAudio();
 32234            StartCoroutine(this.HandleHoseWaterWithDelay(this.waterDelayTime));
 32235            this.lastChangeState = 0f;
 32236        }
 1160937        this.lastChangeState += Time.deltaTime;
 1160938    }
 39
 40    bool IsValidChange()
 1160941    {
 1160942        return this.lastChangeState >= this.changeStateInterval;
 1160943    }
 44
 45    void HandleHoseAudio()
 32246    {
 48347        if (this.hoseIsOn) {
 16148            StartCoroutine(this.StartHoseAudio());
 32249        } else {
 16150            this.EndHoseAudio();
 16151        }
 32252    }
 53
 54    IEnumerator StartHoseAudio()
 16155    {
 16156        this.audioSource.clip = this.hoseAudioStart;
 16157        this.audioSource.Play();
 16158        yield return new WaitForSeconds(this.audioSource.clip.length);
 16159        this.audioSource.clip = this.hoseAudioDuring;
 16160        this.audioSource.Play();
 16161    }
 62
 63    void EndHoseAudio()
 16164    {
 16165        StartCoroutine(AudioUtils.FadeOut(this.audioSource, 0.7f));
 16166    }
 67
 68    IEnumerator HandleHoseWaterWithDelay(float delayTime)
 32269    {
 70        //Wait for the specified delay time before continuing.
 32271        yield return new WaitForSeconds(delayTime);
 72
 73        // Turn water on or off
 32274        this.HandleHoseWater();
 32275    }
 76
 77    void HandleHoseWater()
 32378    {
 48479        if (this.hoseIsOn) {
 16180            this.hoseWaterPs.Play();
 32381        } else {
 16282            this.hoseWaterPs.Stop();
 16283        }
 32384    }
 85
 86}