< Summary

Class:DCL.Main
Assembly:Main
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Scene/Main/Main.cs
Covered lines:23
Uncovered lines:16
Coverable lines:39
Total lines:117
Line coverage:58.9% (23 of 39)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%7.545053.33%
SetupEnvironment()0%2100%
MessagingContextBuilder()0%2100%
PlatformContextBuilder()0%2100%
WorldRuntimeContextBuilder()0%2100%
HUDContextBuilder()0%2100%
Start()0%220100%
Update()0%220100%
LateUpdate()0%110100%
OnDestroy()0%5.024060%
OnGUI()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Scene/Main/Main.cs

#LineLine coverage
 1using System;
 2using DCL.Components;
 3using DCL.Controllers;
 4using DCL.Helpers;
 5using UnityEngine;
 6using UnityEngine.Serialization;
 7
 8namespace DCL
 9{
 10    /// <summary>
 11    /// This is the InitialScene entry point.
 12    /// Most of the application subsystems should be initialized from this class Awake() event.
 13    /// </summary>
 14    public class Main : MonoBehaviour
 15    {
 016        public static Main i { get; private set; }
 17
 18        public PoolableComponentFactory componentFactory;
 19
 20        private PerformanceMetricsController performanceMetricsController;
 21        private IKernelCommunication kernelCommunication;
 22
 23        private PluginSystem pluginSystem;
 24
 25        void Awake()
 26        {
 12327            if (i != null)
 28            {
 029                Utils.SafeDestroy(this);
 030                return;
 31            }
 32
 12333            i = this;
 34
 12335            if (!Configuration.EnvironmentSettings.RUNNING_TESTS)
 36            {
 037                performanceMetricsController = new PerformanceMetricsController();
 038                RenderProfileManifest.i.Initialize();
 039                SetupEnvironment();
 40            }
 41
 12342            pluginSystem = new PluginSystem();
 43
 44#if UNITY_WEBGL && !UNITY_EDITOR
 45            Debug.Log("DCL Unity Build Version: " + DCL.Configuration.ApplicationSettings.version);
 46            Debug.unityLogger.logEnabled = false;
 47
 48            kernelCommunication = new NativeBridgeCommunication(Environment.i.world.sceneController);
 49#else
 50            // TODO(Brian): Remove this branching once we finish migrating all tests out of the
 51            //              IntegrationTestSuite_Legacy base class.
 12352            if (!Configuration.EnvironmentSettings.RUNNING_TESTS)
 53            {
 054                kernelCommunication = new WebSocketCommunication();
 55            }
 56#endif
 57
 58            // TODO(Brian): This is a temporary fix to address elevators issue in the xmas event.
 59            // We should re-enable this later as produces a performance regression.
 12360            if (!Configuration.EnvironmentSettings.RUNNING_TESTS)
 061                Environment.i.platform.cullingController.SetAnimationCulling(false);
 62
 63            // this event should be the last one to be executed after initialization
 64            // it is used by the kernel to signal "EngineReady" or something like that
 65            // to prevent race conditions like "SceneController is not an object",
 66            // aka sending events before unity is ready
 12367            DCL.Interface.WebInterface.SendSystemInfoReport();
 12368        }
 69
 70        protected virtual void SetupEnvironment()
 71        {
 072            Environment.SetupWithBuilders(
 73                messagingBuilder: MessagingContextBuilder,
 74                platformBuilder: PlatformContextBuilder,
 75                worldRuntimeBuilder: WorldRuntimeContextBuilder,
 76                hudBuilder: HUDContextBuilder);
 077        }
 78
 079        protected virtual MessagingContext MessagingContextBuilder() { return MessagingContextFactory.CreateDefault(); }
 80
 081        protected virtual PlatformContext PlatformContextBuilder() { return PlatformContextFactory.CreateDefault(); }
 82
 083        protected virtual WorldRuntimeContext WorldRuntimeContextBuilder() { return WorldRuntimeContextFactory.CreateDef
 84
 085        protected virtual HUDContext HUDContextBuilder() { return HUDContextFactory.CreateDefault(); }
 86
 87        private void Start()
 88        {
 12389            Environment.i.world.sceneController.Start();
 12390            pluginSystem?.Start();
 12391        }
 92
 93        private void Update()
 94        {
 1879495            Environment.i.platform.Update();
 1879496            Environment.i.world.sceneController.Update();
 1879497            performanceMetricsController?.Update();
 1879498            pluginSystem.Update();
 1879499        }
 100
 101        private void LateUpdate()
 102        {
 18793103            Environment.i.world.sceneController.LateUpdate();
 18793104            pluginSystem.LateUpdate();
 18793105        }
 106
 107        private void OnDestroy()
 108        {
 122109            if (!Configuration.EnvironmentSettings.RUNNING_TESTS)
 0110                Environment.Dispose();
 122111            pluginSystem?.OnDestroy();
 122112            kernelCommunication?.Dispose();
 0113        }
 114
 7008115        private void OnGUI() { pluginSystem.OnGUI(); }
 116    }
 117}