Beispiel #1
0
        /// <summary>
        /// Creates a startup context instruction.
        /// </summary>
        /// <param name="xn">The XML repersentation of the instruction to be checked</param>
        /// <param name="con">The current context object</param>
        static StartUpContext CreateStartUpContext(XmlNode xn, Context con)
        {
            StartUpContext su = new StartUpContext();

            su.OnPass    = XmlFiler.getAttribute(xn, "on-pass");
            su.OnFail    = XmlFiler.getAttribute(xn, "on-fail");
            su.ModelNode = con.ModelNode;
            AddInstruction(xn, su, con);

/*			foreach (XmlNode xnChild in xn.ChildNodes)
 *                      {
 *                              InterpretChild(xnChild, su);
 *                      }
 */
            return(su);
        }
		/// <summary>
		/// Creates a startup context instruction.
		/// </summary>
		/// <param name="xn">The XML repersentation of the instruction to be checked</param>
		/// <param name="con">The current context object</param>
		static StartUpContext CreateStartUpContext(XmlNode xn, Context con)
		{
			StartUpContext su = new StartUpContext();
			su.OnPass = XmlFiler.getAttribute(xn, "on-pass");
			su.OnFail = XmlFiler.getAttribute(xn, "on-fail");
			su.ModelNode = con.ModelNode;
			AddInstruction(xn, su, con);
/*			foreach (XmlNode xnChild in xn.ChildNodes)
			{
				InterpretChild(xnChild, su);
			}
*/
			return su;
		}
Beispiel #3
0
        private bool LaunchApp()
        {
            // Launch the Application
            bool fStarted = true;

            isNotNull(m_path, "No application @path specified or in GtdConfig.xml");
            isNotNull(m_exeName, "No application executable name @exe specified or in GtdConfig.xml");
            string fullPath = m_path + @"\" + m_exeName;
            //Process proc = Process.Start(fullPath);
            // Need to set the working directory to m_path
            Process proc = new Process();

            // can proc ever be null?
            isNotNull(proc, "Could not create a new process for this application.");
            proc.StartInfo.FileName = fullPath;
            if (m_args != null)
            {
                proc.StartInfo.Arguments = m_args;
            }
            //proc.StartInfo.Arguments = "/r:System.dll /out:sample.exe stdstr.cs";
            proc.StartInfo.UseShellExecute = false;
            //compiler.StartInfo.RedirectStandardOutput = true;
            if (m_work != null)
            {
                proc.StartInfo.WorkingDirectory = m_work;
            }
            else
            {
                proc.StartInfo.WorkingDirectory = m_path;
            }
            proc.Start();

            if (proc == null)
            {
                fStarted = false;
            }
            // can this happen?
            isNotNull(proc, "Process became null when launched.");

            proc.WaitForInputIdle();
            isNotNull(proc.MainWindowHandle, "Window handle was not grasped");

            // proc.MainWindowHandle is always IntPtr.Zero
            // so, get another process that has proc.Id
            Process pOfId = Process.GetProcessById(proc.Id);

            isNotNull(pOfId, "Grabbed null process");
            isNotNull(pOfId.MainWindowHandle, "Grabbed process with no handle");
////			while (pOfId.MainWindowHandle == IntPtr.Zero)
////			{
////				Thread.Sleep(100);
////				pOfId = Process.GetProcessById(proc.Id);
////				isNotNull(pOfId,"Grabbed null process");
////				isNotNull(pOfId.MainWindowHandle,"Grabbed process with no handle");
////			}
            if (proc.HasExited)
            {
                fStarted = false;
            }

            // make the window show itself
            pOfId.WaitForInputIdle();
            isNotNull(pOfId.MainWindowTitle, "Window has no title");
            Win32.SetForegroundWindow(pOfId.MainWindowHandle);

            // get a new accessibility object as it has more nodes in it now.
            m_ah = new AccessibilityHelper(pOfId.MainWindowHandle);
            isNotNull(m_ah, "Can't access app with title" + pOfId.MainWindowTitle);
            m_app = new AppHandle(null, pOfId, m_ah);
            isNotNull(m_app, "Null application handle for window with title" + pOfId.MainWindowTitle);

            // Call StartUpContext.ExecuteOnDemand(ts) if there is one.
            // Otherwise, wait for and find the main app window.
            StartUpContext startUp = null;

            foreach (Instruction ins in m_components)
            {
                string stType = ins.GetType().ToString();
                if (stType == "GuiTestDriver.StartUpContext")
                {
                    startUp = (StartUpContext)ins;
                    break;
                }
            }
            if (startUp != null)
            {            // pass higher log levels to this child
                if (startUp.LogLevel < LogLevel)
                {
                    startUp.LogLevel = LogLevel;
                }
                startUp.ExecuteOnDemand();
            }

            // Now find the App in case we got the splash screen or something
            fStarted = FindApp(60000);             // look for upto a minute

            return(fStarted);
        }