public void SpyHelper_DeleteSelectedProperties() { //TODO: need to update the unit test UIATestObject testObject = new UIATestObject( ObjectDescriptor.FromJson(@"{ ""identifyProperties"": { ""title"": ""LAP (Running) - Microsoft Visual Studio"", ""helptext"": ""this is help text"", ""url"": ""this is url"", ""type"": ""Window""} }")); Assert.AreEqual(4, testObject.Properties.Count); DataGridView propertyGrid = GetAnEmptyPropertyGrid(); SpyWindowHelper.FillPropertyGrid(propertyGrid, testObject); Assert.AreEqual(5, propertyGrid.Rows.Count, "Should have 5 properties before deletion"); SpyWindowHelper.DeleteSelectedProperties(ControlKeys.Title, testObject); SpyWindowHelper.FillPropertyGrid(propertyGrid, testObject); string data = DumpPropertyGridRows(propertyGrid); Debug.Write(data); Assert.AreEqual(4, propertyGrid.Rows.Count, data); }
public void SpyHelper_AddSelectedProperty() { UIATestObject testObject = new UIATestObject( ObjectDescriptor.FromJson(@"{ ""identifyProperties"": { ""title"": ""LAP (Running) - Microsoft Visual Studio"", ""helptext"": ""this is help text"", ""url"": ""this is url"", ""type"": ""Window""} }")); Assert.AreEqual(4, testObject.Properties.Count); DataGridView propertyGrid = GetAnEmptyPropertyGrid(); SpyWindowHelper.FillPropertyGrid(propertyGrid, testObject); Assert.AreEqual(5, propertyGrid.Rows.Count, "Should have 4 properties before selection"); propertyGrid.Rows[1].Selected = true; propertyGrid.Rows[2].Selected = true; UIATestObject newTestObject = new UIATestObject(); Assert.AreEqual(0, newTestObject.Properties.Count); SpyWindowHelper.AddSelectedProperty(propertyGrid, newTestObject); Assert.AreEqual(2, newTestObject.Properties.Count); }
public void UIAEdit_Text() { ObjectDescriptor descriptor = ObjectDescriptor.FromJson(calcJsonString); ITestObject parentObject = descriptor.GetObject(); UIATestObject button1Object = (UIATestObject)parentObject.FindRecursive(DescriptorKeys.NodeName, "1"); UIATestObject resultObject = (UIATestObject)parentObject.FindRecursive(DescriptorKeys.NodeName, "1"); UIAEdit uiaEdit = new UIAEdit(new UIACondition(resultObject)); }
public void UIAFinder_Identify1() { ObjectDescriptor parentDescriptor = ObjectDescriptor.FromJson(@" {""ntype"": ""uia"", identifyProperties: {name: ""Calculator""}} "); /* * ObjectDescriptor parentDescriptor = ObjectDescriptor.FromJson(@" * { * ""ntype"": ""uia"", * ""nname"": ""LAP (Running) - Microsoft Visual Studio"", * ""description"": null, * ""identifyProperties"": { * ""type"": ""Window"", * ""title"": ""LAP (Running) - Microsoft Visual Studio"" * } * } * "); * * ObjectDescriptor childDescriptor = ObjectDescriptor.FromJson(@" * { * ""ntype"": ""uia"", * ""nname"": ""ToolBarDockTop"", * ""description"": null, * ""identifyProperties"": { * ""type"": ""Pane"", * ""name"": ""ToolBarDockTop"" * } * } * ");*/ ObjectDescriptor childDescriptor = ObjectDescriptor.FromJson(@" {ntype:""uia"",identifyProperties: {name: ""1""}} ", parentDescriptor); parentDescriptor.Children.Add(childDescriptor); UIATestObject parentTestObject = (UIATestObject)parentDescriptor.GetObject(); UIATestObject testObject = (UIATestObject)parentTestObject.Children[0]; List <AutomationElement> elements = UIAFinder.FindAll(parentTestObject); TestUtility.DumpAutomationElements(elements); Assert.AreEqual(1, elements.Count, "only 1 parent element"); elements = UIAFinder.FindAll(testObject); TestUtility.DumpAutomationElements(elements); Assert.AreEqual(1, elements.Count, "only 1 child element"); }
public static AutomationElement GetCalculatorButton1Element() { ObjectDescriptor windowDescriptor = ObjectDescriptor.FromJson(@" {ntype:""uia"",identifyProperties: {name: ""Calculator""}} "); ObjectDescriptor buttonDescriptor = ObjectDescriptor.FromJson(@" {ntype:""uia"",identifyProperties: {name: ""1""}} ", windowDescriptor); ITestObject windowObject = windowDescriptor.GetObject(); UIATestObject uiaObject = (UIATestObject)windowObject.Children[0]; AutomationElement element = uiaObject.AutomationElement; return(element); }
public void ButtonToAutomationElementTest() { ObjectDescriptor descriptor = ObjectDescriptor.FromJson( @" { ntype: ""uia"", nname: ""button1"", ""identifyProperties"": { ""name"": ""1"" } description: ""button"" }" ); UIATestObject testObject = UIATestObject.ToTestObject(descriptor); testObject.TryInvoke(); }
public void VirtualTestObject_CreateTestObject() { ObjectDescriptor descriptor = ObjectDescriptor.FromJson( @" { ""ntype"": ""virtual"", ""nname"": ""commission"", ""identifyProperties"": { ""boundingRectangle"": ""12, 185, 201, 80"" } }"); VirtualTestObject virtualObject = VirtualTestObject.CreateTestObject(descriptor, ModelLoadLevel.Full); Assert.AreEqual("commission", virtualObject.NodeName); Rectangle expectedRect = new Rectangle(12, 185, 201, 80); Assert.AreEqual(expectedRect, virtualObject.BoundingRectangle); }
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); }
public void ObjectDescriptor_GetVirtualTestObject() { //TODO ObjectDescriptor windowDescriptor = ObjectDescriptor.FromJson(@" {""ntype"": ""uia"", identifyProperties: {name: ""Calculator""}} "); ObjectDescriptor virtualDescriptor = ObjectDescriptor.FromJson(@" {""ntype"": ""virtual"", identifyProperties: {""boundingRectangle"": ""12, 185, 201, 80""}} ", windowDescriptor); Assert.AreEqual(1, windowDescriptor.Children.Count, "This top descriptor should contain one child"); ITestObject windowObject = windowDescriptor.GetObject(); Assert.AreEqual(1, windowObject.Children.Count); Assert.AreEqual("Calculator", windowObject.ControlName); ITestObject virtualObject = (ITestObject)windowObject.Children[0]; Assert.IsTrue(virtualObject is VirtualTestObject); }
public void ObjectDescriptor_GetTestObject() { ObjectDescriptor windowDescriptor = ObjectDescriptor.FromJson(@" {ntype:""uia"", identifyProperties: {name: ""Calculator""}} "); ObjectDescriptor buttonDescriptor = ObjectDescriptor.FromJson(@" {ntype:""uia"", identifyProperties: {name: ""1""}} ", windowDescriptor); Assert.AreEqual(1, windowDescriptor.Children.Count, "This top descriptor should contain one child"); ITestObject windowObject = windowDescriptor.GetObject(); Assert.AreEqual(1, windowObject.Children.Count); Assert.AreEqual("Calculator", windowObject.ControlName); UIATestObject uiaObject = (UIATestObject)windowObject.Children[0]; Assert.AreEqual("1", uiaObject.ControlName); }
public void UIACondition_CachedProperties() { ObjectDescriptor descriptor = ObjectDescriptor.FromJson( @" { ntype: ""uia"", nname: ""button1"", identifyProperties:{""name"": ""1""}, cachedProperties:{""className"": ""QWidget""}, description: ""button"" }" ); UIATestObject testObject = UIATestObject.ToTestObject(descriptor); CachedPropertyGroup cachedGroup = testObject.GetContext <CachedPropertyGroup>(); Assert.AreNotEqual(null, cachedGroup); UIACondition condition = new UIACondition(testObject); Assert.AreEqual(1, condition.CachedProperties.Count); }
public void AddObjectsWindow_CaptureTempSnapshot() { ObjectDescriptor descriptor = ObjectDescriptor.FromJson(@" { ""ntype"": ""uia"", ""nname"": ""Window: Calculator"", ""identifyProperties"": { ""type"": ""Window"", ""className"": ""QWidget"", ""title"": ""Calculator"" } }"); UIATestObject testObject = (UIATestObject)descriptor.GetObject(); AutomationElement element = testObject.AutomationElement; string elementInfo = UIAUtility.DumpAutomationElement(element); Debug.WriteLine(elementInfo); AddObjectsWindow window = new AddObjectsWindow(null); string token; SnapshotHelper.CaptureTempSnapshot(element, out token); CacheHandler handler = new CacheHandler(AppEnvironment.CurrentDirectory); string targetPath = Path.Combine(Environment.CurrentDirectory, "calculator.png"); handler.MoveCachedItemToFile(token, targetPath); Assert.IsTrue(File.Exists(targetPath)); Image image = Image.FromFile(targetPath); Assert.AreEqual(302 + 20, image.Size.Width); Assert.AreEqual(317 + 20, image.Size.Height); }