Пример #1
0
        public void Test_MoveElementsActionForMultipleTypes([Values] TestingMode mode)
        {
            var deltaMove = new Vector2(50, -75);
            var itemSize  = new Vector2(100, 100);

            var origNodePosition = Vector2.zero;
            var newNodePosition  = deltaMove;
            var node             = GraphModel.CreateNode <Type0FakeNodeModel>("Node0", Vector2.zero);

            var origStickyPosition = new Rect(Vector2.one * -100, itemSize);
            var newStickyPosition  = new Rect(origStickyPosition.position + deltaMove, itemSize);
            var stickyNote         = (StickyNoteModel)GraphModel.CreateStickyNote(origStickyPosition);

            TestPrereqActionPostreq(mode,
                                    () =>
            {
                Assert.That(GetNodeCount(), Is.EqualTo(1));
                Assert.That(GetEdgeCount(), Is.EqualTo(0));
                Assert.That(GetStickyNoteCount(), Is.EqualTo(1));
                Assert.That(GetNode(0).Position, Is.EqualTo(origNodePosition));
                Assert.That(GetStickyNote(0).Position, Is.EqualTo(origStickyPosition));
                return(new MoveElementsAction(deltaMove, new[] { node }, new[] { stickyNote }));
            },
                                    () =>
            {
                Assert.That(GetNodeCount(), Is.EqualTo(1));
                Assert.That(GetEdgeCount(), Is.EqualTo(0));
                Assert.That(GetStickyNoteCount(), Is.EqualTo(1));
                Assert.That(GetNode(0).Position, Is.EqualTo(newNodePosition));
                Assert.That(GetStickyNote(0).Position.position, Is.EqualTo(newStickyPosition.position));
            });
        }
Пример #2
0
        public void ExtractSticky([Values] TestingMode mode)
        {
            IStickyNoteModel sticky = GraphModel.CreateStickyNote(new Rect()) as StickyNoteModel;

            Undo.IncrementCurrentGroup();

            TestPrereqActionPostreq(mode, () =>
            {
                Refresh();
                Assert.That(GraphModel.NodeModels.OfType <MacroRefNodeModel>().Count(), Is.Zero);
                Assert.That(GraphModel.StickyNoteModels.Count(), Is.EqualTo(1));
                return(new RefactorExtractMacroAction(new List <IGraphElementModel> {
                    sticky
                }, Vector2.zero, null));
            }, () =>
            {
                Refresh();
                var macroRef = GraphModel.NodeModels.OfType <MacroRefNodeModel>().Single();
                Assert.That(macroRef, Is.Not.Null);
                Assert.That(macroRef.GraphAssetModel.GraphModel.Stencil, Is.TypeOf <MacroStencil>());
                Assert.That(((VSGraphModel)macroRef.GraphAssetModel.GraphModel).StickyNoteModels.Count(), Is.EqualTo(1));
                Assert.That(((MacroStencil)macroRef.GraphAssetModel.GraphModel.Stencil).ParentType, Is.EqualTo(GraphModel.Stencil.GetType()));

                // Assert Sticky has been removed from GraphModel
                Assert.That(GraphModel.StickyNoteModels.Count(), Is.EqualTo(0));
            });

            void Refresh()
            {
                RefreshReference(ref sticky);
            }
        }
Пример #3
0
        public IEnumerator ChangeStickyNoteContentUpdatesModel()
        {
            const string newContent = "New Content";

            var stickyNoteModel = GraphModel.CreateStickyNote(new Rect(0, 0, 200, 200));

            stickyNoteModel.Title    = "My Note";
            stickyNoteModel.Contents = "Old Content";
            MarkGraphViewStateDirty();
            yield return(null);

            var stickyNote    = stickyNoteModel.GetUI <GraphElement>(GraphView);
            var label         = stickyNote.SafeQ(StickyNote.contentContainerPartName).SafeQ(EditableLabel.labelName);
            var clickPosition = label.parent.LocalToWorld(label.layout.center);

            EventHelper.Click(clickPosition, clickCount: 2);

            EventHelper.Type(newContent);

            // Commit the changes by clicking outside the field.
            EventHelper.Click(GraphView.layout.min);

            yield return(null);

            Assert.AreEqual(newContent, stickyNoteModel.Contents);
        }
