Exemplo n.º 1
0
        private List <AutomationElement> GetRowElements()
        {
            List <AutomationElement> descendants = automationElementFinder.Descendants(AutomationSearchCondition.ByControlType(ControlType.Custom));
            var automationElements = new BricksCollection <AutomationElement>(descendants);

            return(automationElements.FindAll(rowPredicate));
        }
        private void CreateConfiguration(Dictionary<string, object> defaultValues, NameValueCollection nameValues)
        {
            foreach (KeyValuePair<string, object> pair in defaultValues)
                usedValues.Add(pair.Key, pair.Value.ToString());
            foreach (string key in nameValues.AllKeys)
            {
                string value = nameValues.Get(key);
                if (value != null)
                {
                    usedValues.Remove(key);
                    usedValues[key] = value;
                }
            }

            var allKeys = new BricksCollection<string>(nameValues.AllKeys);
            allKeys.AddRange(defaultValues.Keys);

            foreach (string key in allKeys)
            {
                string value = ConfigurationManager.AppSettings[key];
                if (value != null)
                {
                    usedValues.Remove(key);
                    usedValues[key] = value;
                }
            }
        }
Exemplo n.º 3
0
 public void AllUIItemsHaveDefaultConstructor()
 {
     var collection = new BricksCollection<Class>();
     AllSubsclassesHaveEmptyConstructor(collection, typeof (UIItem));
     AllSubsclassesHaveEmptyConstructor(collection, typeof (SearchCondition));
     AllSubsclassesHaveEmptyConstructor(collection, typeof (SearchCriteria));
     AllSubsclassesHaveEmptyConstructor(collection, typeof (AutomationElementProperty));
 }
Exemplo n.º 4
0
        public void AllUIItemsHaveDefaultConstructor()
        {
            var collection = new BricksCollection <Class>();

            AllSubsclassesHaveEmptyConstructor(collection, typeof(UIItem));
            AllSubsclassesHaveEmptyConstructor(collection, typeof(SearchCondition));
            AllSubsclassesHaveEmptyConstructor(collection, typeof(SearchCriteria));
            AllSubsclassesHaveEmptyConstructor(collection, typeof(AutomationElementProperty));
        }
Exemplo n.º 5
0
        public virtual List <Window> DesktopWindows(Process process, ApplicationSession applicationSession)
        {
            BricksCollection <AutomationElement> collection = FindAllWindowElements(process);
            var list = new List <Window>();

            foreach (AutomationElement automationElement in collection)
            {
                InitializeOption initializeOption = InitializeOption.NoCache;
                list.Add(Create(automationElement, initializeOption, applicationSession.WindowSession(initializeOption)));
            }
            return(list);
        }
Exemplo n.º 6
0
        private void AllSubsclassesHaveEmptyConstructor(BricksCollection<Class> collection, Type type)
        {
            var @class = new Class(type);
            Classes classes = @class.SubClassesInAssembly();
            foreach (Class subClass in classes)
            {
                bool hasDefaultConstructor = false;
                subClass.EachConstructor(delegate(ConstructorInfo constructorInfo)
                                             {
                                                 if (constructorInfo.GetParameters().Length == 0 || subClass.Name.Equals(typeof(ToggleableItem).Name))
                                                     hasDefaultConstructor = true;
                                             });
                if (!hasDefaultConstructor &&  subClass.ClassType.IsVisible && !subClass.Name.Equals("Desktop")) collection.Add(subClass);
            }

            Assert.AreEqual(0, collection.Count, collection.ToString());
        }
Exemplo n.º 7
0
        private BricksCollection <AutomationElement> FindAllWindowElements(Process process)
        {
            var clock = new Clock(CoreAppXmlConfiguration.Instance.UIAutomationZeroWindowBugTimeout, 200);

            Clock.Do @do = delegate
            {
                var windowElements = new BricksCollection <AutomationElement>();
                FindDescendantWindowElements(finder, process, windowElements);
                if (windowElements.Count == 0)
                {
                    WhiteLogger.Instance.Warn("Could not find any windows for this application.");
                }
                return(windowElements);
            };
            Clock.Matched matched = obj => ((BricksCollection <AutomationElement>)obj).Count > 0;
            Clock.Expired expired = () => new BricksCollection <AutomationElement>();

            return((BricksCollection <AutomationElement>)clock.Perform(@do, matched, expired));
        }
