GetSupportedPatterns() public method

public GetSupportedPatterns ( ) : System.Windows.Automation.AutomationPattern[]
return System.Windows.Automation.AutomationPattern[]
Example #1
0
 private void EmptyTextFromChild(AutomationElement element)
 {
     if (element.GetSupportedPatterns().Contains(ValuePattern.Pattern))
     {
         ((ValuePattern)element.GetCurrentPattern(ValuePattern.Pattern)).SetValue(string.Empty);
     }
     else if (element.GetSupportedPatterns().Contains(TextPattern.Pattern))
     {
         TextPatternRange document =
             ((TextPattern)Element.GetCurrentPattern(TextPattern.Pattern)).DocumentRange;
         AutomationElement[] children = document.GetChildren();
         foreach (var child in children)
         {
             EmptyTextFromChild(child);
         }
     }
 }
        /// <summary>
        /// Creates a debug hint
        /// </summary>
        /// <param name="owningWindow">The window that owns the hint</param>
        /// <param name="hintBounds">The hint bounds</param>
        /// <param name="automationElement">The automation element</param>
        /// <returns>A debug hint</returns>
        private DebugHint CreateDebugHint(IntPtr owningWindow, Rect hintBounds, AutomationElement automationElement)
        {
            var supportedPatterns = automationElement.GetSupportedPatterns();
            var programmaticNames = supportedPatterns.Select(x => x.ProgrammaticName);

            if (supportedPatterns.Any())
            {
                return new DebugHint(owningWindow, hintBounds, programmaticNames.ToList());
            }

            return null;
        }
Example #3
0
		//Check the patterns that a control must support according to MSDN.
		public void PatternChcek (Element e, AutomationElement ae, AutomationPattern[] addStates, AutomationPattern[] invalidState)
		{
			procedureLogger.Action (string.Format ("Check {0}'s supported patterns.", e));
			
			//Remove the extra patterns from supported patterns list
			for (int i = 0; i < invalidState.Length; i++)
				if(((System.Collections.IList)e.SupportedPatterns).Contains(invalidState [i]))
					e.SupportedPatterns.Remove(invalidState[i]);
					
			//Add necessary patterns to the supported patterns list		
			for (int j = 0; j < addStates.Length; j++)
				e.SupportedPatterns.Add(addStates [j]);

			//Get list of actual patterns of this control
			AutomationPattern[] actualPatterns = ae.GetSupportedPatterns ();
			procedureLogger.ExpectedResult (string.Format ("supported patterns :"));
			for (int k = 0; k < actualPatterns.Length; k++)
				procedureLogger.ExpectedResult (string.Format ("{0} ", actualPatterns [k]));
			
			//get a list of actual patterns that are missing or extraneous
			List<AutomationPattern> missPattern = new List<AutomationPattern>();
			List<AutomationPattern> extraPattern = new List<AutomationPattern>();
			for (int p = 0; p < e.SupportedPatterns.Count; p++)
				if(!(actualPatterns.Contains (e.SupportedPatterns[p])))
					missPattern.Add(e.SupportedPatterns[p]);

			for (int q = 0; q < actualPatterns.Length; q++)
				if(!(e.SupportedPatterns.Contains (actualPatterns[q])))
					extraPattern.Add(actualPatterns[q]);

			//If missingPatterns and extraPatterns are empty, the test case passes
			//otherwise, throw an exception
			if(0 != missPattern.Count)
					Console.WriteLine("Missing miss actions: ");
					for (int n = 0; n < missPattern.Count; n++)
						Console.WriteLine(" {0}", missPattern[n]);	
			Assert.AreEqual(0, missPattern.Count);
				
			if(0 != actualPatterns.Length)
					Console.WriteLine("Missing actual actions: ");
					for (int m = 0; m < actualPatterns.Length; m++)
						Console.WriteLine(" {0}", actualPatterns[m]);
		}
Example #4
0
 private AutomationElement FindFirstChildWithValuePatternSupported(AutomationElement element)
 {
     if (element.GetSupportedPatterns().Contains(ValuePattern.Pattern))
     {
         return element;
     }
     if (element.GetSupportedPatterns().Contains(TextPattern.Pattern))
     {
         TextPatternRange document =
             ((TextPattern)Element.GetCurrentPattern(TextPattern.Pattern)).DocumentRange;
         AutomationElement[] children = document.GetChildren();
         foreach (var child in children)
         {
             var firstValidChild = FindFirstChildWithValuePatternSupported(child);
             if (firstValidChild != null) { return firstValidChild; }
         }
     }
     return null;
 }
Example #5
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 internal void SetPatterns(AutomationElement element)
 {
     if (element == null)
         return;
     foreach (AutomationPattern ap in element.GetSupportedPatterns())
     {
         Comment("Element supports pattern: " + Automation.PatternName(ap).ToString());
         m_cachedPatternList.Add(element.GetCurrentPattern(ap));
     }
 }
