Ejemplo n.º 1
0
            public TextBoxBaseAccessibleObject(TextBoxBase owner) : base(owner)
            {
                _owningTextBoxBase = owner;
                _textProvider      = new TextBoxBaseUiaTextProvider(owner);

                UseTextProviders(_textProvider, _textProvider);
            }
        public void TextBoxBaseUiaTextProvider_LineCount_Get_ReturnsCorrectValue()
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            textBoxBase.CreateControl();
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            Assert.Equal(1, provider.LinesCount);

            textBoxBase.Multiline = true;
            textBoxBase.Size      = new Size(30, 50);
            Assert.Equal(1, provider.LinesCount);

            textBoxBase.Text += "1\r\n";
            Assert.Equal(2, provider.LinesCount);

            textBoxBase.Text += "2\r\n";
            Assert.Equal(3, provider.LinesCount);

            textBoxBase.Text += "3\r\n";
            Assert.Equal(4, provider.LinesCount);

            textBoxBase.Text += "4\r\n";
            Assert.Equal(5, provider.LinesCount);

            Assert.True(textBoxBase.IsHandleCreated);
        }
 public GridViewEditAccessibleObject(GridViewEdit owner) : base(owner)
 {
     _owningPropertyGridView = owner.psheet;
     _owningGridViewEdit     = owner;
     _textProvider           = new TextBoxBaseUiaTextProvider(owner);
     UseTextProviders(_textProvider, _textProvider);
 }
 public UpDownEditAccessibleObject(UpDownEdit owner, UpDownBase parent) : base(owner)
 {
     _parent           = parent ?? throw new ArgumentNullException(nameof(parent));
     _owningUpDownEdit = owner;
     _textProvider     = new TextBoxBaseUiaTextProvider(owner);
     UseTextProviders(_textProvider, _textProvider);
 }
 public UpDownEditAccessibleObject(UpDownEdit owner, UpDownBase parent) : base(owner)
 {
     _parent           = parent.OrThrowIfNull();
     _owningUpDownEdit = owner;
     _textProvider     = new TextBoxBaseUiaTextProvider(owner);
     UseTextProviders(_textProvider, _textProvider);
 }
        public void TextBoxBaseUiaTextProvider_IsScrollable_False_WithoutHandle()
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            Assert.False(provider.IsScrollable);
            Assert.False(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_LinesPerPage_ReturnsMinusOne_WithoutHandle()
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            Assert.Equal(-1, provider.LinesPerPage);
            Assert.False(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseTextProvider_GetWindowStyle_ReturnsNoneForNotInitializedControl()
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            Assert.Equal(WS.OVERLAPPED, provider.WindowStyle);
            Assert.False(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_DocumentRange_IsNotNull()
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            Assert.NotNull(provider.DocumentRange);
            Assert.False(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_IsReadOnly_IsCorrect(bool readOnly)
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            textBoxBase.ReadOnly = readOnly;
            Assert.Equal(readOnly, provider.IsReadOnly);
            Assert.False(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_ctor_DoesntCreateControlHandle()
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            Assert.False(textBoxBase.IsHandleCreated);

            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            Assert.False(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_GetCaretRange_IsNull_IfHandleIsNotCreated()
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            UiaCore.ITextRangeProvider uiaTextRange = provider.GetCaretRange(out _);
            Assert.Null(uiaTextRange);
            Assert.False(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_SupportedTextSelection_IsNotNull()
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            UiaCore.SupportedTextSelection uiaTextRange = provider.SupportedTextSelection;
            Assert.Equal(UiaCore.SupportedTextSelection.Single, uiaTextRange);
            Assert.False(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_IsReadingRTL_ReturnsFalse_WithoutHandle(RightToLeft rightToLeft)
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            textBoxBase.RightToLeft       = rightToLeft;
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            Assert.False(provider.IsReadingRTL);
            Assert.False(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_GetLogfont_ReturnEmpty_WithoutHandle()
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            Assert.False(textBoxBase.IsHandleCreated);

            Assert.Equal(new LOGFONTW(), provider.Logfont);
        }
        public void TextBoxBaseUiaTextProvider_IsScrollable_IsCorrect()
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            textBoxBase.CreateControl();
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            Assert.True(provider.IsScrollable);
            Assert.True(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_EditStyle_ReturnsLeft_WithoutHandle()
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);
            ES actual = provider.EditStyle;

            Assert.Equal(ES.LEFT, actual);
            Assert.False(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_WindowExStyle_ReturnsLeft_WithoutHandle()
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);
            WS_EX actual = provider.WindowExStyle;

            Assert.Equal(WS_EX.LEFT, actual);
            Assert.False(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_TextLength_ReturnsMinusOne_WithoutHandle(string text)
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            textBoxBase.Text = text;
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            Assert.Equal(-1, provider.TextLength);
            Assert.False(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_RangeFromAnnotation_DoesntThrowAnException()
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            // RangeFromAnnotation doesn't throw an exception
            UiaCore.ITextRangeProvider range = provider.RangeFromAnnotation(textBoxBase.AccessibilityObject);
            // RangeFromAnnotation implementation can be changed so this test can be changed too
            Assert.NotNull(range);
        }
        public void TextBoxBaseUiaTextProvider_GetCaretRange_IsNotNull()
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            textBoxBase.CreateControl();
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            UiaCore.ITextRangeProvider uiaTextRange = provider.GetCaretRange(out _);
            Assert.NotNull(uiaTextRange);
            Assert.True(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_WindowExStyle_ReturnsCorrectValue()
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            textBoxBase.CreateControl();
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);
            WS_EX actual = provider.WindowExStyle;

            Assert.Equal(WS_EX.CLIENTEDGE, actual);
            Assert.True(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_IsReadingRTL_ReturnsCorrectValue(RightToLeft rightToLeft, bool expectedResult)
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            textBoxBase.CreateControl();
            textBoxBase.RightToLeft = rightToLeft;

            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            Assert.Equal(expectedResult, provider.IsReadingRTL);
            Assert.True(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_RangeFromPoint_ReturnsNull_WithoutHandle(Point point)
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            UiaTextRange textRangeProvider = provider.RangeFromPoint(point) as UiaTextRange;

            Assert.Null(textRangeProvider);

            Assert.False(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_Text_ReturnsEmpty_WithoutHandle(string text)
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            textBoxBase.Text = text;
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);
            string expected = string.Empty;
            string actual   = provider.Text.Trim('\0');

            Assert.Equal(expected, actual);
            Assert.False(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_SetSelection_GetSelection_DontWork_WithoutHandle(int start, int end)
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            textBoxBase.Text = "Some test text for testing";
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            provider.SetSelection(start, end);
            Assert.False(textBoxBase.IsHandleCreated);
            UiaCore.ITextRangeProvider[] selection = provider.GetSelection();
            Assert.Null(selection);
            Assert.False(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_RangeFromPoint_DoesntThrowAnException(Point point)
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            textBoxBase.CreateControl();
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            UiaTextRange textRangeProvider = provider.RangeFromPoint(point) as UiaTextRange;

            Assert.NotNull(textRangeProvider);

            Assert.True(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_GetVisibleRanges_ReturnsNull_WithoutHandle(Size size)
        {
            using SubTextBoxBase textBoxBase = new SubTextBoxBase()
                  {
                      Text = "Some test text for testing",
                      Size = size
                  };
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            Assert.Null(provider.GetVisibleRanges());
            Assert.False(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_EditStyle_ReturnsCorrectValue()
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase();
            textBoxBase.CreateControl();
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);
            ES actual = provider.EditStyle;

            Assert.True(actual.HasFlag(ES.LEFT));
            Assert.True(actual.HasFlag(ES.AUTOVSCROLL));
            Assert.True(actual.HasFlag(ES.AUTOHSCROLL));
            Assert.True(textBoxBase.IsHandleCreated);
        }
        public void TextBoxBaseUiaTextProvider_TextLength_ReturnsCorrectValue(string text)
        {
            using TextBoxBase textBoxBase = new SubTextBoxBase
                  {
                      Text = text
                  };
            textBoxBase.CreateControl();
            TextBoxBaseUiaTextProvider provider = new TextBoxBaseUiaTextProvider(textBoxBase);

            Assert.Equal(textBoxBase.Text.Length, provider.TextLength);
            Assert.True(textBoxBase.IsHandleCreated);
        }