Exemplo n.º 8
0
        private AutomationElement FindWindowElement(Process process, Predicate <string> match)
        {
            BricksCollection <AutomationElement> elements = FindAllWindowElements(process);

            return(elements.Find(delegate(AutomationElement obj)
            {
                if (match.Invoke(obj.Current.Name))
                {
                    return true;
                }

                AutomationElement titleBarElement =
                    new AutomationElementFinder(obj).Child(AutomationSearchCondition.ByControlType(ControlType.TitleBar));
                if (titleBarElement == null)
                {
                    return false;
                }
                return match.Invoke(titleBarElement.Current.Name);
            }));
        }
Exemplo n.º 9
0
        private void AllSubsclassesHaveEmptyConstructor(BricksCollection <Class> collection, Type type)
        {
            var     @class  = new Class(type);
            Classes classes = @class.SubClassesInAssembly();

            foreach (Class subClass in classes)
            {
                bool hasDefaultConstructor = false;
                subClass.EachConstructor(delegate(ConstructorInfo constructorInfo)
                {
                    if (constructorInfo.GetParameters().Length == 0 || subClass.Name.Equals(typeof(ToggleableItem).Name))
                    {
                        hasDefaultConstructor = true;
                    }
                });
                if (!hasDefaultConstructor && subClass.ClassType.IsVisible && !subClass.Name.Equals("Desktop"))
                {
                    collection.Add(subClass);
                }
            }

            Assert.AreEqual(0, collection.Count, collection.ToString());
        }
Exemplo n.º 10
0
 private void FindDescendantWindowElements(AutomationElementFinder windowFinder, Process process, BricksCollection<AutomationElement> windowElements)
 {
     List<AutomationElement> children =
         windowFinder.Children(AutomationSearchCondition.ByControlType(ControlType.Window).WithProcessId(process.Id));
     windowElements.AddRange(children);
     foreach (AutomationElement automationElement in children)
         FindDescendantWindowElements(new AutomationElementFinder(automationElement), process, windowElements);
 }
Exemplo n.º 11
0
        private BricksCollection<AutomationElement> FindAllWindowElements(Process process)
        {
            var clock = new Clock(CoreAppXmlConfiguration.Instance.UIAutomationZeroWindowBugTimeout, 200);
            Clock.Do @do = delegate
                               {
                                   var windowElements = new BricksCollection<AutomationElement>();
                                   FindDescendantWindowElements(finder, process, windowElements);
                                   if (windowElements.Count == 0) WhiteLogger.Instance.Warn("Could not find any windows for this application.");
                                   return windowElements;
                               };
            Clock.Matched matched = obj => ((BricksCollection<AutomationElement>) obj).Count > 0;
            Clock.Expired expired = () => new BricksCollection<AutomationElement>();

            return (BricksCollection<AutomationElement>) clock.Perform(@do, matched, expired);
        }
Exemplo n.º 12
0
 public virtual void SetTestLessProjectReferences(BricksCollection<VisualStudioProject> projects)
 {
     List<XmlNode> itemGroups = XML.MatchingNodes(xmlDocument, "ItemGroup",
                                                  obj => obj.ChildNodes.Count != 0 && obj.ChildNodes[0].Name.Equals("ProjectReference"));
     if (itemGroups.Count == 0) return;
     foreach (XmlNode node in itemGroups[0].ChildNodes)
     {
         foreach (VisualStudioProject project in projects)
         {
             XmlAttribute includeAttribute = node.Attributes["Include"];
             if (includeAttribute.Value.Contains(project.ProjectName.Name))
             {
                 includeAttribute.Value = includeAttribute.Value.Replace(project.ProjectName.WithExtension, project.ProjectName.TestLessName.WithExtension);
             }
         }
     }
     Save();
 }
Exemplo n.º 13
0
 public virtual void SetTestLessProjectReferences(BricksCollection<VisualStudioProject> projects)
 {
 }
Exemplo n.º 14
0
        private void FindDescendantWindowElements(AutomationElementFinder windowFinder, Process process, BricksCollection <AutomationElement> windowElements)
        {
            List <AutomationElement> children =
                windowFinder.Children(AutomationSearchCondition.ByControlType(ControlType.Window).WithProcessId(process.Id));

            windowElements.AddRange(children);
            foreach (AutomationElement automationElement in children)
            {
                FindDescendantWindowElements(new AutomationElementFinder(automationElement), process, windowElements);
            }
        }
Exemplo n.º 15
0
 private List<AutomationElement> GetRowElements()
 {
     List<AutomationElement> descendants = automationElementFinder.Descendants(AutomationSearchCondition.ByControlType(ControlType.Custom));
     var automationElements = new BricksCollection<AutomationElement>(descendants);
     return automationElements.FindAll(RowPredicate);
 }