Esempio n. 1
0
        public void GridViewTextBoxAccessibleObject_created_for_string_property()
        {
            TestEntityWithTextField testEntity = new TestEntityWithTextField
            {
                TextProperty = "Test"
            };

            using PropertyGrid propertyGrid = new PropertyGrid
                  {
                      SelectedObject = testEntity
                  };

            PropertyGridView propertyGridView             = propertyGrid.TestAccessor().GridView;
            int firstPropertyIndex                        = 1; // Index 0 corresponds to the category grid entry.
            PropertyDescriptorGridEntry gridEntry         = (PropertyDescriptorGridEntry)propertyGridView.AccessibilityGetGridEntries()[firstPropertyIndex];
            PropertyDescriptorGridEntry selectedGridEntry = propertyGridView.TestAccessor().Dynamic._selectedGridEntry;

            Assert.Equal(gridEntry.PropertyName, selectedGridEntry.PropertyName);
            // Force the entry edit control Handle creation.
            // GridViewEditAccessibleObject exists, if its control is already created.
            // In UI case an entry edit control is created when an PropertyGridView gets focus.
            Assert.NotEqual(IntPtr.Zero, propertyGridView.TestAccessor().Dynamic.EditTextBox.Handle);

            AccessibleObject selectedGridEntryAccessibleObject = gridEntry.AccessibilityObject;

            UiaCore.IRawElementProviderFragment editFieldAccessibleObject = selectedGridEntryAccessibleObject.FragmentNavigate(UiaCore.NavigateDirection.FirstChild);
            Assert.NotNull(editFieldAccessibleObject);

            Assert.Equal("GridViewTextBoxAccessibleObject", editFieldAccessibleObject.GetType().Name);
        }
        public void GridViewEditAccessibleObject_FragmentNavigate_navigates_correctly()
        {
            using PropertyGrid propertyGrid = new PropertyGrid
                  {
                      SelectedObject = Point.Empty
                  };
            propertyGrid.CreateControl();
            PropertyGridView propertyGridView = propertyGrid.TestAccessor().GridView;

            int firstPropertyIndex = 2; // Index of Text property which has a RichEdit control as an editor.
            PropertyDescriptorGridEntry gridEntry = (PropertyDescriptorGridEntry)propertyGridView.AccessibilityGetGridEntries()[firstPropertyIndex];

            propertyGridView.TestAccessor().Dynamic.selectedGridEntry = gridEntry;

            UiaCore.IRawElementProviderFragment editFieldAccessibleObject = gridEntry.AccessibilityObject.FragmentNavigate(UiaCore.NavigateDirection.FirstChild);
            Assert.Equal("GridViewEditAccessibleObject", editFieldAccessibleObject.GetType().Name);

            // The case with drop down holder:
            using TestDropDownHolder dropDownHolder = new TestDropDownHolder(propertyGridView);
            dropDownHolder.CreateControl();
            propertyGridView.TestAccessor().Dynamic.dropDownHolder = dropDownHolder;

            dropDownHolder.SetState(0x00000002, true); // Control class States.Visible flag

            Assert.True(propertyGridView.DropDownVisible);
            object previousAccessibleObject = editFieldAccessibleObject.Navigate(UiaCore.NavigateDirection.PreviousSibling);

            Assert.NotNull(previousAccessibleObject);
            Assert.Same(dropDownHolder.AccessibilityObject, previousAccessibleObject);
        }
        public void GridViewEditAccessibleObject_created_for_string_property()
        {
            TestEntityWithTextField testEntity = new TestEntityWithTextField
            {
                TextProperty = "Test"
            };

            using PropertyGrid propertyGrid = new PropertyGrid
                  {
                      SelectedObject = testEntity
                  };

            PropertyGridView propertyGridView             = propertyGrid.TestAccessor().GridView;
            int firstPropertyIndex                        = 1; // Index 0 corresponds to the category grid entry.
            PropertyDescriptorGridEntry gridEntry         = (PropertyDescriptorGridEntry)propertyGridView.AccessibilityGetGridEntries()[firstPropertyIndex];
            PropertyDescriptorGridEntry selectedGridEntry = propertyGridView.TestAccessor().Dynamic.selectedGridEntry;

            Assert.Equal(gridEntry.PropertyName, selectedGridEntry.PropertyName);

            AccessibleObject selectedGridEntryAccessibleObject = gridEntry.AccessibilityObject;

            UiaCore.IRawElementProviderFragment editFieldAccessibleObject = selectedGridEntryAccessibleObject.FragmentNavigate(UiaCore.NavigateDirection.FirstChild);
            Assert.NotNull(editFieldAccessibleObject);

            Assert.Equal("GridViewEditAccessibleObject", editFieldAccessibleObject.GetType().Name);
        }
