< Summary

Class:TimeReporter
Assembly:TimeReporter
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Rendering/ProceduralSkybox/TimeReporter/TimeReporter.cs
Covered lines:11
Uncovered lines:5
Coverable lines:16
Total lines:55
Line coverage:68.7% (11 of 16)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
TimeReporter()0%110100%
Dispose()0%2100%
Configure(...)0%2100%
ReportTime(...)0%440100%
DoReport(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Rendering/ProceduralSkybox/TimeReporter/TimeReporter.cs

#LineLine coverage
 1using System;
 2using DCL;
 3using DCL.Interface;
 4
 5public interface ITimeReporter : IDisposable
 6{
 7    void Configure(float normalizationFactor, float cycle);
 8    void ReportTime(float time);
 9}
 10
 11public class TimeReporter : ITimeReporter
 12{
 13    private float timeNormalizationFactor;
 14    private float cycleTime;
 15    private bool wasTimeRunning;
 16
 17    internal delegate void OnReportEventHandler(float time, bool isPaused);
 18    internal event OnReportEventHandler OnReport;
 19
 320    public TimeReporter()
 21    {
 322        OnReport += DoReport;
 323    }
 24
 25    public void Dispose()
 26    {
 027        OnReport -= DoReport;
 028    }
 29
 30    public void Configure(float normalizationFactor, float cycle)
 31    {
 032        timeNormalizationFactor = normalizationFactor;
 033        cycleTime = cycle;
 034    }
 35
 36    public void ReportTime(float time)
 37    {
 738        bool isTimeRunning = DataStore.i.skyboxConfig.useDynamicSkybox.Get();
 39
 40        // NOTE: if not paused and pause state didn't change there is no need to report
 41        // current time since it's being calculated on kernel side
 742        if (isTimeRunning && wasTimeRunning)
 43        {
 144            return;
 45        }
 46
 647        wasTimeRunning = isTimeRunning;
 648        OnReport?.Invoke(time, !isTimeRunning);
 649    }
 50
 51    private void DoReport(float time, bool isPaused)
 52    {
 653        WebInterface.ReportTime(time, isPaused, timeNormalizationFactor, cycleTime);
 654    }
 55}