public void EventDataPlayerSession_AddSample_SimpleInstantiationCase()
        {
            EventDataPlayerSession edps = new EventDataPlayerSession();

            DiagnosticEvent evt1 = CreateNewInstantiationEvent(0, 1);
            DiagnosticEvent evt2 = CreateNewInstantiationEvent(0, 1);
            DiagnosticEvent evt3 = CreateNewInstantiationEvent(1, 1);
            DiagnosticEvent evt4 = CreateNewInstantiationEvent(2, 0);

            bool entryCreated = false;

            edps.AddSample(evt1, false, ref entryCreated);
            Assert.IsFalse(entryCreated, "evt1: Either a new entry was created when it shouldn't have been, or the value of entryCreated was not properly updated.");

            edps.AddSample(evt2, false, ref entryCreated);
            Assert.IsFalse(entryCreated, "evt2: Either a new entry was created when it shouldn't have been, or the value of entryCreated was not properly updated.");

            edps.AddSample(evt3, false, ref entryCreated);
            Assert.IsFalse(entryCreated, "evt3: Either a new entry was created when it shouldn't have been, or the value of entryCreated was not properly updated.");

            Assert.AreEqual(2, edps.m_InstantitationCountDataSet.GetStreamValue(0, 0), "Stream value for frame 0 not properly set to 2.");
            Assert.AreEqual(2, edps.m_InstantitationCountDataSet.GetStreamValue(0, 1), "Stream value for frame 1 was updated prematurely - stream values for instantiation counts should not be updated until it is certain that all events for a given frame have been collected. ");

            edps.AddSample(evt4, false, ref entryCreated);
            Assert.IsFalse(entryCreated, "evt3: Either a new entry was created when it shouldn't have been, or the value of entryCreated was not properly updated.");

            Assert.AreEqual(1, edps.m_InstantitationCountDataSet.GetStreamValue(0, 1), "Stream value for frame 1 was not updated properly, should be updated once the sample is added for the following frame.");
        }
        public void EventDataPlayerSession_HandleOperationDestroy_DoesNotDestroyOnNonzeroRefcount()
        {
            EventDataPlayerSession edps = new EventDataPlayerSession();

            DiagnosticEvent creationEvt = CreateNewGenericEvent(ResourceManager.DiagnosticEventType.AsyncOperationCreate, 0, 1, 1000);
            DiagnosticEvent refcountEvt = CreateNewGenericEvent(ResourceManager.DiagnosticEventType.AsyncOperationReferenceCount, 0, 1, 1000);
            DiagnosticEvent deletionEvt = CreateNewGenericEvent(ResourceManager.DiagnosticEventType.AsyncOperationDestroy, 1, 1, 1000);

            bool entryCreated = false;

            edps.AddSample(creationEvt, false, ref entryCreated);
            Assert.IsTrue(entryCreated, "creationEvt: Either a new entry was supposed to be created, but was not, or the value of entryCreated was not properly updated.");

            edps.AddSample(refcountEvt, false, ref entryCreated);
            Assert.IsFalse(entryCreated, "refcountEvt: Either a new entry was created when it shouldn't have been, or the value of entryCreated was not properly updated.");

            edps.AddSample(deletionEvt, false, ref entryCreated);
            Assert.IsFalse(entryCreated, "deletionEvt: Either a new entry was created when it shouldn't have been, or the value of entryCreated was not properly updated.");

            Assert.AreEqual(1, edps.m_Queue.Count, "Deletion event should've been added to the removal queue.");

            edps.HandleOperationDestroy(deletionEvt);

            Assert.IsTrue(edps.m_DataSets.ContainsKey(creationEvt.ObjectId), "Dataset should not have been removed because it's refcount is greater than 0. ");
        }
        public void EventDataPlayerSession_HandleOperationDestroy_DestroyedEventHasParentCase()
        {
            EventDataPlayerSession edps = new EventDataPlayerSession();

            DiagnosticEvent dependencyEvt = CreateNewGenericEvent(ResourceManager.DiagnosticEventType.AsyncOperationReferenceCount, 0, 0, 1001);
            DiagnosticEvent creationEvt   = CreateNewGenericEvent(ResourceManager.DiagnosticEventType.AsyncOperationCreate, 0, 1, 1000, new int[] { dependencyEvt.ObjectId });
            DiagnosticEvent deletionEvt   = CreateNewGenericEvent(ResourceManager.DiagnosticEventType.AsyncOperationDestroy, 1, 1, 1001);

            bool entryCreated = false;

            edps.AddSample(dependencyEvt, false, ref entryCreated);
            Assert.IsTrue(entryCreated, "Either a new entry was supposed to be created, but was not, or the value of entryCreated was not properly updated.");

            edps.AddSample(creationEvt, false, ref entryCreated);
            Assert.IsTrue(entryCreated, "Either a new entry was supposed to be created, but was not, or the value of entryCreated was not properly updated.");

            edps.AddSample(deletionEvt, false, ref entryCreated);
            Assert.IsFalse(entryCreated, "Either a new entry was created when it shouldn't have been, or the value of entryCreated was not properly updated.");
            Assert.AreEqual(1, edps.m_RootStreamEntry.Children.Count(), "DependencyEvt's id should have been removed from RootStreamEntry's children because it is a dependency.");

            Assert.AreEqual(1, edps.m_Queue.Count, "Deletion event should have been added to the removal queue.");

            edps.HandleOperationDestroy(deletionEvt);

            Assert.IsFalse(edps.m_DataSets.ContainsKey(deletionEvt.ObjectId), "DataSet was not properly removed after dependency was cleared. ");

            EventDataSet creationEvtEds = null;

            Assert.IsTrue(edps.m_DataSets.TryGetValue(creationEvt.ObjectId, out creationEvtEds), "Parent event was removed from m_DataSets incorrectly.");
            Assert.IsNull(creationEvtEds.m_Children, "dependencyEvt's dataset should have been removed from the children of creationEvt's dataset. ");

            Assert.AreEqual(1, edps.m_Queue.Count, "No further deletion events should have been added to the deletion queue.");
        }
