/// <summary>
 /// Check whether Pattern is actionable or not based on PatternMethod
 /// </summary>
 /// <param name="ptn"></param>
 /// <returns></returns>
 public static bool IsUIActionablePatternByPatternMethodType(this A11yPattern ptn)
 {
     return((from m in ptn.GetType().GetMethods()
             let a = m.GetCustomAttribute(typeof(PatternMethodAttribute))
                     where a != null && (bool)a.GetType().GetProperty("IsUIAction").GetValue(a) == true
                     select a).Count() != 0);
 }
예제 #2
0
        public void BoundingRectangleContainedInParent_HorizontallyScrollablePass()
        {
            var e      = new MockA11yElement();
            var parent = new MockA11yElement();

            // parent should be smaller Horizontally than child
            e.BoundingRectangle      = new Rectangle(300, 300, 500, 500);
            parent.BoundingRectangle = new Rectangle(300, 300, 200, 500);

            var pattern = new A11yPattern();

            pattern.Id         = PatternIDs.Scroll;
            pattern.Properties = new List <A11yPatternProperty>();
            pattern.Properties.Add(new A11yPatternProperty {
                Name = "HorizontallyScrollable", Value = true
            });
            pattern.Properties.Add(new A11yPatternProperty {
                Name = "HorizontalScrollPercent", Value = 0
            });

            parent.Patterns.Add(pattern);
            e.Parent = parent;

            Assert.AreEqual(Rule.Evaluate(e), EvaluationCode.Pass);
        }
예제 #3
0
        public void BoundingRectangleContainedInParent_VerticallyScrollablePass()
        {
            var e      = new MockA11yElement();
            var parent = new MockA11yElement();

            // parent should be smaller vertically than child
            e.BoundingRectangle      = new Rectangle(300, 300, 500, 500);
            parent.BoundingRectangle = new Rectangle(300, 300, 500, 200);

            var pattern = new A11yPattern();

            pattern.Id         = PatternIDs.Scroll;
            pattern.Properties = new List <A11yPatternProperty>();
            pattern.Properties.Add(new A11yPatternProperty {
                Name = "VerticallyScrollable", Value = true
            });
            pattern.Properties.Add(new A11yPatternProperty {
                Name = "VerticalScrollPercent", Value = 0
            });

            parent.Patterns.Add(pattern);
            e.Parent = parent;

            Assert.IsTrue(Rule.PassesTest(e));
        }
 public void TestScrollPatternNotNullTrue()
 {
     using (var e = new MockA11yElement())
     {
         var scrollPattern = new A11yPattern(e, PatternType.UIA_ScrollPatternId);
         e.Patterns.Add(scrollPattern);
         Assert.IsTrue(ScrollPattern.NotNull.Matches(e));
     } // using
 }
        /// <summary>
        /// Run Action method of a Pattern
        /// </summary>
        /// <param name="ecId">ElementContext Id</param>
        /// <param name="eId">Element Id</param>
        /// <param name="ptId">A11yPattern Id</param>
        /// <param name="mname">method name</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static dynamic RunAction(int eId, int ptId, string mname, object[] parameters)
        {
            var         ecId = SelectAction.GetDefaultInstance().GetSelectedElementContextId();
            A11yPattern ptn  = DataManager.GetDefaultInstance().GetA11yPattern(ecId.Value, eId, ptId);

            MethodInfo mi = ptn.Methods.Where(m => m.Name == mname).First();

            return(mi.Invoke(ptn, parameters));
        }
 public PatternViewModel(A11yElement e, A11yPattern pattern, bool isActionAllowed, bool isExpanded)
 {
     this.IsExpanded       = isExpanded;
     this.Pattern          = pattern ?? throw new ArgumentNullException(nameof(pattern));
     this.Element          = e;
     this.ActionType       = GetActionType();
     this.ActionVisibility = isActionAllowed && this.ActionType != ActionType.NotApplicable ? Visibility.Visible : Visibility.Collapsed;
     this.ActionName       = GetActionButtonText();
     this.Properties       = (from p in this.Pattern.Properties select new PatternPropertyUIWrapper(p)).ToList();
 }
 /// <summary>
 /// add the pattern and its children to the string builder
 /// </summary>
 /// <param name="sb"></param>
 /// <param name="pattern"></param>
 private static void AddPatternToStringBuilder(StringBuilder sb, A11yPattern pattern)
 {
     if (pattern?.Properties != null)
     {
         sb.AppendLine(pattern.Name);
         foreach (var prop in pattern.Properties)
         {
             sb.AppendLine(Invariant($"- {prop.Name}: {prop.Value}"));
         }
     }
 }
예제 #8
0
        /// <summary>
        /// Check whether Pattern is actionable or not based on PatternMethod
        /// </summary>
        /// <param name="ptn"></param>
        /// <returns></returns>
        public static bool IsUIActionablePatternByPatternMethodType(this A11yPattern ptn)
        {
            if (ptn == null)
            {
                throw new ArgumentNullException(nameof(ptn));
            }

            return((from m in ptn.GetType().GetMethods()
                    let a = m.GetCustomAttribute(typeof(PatternMethodAttribute))
                            where a != null && (bool)a.GetType().GetProperty("IsUIAction").GetValue(a) == true
                            select a).Any());
        }
