public void TestEnded(bool ok, PageDataCollectorErrors errcode) { lock (returnLock) { returnCode = (int)errcode; Monitor.PulseAll(returnLock); } }
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); } }
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); } }