예제 #1
0
        public void EventDataPlayerSessionCollection_GetPlayerSession_ReturnsNullOnNoIdMatch()
        {
            EventDataPlayerSessionCollection edpsc = new EventDataPlayerSessionCollection((DiagnosticEvent x) => true);
            EventDataPlayerSession           edps  = edpsc.GetPlayerSession(0, false);

            Assert.IsNull(edps, "New EventDataPlayerSession should not be created when create = false and there is no id match. ");
        }
예제 #2
0
 void OnPlayerConnection(int id)
 {
     if (m_EventData == null)
     {
         m_EventData = new EventDataPlayerSessionCollection(OnRecordEvent);
     }
     m_EventData.GetPlayerSession(id, true).IsActive = true;
 }
예제 #3
0
        public void EventDataPlayerSessionCollection_GetPlayerSession_ProperlyCreatesWhenCreateIsTrue()
        {
            EventDataPlayerSessionCollection edpsc = new EventDataPlayerSessionCollection((DiagnosticEvent x) => true);
            EventDataPlayerSession           edps  = edpsc.GetPlayerSession(0, true);

            Assert.NotNull(edps, "New EventDataPlayerSession should have been created.");
            Assert.AreEqual("Player 0", edps.EventName);
        }
예제 #4
0
        public void EventDataPlayerSessionCollection_RemoveSession_SimpleCase()
        {
            EventDataPlayerSessionCollection edpsc = new EventDataPlayerSessionCollection((DiagnosticEvent x) => true);

            edpsc.AddSession("Test session", 0);
            edpsc.RemoveSession(0);

            Assert.AreEqual(0, edpsc.GetSessionCount(), "Session was not properly removed.");
        }
예제 #5
0
        public void EventDataPlayerSessionCollection_GetSessionIndexById_NullCase()
        {
            EventDataPlayerSessionCollection edpsc = new EventDataPlayerSessionCollection((DiagnosticEvent x) => true);

            edpsc.AddSession("Test session", 0);
            edpsc.AddSession("Test session 2", 1);

            Assert.AreEqual(-1, edpsc.GetSessionIndexById(10000000), "Incorrect value returned, GetSessionIndexById should return -1 when the queried id does not exist.");
        }
예제 #6
0
        public void EventDataPlayerSessionCollection_GetSessionIndexById_SimpleCase()
        {
            EventDataPlayerSessionCollection edpsc = new EventDataPlayerSessionCollection((DiagnosticEvent x) => true);

            edpsc.AddSession("Test session", 0);
            edpsc.AddSession("Test session 2", 1);

            Assert.AreEqual(1, edpsc.GetSessionIndexById(1), "Session index not properly returned. ");
        }
예제 #7
0
        public void EventDataPlayerSessionCollection_GetSessionByIndex_ReturnsNullOnInvalidInput()
        {
            EventDataPlayerSessionCollection edpsc = new EventDataPlayerSessionCollection((DiagnosticEvent x) => true);

            Assert.IsNull(edpsc.GetSessionByIndex(0), "Trying to request a session with a nonexistent index should return null. ");

            edpsc.AddSession("test session", 0);
            Assert.IsNull(edpsc.GetSessionByIndex(2), "Trying to request a session with a nonexistent index should return null. ");
            Assert.NotNull(edpsc.GetSessionByIndex(0), "Session not returned properly on valid index. ");
        }
예제 #8
0
        public void OnEvent(DiagnosticEvent diagnosticEvent, int session)
        {
            if (m_EventData == null)
            {
                m_EventData = new EventDataPlayerSessionCollection(OnRecordEvent);
            }

            var entryCreated = m_EventData.ProcessEvent(diagnosticEvent, session);

            OnEventProcessed(diagnosticEvent, entryCreated);
        }
