public void StartToUpdate(ITestObject topNurse, ITestObject selfNurse, ITestObject leftNurse, ITestObject rightNurse) { LeftCondition = (TestObjectNurse)leftNurse; RightCondition = (TestObjectNurse)rightNurse; SelfCondition = (TestObjectNurse)selfNurse; TestObjectNurse rootNurse = TestObjectNurse.FromTree(_treeObjects); bool changed = MergeObjectsToMainTree(rootNurse, (new List <TestObjectNurse>() { (TestObjectNurse)topNurse }).AsReadOnly()); if (changed) { RaiseMergeCompleteEvent(true); } /* * if (_selfCondition != null) * { * if (_leftCondition != null) * { * _selfCondition.UpdateCondition(UIAPropertyKey.LeftCondition, _leftCondition); * _selfCondition.UpdateCondition(UIAPropertyKey.Left, _leftCondition.NodeName); * } * if (_rightCondition != null) * { * _selfCondition.UpdateCondition(UIAPropertyKey.RightCondition, _rightCondition); * _selfCondition.UpdateCondition(UIAPropertyKey.Right, _rightCondition.NodeName); * } * }*/ }
public void ModelFileHandler_SaveToModelFile() { TreeView treeView = new TreeView(); TestObjectNurse rootNurse = TestObjectNurse.FromTree(treeView); AppModel model = ModelFileHandler.LoadModelFile("UnitTestObjectModel1.json", rootNurse); TestObjectNurse nurseNode = (TestObjectNurse)rootNurse.FindRecursive(DescriptorKeys.NodeName, "Test Explorer"); string imageFilePath = AppEnvironment.GetModelResourceFilePath("TestObjectNurseTest.png"); CacheHandler.EnsureFileDirectoryExists(imageFilePath); Snapshot.CaptureImageToFile(new Rectangle(0, 0, 100, 200), imageFilePath); Assert.IsTrue(File.Exists(imageFilePath)); nurseNode.ImageFile = "TestObjectNurseTest.png"; //remove from root nurseNode.Remove(); AppEnvironment.DumpRecyclingBin(rootNurse); }
public void ModelFileHandler_LoadJsonData() { TreeView treeView = new TreeView(); TestObjectNurse rootNurse = TestObjectNurse.FromTree(treeView); ModelFileHandler.LoadModelFile("ObjectModel2.json", rootNurse); Assert.AreEqual(1, rootNurse.Children.Count, "only one root node"); Assert.AreEqual(1, rootNurse.Children.Count); TestObjectNurse parentNurse = rootNurse[0]; ITestObject testObject = parentNurse.TestObject; Assert.AreEqual(1, parentNurse.Children.Count); Assert.AreEqual("Window", testObject.ControlTypeString); TestObjectNurse childNurse = parentNurse[0]; ITestObject testObject2 = childNurse.TestObject; Assert.AreEqual("Document", testObject2.ControlTypeString, "only one child node"); }
public void ModelFileHandler_SaveJson() { TreeView treeView = new TreeView(); TestObjectNurse rootNurse = TestObjectNurse.FromTree(treeView); AppModel model = ModelFileHandler.LoadModelFile("UnitTestObjectModel1.json", rootNurse); ModelFileHandler.SaveToModelFile(rootNurse, "ObjectModel2.json"); }
private void LoadFile() { string tempFilePath = AppEnvironment.CurrentModelPath; if (File.Exists(tempFilePath)) { TestObjectNurse testObjectNurse = TestObjectNurse.FromTree(_presenterModel.GetTreeView()); ModelFileHandler.LoadModelFile(tempFilePath, testObjectNurse); } }
/// <summary> /// return value indicate whether the load is successful /// </summary> /// <param name="filePath"></param> /// <param name="treeObjects"></param> /// <returns>return false if file cannot be found</returns> public static bool LoadRecentModelFile(string filePath, TreeView treeObjects) { try { TestObjectNurse rootNurse = TestObjectNurse.FromTree(treeObjects); rootNurse.Clear(); LoadModelFile(filePath, rootNurse); //_treeObjects is used by the file watcher event _treeObjects = treeObjects; return(true); } catch (FileNotFoundException) { AppEnvironment.CurrentModelPath = null; return(false); } }
static void watcher_Changed(object sender, FileSystemEventArgs e) { Form form = _treeObjects.FindForm(); form.Invoke(new Action(() => { //"File changed outside the Manager, do you want to reload?" DialogResult result = MessageBox.Show(form, StringResources.LPSpy_ModelFileHandler_ReloadChangedFile , StringResources.LPSPY_Confirm , MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { //reload the file TestObjectNurse rootNurse = TestObjectNurse.FromTree(_treeObjects); rootNurse.Clear(); LoadModelFile(AppEnvironment.CurrentModelPath, rootNurse); } })); }
/// <summary> /// populate tree view with the AppModel /// </summary> /// <param name="treeObjects"></param> /// <returns>indicate whether load successful</returns> public static bool DlgLoadModelFile(TreeView treeObjects) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Multiselect = false; fileDialog.Title = "Plese select an Application Model file"; fileDialog.Filter = "*.json|*.json"; if (fileDialog.ShowDialog() == DialogResult.OK) { TestObjectNurse rootNurse = TestObjectNurse.FromTree(treeObjects); rootNurse.Clear(); LoadModelFile(fileDialog.FileName, rootNurse); //_treeObjects is used by the file watcher event _treeObjects = treeObjects; return(true); } return(false); }
public SpyMainWindow() { InitializeComponent(); _presenterModel = new PresenterModel(this); _presenterModel.Init(); InitMenuStates(); AdjustSize(); _rootNurseObject = TestObjectNurse.FromTree(_presenterModel.GetTreeView()); AppEnvironment.ModelChanged += (status => { this.Text = _windowTitle + " " + AppEnvironment.CurrentModelPath + ((status) ? " - *" : ""); }); mruMenu = new MruStripMenuInline(fileToolStripMenuItem, menuRecentFiles, new MruStripMenu.ClickedHandler(OnMruFile), mruRegKey + "\\MRU" /*, 4 "4 is the max number of recent files*/); mruMenu.LoadFromRegistry(); }
public static void InitTest(TestContext context) { _treeView = new TreeView(); TestObjectNurse treeNurse = TestObjectNurse.FromTree(_treeView); UIATestObject rootObject = new UIATestObject("root node", ControlType.Pane, null); UIATestObject parentObject = new UIATestObject("parent node", ControlType.Pane, null); UIATestObject childObject = new UIATestObject("child1 node", ControlType.Button, null); VirtualTestObject childObject1 = new VirtualTestObject("child2 node", new Rectangle(10, 20, 30, 40)); TestObjectNurse tempNurse = treeNurse.AddChild(rootObject) as TestObjectNurse; tempNurse = tempNurse.AddChild(parentObject) as TestObjectNurse; tempNurse.AddChild(childObject); tempNurse.AddChild(childObject1); UIATestObject rootObject1 = new UIATestObject("root1 node", ControlType.Pane, null); UIATestObject parentObject2 = new UIATestObject("parent2 node", ControlType.Pane, null); tempNurse = treeNurse.AddChild(rootObject1) as TestObjectNurse; treeNurse.AddChild(parentObject2); }
//[TestMethod] /* * public void LPSpy_MenuEditWindowClick() * { * object sender = null; * EventArgs args = new EventArgs(); * * TreeView treeView = window.TreeObjects; * * TreeNode virtualNode = populateTree(treeView, "VirtualNode1").TreeNode; * * window.TreeObjects.SelectedNode = virtualNode; * * window.mnuEditVirtualControls_Click(sender, args); * * }*/ public TestObjectNurse populateTree(TreeView treeView, string nodeToSelect) { TestObjectNurse rootNurse = TestObjectNurse.FromTree(treeView); TestObjectNurse parentNurse = new TestObjectNurse(new UIATestObject() { NodeName = "RootNode1" }) { ImageFile = "test_snapshot.png" }; TestObjectNurse virtualNurse1 = new TestObjectNurse(new VirtualTestObject() { NodeName = "VirtualNode1" }); TestObjectNurse virtualNurse2 = new TestObjectNurse(new VirtualTestObject() { NodeName = "VirtualNode2" }); rootNurse.AddChild(parentNurse); parentNurse.AddChildren(virtualNurse1, virtualNurse2); switch (nodeToSelect) { case "RootNode1": return(parentNurse); case "VirtualNode1": return(virtualNurse1); case "VirtualNode2": return(virtualNurse2); } return(null); }