Пример #4
0
        public void ElementIsHidableByPlacement()
        {
            var placemat = GraphModel.CreatePlacemat(new Rect(0, 0, 200, 500)) as PlacematModel;
            var node     = GraphModel.CreateNode <Type0FakeNodeModel>("Node0", new Vector2(10, 100));
            var sticky   = (StickyNoteModel)GraphModel.CreateStickyNote(new Rect(100, 100, 50, 50));

            placemat.HiddenElements = new[] { node };
            Assert.AreEqual(1, placemat.HiddenElements.Count(), "Node was not properly added to the list of hidden elements");
            Assert.AreEqual(node, placemat.HiddenElements.First(), "Placemat does not contain the expected node in its hidden elements");

            placemat.HiddenElements = new[] { sticky };
            Assert.AreEqual(1, placemat.HiddenElements.Count(), "Sticky note was not properly added to the list of hidden elements");
            Assert.AreEqual(sticky, placemat.HiddenElements.First(), "Placemat does not contain the expected sticky note in its hidden elements");
        }
Пример #5
0
        public void Test_ResizeStickyNoteAction([Values] TestingMode mode)
        {
            var stickyNote = GraphModel.CreateStickyNote(k_StickyNoteRect);

            TestPrereqActionPostreq(mode,
                                    () =>
            {
                Assert.That(GetNodeCount(), Is.EqualTo(0));
                Assert.That(GetEdgeCount(), Is.EqualTo(0));
                Assert.That(GetStickyNoteCount(), Is.EqualTo(1));
                Assert.That(GetStickyNote(0).Position, Is.EqualTo(k_StickyNoteRect));
                return(new ResizeStickyNoteAction(stickyNote, k_StickyNote2Rect));
            },
                                    () =>
            {
                Assert.That(GetNodeCount(), Is.EqualTo(0));
                Assert.That(GetEdgeCount(), Is.EqualTo(0));
                Assert.That(GetStickyNoteCount(), Is.EqualTo(1));
                Assert.That(GetStickyNote(0).Position, Is.EqualTo(k_StickyNote2Rect));
            });
        }
        public void Test_UpdateStickyNoteTextSizeCommand([Values] TestingMode mode)
        {
            var stickyNote = GraphModel.CreateStickyNote(k_StickyNoteRect);

            TestPrereqCommandPostreq(mode,
                                     () =>
            {
                Assert.That(GetNodeCount(), Is.EqualTo(0));
                Assert.That(GetEdgeCount(), Is.EqualTo(0));
                Assert.That(GetStickyNoteCount(), Is.EqualTo(1));
                Assert.That(GetStickyNote(0).TextSize, Is.EqualTo(StickyNoteTextSize.Small.ToString()));
                return(new UpdateStickyNoteTextSizeCommand(StickyNoteTextSize.Huge.ToString(), new[] { stickyNote }));
            },
                                     () =>
            {
                Assert.That(GetNodeCount(), Is.EqualTo(0));
                Assert.That(GetEdgeCount(), Is.EqualTo(0));
                Assert.That(GetStickyNoteCount(), Is.EqualTo(1));
                Assert.That(GetStickyNote(0).TextSize, Is.EqualTo(StickyNoteTextSize.Huge.ToString()));
            });
        }
        public void Test_UpdateStickyNoteThemeCommand([Values] TestingMode mode)
        {
            var stickyNote = GraphModel.CreateStickyNote(k_StickyNoteRect);

            TestPrereqCommandPostreq(mode,
                                     () =>
            {
                Assert.That(GetNodeCount(), Is.EqualTo(0));
                Assert.That(GetEdgeCount(), Is.EqualTo(0));
                Assert.That(GetStickyNoteCount(), Is.EqualTo(1));
                Assert.That(GetStickyNote(0).Theme, Is.EqualTo(StickyNoteColorTheme.Classic.ToString()));
                return(new UpdateStickyNoteThemeCommand(StickyNoteColorTheme.Teal.ToString(), stickyNote));
            },
                                     () =>
            {
                Assert.That(GetNodeCount(), Is.EqualTo(0));
                Assert.That(GetEdgeCount(), Is.EqualTo(0));
                Assert.That(GetStickyNoteCount(), Is.EqualTo(1));
                Assert.That(GetStickyNote(0).Theme, Is.EqualTo(StickyNoteColorTheme.Teal.ToString()));
            });
        }
        public void MoveElementsCommandForMultipleTypesWorks([Values] TestingMode mode)
        {
            var deltaMove = new Vector2(50, -75);
            var itemSize  = new Vector2(100, 100);

            var origNodePosition = Vector2.zero;
            var newNodePosition  = deltaMove;
            var node             = GraphModel.CreateNode <Type0FakeNodeModel>("Node0", Vector2.zero);

            var origStickyPosition = new Rect(Vector2.one * -100, itemSize);
            var newStickyPosition  = new Rect(origStickyPosition.position + deltaMove, itemSize);
            var stickyNote         = (StickyNoteModel)GraphModel.CreateStickyNote(origStickyPosition);

            var origPlacematPosition = new Rect(Vector2.one * 200, itemSize);
            var newPlacematPosition  = new Rect(origPlacematPosition.position + deltaMove, itemSize);
            var placemat             = (PlacematModel)GraphModel.CreatePlacemat(origPlacematPosition);

            placemat.Title = "Blah";

            TestPrereqCommandPostreq(mode,
                                     () =>
            {
                Assert.That(GetNodeCount(), Is.EqualTo(1));
                Assert.That(GetEdgeCount(), Is.EqualTo(0));
                Assert.That(GetStickyNoteCount(), Is.EqualTo(1));
                Assert.That(GetNode(0).Position, Is.EqualTo(origNodePosition));
                Assert.That(GetStickyNote(0).PositionAndSize, Is.EqualTo(origStickyPosition));
                Assert.That(GetPlacemat(0).PositionAndSize, Is.EqualTo(origPlacematPosition));
                return(new MoveElementsCommand(deltaMove, new IMovable[] { node, placemat, stickyNote }));
            },
                                     () =>
            {
                Assert.That(GetNodeCount(), Is.EqualTo(1));
                Assert.That(GetEdgeCount(), Is.EqualTo(0));
                Assert.That(GetStickyNoteCount(), Is.EqualTo(1));
                Assert.That(GetNode(0).Position, Is.EqualTo(newNodePosition));
                Assert.That(GetStickyNote(0).PositionAndSize.position, Is.EqualTo(newStickyPosition.position));
                Assert.That(GetPlacemat(0).PositionAndSize.position, Is.EqualTo(newPlacematPosition.position));
            });
        }
        public void Test_ResizeStickyNoteCommand([Values] TestingMode mode)
        {
            GraphModel.CreateStickyNote(k_StickyNoteRect);

            TestPrereqCommandPostreq(mode,
                                     () =>
            {
                IStickyNoteModel stickyNote = GetStickyNote(0);
                Assert.That(GetNodeCount(), Is.EqualTo(0));
                Assert.That(GetEdgeCount(), Is.EqualTo(0));
                Assert.That(GetStickyNoteCount(), Is.EqualTo(1));
                Assert.That(stickyNote.PositionAndSize, Is.EqualTo(k_StickyNoteRect));
                return(new ChangeElementLayoutCommand(stickyNote, k_StickyNote2Rect));
            },
                                     () =>
            {
                Assert.That(GetNodeCount(), Is.EqualTo(0));
                Assert.That(GetEdgeCount(), Is.EqualTo(0));
                Assert.That(GetStickyNoteCount(), Is.EqualTo(1));
                Assert.That(GetStickyNote(0).PositionAndSize, Is.EqualTo(k_StickyNote2Rect));
            });
        }