Example #4
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. ");
        }
Example #5
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);
        }
Example #6
0
        void DrawToolBar(EventDataPlayerSession session)
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            GUILayout.FlexibleSpace();
            m_Record = GUILayout.Toggle(m_Record, "Record", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false));

            if (GUILayout.Button("Clear", EditorStyles.toolbarButton))
            {
                RegisterEventHandler(false);
                session.Clear();
                if (m_GraphList != null)
                {
                    m_GraphList.Reload();
                }
                RegisterEventHandler(true);
            }
            if (GUILayout.Button("Load", EditorStyles.toolbarButton))
            {
                EditorUtility.DisplayDialog("Feature not implemented", "Saving and loading profile data is not yet supported", "Close");
            }
            if (GUILayout.Button("Save", EditorStyles.toolbarButton))
            {
                EditorUtility.DisplayDialog("Feature not implemented", "Saving and loading profile data is not yet supported", "Close");
            }

            GUILayout.FlexibleSpace();
            GUILayout.Label(m_InspectFrame == m_LatestFrame ? "Frame:     " : "Frame: " + m_InspectFrame + "/" + m_LatestFrame, EditorStyles.miniLabel);

            using (new EditorGUI.DisabledScope(m_InspectFrame <= 0))
                if (GUILayout.Button(m_PrevFrameIcon, EditorStyles.toolbarButton))
                {
                    SetInspectFrame(m_InspectFrame - 1);
                }


            using (new EditorGUI.DisabledScope(m_InspectFrame >= m_LatestFrame))
                if (GUILayout.Button(m_NextFrameIcon, EditorStyles.toolbarButton))
                {
                    SetInspectFrame(m_InspectFrame + 1);
                }


            if (GUILayout.Button("Current", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
            {
                SetInspectFrame(m_LatestFrame);
            }

            GUILayout.EndHorizontal();
        }
        public void EventDataPlayerSession_GetFrameEvents_TestSimpleCase()
        {
            EventDataPlayerSession edps = new EventDataPlayerSession();

            DiagnosticEvent evt1 = CreateNewGenericEvent(ResourceManager.DiagnosticEventType.AsyncOperationCreate, 0, 5);
            DiagnosticEvent evt2 = CreateNewGenericEvent(ResourceManager.DiagnosticEventType.AsyncOperationCreate, 0, 6);

            bool entryCreated = false;

            edps.AddSample(evt1, true, ref entryCreated);
            edps.AddSample(evt2, true, ref entryCreated);


            Assert.AreEqual(new List <DiagnosticEvent> {
                evt1, evt2
            }, edps.GetFrameEvents(0), "Events were not properly added together in FrameEvents");
            Assert.AreEqual(null, edps.GetFrameEvents(1), "FrameEvents for frame 1 should be null. ");
        }
        public void EventDataPlayerSession_AddSample_MultipleObjectCase()
        {
            EventDataPlayerSession edps = new EventDataPlayerSession();

            DiagnosticEvent evt1 = CreateNewGenericEvent(ResourceManager.DiagnosticEventType.AsyncOperationReferenceCount, 0, 1, 1000);
            DiagnosticEvent evt2 = CreateNewGenericEvent(ResourceManager.DiagnosticEventType.AsyncOperationReferenceCount, 1, 1, 1001);

            bool entryCreated = false;

            edps.AddSample(evt1, false, ref entryCreated);
            Assert.IsTrue(entryCreated, "evt1: Either a new entry was supposed to be created, but was not, or the value of entryCreated was not properly updated.");
            Assert.IsTrue(edps.m_DataSets.ContainsKey(evt1.ObjectId), "Entry for evt1 should have been created, but was not added to m_DataSets");
            Assert.AreEqual(1, edps.m_DataSets[evt1.ObjectId].GetStreamValue((int)ResourceManager.DiagnosticEventType.AsyncOperationReferenceCount, 0), "Value was not correctly set within EventDataSet object for evt1. ");

            edps.AddSample(evt2, false, ref entryCreated);
            Assert.IsTrue(entryCreated, "evt2: Either a new entry was supposed to be created, but was not, or the value of entryCreated was not properly updated.");
            Assert.IsTrue(edps.m_DataSets.ContainsKey(evt2.ObjectId), "Entry for evt2 should have been created, but was not added to m_DataSets");
            Assert.AreEqual(1, edps.m_DataSets[evt2.ObjectId].GetStreamValue((int)ResourceManager.DiagnosticEventType.AsyncOperationReferenceCount, 1), "Value was not correctly set within EventDataSet object for evt2. ");
        }
Example #9
0
        void DrawToolBar(EventDataPlayerSession session)
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

            if (GUILayout.Button("Clear Events", EditorStyles.toolbarButton))
            {
                RegisterEventHandler(false);
                session.Clear();
                m_GraphList?.Reload();
                RegisterEventHandler(true);
            }

            if (m_GraphList != null && m_GraphList.HasHiddenEvents && GUILayout.Button("Unhide All Hidden Events", EditorStyles.toolbarButton))
            {
                m_GraphList.UnhideAllHiddenEvents();
            }

            GUILayout.FlexibleSpace();
            GUILayout.Label(m_InspectFrame == m_LatestFrame ? "Frame:     " : "Frame: " + m_InspectFrame + "/" + m_LatestFrame, EditorStyles.miniLabel);

            using (new EditorGUI.DisabledScope(m_InspectFrame <= 0))
                if (GUILayout.Button(m_PrevFrameIcon, EditorStyles.toolbarButton))
                {
                    SetInspectFrame(m_InspectFrame - 1);
                }

            using (new EditorGUI.DisabledScope(m_InspectFrame >= m_LatestFrame))
                if (GUILayout.Button(m_NextFrameIcon, EditorStyles.toolbarButton))
                {
                    SetInspectFrame(m_InspectFrame + 1);
                }

            if (GUILayout.Button("Current", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
            {
                SetInspectFrame(m_LatestFrame);
            }

            GUILayout.EndHorizontal();
        }
        public void DrawGraphs(Rect rect, EventDataPlayerSession data, int inspectFrame)
        {
            EditorGUI.DrawRect(GraphRect, GraphColors.WindowBackground);
            if (data != null)
            {
                m_InspectFrame = inspectFrame;
                if (Event.current.type == EventType.Repaint)
                {
                    multiColumnHeader.state.columns[2].width = rect.width - (multiColumnHeader.state.columns[1].width + multiColumnHeader.state.columns[0].width + 20);
                }

                visibleDuration = Mathf.Max(300, (int)(multiColumnHeader.state.columns[2].width));
                if (data.IsActive)
                {
                    visibleStartTime = data.LatestFrame - visibleDuration;
                }
                if (Time.unscaledTime - m_LastReloadTime > 1 && (EditorApplication.isPlaying || data.PlayerId != 0))
                {
                    Reload();
                    m_LastReloadTime = Time.unscaledTime;
                }
            }
            base.OnGUI(rect);
        }
        public void EventDataPlayerSession_AddSample_SimpleRecordEventCase()
        {
            EventDataPlayerSession edps = new EventDataPlayerSession();

            DiagnosticEvent evt1 = CreateNewGenericEvent(ResourceManager.DiagnosticEventType.AsyncOperationReferenceCount, 0, 1);
            DiagnosticEvent evt2 = CreateNewGenericEvent(ResourceManager.DiagnosticEventType.AsyncOperationCreate, 0, 2);
            DiagnosticEvent evt3 = CreateNewGenericEvent(ResourceManager.DiagnosticEventType.AsyncOperationReferenceCount, 1, 1);

            bool entryCreated = false;

            edps.AddSample(evt1, true, ref entryCreated);
            Assert.IsTrue(entryCreated, "Either a new entry was supposed to be created, but was not, or the value of entryCreated was not properly updated.");

            edps.AddSample(evt2, true, ref entryCreated);
            Assert.IsFalse(entryCreated, "evt2: Either a new entry wasn't supposed to be created, but was, or the value of entryCreated was not properly updated.");

            edps.AddSample(evt3, true, ref entryCreated);
            Assert.IsFalse(entryCreated, "evt3: Either a new entry wasn't supposed to be created for, but was, or the value of entryCreated was not properly updated.");

            Assert.AreEqual(new List <DiagnosticEvent> {
                evt1, evt2
            }, edps.m_FrameEvents[0], "evt1 and evt2 were not properly added to m_FrameEvents");
            Assert.AreEqual(2, edps.m_EventCountDataSet.GetStreamValue(0, 0), "Value of the stream for m_EventCountDataSet was not properly set.");
            Assert.AreEqual(new List <DiagnosticEvent> {
                evt3
            }, edps.m_FrameEvents[1], "evt3 was not properly added to m_FrameEvents");
            Assert.IsTrue(edps.m_DataSets.ContainsKey(evt1.ObjectId), "The corresponding EventDataSet for evt1-3 was not added to m_DataSets");

            EventDataSet eds = null;

            bool edsFound = edps.m_DataSets.TryGetValue(evt1.ObjectId, out eds);

            Assert.IsTrue(edsFound);
            Assert.AreEqual(2, eds.GetStream((int)ResourceManager.DiagnosticEventType.AsyncOperationReferenceCount).samples.Count);
            Assert.AreEqual(1, eds.GetStream((int)ResourceManager.DiagnosticEventType.AsyncOperationCreate).samples.Count);
        }