开发者

Implementing IGridProvider, IValueProvider in AutomationPeer class

开发者 https://www.devze.com 2023-02-07 14:21 出处:网络
I have written AutomationPeer class for my custom control: // Automation Peer for the CustomControl private class CustommControlAutomationPeer : FrameworkElementAutomationPeer, IValueProvider, IGridP

I have written AutomationPeer class for my custom control:

    // Automation Peer for the CustomControl
    private class CustommControlAutomationPeer : FrameworkElementAutomationPeer, IValueProvider, IGridProvider
    {
        public CustomControlAutomationPeer(CustomControl control)
            : base(control)
        { }

        #region overriding the "Core" methods from the base automation peer class that describe behavior unique and specific to custom control
         ...
        #endregion

        #region overriding of GetPattern should return the object that implements the specified pattern
        public override object GetPattern(PatternInterface patternInterface)
        {
            if (patternInterface == PatternInterface.Grid || patternInterface == PatternInterface.Value)
            {
                return this;
            }
            return base.GetPattern(patternInterface);
        }

        #endregion

        #region IGridProvider
         ...
        #endregion

        #region IValueProvider
         ...
        #endregion

        /// <summary>
        /// Pointer to CustomControl
        /// </summary>
        private CustomControl Control
        {
            get
            {
                return (CustonControl)base.Owner;
            }
    开发者_运维百科    }
    }

In computer, where installed Visual Studio, and other computer, where installed test agent I started testmethod with code:

AutomationPattern[] supportedPatterns = customControl.GetSupportedPatterns();
        foreach (var supPattern in supportedPatterns)
            Trace.WriteLine(supPattern.ProgrammaticName);

Result in trace:

in computer with visual studio:

QTAgent32.exe, <a class=success>Playback - {43} [SUCCESS] MouseButtonClick - "[UIA]ControlType='RadioButton' && AutomationId='allCriteriaRadioButton'"
\0</a>  
**ValuePatternIdentifiers.Pattern;  
GridPatternIdentifiers.Pattern**  
QTAgent32.exe, IEDOM : StopSession of the plugin called before StartSession
QTAgent32.exe, UIA : StopSession of the plugin called before StartSession

in computer with test agent:

QTAgent32.exe, &lt;a class=success&gt;Playback - {43} [SUCCESS] MouseButtonClick - "[UIA]ControlType='RadioButton' &amp;&amp; AutomationId='allCriteriaRadioButton'"
\0&lt;/a&gt;  
**GridPatternIdentifiers.Pattern**  
 QTAgent32.exe, IEDOM : StopSession of the plugin called before StartSession
QTAgent32.exe, UIA : StopSession of the plugin called before StartSession

Why am I get only IGridProvider in second case?

0

精彩评论

暂无评论...
验证码 换一张
取 消