Exemple #1
0
        /// <summary>
        /// Compares the help text.
        /// </summary>
        /// <param name="currentControl">The current control.</param>
        /// <param name="loadedMap">The loaded map.</param>
        private static void CompareHelpText(MappedControl currentControl, MappedControl loadedMap)
        {
            /* If this is empty, its serialized as a null */
            if (loadedMap.HelpText == null)
            {
                loadedMap.HelpText = string.Empty;
            }

            CompareResult cr = new CompareResult
            {
                Category    = "HelpText",
                LiveValue   = currentControl.HelpText,
                LoadedValue = loadedMap.HelpText
            };

            if (string.Compare(currentControl.HelpText, loadedMap.HelpText, true, CultureInfo.CurrentCulture) != 0)
            {
                cr.Score  = -4;
                cr.Passed = false;
            }
            else
            {
                cr.Passed = true;
            }
            _results.Add(cr);
        }
        /// <summary>
        /// Enumerates the control elements.
        /// </summary>
        /// <param name="aeRoot">The root AutomationElement.</param>
        private void EnumControlElements(AutomationElement aeRoot)
        {
            AutomationElement aeNode = TreeWalker.ControlViewWalker.GetFirstChild(aeRoot);

            while (aeNode != null)
            {
                _controlCounter++;
                MappedControl ctrl = new MappedControl();
                ctrl.LoadControl(aeNode, ProdUiTypes);
                ctrl.ControlTreePosition = _controlCounter;
                AllFormsControls.Add(ctrl);
                EnumControlElements(aeNode);
                aeNode = TreeWalker.ControlViewWalker.GetNextSibling(aeNode);
            }
        }
Exemple #3
0
        /// <summary>
        /// Compares a loaded map to the supplied map file
        /// </summary>
        /// <param name="currentControl">The current control.</param>
        /// <param name="loadedMapControl">The loaded map.</param>
        /// <returns>
        /// The list of compare results for each comparison
        /// </returns>
        internal static List <CompareResult> Compare(MappedControl currentControl, MappedControl loadedMapControl)
        {
            _results = new List <CompareResult>();
            if (!CompareClasses(currentControl, loadedMapControl))
            {
                return(_results);
            }

            /* functions to handle comparing the individual criteria */
            CompareHelpText(currentControl, loadedMapControl);
            CompareAcceleratorKey(currentControl, loadedMapControl);
            CompareAccessKey(currentControl, loadedMapControl);
            CompareLabeledBy(currentControl, loadedMapControl);
            CompareTreePosition(currentControl, loadedMapControl);
            CompareAutomationId(currentControl, loadedMapControl);
            CompareName(currentControl, loadedMapControl);
            CompareItemType(currentControl, loadedMapControl);

            return(_results);
        }
Exemple #4
0
        /// <summary>
        /// Compares the ItemType values.
        /// </summary>
        /// <param name="currentControl">The current control.</param>
        /// <param name="loadedMap">The loaded map.</param>
        private static void CompareItemType(MappedControl currentControl, MappedControl loadedMap)
        {
            CompareResult cr = new CompareResult
            {
                Category    = "ItemType",
                LiveValue   = currentControl.ItemType,
                LoadedValue = loadedMap.ItemType
            };

            if (string.Compare(currentControl.ItemType, loadedMap.ItemType, true, CultureInfo.CurrentCulture) != 0)
            {
                cr.Score  = -2;
                cr.Passed = false;
            }
            else
            {
                cr.Passed = true;
            }
            _results.Add(cr);
        }
Exemple #5
0
        /// <summary>
        /// Compares the control tree positions.
        /// </summary>
        /// <param name="currentControl">The current control.</param>
        /// <param name="loadedMap">The loaded map.</param>
        private static void CompareTreePosition(MappedControl currentControl, MappedControl loadedMap)
        {
            CompareResult cr = new CompareResult
            {
                Category    = "ControlTreePosition",
                LiveValue   = currentControl.ControlTreePosition.ToString(CultureInfo.CurrentCulture),
                LoadedValue = loadedMap.ControlTreePosition.ToString(CultureInfo.CurrentCulture)
            };

            if (currentControl.ControlTreePosition != loadedMap.ControlTreePosition)
            {
                cr.Score  = -3;
                cr.Passed = false;
            }
            else
            {
                cr.Passed = true;
            }
            _results.Add(cr);
        }
Exemple #6
0
        /// <summary>
        /// Compares the labeledBy value.
        /// </summary>
        /// <param name="currentControl">The current control.</param>
        /// <param name="loadedMap">The loaded map.</param>
        private static void CompareLabeledBy(MappedControl currentControl, MappedControl loadedMap)
        {
            CompareResult cr = new CompareResult
            {
                Category    = "LabeledBy",
                LiveValue   = currentControl.LabeledBy,
                LoadedValue = loadedMap.LabeledBy
            };

            if (string.Compare(currentControl.LabeledBy, loadedMap.LabeledBy, true, CultureInfo.CurrentCulture) != 0)
            {
                cr.Score  = -3;
                cr.Passed = false;
            }
            else
            {
                cr.Passed = true;
            }
            _results.Add(cr);
        }
Exemple #7
0
        /// <summary>
        /// Compares the class and Automation.ControlType values.
        /// </summary>
        /// <param name="currentControl">The current control.</param>
        /// <param name="loadedMap">The loaded map.</param>
        /// <returns>
        ///   <c>true</c> if passed <c>false</c> otherwise
        /// </returns>
        /// <remarks>
        /// If this fails, the whole control fails
        /// </remarks>
        private static bool CompareClasses(MappedControl currentControl, MappedControl loadedMap)
        {
            /* 5's */

            /* Do the windows Class comparison */
            CompareResult cr = new CompareResult
            {
                Category    = "ClassName",
                LiveValue   = currentControl.ClassName,
                LoadedValue = loadedMap.ClassName
            };

            if (string.Compare(currentControl.ClassName, loadedMap.ClassName, true, CultureInfo.CurrentCulture) != 0)
            {
                cr.Score  = 0;
                cr.Passed = false;
                _results.Add(cr);
                return(false);
            }
            cr.Passed = true;
            _results.Add(cr);

            /* and now the Automation ControlType compare */
            cr = new CompareResult
            {
                Category    = "ControlType",
                LiveValue   = currentControl.ControlType,
                LoadedValue = loadedMap.ControlType
            };
            if (string.Compare(currentControl.ControlType, loadedMap.ControlType, true, CultureInfo.CurrentCulture) != 0)
            {
                cr.Score  = 0;
                cr.Passed = false;
                _results.Add(cr);
                return(false);
            }
            cr.Passed = true;
            _results.Add(cr);

            return(true);
        }
 /// <summary>
 /// Compares a loaded map to the supplied map file
 /// </summary>
 /// <param name="loadedMap">The loaded map.</param>
 /// <returns>
 /// The list of compare results for each comparison
 /// </returns>
 public List <CompareResult> CompareTo(MappedControl loadedMap)
 {
     return(MappedControlComparer.Compare(this, loadedMap));
 }