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 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); }