/// <summary> /// AppMonitorLoader Main Method for STi consumption, direct-application-launching version /// </summary> /// <param name="commandline">Arguments to AppMonitor loader, either a config file or original format</param> public static void RunApplication(string commandline) { ProcessStartInfo pInfo = ProcessArgs(commandline); DictionaryStore.StartServer(); ApplicationMonitor appMon = new ApplicationMonitor(); // if we're launching a ClickOnce application, clean the cache // Since this method precludes remote deployment and our enlistment should build properly signed manifests, there's no need to update / resign the manifests. if (pInfo.FileName.ToLowerInvariant().EndsWith(ApplicationDeploymentHelper.STANDALONE_APPLICATION_EXTENSION) || pInfo.FileName.ToLowerInvariant().EndsWith(ApplicationDeploymentHelper.BROWSER_APPLICATION_EXTENSION)) { ApplicationDeploymentHelper.CleanClickOnceCache(); } // shell exec the app appMon.StartProcess(pInfo); // Some Xbap tests exit early unless we add PresentationHost.exe as a monitored process. Has to happen after StartProcess. // Timing is not an issue, since this is simply adding a string to a List, so will execute orders of magnitude faster than actually starting any Xbap. if (pInfo.FileName.ToLowerInvariant().EndsWith(ApplicationDeploymentHelper.BROWSER_APPLICATION_EXTENSION)) { appMon.MonitorProcess("PresentationHost.exe"); } appMon.WaitForUIHandlerAbort(); CloseCurrentVariationIfOneExists(); appMon.Close(); }
/// <summary> /// AppMonitorLoader Main Method for STi consumption, configuration File version /// </summary> /// <param name="filename">File name of application monitor config file</param> public static void RunConfigurationFile(string filename) { DictionaryStore.StartServer(); // ApplicationMonitorConfig config = new ApplicationMonitorConfig(filename); config.RunSteps(); CloseCurrentVariationIfOneExists(); }
/// <summary> /// Start Host /// </summary> /// <param name="startupUri"></param> public void StartHost(string startupUri) { if (monitor != null) { throw new InvalidOperationException("You must first Close the Host before calling StartHost again."); } DictionaryStore.StartServer(); //use a custom startup page if (!string.IsNullOrEmpty(startupUri)) { DictionaryStore.Current[UiaDistributedTestcaseHost.StartupUriId] = startupUri; } monitor = new ApplicationMonitor(); GetHwndUIHandler handler = new GetHwndUIHandler(); // register for iexplore and have your app set the title monitor.RegisterUIHandler(handler, "iexplore", "RegExp:(Ready)", UIHandlerNotification.TitleChanged); //Clear the Click Once cache so the app is always re-activated ApplicationDeploymentHelper.CleanClickOnceCache(); //run the app monitor.StartProcess(xbapFileName); //wait for the UIHandler to return abort or timeout in 90 seconds if (!monitor.WaitForUIHandlerAbort(90000) || handler.topLevelhWnd == IntPtr.Zero) { throw new TimeoutException("A timeout occured while waiting for the XamlBrowserHost to navigate to the startUpPage"); } // monitor.StopMonitoring(); //Get the remoteHost object // //if we timedout then let the caller know that the app is not hosting this object //if (remoteHost == null) // throw new InvalidOperationException("The launched application did not create a host object in the Harness remote site"); //set the host hwnd hWndHost = handler.topLevelhWnd; }