public void TestPreviousAndNextShouldntUpdateHistory()
        {
            var selectionHistory = new SelectionHistory();

            var selection1 = new GameObject();
            var selection2 = new GameObject();

            selectionHistory.UpdateSelection(selection1);
            selectionHistory.UpdateSelection(selection2);

            Assert.AreSame(selectionHistory.GetSelection(), selection2);
            Assert.AreEqual(selectionHistory.GetHistoryCount(), 2);

            selectionHistory.Previous();
            selectionHistory.UpdateSelection(selection1);

            Assert.AreSame(selectionHistory.GetSelection(), selection1);
            Assert.AreEqual(selectionHistory.GetHistoryCount(), 2);

            selectionHistory.Next();
            selectionHistory.UpdateSelection(selection2);

            Assert.AreSame(selectionHistory.GetSelection(), selection2);
            Assert.AreEqual(selectionHistory.GetHistoryCount(), 2);
        }
        public void ClearDeletedEntriesShouldKeepSelectedIndex()
        {
            var selectionHistory = new SelectionHistory();

            var selection1 = new GameObject();
            var selection2 = new GameObject();
            var selection3 = new GameObject();
            var selection4 = new GameObject();

            selectionHistory.UpdateSelection(selection1);
            selectionHistory.UpdateSelection(selection2);
            selectionHistory.UpdateSelection(selection3);
            selectionHistory.UpdateSelection(selection4);

            Assert.IsTrue(selectionHistory.IsSelected(3));
            Assert.AreEqual(selectionHistory.GetHistoryCount(), 4);

            GameObject.DestroyImmediate(selection2);

            selectionHistory.ClearDeleted();

            Assert.IsTrue(selectionHistory.IsSelected(2));
            Assert.AreEqual(selectionHistory.GetHistoryCount(), 3);

            selectionHistory.SetSelection(selection3);

            GameObject.DestroyImmediate(selection1);
            GameObject.DestroyImmediate(selection4);

            selectionHistory.ClearDeleted();

            Assert.IsTrue(selectionHistory.IsSelected(0));
            Assert.AreEqual(selectionHistory.GetHistoryCount(), 1);
        }
        public void UpdateWithSameSelectionShouldntAddTwiceToHistory()
        {
            var selectionHistory = new SelectionHistory();

            var selection1 = new GameObject();

            selectionHistory.UpdateSelection(selection1);
            selectionHistory.UpdateSelection(selection1);

            Assert.AreSame(selectionHistory.GetSelection(), selection1);
            Assert.AreEqual(selectionHistory.GetHistoryCount(), 1);
        }
        public void NavigationWindowTest2()
        {
            var selectionHistory = new SelectionHistory();

            var selection1 = new GameObject();
            var selection2 = new GameObject();

            selectionHistory.UpdateSelection(selection1);
            selectionHistory.UpdateSelection(selection2);

            Assert.AreSame(selectionHistory.GetSelection(), selection2);
            Assert.AreEqual(selectionHistory.GetHistoryCount(), 2);
        }
        public void TestRemoveDuplicatedElementsInOrder()
        {
            var selectionHistory = new SelectionHistory();

            var selection1 = new GameObject();
            var selection2 = new GameObject();
            var selection3 = new GameObject();

            selectionHistory.UpdateSelection(selection1);
            selectionHistory.UpdateSelection(selection2);
            selectionHistory.UpdateSelection(selection1);
            selectionHistory.UpdateSelection(selection3);
            selectionHistory.UpdateSelection(selection1);

            selectionHistory.RemoveDuplicated();

            Assert.That(selectionHistory.GetHistoryCount(), Is.EqualTo(3));
            Assert.That(selectionHistory.GetSelection(), Is.SameAs(selection1));
            Assert.That(selectionHistory.IsSelected(2), Is.True);

            selectionHistory.UpdateSelection(selection3);
            Assert.That(selectionHistory.GetSelection(), Is.SameAs(selection3));

            selectionHistory.UpdateSelection(selection2);
            Assert.That(selectionHistory.GetSelection(), Is.SameAs(selection2));
        }
示例#6
0
        public static void SelectionRecorder()
        {
            if (Selection.activeObject != null)
            {
                if (debugEnabled)
                {
                    Debug.Log("Recording new selection: " + Selection.activeObject.name);
                }

                selectionHistory = EditorTemporaryMemory.Instance.selectionHistory;
                selectionHistory.UpdateSelection(Selection.activeObject);
            }
        }
        public void ClearDeletedItemsShouldntSelectIfSelectionDeleted()
        {
            var selectionHistory = new SelectionHistory();

            var selection1 = new GameObject();
            var selection2 = new GameObject();
            var selection3 = new GameObject();

            selectionHistory.UpdateSelection(selection1);
            selectionHistory.UpdateSelection(selection2);
            selectionHistory.UpdateSelection(selection3);

            Assert.IsTrue(selectionHistory.IsSelected(2));
            Assert.That(selectionHistory.GetHistoryCount(), Is.EqualTo(3));

            GameObject.DestroyImmediate(selection3);

            selectionHistory.ClearDeleted();

            Assert.IsFalse(selectionHistory.IsSelected(0));
            Assert.IsFalse(selectionHistory.IsSelected(1));
            Assert.AreEqual(selectionHistory.GetHistoryCount(), 2);
        }