Пример #1
0
        private static TestObjectNurse BuildTestObjectsHierarchy(List <AutomationElement> ancestorElements,
                                                                 BreadcrumbControl breadcrumbControl,
                                                                 LAPListViewControl listView,
                                                                 Bitmap bmpDeskTop
                                                                 )
        {
            int ancestorCount            = ancestorElements.Count;
            int breadcrumbCount          = breadcrumbControl.Count;
            int indexOfAutomationElement = 0;

            UIATestObject   topTestObject      = UIAUtility.CreateTestObject(ancestorElements[0]);
            TestObjectNurse topNurseObject     = new TestObjectNurse(topTestObject);
            TestObjectNurse currentNurseObject = topNurseObject;

            if (ancestorCount > breadcrumbCount)
            {
                for (indexOfAutomationElement = 1; indexOfAutomationElement < ancestorCount && breadcrumbCount < ancestorCount - indexOfAutomationElement; ++indexOfAutomationElement)
                {
                    AutomationElement element = ancestorElements[indexOfAutomationElement];
                    if (!string.IsNullOrEmpty(element.Current.Name))
                    {
                        UIATestObject childTestObject = UIAUtility.CreateTestObject(element);
                        currentNurseObject = (TestObjectNurse)currentNurseObject.AddChild(childTestObject);
                    }
                }
            }

            Breadcrumb[] breadcrumbs = breadcrumbControl.GetItems();
            foreach (Breadcrumb breadcrumb in breadcrumbs)
            {
                if (breadcrumb.Checked)
                {
                    UIATestObject childTestObject = UIAUtility.CreateTestObject((breadcrumb.Tag as ElementProperties).AutomationElement);
                    currentNurseObject = (TestObjectNurse)currentNurseObject.AddChild(childTestObject);
                }
            }

            ListView.CheckedListViewItemCollection selectedItems = listView.CheckedItems;

            foreach (ListViewItem item in selectedItems)
            {
                if (null == item.Tag)
                {
                    continue;
                }
                ElementProperties ep       = item.Tag as ElementProperties;
                TestObjectNurse   subNurse = ep.ToNurseObject();

                subNurse.ImageFile = SnapshotHelper.SnapshotFileFromBitmap(subNurse.TestObject, bmpDeskTop);
                currentNurseObject.AddChild(subNurse);
            }
            return(topNurseObject);
        }
Пример #2
0
        internal static void BuildBreadcrumbControl(List <AutomationElement> ancestorElements, BreadcrumbControl breadcrumbControl)
        {
            int elementsCount = ancestorElements.Count;
            List <ElementProperties> properties = new List <ElementProperties>();

            Utility.AsyncCall(() =>
            {
                foreach (AutomationElement element in ancestorElements)
                {
                    string name = element.Current.Name;
                    properties.Add(new ElementProperties(element));
                }
            });

            breadcrumbControl.Clear();

            foreach (ElementProperties element in properties)
            {
                bool   isNotEmpty  = !string.IsNullOrEmpty(element.Name);
                string displayName = (isNotEmpty) ? element.ControlType.ControlTypeToString() + ": " + element.Name : element.ControlType.ControlTypeToString();

                breadcrumbControl.AddItem(displayName, isNotEmpty, element);
            }
        }