Example #6
0
 public static void AutomationElementGetSupportedPatterns(AutomationElement element)
 {
     Dump("GetSupportedPatterns()", true, element);
     try
     {
         AutomationPattern[] obj = element.GetSupportedPatterns();
     }
     catch (Exception exception)
     {
         VerifyException(element, exception, typeof(ElementNotAvailableException));
     }
 }
Example #7
0
        private void writingAvailablePatterns(AutomationElement element)
        {
            try {
                this.richPatterns.Text = "available patterns";
                this.richPatterns.Text += "\r\n";

                // 20120618 UIACOMWrapper
                AutomationPattern[] supportedPatterns =
                    element.GetSupportedPatterns();
                //UIACOM::System.Windows.Automation.AutomationPattern[] supportedPatterns =
                //    element.GetSupportedPatterns();

                if (supportedPatterns != null &&
                    supportedPatterns.Length > 0) {
                    for (int i = 0; i < supportedPatterns.Length; i++) {
                        if (i > 0) {
                            this.richPatterns.Text += "\r\n";
                        }
                        this.richPatterns.Text +=
                            supportedPatterns[i].ProgrammaticName.Replace("Identifiers.Pattern", "");
                    }
                }
            }
            catch {}
        }
Example #8
0
File: Debug.cs Project: ritro/White
 private static void DisplayPattern(AutomationElement automationElement, StringBuilder stringBuilder, string displayPadding)
 {
     AutomationPattern[] supportedPatterns = automationElement.GetSupportedPatterns();
     foreach (AutomationPattern automationPattern in supportedPatterns)
     {
         var pattern = (BasePattern) automationElement.GetCurrentPattern(automationPattern);
         stringBuilder.Append(displayPadding).AppendLine(pattern.ToString());
     }
     stringBuilder.AppendLine();
 }
Example #9
0
 /// <summary>
 /// Gets the most useful pattern from the element to use in the test path.
 /// </summary>
 /// <param name="rootElement"></param>
 /// <returns></returns>
 private string getBestPattern(AutomationElement rootElement)
 {
     string pathImage = "";
     AutomationPattern[] aps = rootElement.GetSupportedPatterns();
     if (aps.Length == 0) pathImage += "none";
     else if (aps.Length == 1) pathImage += aps[0].ProgrammaticName;
     else
     {
         string best = "";
         int bestWeight = 9999;
         foreach (AutomationPattern ap in aps)
         {
             int ind = ap.Id - 10000;
             int w = bestPattern[ind];
             if (w < bestWeight)
             {
                 bestWeight = w;
                 best = ap.ProgrammaticName;
             }
         }
         pathImage = best;
     }
     return pathImage.Replace("Pattern", null).Replace("Identifiers.", null) + ":";
 }
        private ValuePattern SupportsValuePattern(AutomationElement ae)
        {
            try
            {
                ValuePattern valpat = (ValuePattern)ae.GetCurrentPattern(ValuePattern.Pattern);
                AutomationPattern[] p1 = ae.GetSupportedPatterns();
                logTofile(_eLogPtah, "patterns lenght for ae =" + p1.Length);
                //for (int jj = 0; jj < p1.Length; jj++)
                //{
                // }

                return valpat;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
                //  return null;
            }
        }
Example #11
0
 private string RetrieveTextFrom(AutomationElement element)
 {
     string text = string.Empty;
     if (element.GetSupportedPatterns().Contains(ValuePattern.Pattern))
     {
         text = text + new ValuePatternWrapper(element).Value;
     }
     else if (element.GetSupportedPatterns().Contains(TextPattern.Pattern))
     {
         TextPatternRange document =
             ((TextPattern)Element.GetCurrentPattern(TextPattern.Pattern)).DocumentRange;
         AutomationElement[] children = document.GetChildren();
         foreach (var child in children)
         {
             text = text + RetrieveTextFrom(child);
         }
     }
     return text;
 }
Example #12
0
    private static AutomationPattern GetSpecifiedPattern(AutomationElement element, string patternName)
    {
        AutomationPattern[] supportedPattern = element.GetSupportedPatterns();
        foreach (AutomationPattern pattern in supportedPattern)
        {
            if (pattern.ProgrammaticName == patternName)
                return pattern;
        }

        return null;
    }
Example #13
0
		private void SupportedPropertiesTestInternal (AutomationElement element)
		{
			var supportedProperties = element.GetSupportedProperties ();
			foreach (AutomationPattern pattern in element.GetSupportedPatterns ()) {
				foreach (var prop in GetPatternProperties (pattern)) {
					Assert.IsTrue (supportedProperties.Contains (prop),
						string.Format ("[{0}] {1} shall be supported since {2} pattern is supported",
							element.Current.Name,
							prop.ProgrammaticName,
							At.PatternName (pattern)));
				}
			}
			foreach (var prop in supportedProperties) {
				Assert.AreNotEqual (AutomationElement.NotSupported,
					element.GetCurrentPropertyValue (prop, true),
					string.Format ("[{0}] {1} shall be supported since it's in SupportedProperties",
						element.Current.Name,
						prop.ProgrammaticName));
			}
		}