public void ComboBoxAccessibleObject_Ctor_Default(ComboBox owner)
        {
            var accessibleObject = new ComboBox.ComboBoxAccessibleObject(owner);

            Assert.NotNull(accessibleObject.Owner);
            Assert.Equal(AccessibleRole.ComboBox, accessibleObject.Role);
        }
        public void ComboBoxItemAccessibleObject_Get_Not_ThrowsException()
        {
            using (new NoAssertContext())
            {
                using ComboBox control = new ComboBox();

                HashNotImplementedObject item1 = new();
                HashNotImplementedObject item2 = new();
                HashNotImplementedObject item3 = new();

                control.Items.AddRange(new[] { item1, item2, item3 });

                ComboBox.ComboBoxAccessibleObject comboBoxAccessibleObject = (ComboBox.ComboBoxAccessibleObject)control.AccessibilityObject;

                bool exceptionThrown = false;

                try
                {
                    ComboBox.ComboBoxItemAccessibleObject item1AccessibleObject = comboBoxAccessibleObject.ItemAccessibleObjects.GetComboBoxItemAccessibleObject(control.Items.InnerList[0]);
                    ComboBox.ComboBoxItemAccessibleObject item2AccessibleObject = comboBoxAccessibleObject.ItemAccessibleObjects.GetComboBoxItemAccessibleObject(control.Items.InnerList[1]);
                    ComboBox.ComboBoxItemAccessibleObject item3AccessibleObject = comboBoxAccessibleObject.ItemAccessibleObjects.GetComboBoxItemAccessibleObject(control.Items.InnerList[2]);
                }
                catch
                {
                    exceptionThrown = true;
                }

                Assert.False(exceptionThrown, "Getting accessible object for ComboBox item has thrown an exception.");
            }
        }
        public void ComboBoxAccessibleObject_Ctor_Default()
        {
            using var control = new ComboBox();
            var accessibleObject = new ComboBox.ComboBoxAccessibleObject(control);

            Assert.NotNull(accessibleObject.Owner);
            Assert.Equal(AccessibleRole.ComboBox, accessibleObject.Role);
        }
예제 #4
0
        public void ComboBoxAccessibleObject_GetPropertyValue_Pattern_ReturnsExpected(bool expected, int propertyId)
        {
            using ComboBox comboBox = new();
            comboBox.CreateControl(false);
            ComboBox.ComboBoxAccessibleObject accessibleObject = (ComboBox.ComboBoxAccessibleObject)comboBox.AccessibilityObject;

            Assert.Equal(expected, accessibleObject.GetPropertyValue((UiaCore.UIA)propertyId) ?? false);
            Assert.True(comboBox.IsHandleCreated);
        }
        public void ComboBoxAccessibleObject_Ctor_Default(bool createControl, AccessibleRole expectedAccessibleRole)
        {
            using ComboBox control = new ComboBox();
            if (createControl)
            {
                control.CreateControl();
            }

            Assert.Equal(createControl, control.IsHandleCreated);
            ComboBox.ComboBoxAccessibleObject accessibleObject = new ComboBox.ComboBoxAccessibleObject(control);
            Assert.Equal(createControl, control.IsHandleCreated);
            Assert.NotNull(accessibleObject.Owner);
            Assert.Equal(expectedAccessibleRole, accessibleObject.Role);
        }
        public void ComboBoxItemAccessibleObject_DataBoundAccessibleName()
        {
            // Regression test for https://github.com/dotnet/winforms/issues/3549

            using var control = new ComboBox()
                  {
                      DataSource    = TestDataSources.GetPersons(),
                      DisplayMember = TestDataSources.PersonDisplayMember
                  };

            ComboBox.ComboBoxAccessibleObject accessibleObject = Assert.IsType <ComboBox.ComboBoxAccessibleObject>(control.AccessibilityObject);

            foreach (Person person in TestDataSources.GetPersons())
            {
                var item = accessibleObject.ItemAccessibleObjects[person];
                AccessibleObject itemAccessibleObject = Assert.IsType <ComboBox.ComboBoxItemAccessibleObject>(item);
                Assert.Equal(person.Name, itemAccessibleObject.Name);
            }
        }
예제 #7
0
        public unsafe void SystemAccessibleObject_Enumeration()
        {
            using ComboBox control = new ComboBox
                  {
                      DropDownStyle = ComboBoxStyle.DropDown
                  };
            control.CreateControl();
            ComboBox.ComboBoxAccessibleObject accessibleObject = new ComboBox.ComboBoxAccessibleObject(control);

            var enumVariant = (IEnumVariant)accessibleObject;

            Assert.Equal(HRESULT.S_OK, enumVariant.Reset());

            VARIANT variantObject;
            uint    retreivedCount;
            var     result = enumVariant.Next(1, (IntPtr)(void *)&variantObject, &retreivedCount);

            Assert.Equal(HRESULT.S_OK, result);

            var retreivedItem = variantObject.ToObject();

            Assert.Equal(1, Assert.IsType <int>(retreivedItem));
        }