< 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:21
Uncovered lines:11
Coverable lines:32
Total lines:76
Line coverage:65.6% (21 of 32)
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%2.022083.33%
SetupQualityPresetLabels()0%220100%
SetupQualityPresetLabelsWithCustom()0%6200%
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)
 025                return;
 26
 127            QualitySettings preset = Settings.i.qualitySettingsPresets[value];
 128            currentQualitySetting = preset;
 129        }
 30
 31        private void SetupQualityPresetLabels()
 32        {
 233            List<string> presetNames = new List<string>();
 34            QualitySettings preset;
 2035            for (int i = 0; i < Settings.i.qualitySettingsPresets.Length; i++)
 36            {
 837                preset = Settings.i.qualitySettingsPresets[i];
 838                presetNames.Add(preset.displayName);
 39            }
 40
 241            RaiseOnOverrideIndicatorLabel(presetNames.ToArray());
 242        }
 43
 44        private void SetupQualityPresetLabelsWithCustom()
 45        {
 046            List<string> presetNames = new List<string>();
 47            QualitySettings preset;
 048            for (int i = 0; i < Settings.i.qualitySettingsPresets.Length; i++)
 49            {
 050                preset = Settings.i.qualitySettingsPresets[i];
 051                presetNames.Add(preset.displayName);
 52            }
 053            presetNames.Add(TEXT_QUALITY_CUSTOM);
 054            RaiseOnOverrideIndicatorLabel(presetNames.ToArray());
 055        }
 56
 57        private int GetCurrentStoredValue()
 58        {
 59            QualitySettings preset;
 460            for (int i = 0; i < Settings.i.qualitySettingsPresets.Length; i++)
 61            {
 262                preset = Settings.i.qualitySettingsPresets[i];
 263                if (preset.Equals(currentQualitySetting))
 64                {
 165                    SetupQualityPresetLabels();
 166                    RaiseOnCurrentLabelChange(preset.displayName);
 167                    return i;
 68                }
 69            }
 70
 071            SetupQualityPresetLabelsWithCustom();
 072            RaiseOnCurrentLabelChange(TEXT_QUALITY_CUSTOM);
 073            return Settings.i.qualitySettingsPresets.Length;
 74        }
 75    }
 76}