Esempio n. 4
0
        public void GridViewTextBoxAccessibleObject_FragmentNavigate_navigates_correctly()
        {
            using PropertyGrid propertyGrid = new PropertyGrid
                  {
                      SelectedObject = Point.Empty
                  };
            propertyGrid.CreateControl();
            PropertyGridView propertyGridView = propertyGrid.TestAccessor().GridView;

            int firstPropertyIndex = 2; // Index of Text property which has a RichEdit control as an editor.
            PropertyDescriptorGridEntry gridEntry = (PropertyDescriptorGridEntry)propertyGridView.AccessibilityGetGridEntries()[firstPropertyIndex];

            propertyGridView.TestAccessor().Dynamic._selectedGridEntry = gridEntry;

            // Force the entry edit control Handle creation.
            // GridViewEditAccessibleObject exists, if its control is already created.
            // In UI case an entry edit control is created when an PropertyGridView gets focus.
            Assert.NotEqual(IntPtr.Zero, propertyGridView.TestAccessor().Dynamic.EditTextBox.Handle);

            UiaCore.IRawElementProviderFragment editFieldAccessibleObject = gridEntry.AccessibilityObject.FragmentNavigate(UiaCore.NavigateDirection.FirstChild);
            Assert.Equal("GridViewTextBoxAccessibleObject", editFieldAccessibleObject.GetType().Name);

            // The case with drop down holder:
            using PropertyGridView.DropDownHolder dropDownHolder = new(propertyGridView);
            dropDownHolder.CreateControl();
            propertyGridView.TestAccessor().Dynamic._dropDownHolder = dropDownHolder;

            dropDownHolder.TestAccessor().Dynamic.SetState(0x00000002, true); // Control class States.Visible flag
            UiaCore.IRawElementProviderFragment dropDownHolderAccessibleObject = gridEntry.AccessibilityObject.FragmentNavigate(UiaCore.NavigateDirection.FirstChild);

            Assert.Equal("DropDownHolderAccessibleObject", dropDownHolderAccessibleObject.GetType().Name);
            Assert.True(propertyGridView.DropDownVisible);
            object previousAccessibleObject = editFieldAccessibleObject.Navigate(UiaCore.NavigateDirection.PreviousSibling);

            Assert.NotNull(previousAccessibleObject);
            Assert.Same(dropDownHolder.AccessibilityObject, previousAccessibleObject);
        }
        public void PropertyDescriptorGridEntryAccessibleObject_Navigates_to_DropDownControlHolder()
        {
            using PropertyGrid propertyGrid = new PropertyGrid();
            using TestPropertyGridView testPropertyGridView = new TestPropertyGridView(null, propertyGrid);

            TestPropertyDescriptorGridEntry gridEntry = new TestPropertyDescriptorGridEntry(propertyGrid, null, false);

            testPropertyGridView.TestAccessor().Dynamic.selectedGridEntry = gridEntry;

            TestDropDownHolder dropDownHolder = new TestDropDownHolder(testPropertyGridView);

            dropDownHolder.SetState(0x00000002, true); // Control class States.Visible flag
            testPropertyGridView.TestAccessor().Dynamic.dropDownHolder = dropDownHolder;
            gridEntry.parentPE = new TestGridEntry(propertyGrid, null, testPropertyGridView);

            UiaCore.IRawElementProviderFragment firstChild = gridEntry.AccessibilityObject.FragmentNavigate(UiaCore.NavigateDirection.FirstChild);
            Assert.NotNull(firstChild);
            Assert.Equal(typeof(PropertyGridView.DropDownHolder.DropDownHolderAccessibleObject), firstChild.GetType());
        }
        public void PropertyDescriptorGridEntryAccessibleObject_Navigates_to_DropDownControlHolder()
        {
            using PropertyGrid propertyGrid         = new();
            using PropertyGridView propertyGridView = new(serviceProvider : null, propertyGrid);

            TestPropertyGridViewAccessibleObject accessibleObject = new(propertyGridView, parentPropertyGrid : null);

            propertyGridView.Properties.SetObject(propertyGrid.TestAccessor().Dynamic.s_accessibilityProperty, accessibleObject);

            TestPropertyDescriptorGridEntry gridEntry = new(propertyGrid, null, false);

            propertyGridView.TestAccessor().Dynamic._selectedGridEntry = gridEntry;

            PropertyGridView.DropDownHolder dropDownHolder = new(propertyGridView);
            dropDownHolder.TestAccessor().Dynamic.SetState(0x00000002, true); // Control class States.Visible flag
            propertyGridView.TestAccessor().Dynamic._dropDownHolder = dropDownHolder;
            gridEntry.TestAccessor().Dynamic._parent = new TestGridEntry(propertyGrid, null, propertyGridView);

            UiaCore.IRawElementProviderFragment firstChild = gridEntry.AccessibilityObject.FragmentNavigate(UiaCore.NavigateDirection.FirstChild);
            Assert.NotNull(firstChild);
            Assert.Equal(typeof(PropertyGridView.DropDownHolder.DropDownHolderAccessibleObject), firstChild.GetType());
        }