// return the current object condtion array to string;
        public static UIATestObject GetTO(ITestObject parentTestObject, ControlType controlType, params string[] conditionStrings)
        {
            UIATestObject testObject = new UIATestObject();

            testObject.ControlType = controlType;

            foreach (string condition in conditionStrings)
            {
                if (!string.IsNullOrEmpty(condition))
                {
                    string[] values = condition.Split(new string[] { DescriptionString.AssignOperator }, StringSplitOptions.None);
                    if (values.Length == 1)
                    {
                        string name = values[0];
                        if (parentTestObject == null)
                        {
                            return((UIATestObject)AppModel.Current.GetTestObject(name));
                        }
                        else
                        {
                            return((UIATestObject)parentTestObject.FindRecursive(DescriptorKeys.NodeName, name));
                        }
                    }
                    else
                    {
                        testObject.AddProperty(values[0].Trim(), values[1].Trim());
                    }
                }
            }

            return(testObject);
        }
        public void UIATestObject_ControlTypeInit()
        {
            UIATestObject testObject = new UIATestObject();

            testObject.AddProperty(ControlKeys.Type, ControlType.Slider.ControlTypeToString());

            Assert.AreEqual(1, testObject.Properties.Count);
            Assert.AreEqual(ControlType.Slider, testObject.ControlType);
        }
Example #3
0
        public static ITestObject ConvertStringToTestObject(string conditionString)
        {
            string[] propertiesStrings = conditionString.Split(new string[] { DescriptionString.LeftRightPropertySplitString }, StringSplitOptions.RemoveEmptyEntries);

            ITestObject descriptor = new UIATestObject();

            foreach (string propertyString in propertiesStrings)
            {
                string[] temp = propertyString.Split(new string[] { DescriptionString.LeftRightQtpString }, StringSplitOptions.RemoveEmptyEntries);
                if (temp.Length >= 2)
                {
                    descriptor.AddProperty(temp[0], temp[1]);
                }
            }
            return(descriptor);
            //conditionString = conditionString.Replace(DescriptionString.LeftRightQtpString, DescriptionString.AssignOperator);
            //conditionString = conditionString.Replace(DescriptionString.LeftRightPropertySplitString, DescriptionString.PropertySplitString);
        }
Example #4
0
        public void SpyHelper_FillPropertyGrid()
        {
            UIATestObject testObject = new UIATestObject(
                ObjectDescriptor.FromJson(@"{
              ""identifyProperties"": {
                ""title"": ""LAP (Running) - Microsoft Visual Studio"",
                ""type"": ""Window""}
              }"));

            DataGridView propertyGrid = GetAnEmptyPropertyGrid();

            int count = SpyWindowHelper.FillPropertyGrid(propertyGrid, testObject);

            Assert.AreEqual(2, count);

            testObject.AddProperty("property3", "value3");

            count = SpyWindowHelper.FillPropertyGrid(propertyGrid, testObject);

            Assert.AreEqual(3, count);
        }
Example #5
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
        }