public void TreeNodeHelper_MergeVirtualControlsToTree_TheSame() { TreeView treeView = new TreeView(); UIATestObject parentTestObject = new UIATestObject(); TestObjectNurse parentNurse = new TestObjectNurse(parentTestObject); parentNurse.AddChild(new VirtualTestObject("all", new Rectangle(11, 16, 200, 84))); parentNurse.AddChild(new VirtualTestObject("salary", new Rectangle(11, 102, 199, 74))); Assert.AreEqual(2, parentNurse.Children.Count); VirtualTestObject[] controls = new VirtualTestObject[] { new VirtualTestObject("all", new Rectangle(11, 16, 200, 84)), new VirtualTestObject("salary", new Rectangle(11, 102, 199, 74)) }; // in total 6 controls. bool ret = TreeNodeHelper.MergeVirtualControlsToTree(controls, parentNurse.TreeNode); Assert.IsFalse(ret); }
internal void EditVirtualControl(TestObjectNurse nurseObject) { if (nurseObject.ControlTypeString == NodeType.VirtualControl) { nurseObject = nurseObject.ParentNurse; Debug.Assert(nurseObject.TestObject is UIATestObject); } if (nurseObject.ImageFile == null) { //"Please capture the screen shot of the control before editing virtual controls" MessageBox.Show(StringResources.LPSpy_SpyMainWindow_CaptureSnapshotFirst); return; } string imagePath = AppEnvironment.GetModelResourceFilePath(nurseObject.ImageFile); VirtualTestObject[] virtualControls = VirtualControlHelper.GetVirtualControls(nurseObject.TestObject); System.Drawing.Image controlImage = System.Drawing.Image.FromFile(imagePath); UIATestObject testObject = (UIATestObject)nurseObject.TestObject; bool changed = VirtualControlHelper.EditVirtualControls(testObject, controlImage, ref virtualControls); if (changed) { VirtualTestObject[] updatedControls = virtualControls; bool different = TreeNodeHelper.MergeVirtualControlsToTree(updatedControls, nurseObject.TreeNode); nurseObject.TreeNode.Expand(); if (different) { AppEnvironment.SetModelChanged(true); } } }