Пример #10
0
        public IEnumerator ResizeStickyNoteChangeModelRect()
        {
            var originalRect = new Rect(0, 0, 100, 100);
            var move         = new Vector2(100, 0);

            var stickyNoteModel = GraphModel.CreateStickyNote(originalRect);

            stickyNoteModel.Title           = "Placemat";
            stickyNoteModel.PositionAndSize = originalRect;
            MarkGraphViewStateDirty();
            yield return(null);

            var stickyNote    = stickyNoteModel.GetUI <GraphElement>(GraphView);
            var rightResizer  = stickyNote.SafeQ(Placemat.resizerPartName).SafeQ("right-resize");
            var clickPosition = rightResizer.parent.LocalToWorld(rightResizer.layout.center);

            EventHelper.DragTo(clickPosition, clickPosition + move);
            yield return(null);

            var newRect = new Rect(originalRect.position, originalRect.size + move);

            Assert.AreEqual(newRect, stickyNoteModel.PositionAndSize);
        }
Пример #11
0
        public void Test_MoveElementsActionForStickyNodes([Values] TestingMode mode)
        {
            var origStickyPosition = new Rect(Vector2.zero, new Vector2(100, 100));
            var newStickyPosition  = new Rect(Vector2.right * 100, new Vector2(100, 100));
            var stickyNote         = (StickyNoteModel)GraphModel.CreateStickyNote(origStickyPosition);

            TestPrereqActionPostreq(mode,
                                    () =>
            {
                Assert.That(GetNodeCount(), Is.EqualTo(0));
                Assert.That(GetEdgeCount(), Is.EqualTo(0));
                Assert.That(GetStickyNoteCount(), Is.EqualTo(1));
                Assert.That(GetStickyNote(0).Position, Is.EqualTo(origStickyPosition));
                return(new MoveElementsAction(newStickyPosition.position - origStickyPosition.position, null, new[] { stickyNote }));
            },
                                    () =>
            {
                Assert.That(GetNodeCount(), Is.EqualTo(0));
                Assert.That(GetEdgeCount(), Is.EqualTo(0));
                Assert.That(GetStickyNoteCount(), Is.EqualTo(1));
                Assert.That(GetStickyNote(0).Position.position, Is.EqualTo(newStickyPosition.position));
            });
        }
