< Summary

Class:ApplicationFocusService
Assembly:ApplicationFocusService
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLServices/ApplicationFocus/ApplicationFocusService.cs
Covered lines:15
Uncovered lines:1
Coverable lines:16
Total lines:49
Line coverage:93.7% (15 of 16)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Initialize()0%110100%
FocusChange(...)0%3.033085.71%
OnFocusGained()0%220100%
OnFocusLost()0%220100%
Dispose()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLServices/ApplicationFocus/ApplicationFocusService.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using UnityEngine;
 5
 6public class ApplicationFocusService : IApplicationFocusService
 7{
 8
 9    public event Action OnApplicationFocus;
 10    public event Action OnApplicationFocusLost;
 11    private bool currentFocusState;
 12
 13    public void Initialize()
 14    {
 49515        Application.focusChanged += FocusChange;
 49516        currentFocusState = Application.isFocused;
 49517    }
 18    private void FocusChange(bool focus)
 19    {
 620        if (currentFocusState == focus)
 021            return;
 22
 623        if (focus)
 24        {
 425            OnFocusGained();
 26        }
 27        else
 28        {
 229            OnFocusLost();
 30        }
 631        currentFocusState = focus;
 632    }
 33
 34    internal void OnFocusGained()
 35    {
 536        OnApplicationFocus?.Invoke();
 137    }
 38
 39    internal void OnFocusLost()
 40    {
 341        OnApplicationFocusLost?.Invoke();
 142    }
 43
 44    public void Dispose()
 45    {
 49346        Application.focusChanged -= FocusChange;
 49347    }
 48
 49}