public void VirtualControlHelper_MergeVirtualControls()
        {
            UIATestObject testObject = new UIATestObject();

            testObject.AddChild(new VirtualTestObject());
            testObject.AddChild(new VirtualTestObject());
            testObject.AddChild(new VirtualTestObject());
            testObject.AddChild(new VirtualTestObject());
            testObject.AddChild(new UIATestObject());
        }
Example #2
0
        public void UIAConditionMatcher_Match_Positive()
        {
            UIATestObject to = new UIATestObject();

            to.ControlName = "Clear";

            UIATestObject rootWindow = new UIATestObject();

            rootWindow.ControlName = "Calculator";

            UIATestObject targetTestObject = new UIATestObject();

            targetTestObject.ControlName = "Clear";

            rootWindow.AddChild(targetTestObject);

            AutomationElement element = targetTestObject.AutomationElement;

            Assert.IsNotNull(element, "Target element is not found, has Calculator.exe process launched?");

            UIAConditionMatcher matcher = new UIAConditionMatcher();

            //positive match
            bool matched = matcher.Match(to, element);

            Assert.AreEqual(true, matched);

            to.ControlName = "something else";

            matched = matcher.Match(to, element);

            Assert.AreEqual(false, matched);
        }
        public void VirtualControlHelper_GetVirtualControls()
        {
            UIATestObject testObject = new UIATestObject();

            testObject.AddChild(new VirtualTestObject());
            testObject.AddChild(new VirtualTestObject());
            testObject.AddChild(new VirtualTestObject());
            testObject.AddChild(new VirtualTestObject());
            testObject.AddChild(new UIATestObject());

            Assert.AreEqual(5, testObject.Children.Count);


            VirtualTestObject[] virtualObjects = VirtualControlHelper.GetVirtualControls(testObject);

            Assert.AreEqual(4, virtualObjects.Length, "Should only return the direct virtual test objects");
        }
        public void UIAHighlight_SearchandHighlight_Virtual()
        {
            UIATestObject testObject = descriptor.GetObject() as UIATestObject;

            VirtualTestObject virtualButton7 = new VirtualTestObject("button7", new Rect(76, 139, 34, 34));
            VirtualTestObject virtualButton4 = new VirtualTestObject("button4", new Rect(74, 177, 36, 40));

            testObject.AddChild(virtualButton7);
            testObject.AddChild(virtualButton4);


            //this should also succeed
            bool result = UIAHighlight.SearchAndHighlight(virtualButton7);

            Assert.IsTrue(result);
            result = UIAHighlight.SearchAndHighlight(virtualButton4);
            Assert.IsTrue(result);
        }
Example #5
0
        public void TestObjectNurse_Clear()
        {
            _childTestObject.AddChild(_grandChildTestObject);
            _parentTestObject.AddChild(_childTestObject);

            //root Nurse doesn't contain valid testObject, valid test objects start from its children
            TestObjectNurse rootNurse = TestObjectNurse.AddTree(_treeView, _parentTestObject);

            rootNurse.Clear();

            Assert.AreEqual(0, rootNurse.Children.Count);
            Assert.AreEqual(0, rootNurse.Nodes.Count);
        }
Example #6
0
        public void AppModelManager_HierarchySave()
        {
            UIATestObject d1 = new UIATestObject()
            {
                NodeName    = "rootWindow1",
                ControlName = "rootWindow1_controlName",
                ControlType = ControlType.Window,
                Description = "this is root window"
            };
            UIATestObject d2 = new UIATestObject()
            {
                ControlName = "Panel1",
                ControlType = ControlType.TitleBar
            };
            UIATestObject d3 = new UIATestObject()
            {
                ControlName = "Button",
                ControlType = ControlType.Tree
            };

            /*                    {
             *          {"name", "Button1"},
             *          {"index", "0"},
             *          {"helpText", "Some help Text"}
             *      };
             *
             * d3.AddProperty("name", "Button1");
             * d3.AddProperty("index", "0");
             * d3.AddProperty("helpText", "Some help Text");
             */
            UIATestObject d4 = new UIATestObject()
            {
                ControlType = ControlType.Text
            };

            d4.AddProperty("id", "Text1");

            /*
             * d4.SetItem<UIAPropertyItem>(new UIAPropertyItem()
             * {
             *  Properties = new PropertyEntry()
             *      {
             *          {"id", "Text1"}
             *      }
             * });*/

            d1.AddChild(d2);
            d2.AddChild(d4);

            d2.AddChild(d3);
            AppModel model = new AppModel()
            {
                ProcessName = "calc.exe"
            };

            model.Add(d1);

            AppModelManager.Save(model, "CalcAppModel3.json");

            TestUtility.LaunchNotepad(Path.Combine(System.Environment.CurrentDirectory, "CalcAppModel3.json"));
            //TODO validate the content
        }