public void PublishVars() { if (m_scriptPath == null) { m_scriptPath = getScriptPath(); } Var sp = new Var(); sp.Id = "ScriptPath"; sp.Set = m_scriptPath; sp.Execute(); // sets and interprets the value and adds to the hash }
/// <summary> /// Overriden in this class to set context variables available to child instructions. /// $guiPath, $appPath, $guiRole and $guiName /// </summary> protected override void SetContextVariables() { Var guiPath = new Var("guiPath", m_path); Var appPath = new Var("appPath", m_select); Var guiRole = new Var("guiRole", m_role); Var guiName = new Var("guiName", m_name); Var nodeName = new Var("nodeName", m_nodeName); guiPath.Execute(); appPath.Execute(); guiRole.Execute(); guiName.Execute(); nodeName.Execute(); }
public void ParseVarTest() { TestState ts = TestState.getOnly("LT"); ts.Script = "UtilitiesTest.xml"; Var ins2 = new Var(); ts.AddNamedInstruction("one", ins2); ins2.Set = "4"; ins2.Execute(); Assert.IsTrue(GuiPath.parseIndexTesting("stuff[$hi]", "stuff[$hi]", 0, null)); Assert.IsTrue(GuiPath.parseIndexTesting("stuff[$one]", "stuff", 4, null)); Assert.IsTrue(GuiPath.parseIndexTesting("stuff3[$one;3]", "stuff3", 43, null)); Assert.IsTrue(GuiPath.parseIndexTesting("stuff[3$one]", "stuff[3$one]", 0, null)); }
public void evalFunction() { TestState ts = TestState.getOnly("LT"); ts.Script = "UtilitiesTest.xml"; SelectText ins1 = new SelectText(); ts.AddNamedInstruction("one", ins1); ins1.Path = "window:cleaner/item:dust"; // note: ins1 has no default data set (ie. $one.text = null) Var ins2 = new Var(); ts.AddNamedInstruction("_two", ins2); ins2.Set = " how's this??"; Var ins3 = new Var(); ts.AddNamedInstruction("thr-ee", ins3); ins3.Set = "And $_two; this should be ignored?"; ins2.Execute(); ins3.Execute(); string result = Utilities.evalExpr("$random()"); Assert.IsTrue(result == "0" || result == "1", "default random not 0 or 1"); result = Utilities.evalExpr("$random(,)"); Assert.IsTrue(result == "$random(,)", "random can't just have a comma for an argument"); result = Utilities.evalExpr("$random(,4)"); Assert.IsTrue(result == "$random(,4)", "random has to have a max argument"); result = Utilities.evalExpr("$random(4,)"); Assert.IsTrue(result == "$random(4,)", "random has to have a min argument when there's a comma"); result = Utilities.evalExpr("$random(45,50)"); Assert.IsTrue(result == "$random(45,50)", "min has to be less than max"); result = Utilities.evalExpr("$random(50,45)"); Assert.IsTrue(result == "45" || result == "46" || result == "47" || result == "48" || result == "49" || result == "50", "Random must be between 45 and 50"); result = Utilities.evalExpr("$random(-6,-10)"); Assert.IsTrue(result == "-6" || result == "-7" || result == "-8" || result == "-9" || result == "-10", "Random must be between -10 and -6"); result = Utilities.evalExpr("$random(3,-2)"); Assert.IsTrue(result == "-2" || result == "-1" || result == "0" || result == "1" || result == "2" || result == "3", "Random must be between -2 and 3"); }
public void PublishVars() { Var sp = new Var(); // sp.finishCreation() not needed sp.Id = "ScriptPath"; sp.Set = getScriptPath(); sp.Execute(); // sets and interprets the value and adds to the hash Var ep = new Var(); // ep.finishCreation() not needed ep.Id = "AppPath"; ep.Set = getAppPath(); ep.Execute(); // sets and interprets the value and adds to the hash Var mp = new Var(); // mp.finishCreation() not needed mp.Id = "ModelPath"; mp.Set = getModelPath(); mp.Execute(); // sets and interprets the value and adds to the hash }
public void evalFunction() { TestState ts = TestState.getOnly("LT"); ts.Script = "UtilitiesTest.xml"; SelectText ins1 = new SelectText(); ts.AddNamedInstruction("one", ins1); ins1.Path = "window:cleaner/item:dust"; // note: ins1 has no default data set (ie. $one.text = null) Var ins2 = new Var(); ts.AddNamedInstruction("_two", ins2); ins2.Set = " how's this??"; Var ins3 = new Var(); ts.AddNamedInstruction("thr-ee", ins3); ins3.Set = "And $_two; this should be ignored?"; ins2.Execute(); ins3.Execute(); string result = Utilities.evalExpr("$random()"); Assert.IsTrue(result == "0" || result == "1", "default random not 0 or 1"); result = Utilities.evalExpr("$random(,)"); Assert.IsTrue(result == "$random(,)", "random can't just have a comma for an argument"); result = Utilities.evalExpr("$random(,4)"); Assert.IsTrue(result == "$random(,4)", "random has to have a max argument"); result = Utilities.evalExpr("$random(4,)"); Assert.IsTrue(result == "$random(4,)", "random has to have a min argument when there's a comma"); result = Utilities.evalExpr("$random(45,50)"); Assert.IsTrue(result == "$random(45,50)", "min has to be less than max"); result = Utilities.evalExpr("$random(50,45)"); Assert.IsTrue(result == "45" || result == "46" || result == "47" || result == "48" || result == "49" || result == "50", "Random must be between 45 and 50"); result = Utilities.evalExpr("$random(-6,-10)"); Assert.IsTrue(result == "-6" || result == "-7" || result == "-8" || result == "-9" || result == "-10", "Random must be between -10 and -6"); result = Utilities.evalExpr("$random(3,-2)"); Assert.IsTrue(result == "-2" || result == "-1" || result == "0" || result == "1" || result == "2" || result == "3", "Random must be between -2 and 3"); }
public void evalExpr() { TestState ts = TestState.getOnly("LT"); ts.Script = "UtilitiesTest.xml"; SelectText ins1 = new SelectText(); ts.AddNamedInstruction("one",ins1); ins1.Path = "window:cleaner/item:dust"; // note: ins1 has no default data set (ie. $one.text = null) Var ins2 = new Var(); ts.AddNamedInstruction("_two",ins2); ins2.Set = " how's this??"; Var ins3 = new Var(); ts.AddNamedInstruction("thr-ee",ins3); ins3.Set = "And $_two; this should be ignored?"; ins2.Execute(); ins3.Execute(); string result = Utilities.evalExpr("$one"); Assert.AreEqual(null,result); result = Utilities.evalExpr("$one;"); Assert.AreEqual(null,result); result = Utilities.evalExpr("$one "); Assert.AreEqual(" ",result); result = Utilities.evalExpr(" $one"); Assert.AreEqual(" ",result); result = Utilities.evalExpr("$one; "); Assert.AreEqual(" ",result); result = Utilities.evalExpr(";$one; "); Assert.AreEqual("; ",result); result = Utilities.evalExpr(";$one;;"); Assert.AreEqual(";;",result); result = Utilities.evalExpr("$one1"); Assert.AreEqual("$one1",result); result = Utilities.evalExpr("$on;e"); Assert.AreEqual("$on;e",result); result = Utilities.evalExpr("$_two"); Assert.AreEqual(" how's this??",result); result = Utilities.evalExpr("$_two;"); Assert.AreEqual(" how's this??",result); result = Utilities.evalExpr("$_two "); Assert.AreEqual(" how's this?? ",result); result = Utilities.evalExpr(" $_two"); Assert.AreEqual(" how's this??",result); result = Utilities.evalExpr("$_two; "); Assert.AreEqual(" how's this?? ",result); result = Utilities.evalExpr(";$_two; "); Assert.AreEqual("; how's this?? ",result); result = Utilities.evalExpr(";$_two;;"); Assert.AreEqual("; how's this??;",result); result = Utilities.evalExpr("$_two1"); Assert.AreEqual("$_two1",result); result = Utilities.evalExpr("$_tw;o"); Assert.AreEqual("$_tw;o",result); result = Utilities.evalExpr("$one.;"); Assert.AreEqual(null,result); result = Utilities.evalExpr("$one..;"); Assert.AreEqual("[select-text-1 does not have data for '.']",result); result = Utilities.evalExpr("$one.path"); Assert.AreEqual("window:cleaner/item:dust",result); result = Utilities.evalExpr("$one.path;"); Assert.AreEqual("window:cleaner/item:dust",result); result = Utilities.evalExpr("$one.path.;"); Assert.AreEqual("[select-text-1 does not have data for 'path.']",result); result = Utilities.evalExpr("text$one;$_two;$thr-ee"); Assert.AreEqual("text how's this??And how's this?? this should be ignored?",result); result = Utilities.evalExpr("text$one;$_two;$thr-ee"); Assert.AreEqual("text how's this??And how's this?? this should be ignored?",result); result = Utilities.evalExpr("text$one.path;$_two;$thr-ee OK"); Assert.AreEqual("textwindow:cleaner/item:dust how's this??And how's this?? this should be ignored? OK",result); result = Utilities.evalExpr("text $_two $one.path OK"); Assert.AreEqual("text how's this?? window:cleaner/item:dust OK",result); }
/// <summary> /// The search is almost breadth-first: /// The first step in the path has an unknown sibling index and its role is not 'value'. /// If this ah has children of the step type, they are searched until all the /// subsequent steps find matching ah's. This search substitutes its own visitor /// that records the successful path ah's. Upon success, a sibling index is assigned to /// the variable named in the step, the non-terminal subpath ah's are exposed /// to the caller's visitor in turn and this method returns the last ah on the path. /// Subpath steps are searched for depending on their content. /// </summary> /// <param name="path">The path to search. Each step in the path contains an /// Accessibility name and Accessibility role of the matching gui object.</param> /// <param name="visitor">null or the object providing methods that are called when steps are found.</param> /// <returns>A new <see cref="AccessibilityHelper"/> object that wraps the matched /// window.</returns> private AccessibilityHelper SearchPathForIndex(GuiPath path, IPathVisitor visitor) { Logger log = Logger.getOnly(); log.startList("SearchPathForIndex('" + path.toString() + "') starting from ('" + this.Role + "','" + this.Name + "')"); if (ChildCount <= 0) { if (visitor != null) visitor.notFound(path); log.endList(); return null; } AccessibilityHelper ah = null; int nnum = 0; int index = 0; string parentName = null; if (path.Prev != null) parentName = path.Prev.Name; foreach (AccessibilityHelper child in this) { if (child == null) continue; string logStr = "-> Child(" + (++nnum) + ") ('" + child.Role + "','" + child.Name + "')"; if (path.Next != null && path.Next.Role == AccessibleRole.Alert) logStr += "NOT SUPPOSED TO BE VALUE!! val[" + child.Value + "]"; log.listItem(logStr); if (MatchNameAndRole(path.Name, path.Role, child)) { // this is a candidate for matching the path ++index; // the first one is 1 if (path.Next != null) { // This method won't allow for caller's visitors on candidate nodes until proved needed TrackingVisitor tv = new TrackingVisitor(); // tv may need to open sub menus if (tv != null) tv.visitNode(child); // add child to node list to visit later if this is the right path ah = ValueOrChild(path.Next, child, tv); if (ah != null) { // the subpath was matched to the end if (path.VarId != null && path.VarId != "") { // Create and execute a variable to record the index Var var = new Var(); var.Id = path.VarId; var.Set = System.Convert.ToString(index); // 1 based count var.Execute(); // puts the var in the TestState hash // don't set path.Nth = index since it might change if the path is used again } // let the caller's visitor tend to all the path ah's if (visitor != null) { if (tv != null) tv.StepDownPath(visitor); } log.endList(); return ah; } } } else if (parentName != null && child.Role == AccessibleRole.Client && child.Name == parentName) { // try the client instead ah = child.SearchPathForIndex(path, visitor); if (ah != null) { log.endList(); return ah; // found it } } } if (visitor != null) visitor.notFound(path); log.endList(); return null; }
public void evalExpr() { TestState ts = TestState.getOnly("LT"); ts.Script = "UtilitiesTest.xml"; SelectText ins1 = new SelectText(); ts.AddNamedInstruction("one", ins1); ins1.Path = "window:cleaner/item:dust"; // note: ins1 has no default data set (ie. $one.text = null) Var ins2 = new Var(); ts.AddNamedInstruction("_two", ins2); ins2.Set = " how's this??"; Var ins3 = new Var(); ts.AddNamedInstruction("thr-ee", ins3); ins3.Set = "And $_two; this should be ignored?"; ins2.Execute(); ins3.Execute(); string result = Utilities.evalExpr("$one"); Assert.AreEqual(null, result); result = Utilities.evalExpr("$one;"); Assert.AreEqual(null, result); result = Utilities.evalExpr("$one "); Assert.AreEqual(" ", result); result = Utilities.evalExpr(" $one"); Assert.AreEqual(" ", result); result = Utilities.evalExpr("$one; "); Assert.AreEqual(" ", result); result = Utilities.evalExpr(";$one; "); Assert.AreEqual("; ", result); result = Utilities.evalExpr(";$one;;"); Assert.AreEqual(";;", result); result = Utilities.evalExpr("$one1"); Assert.AreEqual("$one1", result); result = Utilities.evalExpr("$on;e"); Assert.AreEqual("$on;e", result); result = Utilities.evalExpr("$_two"); Assert.AreEqual(" how's this??", result); result = Utilities.evalExpr("$_two;"); Assert.AreEqual(" how's this??", result); result = Utilities.evalExpr("$_two "); Assert.AreEqual(" how's this?? ", result); result = Utilities.evalExpr(" $_two"); Assert.AreEqual(" how's this??", result); result = Utilities.evalExpr("$_two; "); Assert.AreEqual(" how's this?? ", result); result = Utilities.evalExpr(";$_two; "); Assert.AreEqual("; how's this?? ", result); result = Utilities.evalExpr(";$_two;;"); Assert.AreEqual("; how's this??;", result); result = Utilities.evalExpr("$_two1"); Assert.AreEqual("$_two1", result); result = Utilities.evalExpr("$_tw;o"); Assert.AreEqual("$_tw;o", result); result = Utilities.evalExpr("$one.;"); Assert.AreEqual(null, result); result = Utilities.evalExpr("$one..;"); Assert.AreEqual("[select-text-1 does not have data for '.']", result); result = Utilities.evalExpr("$one.path"); Assert.AreEqual("window:cleaner/item:dust", result); result = Utilities.evalExpr("$one.path;"); Assert.AreEqual("window:cleaner/item:dust", result); result = Utilities.evalExpr("$one.path.;"); Assert.AreEqual("[select-text-1 does not have data for 'path.']", result); result = Utilities.evalExpr("text$one;$_two;$thr-ee"); Assert.AreEqual("text how's this??And how's this?? this should be ignored?", result); result = Utilities.evalExpr("text$one;$_two;$thr-ee"); Assert.AreEqual("text how's this??And how's this?? this should be ignored?", result); result = Utilities.evalExpr("text$one.path;$_two;$thr-ee OK"); Assert.AreEqual("textwindow:cleaner/item:dust how's this??And how's this?? this should be ignored? OK", result); result = Utilities.evalExpr("text $_two $one.path OK"); Assert.AreEqual("text how's this?? window:cleaner/item:dust OK", result); }
public void PublishVars() { if (m_scriptPath == null) m_scriptPath = getScriptPath(); Var sp = new Var(); sp.Id = "ScriptPath"; sp.Set = m_scriptPath; sp.Execute(); // sets and interprets the value and adds to the hash }
/// <summary> /// Overriden in this class to set context variables available to child instructions. /// $guiPath, $appPath, $guiRole and $guiName /// </summary> protected override void SetContextVariables() { Var guiPath = new Var("guiPath", m_path); Var appPath = new Var("appPath", m_select); Var guiRole = new Var("guiRole", m_role); Var guiName = new Var("guiName", m_name); Var nodeName = new Var("nodeName", m_nodeName); guiPath.Execute(); appPath.Execute(); guiRole.Execute(); guiName.Execute(); nodeName.Execute(); }
public void PublishVars() { Var sp = new Var(); // sp.finishCreation() not needed sp.Id = "ScriptPath"; sp.Set = getScriptPath(); sp.Execute(); // sets and interprets the value and adds to the hash Var ep = new Var(); // ep.finishCreation() not needed ep.Id = "AppPath"; ep.Set = getAppPath(); ep.Execute(); // sets and interprets the value and adds to the hash Var mp = new Var(); // mp.finishCreation() not needed mp.Id = "ModelPath"; mp.Set = getModelPath(); mp.Execute(); // sets and interprets the value and adds to the hash }
public void ParseVarTest() { TestState ts = TestState.getOnly("LT"); ts.Script = "UtilitiesTest.xml"; Var ins2 = new Var(); ts.AddNamedInstruction("one",ins2); ins2.Set = "4"; ins2.Execute(); Assert.IsTrue(GuiPath.parseIndexTesting("stuff[$hi]", "stuff[$hi]", 0, null)); Assert.IsTrue(GuiPath.parseIndexTesting("stuff[$one]", "stuff", 4, null)); Assert.IsTrue(GuiPath.parseIndexTesting("stuff3[$one;3]", "stuff3", 43, null)); Assert.IsTrue(GuiPath.parseIndexTesting("stuff[3$one]", "stuff[3$one]", 0, null)); }