< 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()
 1265628    {
 1265629        if (this.IsValidChange() && !this.hoseHandle.getIsTurning() && ActionMapper.GetDevicesTrigger())
 52630        {
 52631            this.hoseIsOn = !this.hoseIsOn;
 52632            this.hoseHandle.ActivateHandleMovement(this.hoseIsOn);
 52633            this.HandleHoseAudio();
 52634            StartCoroutine(this.HandleHoseWaterWithDelay(this.waterDelayTime));
 52635            this.lastChangeState = 0f;
 52636        }
 1265637        this.lastChangeState += Time.deltaTime;
 1265638    }
 39
 40    bool IsValidChange()
 1265641    {
 1265642        return this.lastChangeState >= this.changeStateInterval;
 1265643    }
 44
 45    void HandleHoseAudio()
 52646    {
 78947        if (this.hoseIsOn) {
 26348            StartCoroutine(this.StartHoseAudio());
 52649        } else {
 26350            this.EndHoseAudio();
 26351        }
 52652    }
 53
 54    IEnumerator StartHoseAudio()
 26355    {
 26356        this.audioSource.clip = this.hoseAudioStart;
 26357        this.audioSource.Play();
 26358        yield return new WaitForSeconds(this.audioSource.clip.length);
 26359        this.audioSource.clip = this.hoseAudioDuring;
 26360        this.audioSource.Play();
 26361    }
 62
 63    void EndHoseAudio()
 26364    {
 26365        StartCoroutine(AudioUtils.FadeOut(this.audioSource, 0.7f));
 26366    }
 67
 68    IEnumerator HandleHoseWaterWithDelay(float delayTime)
 52669    {
 70        //Wait for the specified delay time before continuing.
 52671        yield return new WaitForSeconds(delayTime);
 72
 73        // Turn water on or off
 52674        this.HandleHoseWater();
 52675    }
 76
 77    void HandleHoseWater()
 52778    {
 79079        if (this.hoseIsOn) {
 26380            this.hoseWaterPs.Play();
 52781        } else {
 26482            this.hoseWaterPs.Stop();
 26483        }
 52784    }
 85
 86}