예제 #9
0
        void OnPlayerConnection(int id)
        {
            if (m_EventData == null)
            {
                m_EventData = new EventDataPlayerSessionCollection(OnRecordEvent);
            }
            m_EventData.GetPlayerSession(id, true).IsActive = true;
            int connectedSessionIndex = m_EventData.GetSessionIndexById(id);

            m_PlayerSessionIndex = connectedSessionIndex != -1 ? connectedSessionIndex : 0;
        }
예제 #10
0
 void OnEditorPlayModeEvent(DiagnosticEvent evt)
 {
     if (m_EventData == null)
     {
         m_EventData = new EventDataPlayerSessionCollection(OnRecordEvent);
     }
     if (m_EventData.GetPlayerSession(0, false) == null)
     {
         m_EventData.AddSession("Editor", m_PlayerSessionIndex = 0);
     }
     OnEvent(evt, 0);
 }
예제 #11
0
        public void EventDataPlayerSessionCollection_TestPlayerConnection()
        {
            EventDataPlayerSessionCollection edpsc = new EventDataPlayerSessionCollection((DiagnosticEvent x) => true);

            edpsc.AddSession("Default", 0);
            edpsc.GetPlayerSession(1000, true).IsActive = true;
            Assert.AreEqual(2, edpsc.GetSessionCount(), "Session not properly added. ");

            int connectedSessionIndex = edpsc.GetSessionIndexById(1000);

            Assert.AreEqual(1, connectedSessionIndex, "Session index not properly set. ");
        }
예제 #12
0
 void OnEditorPlayModeChanged(PlayModeStateChange state)
 {
     if (state == PlayModeStateChange.EnteredPlayMode)
     {
         m_EventData           = null;
         m_LastEventListUpdate = 0;
         m_InspectFrame        = -1;
         m_LatestFrame         = -1;
         m_PlayerSessionIndex  = 0;
         RegisterEventHandler(true);
     }
     else if (state == PlayModeStateChange.EnteredEditMode)
     {
         RegisterEventHandler(false);
     }
 }
예제 #13
0
        void OnEnable()
        {
            EditorConnection.instance.Initialize();
            EditorConnection.instance.Register(DiagnosticEventCollector.PlayerConnectionGuid, OnPlayerConnectionMessage);
            EditorConnection.instance.RegisterConnection(OnPlayerConnection);
            EditorConnection.instance.RegisterDisconnection(OnPlayerDisconnection);

            m_LastEventListUpdate = 0;
            m_PrevFrameIcon       = EditorGUIUtility.IconContent("Profiler.PrevFrame", "|Go one frame backwards");
            m_NextFrameIcon       = EditorGUIUtility.IconContent("Profiler.NextFrame", "|Go one frame forwards");
            EditorApplication.playModeStateChanged += OnEditorPlayModeChanged;
            RegisterEventHandler(true);
            if (m_EventData == null)
            {
                m_EventData = new EventDataPlayerSessionCollection(OnRecordEvent);
            }
            m_EventData.GetPlayerSession(0, true).IsActive = true;
        }
예제 #14
0
        void OnEditorPlayModeChanged(PlayModeStateChange state)
        {
            if (state == PlayModeStateChange.EnteredPlayMode)
            {
                m_EventData = new EventDataPlayerSessionCollection(OnRecordEvent);
                m_EventData.GetPlayerSession(0, true).IsActive = true;

                m_LastEventListUpdate = 0;
                m_InspectFrame        = -1;
                m_LatestFrame         = -1;
                m_PlayerSessionIndex  = 0;
                RegisterEventHandler(true);
            }
            else if (state == PlayModeStateChange.EnteredEditMode)
            {
                RegisterEventHandler(false);
            }
        }
예제 #15
0
        public void EventDataPlayerSessionCollection_RecordEvent_ReturnsFalseOnNullEventHandler()
        {
            EventDataPlayerSessionCollection edpsc = new EventDataPlayerSessionCollection(null);

            Assert.IsFalse(edpsc.RecordEvent(new DiagnosticEvent()), "RecordEvent should return null if m_OnRecordEvent is null");
        }