예제 #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_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);
        }
예제 #3
0
        public void GridViewTextBoxAccessibleObject_RuntimeId_ReturnsNull()
        {
            using PropertyGrid propertyGrid = new() { SelectedObject = new TestEntityWithTextField()
                                                      {
                                                          TextProperty = "Test"
                                                      } };

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

            // 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 editFieldAccessibleObject = (AccessibleObject)gridEntry.AccessibilityObject.FragmentNavigate(UiaCore.NavigateDirection.FirstChild);

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

            Assert.NotNull(editFieldAccessibleObject.RuntimeId);
        }