예제 #1
0
        public void Arrange_Empty()
        {
            var textField = new TextField(LayoutTestStyle.Create());

            textField.Arrange(new Rectangle(10, 20, 300, 100));
            textField.LayoutRect.Should().Be(new Rectangle(10, 20, 300, 100));
        }
예제 #2
0
        public void Arrange_Zero()
        {
            var style     = LayoutTestStyle.Create();
            var textField = new TextField(style);

            style.StyleResolver.AddRoot(textField);

            textField.Padding = new Insets();
            textField.Arrange(new Rectangle(10, 20, 0, 0));
            textField.LayoutRect.Should().Be(new Rectangle(10, 20, 0, 0));
        }
예제 #3
0
        public void View_Backspace()
        {
            var uiStyle = LayoutTestStyle.Create();

            var eb = new TextField(uiStyle, new TestDocumentViewEditor <PlainTextDocument>(new PlainTextDocumentEditor(uiStyle)));

            uiStyle.StyleResolver.AddRoot(eb);

            eb.Text = "Hello World";
            eb.Caret.SelectionEndOffset.Should().Be(11);
            eb.Arrange(new Rectangle(10, 20, 100, 40));

            eb.DispatchEvent(new KeyEventArgs(new KeyEventData(KeyEventType.KeyPressed, TimeSpan.Zero, 0, InputFlags.None, Keys.Back)));
            eb.Text.Should().Be("Hello Worl");

            eb.Arrange(new Rectangle(10, 20, 100, 40));
            var exposed = (TestDocumentView <PlainTextDocument>)eb.Content;
            var chunk   = (TextChunkView <PlainTextDocument>)exposed.ExposedRootView[0][0];

            chunk.Text.Should().Be("Hello Worl");
        }
예제 #4
0
        public void View_Navigate_then_backspace()
        {
            var style     = LayoutTestStyle.Create();
            var textField = new TextField(style, new TestDocumentViewEditor <PlainTextDocument>(new PlainTextDocumentEditor(style)));

            style.StyleResolver.AddRoot(textField);

            textField.Padding = new Insets();
            textField.Text    = "Hello World";
            textField.Caret.SelectionEndOffset.Should().Be(11);
            textField.Arrange(new Rectangle(10, 20, 100, 40));

            textField.DispatchEvent(new KeyEventArgs(new KeyEventData(KeyEventType.KeyPressed, TimeSpan.Zero, 0, InputFlags.None, Keys.Left)));
            textField.DispatchEvent(new KeyEventArgs(new KeyEventData(KeyEventType.KeyPressed, TimeSpan.Zero, 0, InputFlags.None, Keys.Left)));
            textField.DispatchEvent(new KeyEventArgs(new KeyEventData(KeyEventType.KeyPressed, TimeSpan.Zero, 0, InputFlags.None, Keys.Back)));
            textField.Text.Should().Be("Hello Wold");

            textField.Arrange(new Rectangle(10, 20, 100, 40));
            var exposed = (TestDocumentView <PlainTextDocument>)textField.Content;
            var chunk   = (TextChunkView <PlainTextDocument>)exposed.ExposedRootView[0][0];

            chunk.Text.Should().Be("Hello Wold");
        }
예제 #5
0
        public void Caret_Layout()
        {
            var style     = LayoutTestStyle.Create();
            var textField = new TextField(style);

            style.StyleResolver.AddRoot(textField);

            textField.Padding = new Insets();
            textField.Text    = "Hello World";
            textField.Caret.MoveTo(6);

            textField.Arrange(new Rectangle(10, 20, 400, 30));
            textField.Caret.LayoutRect.Should().Be(new Rectangle(76, 20, 1, 15));
        }
예제 #6
0
        public void View_Navigate_then_delete()
        {
            var style     = LayoutTestStyle.Create();
            var textField = new TextField(style, new TestDocumentViewEditor <PlainTextDocument>(new PlainTextDocumentEditor(style)));

            style.StyleResolver.AddRoot(textField);

            textField.Padding = new Insets();
            textField.Text    = "Hello World";
            textField.Caret.SelectionEndOffset.Should().Be(11);
            textField.Arrange(new Rectangle(10, 20, 100, 40));

            textField.DispatchEvent(new KeyEventArgs(new KeyEventData(KeyEventType.KeyPressed, TimeSpan.Zero, 0, InputFlags.None, Keys.Left)));
            textField.DispatchEvent(new KeyEventArgs(new KeyEventData(KeyEventType.KeyPressed, TimeSpan.Zero, 0, InputFlags.None, Keys.Left)));
            textField.DispatchEvent(new KeyEventArgs(new KeyEventData(KeyEventType.KeyPressed, TimeSpan.Zero, 0, InputFlags.None, Keys.Delete)));
            textField.Text.Should().Be("Hello Word");

            textField.Arrange(new Rectangle(10, 20, 100, 40));
            var exposed = (TestDocumentView <PlainTextDocument>)textField.Content;
            var chunk   = (TextChunkView <PlainTextDocument>)exposed.ExposedRootView[0][0];

            // the edit should have flushed out the old chunk. Chunks retain the text/strings to match what we give to SpriteBatch.
            chunk.Text.Should().Be("Hello Word");
        }
예제 #7
0
        public void Arrange_Long_Text_caret_at_start()
        {
            var style     = LayoutTestStyle.Create();
            var textField = new TextField(style);

            style.StyleResolver.AddRoot(textField);

            textField.Padding = new Insets();
            textField.Text    = "A very long text that will exceed the layout size we give to the edit-box";
            textField.Caret.MoveTo(2);

            textField.Arrange(new Rectangle(10, 20, 100, 20));
            textField.LayoutRect.Should().Be(new Rectangle(10, 20, 100, 20));
            textField.Content.LayoutRect.Should().Be(new Rectangle(10, 20, 100, 15));
            textField.Caret.LayoutRect.Should().Be(new Rectangle(32, 20, 1, 15));
        }
예제 #8
0
        public void EnsureWrapIsDisabled()
        {
            var uiStyle = LayoutTestStyle.Create();
            var style   = uiStyle.StyleSystem.StylesFor <TextStyleDefinition>();

            var textField = new TextField(uiStyle);

            uiStyle.StyleResolver.AddRoot(textField);

            textField.Text = "TEst";
            textField.WrapText.Should().Be(WrapText.None);
            textField.Measure(Size.Auto);
            textField.WrapText.Should().Be(WrapText.None);

            textField.Arrange(new Rectangle(10, 20, 400, 40));
            textField.Content.Style.GetValue(style.WrapText).Should().Be(WrapText.None);
        }