public void StartTest(PageDataCollectorStartInfo startInfo) { this.StartInfo = startInfo; CheckUIHostRegistration(); ieInstance.Silent = true; ieInstance.AddressBar = false; ieInstance.MenuBar = false; ieInstance.ToolBar = 0; ieInstance.StatusBar = false; if (startInfo.IsDebug == false) { long style = Win32API.GetWindowLong(_mainHWND, -20); style |= (long)0x80; style = Win32API.SetWindowLong(_mainHWND, -20, style); Win32API.MoveWindow(_mainHWND, 10000, 0, 1000, 738, false); } else { Win32API.MoveWindow(_mainHWND, 0, 0, 1000, 738, false); } Win32API.ShowWindow(_mainHWND, Win32API.WindowShowStyle.ShowDefault); object oEmpty = String.Empty; object oURL = startInfo.LaunchWithURL; ieInstance.Navigate2(ref oURL, ref oEmpty, ref oEmpty, ref oEmpty, ref oEmpty); }
public void StartTest(PageDataCollectorStartInfo settings) { if (OnStartingTest != null) { OnStartingTest(this); } if (settings == null || settings.IsValid() == false) { if (OnTestEnded != null) { OnTestEnded(this, settings, false, PageDataCollectorErrors.InvalidOrMissingArguments, -1); } return; } lock (startedLock) { if (started) { if (OnTestEnded != null) { OnTestEnded(this, settings, false, PageDataCollectorErrors.ObjectDisposed, -1); } return; } started = true; } new Thread(delegate() { this.StartTestThread(settings); }).Start(); }
void tm_OnTestEnded(AsyncBufferPageDataCollector sender, PageDataCollectorStartInfo settings, bool success, PageDataCollectorErrors errCode, int resultsId) { if (success == false && errCode != PageDataCollectorErrors.TestAborted) { ExceptionsHandler.HandleException(new Exception(String.Format("Test Failed. Error #{0} Command Args \"{1}\"", errCode, ((settings != null && settings.CreateCommandLineArgs() != null) ? settings.CreateCommandLineArgs() : "")))); } if (this.pageDataCollector != null) { this.pageDataCollector.Dispose(); } this.pageDataCollector = null; if (success == false) { SetTestRunning(false); SetTestStatus(TestEventType.TestEnded, success, errCode, resultsId); int[] pp = GetProxyPorts(); if (pp == null) { return; } if (errCode == PageDataCollectorErrors.CantStartProxy && proxyRangeOffset < pp.Length - 1) { proxyRangeOffset++; StartTest(); } else if (errCode != PageDataCollectorErrors.TestAborted) { if (errCode == PageDataCollectorErrors.InvalidConfiguration) { MessageBox.Show("Invalid configuration detected.\r\nPlease make sure the settings are correct", "Test Aborted", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (errCode == PageDataCollectorErrors.TestAlreadyRunning) { MessageBox.Show("Test is already running on a different page.", "Test Aborted", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (errCode == PageDataCollectorErrors.TestTimeout) { MessageBox.Show("Test has timed-out.", "Test Aborted", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Unexpected error occured while trying to test the page\r\n(err#" + ((int)errCode) + ")", "Test Aborted", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { ProcessResults(resultsId); } }
private void StartTestThread(PageDataCollectorStartInfo settings) { PageDataCollector pd = new PageDataCollector(); pd.OnTestProgress += new OnTestEventHandler(pd_OnTestProgress); int res = pd.StartTest(settings); if (OnTestEnded != null) { OnTestEnded(this, settings, (res == 0), (PageDataCollectorErrors)Enum.ToObject(typeof(PageDataCollectorErrors), res), (res == 0) ? settings.CollectionID : -1); } }
public int StartTest(PageDataCollectorStartInfo startInfo) { if (startInfo.ClearCache) { try { WatiN.Core.Native.InternetExplorer.WinInet.ClearCache(); } catch { } } if (ProxyHelper.SetProxy(startInfo.ProxyAddress) == false) { TestEnded(false, PageDataCollectorErrors.CantSetProxy); } else { browserWrapperIEImpl.StartTest(startInfo); lock (returnLock) { if (returnCode == -1) { Monitor.Wait(returnLock, startInfo.Timeout * 1000 * 60); } if (returnCode == -1) { returnCode = (int)PageDataCollectorErrors.TestTimeout; } } } Dispose(); return(returnCode); }
static void Main(string[] args) { commandArgs = args; AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); PageDataCollectorStartInfo pdcsi = new PageDataCollectorStartInfo(args); if (pdcsi.IsValid() == false) { PageDataCollectorStartInfo.PrintUsage(System.Console.Error); System.Environment.ExitCode = (int)(PageDataCollectorErrors.InvalidOrMissingArguments); } else { TestEvents.IsVerbose = pdcsi.IsVerbose; TestEvents.FireProgressEvent(TestEventType.TestStarted); pdcsi.IsDebug = true; _Collector c = new _Collector(pdcsi); try { System.Environment.ExitCode = c.Run(); } catch { System.Environment.ExitCode = (int)PageDataCollectorErrors.Unknown; } finally { c.Release(); } TestEvents.FireProgressEvent(TestEventType.TestEnded); } }
public int StartTest(PageDataCollectorStartInfo settings) { if (settings == null || settings.IsValid() == false) { return((int)PageDataCollectorErrors.InvalidOrMissingArguments); } lock (startedLock) { if (started) { return((int)PageDataCollectorErrors.ObjectDisposed); } started = true; } PageDataCollectorErrors prepareResults = settings.PrepareStartInfo(); if (prepareResults != PageDataCollectorErrors.NoError) { return((int)prepareResults); } String executable = settings.EngineExecutable; if (String.IsNullOrEmpty(executable)) { try { executable = Path.GetDirectoryName(Assembly.GetAssembly(typeof(PageDataCollector)).Location).Replace("\\", "/") + "/engine.exe"; } catch { } } if (executable == null || File.Exists(executable) == false) { return((int)PageDataCollectorErrors.Unknown); } ProcessStartInfo psi = new ProcessStartInfo(executable); psi.CreateNoWindow = true; psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; psi.UseShellExecute = false; psi.Arguments = settings.CreateCommandLineArgs(); psi.RedirectStandardOutput = true; Process listFiles = new Process(); listFiles.OutputDataReceived += new DataReceivedEventHandler(OutputDataReceived); listFiles.StartInfo = (psi); listFiles.Start(); listFiles.BeginOutputReadLine(); listFiles.WaitForExit((settings.Timeout + 1) * 60 * 1000); //Wait timeout + minute settings.CleanUp(); settings.Dispose(); settings = null; if (listFiles.HasExited) { return(listFiles.ExitCode); } else { return((int)PageDataCollectorErrors.TestTimeout); } }
public _Collector(PageDataCollectorStartInfo startInfo) { this.startInfo = startInfo; }