Exemplo n.º 1
0
        private static string CreateSearchContext(A11yElement e)
        {
            if (e == null)
            {
                return(null);
            }

            var properties      = CreateSearchPropertiesString(e);
            var patterns        = CreateSearchPatternsString(e);
            var controlTypeName = ControlType.GetInstance().GetNameById(e.ControlTypeId);

            return(string.Join(" ", properties, patterns, controlTypeName));
        }
Exemplo n.º 2
0
        public void CheckHasExpectedValues()
        {
            var values   = ControlType.GetInstance().Values;
            var minValue = ControlType.UIA_ButtonControlTypeId;
            var maxValue = ControlType.UIA_AppBarControlTypeId;

            // Adding 1 because the true count of objects is max + 1 - min.
            Assert.AreEqual(values.Count(), maxValue + 1 - minValue);

            for (int i = minValue; i <= maxValue; ++i)
            {
                Assert.IsTrue(values.Contains(i), $"{nameof(ControlType)} does not contain the expected value {i}");
            }
        }
        /// <summary>
        /// Add the rule-agnostic fingerprint contributions for this element
        /// </summary>
        /// <param name="contributions">The set of contributions to update</param>
        /// <param name="element">Element under consideration</param>
        /// <param name="levelBaseName">The "base" to use when specifying contribution keys</param>
        /// <param name="ignoreNameProperty">If true, exclude the "Name" property from contributions</param>
        private static void AddRuleAgnosticContributions(IList <FingerprintContribution> contributions, A11yElement element, int level,
                                                         bool ignoreNameProperty)
        {
            string levelBaseName = (level > 0) ?
                                   Invariant($"Ancestor{level}.") :
                                   string.Empty;

            AddValidContribution(contributions, levelBaseName, "AcceleratorKey", element.AcceleratorKey);
            AddValidContribution(contributions, levelBaseName, "AccessKey", element.AccessKey);
            AddValidContribution(contributions, levelBaseName, "AutomationId", element.AutomationId);
            AddValidContribution(contributions, levelBaseName, "ClassName", element.GetClassName());
            AddValidContribution(contributions, levelBaseName, "ControlType", ControlType.GetInstance().GetNameById(element.ControlTypeId));
            AddValidContribution(contributions, levelBaseName, "FrameworkId", element.GetUIFramework());
            AddValidContribution(contributions, levelBaseName, "LocalizedControlType", element.LocalizedControlType);
            AddValidContribution(contributions, levelBaseName, "Name", ignoreNameProperty ? null : element.Name);
        }
Exemplo n.º 4
0
        public override string ToString()
        {
            string txt = null;

            if (this.Value != null)
            {
                switch (this.Id)
                {
                case PropertyType.UIA_RuntimeIdPropertyId:
                    txt = this.ConvertIntArrayToString();
                    break;

                case PropertyType.UIA_ControlTypePropertyId:
                    txt = this.Value != null?ControlType.GetInstance().GetNameById(this.Value) : "";

                    break;

                case PropertyType.UIA_BoundingRectanglePropertyId:
                    // if bounding rectangle is [0,0,0,0], treat it as non-exist. same behavior as Inspect
                    txt = GetBoundingRectangleText();
                    break;

                case PropertyType.UIA_OrientationPropertyId:
                    switch ((int)this.Value)
                    {
                    case 0:         //OrientationType_None
                        txt = "None(0)";
                        break;

                    case 1:         //OrientationType_Horizontal
                        txt = "Horizontal(1)";
                        break;

                    case 2:         // OrientationType_Vertical
                        txt = "Vertical(2)";
                        break;
                    }
                    break;

                case PropertyType.UIA_PositionInSetPropertyId:
                case PropertyType.UIA_LevelPropertyId:
                case PropertyType.UIA_SizeOfSetPropertyId:
                    /// these properties are 1 based.
                    /// if value is smaller than 1, it should be ignored.
                    if (this.Value != null && this.Value > 0)
                    {
                        txt = this.Value?.ToString();
                    }
                    break;

                case PropertyType.UIA_HeadingLevelPropertyId:
                    txt = HeadingLevelType.GetInstance().GetNameById(this.Value);
                    break;

                case PropertyType.UIA_LandmarkTypePropertyId:
                    txt = this.Value != 0 ? LandmarkType.GetInstance().GetNameById(this.Value) : null;     // 0 is default value.
                    break;

                default:
                    if (this.Value is Int32[])
                    {
                        txt = ((Int32[])this.Value).ConvertInt32ArrayToString();
                    }
                    else if (this.Value is Double[])
                    {
                        txt = ((Double[])this.Value).ConvertDoubleArrayToString();
                    }
                    else
                    {
                        txt = this.Value?.ToString();
                    }
                    break;
                }
            }
            return(txt);
        }
Exemplo n.º 5
0
 public void CheckGetNameById()
 {
     Assert.AreEqual("AppBar(50040)", ControlType.GetInstance().GetNameById(ControlType.UIA_AppBarControlTypeId));
 }
Exemplo n.º 6
0
 public void CheckExists()
 {
     Assert.AreEqual(true, ControlType.GetInstance().Exists(ControlType.UIA_AppBarControlTypeId));
     Assert.AreEqual(false, ControlType.GetInstance().Exists(0));
 }