GetCachedPattern() public method

public GetCachedPattern ( AutomationPattern pattern ) : object
pattern AutomationPattern
return object
Example #1
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        internal object GetPattern(AutomationElement element, bool m_useCurrent, AutomationPattern pattern)
        {

            object patternObj = null;

            if (m_useCurrent)
                patternObj = element.GetCurrentPattern(pattern);
            else
                patternObj = element.GetCachedPattern(pattern);

            if (patternObj == null)
                throw new Exception(Helpers.PatternNotSupported);

            return patternObj;
        }
        /// -------------------------------------------------------------------
        /// <summary>
        /// Test that a password edit box throws expection when calling ValuePattern.Value
        /// </summary>
        /// -------------------------------------------------------------------
        void TS_PasswordText(AutomationElement element, CheckType checktype)
        {
            try
            {
                ValuePattern vp;
                string buffer;

                if (m_useCurrent)
                {
                    vp = element.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;
                    buffer = vp.Current.Value;
                }
                else
                {
                    vp = element.GetCachedPattern(ValuePattern.Pattern) as ValuePattern;
                    buffer = vp.Cached.Value;
                }

            }
            catch (InvalidOperationException)
            {
                m_TestStep++;
                return;
            }

            ThrowMe(checktype, "Calling ValuePattern.Value on a password edit box should throw InvalidOperationException");
        }