< Summary

Class:DCL.MainDesktop
Assembly:MainDesktop
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Desktop/Scripts/MainScripts/DCL/MainDesktop/MainDesktop.cs
Covered lines:0
Uncovered lines:49
Coverable lines:49
Total lines:132
Line coverage:0% (0 of 49)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:11
Method coverage:0% (0 of 11)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%2100%
InitializeDataStore()0%2100%
InitializeCommunication()0%6200%
SetupPlugins()0%2100%
InitializeSettings()0%2100%
Dispose()0%2100%
DesktopDestroy()0%2100%
OnCommunicationEstablished(...)0%6200%
Update()0%30500%
SetupServices()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Desktop/Scripts/MainScripts/DCL/MainDesktop/MainDesktop.cs

#LineLine coverage
 1using System;
 2using DCL.SettingsCommon;
 3using DCL.Components;
 4using MainScripts.DCL.Controllers.SettingsDesktop;
 5using UnityEngine;
 6using UnityEngine.Diagnostics;
 7using DCL.Helpers;
 8
 9namespace DCL
 10{
 11    /// <summary>
 12    /// This is the MainDesktop entry point.
 13    /// Most of the application subsystems should be initialized from this class Awake() event.
 14    /// </summary>
 15    public class MainDesktop : Main
 16    {
 17        [SerializeField] private bool logWs = false;
 18        //private PreloadingController preloadingController;
 19        private bool isConnectionLost;
 20        private readonly DataStoreRef<DataStore_LoadingScreen> loadingScreenRef;
 21
 022        private BaseVariable<FeatureFlag> featureFlags => DataStore.i.featureFlags.flags;
 23
 24        protected override void Awake()
 25        {
 026            CommandLineParserUtils.ParseArguments();
 027            isConnectionLost = false;
 28
 029            DCLVideoTexture.videoPluginWrapperBuilder = VideoProviderFactory.CreateVideoProvider;
 30
 031            InitializeSettings();
 32
 033            base.Awake();
 34
 035            DataStore.i.wsCommunication.communicationEstablished.OnChange += OnCommunicationEstablished;
 036            DataStore.i.performance.multithreading.Set(true);
 037            DataStore.i.performance.maxDownloads.Set(50);
 038            Texture.allowThreadedTextureCreation = true;
 039        }
 40
 41        protected override void InitializeDataStore()
 42        {
 043            DataStore.i.textureConfig.gltfMaxSize.Set(TextureCompressionSettingsDesktop.GLTF_TEX_MAX_SIZE_DESKTOP);
 044            DataStore.i.textureConfig.generalMaxSize.Set(TextureCompressionSettingsDesktop.GENERAL_TEX_MAX_SIZE_DESKTOP)
 045            DataStore.i.avatarConfig.useHologramAvatar.Set(true);
 046        }
 47
 48        protected override void InitializeCommunication()
 49        {
 050            DataStore.i.debugConfig.logWs = logWs;
 51
 52            // TODO(Brian): Remove this branching once we finish migrating all tests out of the
 53            //              IntegrationTestSuite_Legacy base class.
 054            if (!Configuration.EnvironmentSettings.RUNNING_TESTS)
 55            {
 056                var withSSL = true;
 057                int startPort = CommandLineParserUtils.startPort;
 58
 59#if UNITY_EDITOR
 060                withSSL = DebugConfigComponent.i.webSocketSSL;
 061                startPort = 7666;
 62#else
 63                withSSL = CommandLineParserUtils.withSSL;
 64#endif
 65
 066                int endPort = startPort + 100;
 067                kernelCommunication = new WebSocketCommunication(withSSL, startPort, endPort);
 68            }
 069        }
 70
 71        protected override void SetupPlugins()
 72        {
 073            pluginSystem = PluginSystemFactoryDesktop.Create();
 074            pluginSystem.Initialize();
 075        }
 76
 77        private void InitializeSettings()
 78        {
 079            Settings.CreateSharedInstance(new DefaultSettingsFactory()
 80               .WithGraphicsQualitySettingsPresetPath("DesktopGraphicsQualityPresets"));
 081        }
 82
 83        protected override void Dispose()
 84        {
 085            SettingsDesktop.i.displaySettings.Save();
 86
 87            try
 88            {
 089                DataStore.i.wsCommunication.communicationEstablished.OnChange -= OnCommunicationEstablished;
 90
 091                base.Dispose();
 092                DesktopDestroy();
 093            }
 094            catch (Exception e) { Debug.LogException(e); }
 095        }
 96
 97        private void DesktopDestroy()
 98        {
 99            //preloadingController.Dispose();
 100#if !AV_PRO_PRESENT
 0101            DCLVideoPlayer.StopAllThreads();
 102#endif
 0103        }
 104
 105        void OnCommunicationEstablished(bool current, bool previous)
 106        {
 0107            if (current == false && previous) { isConnectionLost = true; }
 0108        }
 109
 110        protected override void Update()
 111        {
 0112            base.Update();
 113
 0114            if (isConnectionLost) { Helpers.Utils.QuitApplication(); }
 115
 116            // TODO: Remove this after we refactor InputController to support overrides from desktop or to use the lates
 117            // This shortcut will help some users to fix the small resolution bugs that may happen if the player prefs a
 0118            if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
 119                && Input.GetKeyDown(KeyCode.F11))
 120            {
 0121                DisplaySettings newDisplaySettings = new DisplaySettings { windowMode = WindowMode.Borderless };
 0122                SettingsDesktop.i.displaySettings.Apply(newDisplaySettings);
 0123                SettingsDesktop.i.displaySettings.Save();
 124            }
 0125        }
 126
 127        protected override void SetupServices()
 128        {
 0129            Environment.Setup(ServiceLocatorDesktopFactory.CreateDefault());
 0130        }
 131    }
 132}