< Summary

Class:DCL.SettingsCommon.SettingsControllers.SpecificControllers.QualityPresetControlController
Assembly:SettingsControllers
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Settings/SettingsControllers/SpecificControllers/QualityPresetControlController.cs
Covered lines:20
Uncovered lines:3
Coverable lines:23
Total lines:59
Line coverage:86.9% (20 of 23)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Initialize()0%110100%
GetStoredValue()0%110100%
UpdateSetting(...)0%220100%
SetupQualityPresetLabels(...)0%220100%
GetCurrentStoredValue()0%3.183072.73%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Settings/SettingsControllers/SpecificControllers/QualityPresetControlController.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using DCL.SettingsCommon.SettingsControllers.BaseControllers;
 3using UnityEngine;
 4
 5namespace DCL.SettingsCommon.SettingsControllers.SpecificControllers
 6{
 7    [CreateAssetMenu(menuName = "Settings/Controllers/Controls/Quality Preset", fileName = "QualityPresetControlControll
 8    public class QualityPresetControlController : SpinBoxSettingsControlController
 9    {
 10        public const string TEXT_QUALITY_CUSTOM = "Custom";
 11
 12        public override void Initialize()
 13        {
 114            base.Initialize();
 15
 116            SetupQualityPresetLabels();
 117        }
 18
 119        public override object GetStoredValue() { return GetCurrentStoredValue(); }
 20
 21        public override void UpdateSetting(object newValue)
 22        {
 123            int value = (int)newValue;
 124            if (value != Settings.i.qualitySettingsPresets.Length)
 125                currentQualitySetting = Settings.i.qualitySettingsPresets[value];
 126        }
 27
 28        private void SetupQualityPresetLabels(params string[] customs)
 29        {
 230            List<string> presetNames = new List<string>();
 31
 2032            for (int i = 0; i < Settings.i.qualitySettingsPresets.Length; i++)
 833                presetNames.Add(Settings.i.qualitySettingsPresets[i].displayName);
 34
 235            presetNames.AddRange(customs);
 36
 237            RaiseOnOverrideIndicatorLabel(presetNames.ToArray());
 238        }
 39
 40        private int GetCurrentStoredValue()
 41        {
 442            for (int i = 0; i < Settings.i.qualitySettingsPresets.Length; i++)
 43            {
 244                QualitySettings preset = Settings.i.qualitySettingsPresets[i];
 45
 246                if (preset.Equals(currentQualitySetting))
 47                {
 148                    SetupQualityPresetLabels();
 149                    RaiseOnCurrentLabelChange(preset.displayName);
 150                    return i;
 51                }
 52            }
 53
 054            SetupQualityPresetLabels(TEXT_QUALITY_CUSTOM);
 055            RaiseOnCurrentLabelChange(TEXT_QUALITY_CUSTOM);
 056            return Settings.i.qualitySettingsPresets.Length;
 57        }
 58    }
 59}