Пример #12
0
        public void Test_UpdateStickyNoteAction([Values] TestingMode mode)
        {
            var stickyNote = GraphModel.CreateStickyNote(k_StickyNoteRect);

            TestPrereqActionPostreq(mode,
                                    () =>
            {
                Assert.That(GetNodeCount(), Is.EqualTo(0));
                Assert.That(GetEdgeCount(), Is.EqualTo(0));
                Assert.That(GetStickyNoteCount(), Is.EqualTo(1));
                Assert.That(string.IsNullOrEmpty(GetStickyNote(0).Title));
                Assert.IsTrue(string.IsNullOrEmpty(GetStickyNote(0).Contents));
                return(new UpdateStickyNoteAction(stickyNote, "stickyNote2", "This is a note"));
            },
                                    () =>
            {
                Assert.That(GetNodeCount(), Is.EqualTo(0));
                Assert.That(GetEdgeCount(), Is.EqualTo(0));
                Assert.That(GetStickyNoteCount(), Is.EqualTo(1));
                Assert.That(GetStickyNote(0).Title, Is.EqualTo("stickyNote2"));
                Assert.That(GetStickyNote(0).Contents, Is.EqualTo("This is a note"));
            });
        }
Пример #13
0
        public void Test_UpdateStickyNoteTextSizeAction([Values] TestingMode mode)
        {
            var stickyNote = GraphModel.CreateStickyNote(k_StickyNoteRect);

            TestPrereqActionPostreq(mode,
                                    () =>
            {
                Assert.That(GetNodeCount(), Is.EqualTo(0));
                Assert.That(GetEdgeCount(), Is.EqualTo(0));
                Assert.That(GetStickyNoteCount(), Is.EqualTo(1));
                Assert.That(GetStickyNote(0).TextSize, Is.EqualTo(StickyNoteTextSize.Small));
                return(new UpdateStickyNoteTextSizeAction(new List <IStickyNoteModel> {
                    stickyNote
                }, StickyNoteTextSize.Huge));
            },
                                    () =>
            {
                Assert.That(GetNodeCount(), Is.EqualTo(0));
                Assert.That(GetEdgeCount(), Is.EqualTo(0));
                Assert.That(GetStickyNoteCount(), Is.EqualTo(1));
                Assert.That(GetStickyNote(0).TextSize, Is.EqualTo(StickyNoteTextSize.Huge));
            });
        }