Example #1
0
        object?IRawElementProviderSimple.GetPatternProvider(UIA patternId)
        {
            object?obj = publicIRawElementProviderSimple.GetPatternProvider(patternId);

            if (obj is null)
            {
                return(null);
            }

            // we always want to return the internal accessible object
            return(patternId switch
            {
                UIA.ExpandCollapsePatternId => (IExpandCollapseProvider)this,
                UIA.ValuePatternId => (IValueProvider)this,
                UIA.RangeValuePatternId => (IRangeValueProvider)this,
                UIA.TogglePatternId => (IToggleProvider)this,
                UIA.TablePatternId => (ITableProvider)this,
                UIA.TableItemPatternId => (ITableItemProvider)this,
                UIA.GridPatternId => (IGridProvider)this,
                UIA.GridItemPatternId => (IGridItemProvider)this,
                UIA.InvokePatternId => (IInvokeProvider)this,
                UIA.LegacyIAccessiblePatternId => (ILegacyIAccessibleProvider)this,
                UIA.SelectionPatternId => (ISelectionProvider)this,
                UIA.SelectionItemPatternId => (ISelectionItemProvider)this,
                UIA.ScrollItemPatternId => (IScrollItemProvider)this,
                UIA.MultipleViewPatternId => (IMultipleViewProvider)this,
                UIA.TextPatternId => (ITextProvider)this,
                UIA.TextPattern2Id => (ITextProvider2)this,
                _ => null
            });
        public void AccessibleRoleControlTypeMap_GetControlType_ReturnsExpectedValue(AccessibleRole role, int expectedType)
        {
            // UIA is less accessible than the test
            // so we have to use "int" type for "expectedType" argument
            UIA actual = AccessibleRoleControlTypeMap.GetControlType(role);

            Assert.Equal((UIA)expectedType, actual);
        }
        public void AccessibleRoleControlTypeMap_Contains_AllRoles(AccessibleRole role)
        {
            // Check if the map contains the role
            // If so the map returns an exist UIA_ControlTypeId
            UIA actual = AccessibleRoleControlTypeMap.GetControlType(role);

            Assert.True(actual >= UIA.ButtonControlTypeId && actual <= UIA.AppBarControlTypeId);
        }
        public void CheckBoxAccessibleObject_GetPropertyValue_ControlType_IsExpected_ForCustomRole(AccessibleRole role)
        {
            using CheckBox checkBox = new CheckBox();
            checkBox.AccessibleRole = role;
            UIA expected = AccessibleRoleControlTypeMap.GetControlType(role);

            Assert.Equal(expected, checkBox.AccessibilityObject.GetPropertyValue(UIA.ControlTypePropertyId));
            Assert.Equal(checkBox.AccessibilityObject.DefaultAction, checkBox.AccessibilityObject.GetPropertyValue(UIA.LegacyIAccessibleDefaultActionPropertyId));
            Assert.False(checkBox.IsHandleCreated);
        }
Example #5
0
        public void TabPageAccessibleObject_GetPropertyValue_ControlType_IsExpected_ForCustomRole(AccessibleRole role)
        {
            using TabPage tabPage  = new();
            tabPage.AccessibleRole = role;

            object actual   = tabPage.AccessibilityObject.GetPropertyValue(UIA.ControlTypePropertyId);
            UIA    expected = AccessibleRoleControlTypeMap.GetControlType(role);

            Assert.Equal(expected, actual);
            Assert.False(tabPage.IsHandleCreated);
        }
        public void SplitContainerAccessibleObject_GetPropertyValue_ControlType_IsExpected_ForCustomRole(AccessibleRole role)
        {
            using SplitContainer splitContainer = new();
            splitContainer.AccessibleRole       = role;

            object actual   = splitContainer.AccessibilityObject.GetPropertyValue(UIA.ControlTypePropertyId);
            UIA    expected = AccessibleRoleControlTypeMap.GetControlType(role);

            Assert.Equal(expected, actual);
            Assert.False(splitContainer.IsHandleCreated);
        }
Example #7
0
        public void PanelAccessibleObject_GetPropertyValue_ControlType_IsExpected_ForCustomRole(AccessibleRole role)
        {
            using Panel panel    = new();
            panel.AccessibleRole = role;

            object actual   = panel.AccessibilityObject.GetPropertyValue(UIA.ControlTypePropertyId);
            UIA    expected = AccessibleRoleControlTypeMap.GetControlType(role);

            Assert.Equal(expected, actual);
            Assert.False(panel.IsHandleCreated);
        }
Example #8
0
        public void ToolStripItemAccessibleObject_ControlType_IsButton_IfAccessibleRoleIsDefault()
        {
            // Test the Default role case separatelly because ToolStripItemAccessibleObject
            // has default Role property value as "PushButton"

            using ToolStripItem toolStripItem = new SubToolStripItem();
            // AccessibleRole is not set = Default

            UIA actual = (UIA)toolStripItem.AccessibilityObject.GetPropertyValue(UIA.ControlTypePropertyId);

            Assert.Equal(UIA.ButtonControlTypeId, actual);
        }
Example #9
0
        public void ToolStripItemAccessibleObject_GetPropertyValue_ControlTypeProperty_ReturnsCorrectValue(AccessibleRole role)
        {
            using ToolStripItem toolStripItem = new SubToolStripItem();
            toolStripItem.AccessibleRole      = role;

            UIA actual   = (UIA)toolStripItem.AccessibilityObject.GetPropertyValue(UIA.ControlTypePropertyId);
            UIA expected = AccessibleRoleControlTypeMap.GetControlType(role);

            Assert.Equal(expected, actual);
            // Check if the method returns an exist UIA_ControlTypeId
            Assert.True(actual >= UIA.ButtonControlTypeId && actual <= UIA.AppBarControlTypeId);
        }
Example #10
0
    void Start()
    {
        // TODO get config from xml
        UIA           uiA      = new UIA();
        GameObject    prefab   = Resources.Load <GameObject>("UI/UIA");
        GameObject    go       = Instantiate(prefab);
        UIControlData ctrlData = go.GetComponent <UIControlData>();

        if (ctrlData != null)
        {
            ctrlData.BindAllFields(uiA);
        }

        uiA.CheckBinding();
    }
 public static int GetPropertyValueInternal(IntPtr thisPtr, UIA patternId, IntPtr *i)
 {
     *i = IntPtr.Zero;
     try
     {
         var    inst            = ComInterfaceDispatch.GetInstance <IRawElementProviderSimple>((ComInterfaceDispatch *)thisPtr);
         var    target          = inst.GetPropertyValue(patternId);
         IntPtr pUnk            = WinFormsComWrappers.Instance.GetOrCreateComInterfaceForObject(target, CreateComInterfaceFlags.None);
         Guid   targetInterface = WinFormsComWrappers.IRawElementProviderSimple_GUID;
         int    result          = Marshal.QueryInterface(pUnk, ref targetInterface, out *i);
         Marshal.Release(pUnk);
     }
     catch (Exception e)
     {
         return(e.HResult);
     }
     return(0); // S_OK;
 }
 private static extern string Test_IRawElementProviderSimpleGetPropertyValue(
     [MarshalAs(UnmanagedType.IUnknown)] object pUnk,
     UIA patternId,
     out VARIANT expected);
Example #13
0
 internal override object?GetPropertyValue(UIA propertyID)
 => propertyID switch
 {
Example #14
0
 /// -------------------------------------------------------------------
 /// <summary>Call this to initialize the class so that one can call the
 /// entry points depending on which framework is used</summary>
 /// -------------------------------------------------------------------
 public StressScenarioTests(UIA.AutomationElement element, bool testEvents, bool testChildren, int numThreads, TestLab testLab, IApplicationCommands commands)
     :
     base(element, null, TestPriorities.PriAll, TypeOfControl.UnknownControl, TypeOfPattern.Unknown, null, testEvents, commands)
 {
     _testChildren = testChildren;
     _numThreads = numThreads;
     _testLab = testLab;
     //PopulateAutomationElementProperties(ref _automationProperties, ref _automationPatterns);
 }
Example #15
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public ValuePattern(UIA.AutomationElement automationElement) : base(automationElement) { }
Example #16
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public TogglePattern(UIA.AutomationElement automationElement) : base(automationElement) { }
Example #17
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public SelectionPattern(UIA.AutomationElement automationElement) : base(automationElement) { }
Example #18
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public MultipleViewPattern(UIA.AutomationElement automationElement) : base(automationElement) { }
Example #19
0
 internal override bool RaiseAutomationEvent(UIA eventId)
 {
     RaiseAutomationEventCallsCount++;
     return(base.RaiseAutomationEvent(eventId));
 }
 public static extern HRESULT UiaRaiseAutomationPropertyChangedEvent(IRawElementProviderSimple pProvider, UIA id, object?oldValue, object?newValue);
Example #21
0
 public void iSet(UIA k, int v)
 {
     iAttr[(int)k] = v;
 }
Example #22
0
 public int iGet(UIA v)
 {
     return(iAttr[(int)v]);
 }
Example #23
0
 object?IRawElementProviderSimple.GetPropertyValue(UIA propertyID)
 => publicIRawElementProviderSimple.GetPropertyValue(propertyID);
Example #24
0
        object?IRawElementProviderSimple.GetPatternProvider(UIA patternId)
        {
            object?obj = publicIRawElementProviderSimple.GetPatternProvider(patternId);

            if (obj != null)
            {
                // we always want to return the internal accessible object
                if (patternId == UIA.ExpandCollapsePatternId)
                {
                    return((IExpandCollapseProvider)this);
                }
                else if (patternId == UIA.ValuePatternId)
                {
                    return((IValueProvider)this);
                }
                else if (patternId == UIA.RangeValuePatternId)
                {
                    return((IRangeValueProvider)this);
                }
                else if (patternId == UIA.TogglePatternId)
                {
                    return((IToggleProvider)this);
                }
                else if (patternId == UIA.TablePatternId)
                {
                    return((ITableProvider)this);
                }
                else if (patternId == UIA.TableItemPatternId)
                {
                    return((ITableItemProvider)this);
                }
                else if (patternId == UIA.GridPatternId)
                {
                    return((IGridProvider)this);
                }
                else if (patternId == UIA.GridItemPatternId)
                {
                    return((IGridItemProvider)this);
                }
                else if (patternId == UIA.InvokePatternId)
                {
                    return((IInvokeProvider)this);
                }
                else if (patternId == UIA.LegacyIAccessiblePatternId)
                {
                    return((ILegacyIAccessibleProvider)this);
                }
                else if (patternId == UIA.SelectionPatternId)
                {
                    return((ISelectionProvider)this);
                }
                else if (patternId == UIA.SelectionItemPatternId)
                {
                    return((ISelectionItemProvider)this);
                }
                else if (patternId == UIA.ScrollItemPatternId)
                {
                    return((IScrollItemProvider)this);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
 private static extern string Test_IRawElementProviderSimpleGetPatternProvider(
     [MarshalAs(UnmanagedType.IUnknown)] object pUnk,
     UIA patternId,
     BOOL expected);
Example #26
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public GridPattern(UIA.AutomationElement automationElement) : base(automationElement) { }
Example #27
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public InvokePattern(UIA.AutomationElement automationElement) : base(automationElement) { }
Example #28
0
 internal override bool RaiseAutomationPropertyChangedEvent(UIA propertyId, object oldValue, object newValue)
 {
     RaiseAutomationPropertyChangedEventCallsCount++;
     return(base.RaiseAutomationPropertyChangedEvent(propertyId, oldValue, newValue));
 }
Example #29
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public ScrollPattern(UIA.AutomationElement automationElement) : base(automationElement) { }
 internal override bool IsPatternSupported(UIA patternId)
 => _accessibleObject.IsPatternSupported(patternId);
Example #31
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public TextPattern(UIA.AutomationElement automationElement) : base(automationElement) { }
Example #32
0
 public UIAutomationTestTypes(UIA.AutomationElement element)
 {
     _automationElement = element;
 }
Example #33
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public TransformPattern(UIA.AutomationElement automationElement) : base(automationElement) { }
Example #34
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public AutomationElement(UIA.AutomationElement automationElement) : base(automationElement) { }
Example #35
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public WindowPattern(UIA.AutomationElement automationElement) : base(automationElement) { }
Example #36
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public DockPattern(UIA.AutomationElement automationElement) : base(automationElement) { }
 internal override object?GetPropertyValue(UIA propertyID)
 => _accessibleObject.GetPropertyValue(propertyID);
Example #38
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 public ExpandCollapsePattern(UIA.AutomationElement automationElement) : base(automationElement) { }
Example #39
0
        private void BuildElementTable(UIA.AutomationElement _originalElement)
        {
            Assembly assembly = Assembly.GetAssembly(typeof(UIA.AutomationElement));
            Assembly curAssembly = Assembly.GetCallingAssembly();

            // Get all patterns currently supported by UIA
            if (_patterns == null)
                _patterns = GetPatternList();

            try
            {
                // Use refelction to build up the list of elements
                foreach (UIA.AutomationElement element in _originalElement.FindAll(UIA.TreeScope.Subtree, UIA.Condition.TrueCondition))
                {
                    // Everything supports the AutomationElement "pattern" so add them
                    // as AutomationStressTests.AutomationElement
                    _contextElements.Add(new AutomationElement(element));

                    // If the AutomationElement supports a specific pattern, then 
                    // create an UIAutomationTestTypes based on the specific 
                    // pattern that is supported.  If the AutomationElement
                    // supports more than one pattern, then create another
                    // UIAutomationTestTypes of the other patterns and store them
                    // for later retrieval using the GetRandomObjectByType()
                    foreach (string patternName in _patterns)
                    {
                        // Get the particular Is<Pattern>Supported property such as IsScrollPatternSupported
                        FieldInfo fi = assembly.GetType("System.Windows.Automation.AutomationElement").GetField("Is" + patternName + "AvailableProperty");

                        // Use the property to get the actual value of the Is<Pattern>Supported 
                        // associated with the specific AutomationElement
                        if ((bool)element.GetCurrentPropertyValue((UIA.AutomationProperty)fi.GetValue(element)))
                        {
                            // If it's not the close button, create the AutomationStressTests.<Pattern> and store
                            // it in the context for later retrieval using GetRandomObjectByType()
                            if (patternName != UIA.InvokePattern.Pattern.ProgrammaticName && element.Current.Name != "Close")
                            {
                                _appCommands.TraceMethod("Creating UIAStressHelpers." + patternName);
                                _contextElements.Add(Activator.CreateInstance(curAssembly.GetType("UIAStressHelpers." + patternName), new object[] { element }));
                            }
                        }
                    }
                }
            }
            catch (InvalidCastException e)
            {
                System.Diagnostics.Debug.Assert(false);
                Console.WriteLine(e.ToString());
            }

        }
 public static extern HRESULT UiaRaiseAutomationEvent(IRawElementProviderSimple provider, UIA id);
Example #41
0
 /// -------------------------------------------------------------------
 /// <summary>Constructor of object to pass to the thread</summary>
 /// -------------------------------------------------------------------
 public PacketInfo(
     UIA.AutomationElement applicationElement,
     UIA.AutomationElement element,
     IApplicationCommands appCommands,
     TestLab testLab,
     int actionCount,
     ArrayList automationProperties,
     ArrayList automationPatterns,
     Scenario scenario)
 {
     _applicationElement = applicationElement;
     _element = element;
     _appCommands = appCommands;
     _testLab = testLab;
     _actionCount = actionCount;
     _automationProperties = automationProperties;
     _automationPatterns = automationPatterns;
     _scenario = scenario;
     _testLab = testLab;
 }
 internal override bool IsPatternSupported(UIA patternId)
 => patternId switch
 {