예제 #9
0
 public void TestTextSelectionSupportedFalse()
 {
     using (var e = new MockA11yElement())
     {
         var pattern  = new A11yPattern(e, PatternIDs.Text);
         var property = new A11yPatternProperty {
             Name = "SupportedTextSelection", Value = UIAutomationClient.SupportedTextSelection.SupportedTextSelection_None
         };
         pattern.Properties.Add(property);
         e.Patterns.Add(pattern);
         Assert.IsFalse(Patterns.TextSelectionSupported.Matches(e));
     } // using
 }
 /// <summary>
 /// add the pattern and its children to the string builder
 /// </summary>
 /// <param name="sb"></param>
 /// <param name="pattern"></param>
 private static void AddPatternToStringBuilder(StringBuilder sb, A11yPattern pattern)
 {
     if (pattern?.Properties != null)
     {
         sb.AppendLine(pattern.Name);
         foreach (var prop in pattern.Properties)
         {
             sb.AppendLine(string.Format(CultureInfo.InvariantCulture,
                                         Properties.Resources.PatternInfoControl_PatternPropertyFormat,
                                         prop.Name, prop.Value));
         }
     }
 }
 public void TestScrollPatternNotVerticallyScrollableValueTrue()
 {
     using (var e = new MockA11yElement())
     {
         var scrollPattern = new A11yPattern(e, PatternType.UIA_ScrollPatternId);
         e.Patterns.Add(scrollPattern);
         scrollPattern.Properties.Add(new A11yPatternProperty()
         {
             Name = ScrollPattern.VerticallyScrollableProperty, Value = false
         });
         scrollPattern.Properties.Add(new A11yPatternProperty()
         {
             Name = ScrollPattern.VerticalScrollPercentProperty, Value = 0
         });
         Assert.IsTrue(ScrollPattern.NotVerticallyScrollable.Matches(e));
     } // using
 }
        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="ptn"></param>
        /// <param name="m"></param>
        protected BaseActionViewModel(A11yPattern ptn, MethodInfo m)
        {
            this.pattern    = ptn;
            this.methodinfo = m;

            this.PatternName = ptn.Name;
            this.Name        = m.Name;
            this.ReturnType  = m.ReturnType;

            this.Parameters = (from p in m.GetParameters()
                               select new Parameter()
            {
                ParamType = p.ParameterType,
                Name = string.Format(CultureInfo.InvariantCulture, "{0}({1})", p.Name, p.ParameterType.Name),
                ParamEnums = p.ParameterType.IsEnum ? Enum.GetValues(p.ParameterType) : null
            }).ToList();
        }
 public void TestScrollPatternHorizontallyScrollableInvalidScrollPercentFalse()
 {
     using (var e = new MockA11yElement())
     {
         var scrollPattern = new A11yPattern(e, PatternType.UIA_ScrollPatternId);
         e.Patterns.Add(scrollPattern);
         scrollPattern.Properties.Add(new A11yPatternProperty()
         {
             Name = ScrollPattern.HorizontallyScrollableProperty, Value = true
         });
         scrollPattern.Properties.Add(new A11yPatternProperty()
         {
             Name = ScrollPattern.HorizontalScrollPercentProperty, Value = (double)0 / 0
         });
         Assert.IsFalse(ScrollPattern.HorizontallyScrollable.Matches(e));
     } // using
 }
        /// <summary>
        /// Get appropriate Action View Model
        /// </summary>
        /// <param name="p"></param>
        /// <param name="m"></param>
        /// <returns></returns>
        internal static BaseActionViewModel GetActionViewModel(A11yPattern p, MethodInfo m)
        {
            if (m.ReturnType == typeof(DesktopElement) || m.ReturnType == typeof(List <DesktopElement>))
            {
                return(new ReturnA11yElementsViewModel(p, m));
            }
            else if (m.ReturnType.Name != "IAccessible")
            {
                if (m.ReturnType != typeof(TextRange) && m.ReturnType != typeof(List <TextRange>))
                {
                    return(new GeneralActionViewModel(p, m));
                }
                else if (m.ReturnType == typeof(TextRange))
                {
                    return(new TextRangeActionViewModel(p, m));
                }
            }

            return(new NotSupportedActionViewModel(p, m));
        }
예제 #15
0
        public void ConditionMatch_NonXAMLTextControlWithTextPattern_ReturnTrue()
        {
            var e = new MockA11yElement();
            var p = new A11yPattern(e, PatternType.UIA_TextPatternId);

            e.ControlTypeId     = Axe.Windows.Core.Types.ControlType.UIA_TextControlTypeId;
            e.IsEnabled         = true;
            e.IsOffScreen       = false;
            e.IsContentElement  = true;
            e.BoundingRectangle = new System.Drawing.Rectangle(0, 0, 100, 100);

            p.Properties.Add(new A11yPatternProperty()
            {
                Name = "SupportedTextSelection", Value = UIAutomationClient.SupportedTextSelection.SupportedTextSelection_Single
            });

            e.Patterns.Add(p);

            Assert.IsTrue(Rule.Condition.Matches(e));
        }
예제 #16
0
 public NotSupportedActionViewModel(A11yPattern p, MethodInfo m) : base(p, m)
 {
 }
예제 #17
0
 public ReturnA11yElementsViewModel(A11yPattern pattern, MethodInfo m) : base(pattern, m)
 {
 }
 public TextRangeActionViewModel(A11yPattern pattern, MethodInfo m) : base(pattern, m)
 {
 }
예제 #19
0
 /// <summary>
 /// GeneralActionViewModel constructor
 /// </summary>
 /// <param name="pattern"></param>
 /// <param name="m"></param>
 public GeneralActionViewModel(A11yPattern pattern, MethodInfo m) : base(pattern, m)
 {
 }