public void PropertyGridViewAccessibleObject_GetItem_ReturnsCorrectValue() { using PropertyGrid propertyGrid = new PropertyGrid(); propertyGrid.CreateControl(); using ComboBox comboBox = new ComboBox(); propertyGrid.SelectedObject = comboBox; AccessibleObject accessibleObject = propertyGrid.GridViewAccessibleObject; int i = 0; foreach (GridEntry category in propertyGrid.GetPropEntries()) { AccessibleObject categoryAccessibilityObject = category.AccessibilityObject; AccessibleObject categoryItem = (AccessibleObject)accessibleObject.GetItem(i, 1); Assert.Equal(categoryAccessibilityObject, categoryItem); i++; foreach (GridEntry entry in category.Children) { AccessibleObject entryAccessibilityObject = entry.AccessibilityObject; AccessibleObject entryItem = (AccessibleObject)accessibleObject.GetItem(i, 1); Assert.Equal(categoryAccessibilityObject, categoryItem); i++; } } }
public void PropertyGridToolStripButtonAccessibleObject_Invoke_UpdatesCheckedStateAndPropertySort() { using PropertyGrid propertyGrid = new PropertyGrid(); propertyGrid.CreateControl(); ToolStripButton[] toolStripButtons = propertyGrid.TestAccessor().Dynamic._viewSortButtons; ToolStripButton categoryButton = toolStripButtons[0]; ToolStripButton alphaButton = toolStripButtons[1]; AccessibleObject alphaButtonAccessibleObject = alphaButton.AccessibilityObject; AccessibleObject categoryButtonAccessibleObject = categoryButton.AccessibilityObject; Assert.True(categoryButton.Checked); Assert.False(alphaButton.Checked); Assert.Equal(PropertySort.CategorizedAlphabetical, propertyGrid.PropertySort); alphaButtonAccessibleObject.Invoke(); Assert.False(categoryButton.Checked); Assert.True(alphaButton.Checked); Assert.Equal(PropertySort.Alphabetical, propertyGrid.PropertySort); categoryButtonAccessibleObject.Invoke(); Assert.True(categoryButton.Checked); Assert.False(alphaButton.Checked); Assert.Equal(PropertySort.CategorizedAlphabetical, propertyGrid.PropertySort); }
public void BeforeEach() { _viewModel = new TestViewModel(); _binder = Create.Binder(_viewModel); _userControl = new PropertyGrid(); _userControl.CreateControl(); }
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 GridViewListBoxAccessibleObject_checks_arguments() { using PropertyGrid propertyGrid = new PropertyGrid { SelectedObject = Size.Empty }; propertyGrid.CreateControl(); PropertyGridView propertyGridView = propertyGrid.TestAccessor().GridView; using PropertyGridView.GridViewListBox gridViewListBox = new PropertyGridView.GridViewListBox(propertyGridView); AccessibleObject gridViewListBoxAccessibleObject = gridViewListBox.AccessibilityObject; Assert.NotNull(gridViewListBoxAccessibleObject); Assert.Throws <ArgumentNullException>(() => { Type gridViewListBoxAccessibleObjectType = gridViewListBoxAccessibleObject.GetType(); Assert.Equal("GridViewListBoxAccessibleObject", gridViewListBoxAccessibleObjectType.Name); ConstructorInfo constructorInfo = gridViewListBoxAccessibleObjectType.GetConstructors()[0]; using PropertyGridView.GridViewListBox owningGridViewListBox = new PropertyGridView.GridViewListBox(null); constructorInfo.Invoke(new object[] { owningGridViewListBox }); }); }
public void PropertyGridViewAccessibleObject_Parent_IsNotNull_IfHandleIsCreated() { using PropertyGrid propertyGrid = new PropertyGrid(); propertyGrid.CreateControl(); ControlAccessibleObject accessibleObject = (ControlAccessibleObject)propertyGrid.GridViewAccessibleObject; Assert.NotNull(accessibleObject.Parent); }
public void PropertyGridViewAccessibleObject_State_IsFocusable() { using PropertyGrid propertyGrid = new PropertyGrid(); propertyGrid.CreateControl(); using ComboBox comboBox = new ComboBox(); propertyGrid.SelectedObject = comboBox; AccessibleObject accessibleObject = propertyGrid.GridViewAccessibleObject; Assert.Equal(AccessibleStates.Focusable, accessibleObject.State & AccessibleStates.Focusable); }
public void BindControlObjectPropertyToDecimalViewModelProperty() { // Arrange using (var control = new PropertyGrid()) { control.CreateControl(); _binder.Control(control).Property(c => c.SelectedObject).Bind(vm => vm.IntValue); _viewModel.IntValue = 5; Assert.That(control.SelectedObject, Is.EqualTo(_viewModel.IntValue)); } }
public void PropertyGridViewAccessibleObject_Bounds_InsidePropertyGridBounds() { using PropertyGrid propertyGrid = new PropertyGrid(); propertyGrid.CreateControl(); propertyGrid.Size = new Size(300, 500); using ComboBox comboBox = new ComboBox(); propertyGrid.SelectedObject = comboBox; AccessibleObject accessibleObject = propertyGrid.GridViewAccessibleObject; Rectangle gridViewBounds = propertyGrid.RectangleToClient(accessibleObject.Bounds); Rectangle propertyGridBounds = propertyGrid.Bounds; Assert.True(propertyGridBounds.Contains(gridViewBounds)); }
public void PropertyGridToolStripButtonAccessibleObject_IsItemSelected_ReturnsExpected() { using PropertyGrid propertyGrid = new PropertyGrid(); propertyGrid.CreateControl(); ToolStripButton[] toolStripButtons = propertyGrid.TestAccessor().Dynamic._viewSortButtons; AccessibleObject categoryButtonAccessibleObject = toolStripButtons[0].AccessibilityObject; AccessibleObject alphaButtonAccessibleObject = toolStripButtons[1].AccessibilityObject; Assert.True(categoryButtonAccessibleObject.IsItemSelected); Assert.False(alphaButtonAccessibleObject.IsItemSelected); alphaButtonAccessibleObject.SelectItem(); Assert.False(categoryButtonAccessibleObject.IsItemSelected); Assert.True(alphaButtonAccessibleObject.IsItemSelected); }
public void PropertyGridAccessibleObject_SupportsPattern(int pattern) { using PropertyGrid propertyGrid = new PropertyGrid(); propertyGrid.CreateControl(); using ComboBox comboBox = new ComboBox(); propertyGrid.SelectedObject = comboBox; PropertyGridAccessibleObject propertyGridAccessibleObject = new PropertyGridAccessibleObject(propertyGrid); // First child should be PropertyGrid toolbox. AccessibleObject firstChild = (AccessibleObject)propertyGridAccessibleObject.FragmentNavigate(UiaCore.NavigateDirection.FirstChild); // Second child entry should be PropertyGridView. AccessibleObject gridViewChild = (AccessibleObject)firstChild.FragmentNavigate(UiaCore.NavigateDirection.NextSibling); Assert.True(gridViewChild.IsPatternSupported((UiaCore.UIA)pattern)); }
public void PropertyGridAccessibleObject_ControlType_IsPane_IfAccessibleRoleIsDefault(bool createControl, AccessibleRole expectedRole) { using PropertyGrid propertyGrid = new PropertyGrid(); // AccessibleRole is not set = Default if (createControl) { propertyGrid.CreateControl(); } AccessibleObject accessibleObject = propertyGrid.AccessibilityObject; object actual = accessibleObject.GetPropertyValue(UiaCore.UIA.ControlTypePropertyId); Assert.Equal(expectedRole, accessibleObject.Role); Assert.Equal(UiaCore.UIA.PaneControlTypeId, actual); Assert.Equal(createControl, propertyGrid.IsHandleCreated); }
public void PropertyGridViewAccessibleObject_Entry_IsOffscreen_ReturnsCorrectValue() { using PropertyGrid propertyGrid = new PropertyGrid(); propertyGrid.Size = new Size(300, 500); propertyGrid.Location = new Point(0, 0); propertyGrid.CreateControl(); using ComboBox comboBox = new ComboBox(); propertyGrid.SelectedObject = comboBox; ControlAccessibleObject accessibleObject = (ControlAccessibleObject)propertyGrid.GridViewAccessibleObject; PropertyGridView propertyGridView = (PropertyGridView)accessibleObject.Owner; Rectangle gridViewRectangle = accessibleObject.Bounds; int ROWLABEL = 1; int ROWVALUE = 2; foreach (GridEntry category in propertyGrid.GetPropEntries()) { AccessibleObject categoryAccessibilityObject = category.AccessibilityObject; int row = propertyGridView.GetRowFromGridEntry(category); Rectangle rect = propertyGridView.GetRectangle(row, ROWVALUE | ROWLABEL); rect = propertyGridView.RectangleToScreen(rect); bool visible = rect.Height > 0 && ((rect.Y > gridViewRectangle.Y + 1 && rect.Y < gridViewRectangle.Bottom - 1) || (rect.Y <gridViewRectangle.Bottom - 1 && rect.Bottom> gridViewRectangle.Y + 1)); // +-1 are borders Assert.Equal(!visible, (bool)categoryAccessibilityObject.GetPropertyValue(UiaCore.UIA.IsOffscreenPropertyId)); foreach (GridEntry entry in category.Children) { AccessibleObject entryAccessibilityObject = entry.AccessibilityObject; row = propertyGridView.GetRowFromGridEntry(entry); rect = propertyGridView.GetRectangle(row, ROWVALUE | ROWLABEL); rect = propertyGridView.RectangleToScreen(rect); visible = rect.Height > 0 && ((rect.Y > gridViewRectangle.Y + 1 && rect.Y < gridViewRectangle.Bottom - 1) || (rect.Y <gridViewRectangle.Bottom - 1 && rect.Bottom> gridViewRectangle.Y + 1)); // +-1 are borders Assert.Equal(!visible, (bool)entryAccessibilityObject.GetPropertyValue(UiaCore.UIA.IsOffscreenPropertyId)); } } }
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); }