Exemplo n.º 1
0
        private void Reset()
        {
            IConfigGetter getter = ConfigProvider.Instance.GetConfigGetter("MSFast.Global");

            if (getter != null)
            {
                //String tempFolder = getter.GetString(MSFastGlobalConfigKeys.TEMP_FOLDER);
                String dumpFolder = getter.GetString(MSFastGlobalConfigKeys.DUMP_FOLDER);

                this.txtCPDumpFolder.Text = dumpFolder;
                this.txtCPProxyPort.Text  = getter.GetString(MSFastGlobalConfigKeys.DEFAULT_PROXY_PORT);

                this.chkCPClearCache.Checked      = getter.GetBoolean(MSFastGlobalConfigKeys.CLEAR_CACHE_BEFORE_TEST);
                this.chkCPIPageValidation.Checked = getter.GetBoolean(MSFastGlobalConfigKeys.PAGE_VALIDATION);
                this.chkCPIPageGraph.Checked      = getter.GetBoolean(MSFastGlobalConfigKeys.PAGE_GRAPH);

                this.numDumpSize.Value = Math.Min(1024, (Math.Max(16, getter.GetInt(MSFastGlobalConfigKeys.DUMP_MAX_SIZE))));
            }

            FormSet();
        }
Exemplo n.º 2
0
        private void ProcessResults(ProcessedDataPackage package)
        {
            IConfigGetter getter = ConfigProvider.Instance.GetConfigGetter("MSFast.Global");

            if (getter == null)
            {
                SetTestRunning(false);
                SetTestStatus(TestEventType.TestEnded, false, PageDataCollectorErrors.InvalidConfiguration, -1);
            }

            #region Collected Data

            String graphResults = null;

            if (getter.GetBoolean(MSFastGlobalConfigKeys.PAGE_GRAPH))
            {
                if (package.ContainsKey(typeof(DownloadData)) != false ||
                    package.ContainsKey(typeof(RenderData)) != false ||
                    package.ContainsKey(typeof(PerformanceData)) != false)
                {
                    SerializedResultsFilesInfo srfi = new SerializedResultsFilesInfo(package);

                    if (String.IsNullOrEmpty(srfi.GetFolderNameAndCheckIfValid()))
                    {
                        SetTestRunning(false);
                        SetTestStatus(TestEventType.TestEnded, false, PageDataCollectorErrors.InvalidConfiguration, -1);
                        return;
                    }

                    package.ThumbnailsRoot = "file://" + srfi.GetFolderNameAndCheckIfValid();

                    XmlDocument x = package.Serialize();

                    if (x == null)
                    {
                        SetTestRunning(false);
                        SetTestStatus(TestEventType.TestEnded, false, PageDataCollectorErrors.Unknown, -1);
                        return;
                    }

                    try
                    {
                        x.Save(srfi.GetFullPath());
                        graphResults = srfi.GetFullPath();
                    }
                    catch
                    {
                        SetTestRunning(false);
                        SetTestStatus(TestEventType.TestEnded, false, PageDataCollectorErrors.Unknown, -1);
                        return;
                    }
                }
            }
            #endregion

            #region Validation

            ValidationResultsPackage validationResults = null;

            if (getter.GetBoolean(MSFastGlobalConfigKeys.PAGE_VALIDATION))
            {
                if (validationRunner == null)
                {
                    CreateValidationRunner();
                }

                if (validationRunner != null)
                {
                    validationResults = validationRunner.ValidateBlocking(package);
                }
            }

            #endregion

            SetTestRunning(false);
            SetTestStatus(TestEventType.TestEnded, true);

            ShowOutcome(graphResults, validationResults, package);
        }
Exemplo n.º 3
0
        private void StartTest()
        {
            if (isRunning)
            {
                return;
            }

            if (this.browser == null || this.browser.State != BrowserStatus.Ready)
            {
                throw new Exception("Invalid Browser");
            }

            if (pageDataCollector != null)
            {
                return;
            }

            String url = browser.URL;

            if (String.IsNullOrEmpty(url))
            {
                throw new Exception("Invalid Browser");
            }
            if (url.ToLower().StartsWith("http:") == false)
            {
                MessageBox.Show("Tests are currently available for pages with an \"http://\" address only...", "Sorry...", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            pageDataCollector = new AsyncBufferPageDataCollector();
            pageDataCollector.OnStartingTest += new AsyncBufferPageDataCollector.StartingTestEventHandler(tm_OnStartingTest);
            pageDataCollector.OnTestEnded    += new AsyncBufferPageDataCollector.TestEndedEventHandler(tm_OnTestEnded);
            pageDataCollector.OnTestEvent    += new OnTestEventHandler(pageDataCollector_OnTestEvent);
            IConfigGetter getter = ConfigProvider.Instance.GetConfigGetter("MSFast.Global");

            if (getter == null ||
                String.IsNullOrEmpty(getter.GetString(MSFastGlobalConfigKeys.TEMP_FOLDER)))
            {
                tm_OnTestEnded(pageDataCollector, null, false, PageDataCollectorErrors.InvalidConfiguration, -1);
            }

            if (browser.GetBuffer(new Browser.GetBufferCallback(delegate(String buffer)
            {
                if (pageDataCollector != null && String.IsNullOrEmpty(buffer) == false && String.IsNullOrEmpty(url) == false)
                {
                    int[] pp = GetProxyPorts();

                    if (pp == null)
                    {
                        tm_OnTestEnded(pageDataCollector, null, false, PageDataCollectorErrors.InvalidOrMissingArguments, -1);
                        return;
                    }

                    if (proxyRangeOffset >= pp.Length)
                    {
                        proxyRangeOffset = 0;
                    }

                    BufferedPageDataCollectorStartInfo b = new BufferedPageDataCollectorStartInfo();
                    b.URL = url;
                    b.CollectionID = Math.Max(1, getter.GetInt(MSFastGlobalConfigKeys.LAST_COLLECTION_ID));

                    IConfigSetter setter = ConfigProvider.Instance.GetConfigSetter("MSFast.Global");
                    setter.SetInt(MSFastGlobalConfigKeys.LAST_COLLECTION_ID, b.CollectionID + 1);

                    String tempFolder = getter.GetString(MSFastGlobalConfigKeys.TEMP_FOLDER);

                    TryCleanTempFolder(tempFolder);

                    b.CollectionType = CollectPageInformation.Download_Proxy | CollectPageInformation.Performance | CollectPageInformation.Render;

                    if (getter.GetBoolean(MSFastGlobalConfigKeys.PAGE_GRAPH))
                    {
                        b.CollectionType |= CollectPageInformation.Screenshots_Small;
                    }

                    if (getter.GetBoolean(MSFastGlobalConfigKeys.CLEAR_CACHE_BEFORE_TEST))
                    {
                        b.CollectionType |= CollectPageInformation.ClearCache;
                    }

                    b.Buffer = buffer;
                    b.ClearCache = getter.GetBoolean(MSFastGlobalConfigKeys.CLEAR_CACHE_BEFORE_TEST);
                    b.TempFolder = tempFolder;
                    b.DumpFolder = tempFolder;
                    b.ProxyPort = GetProxyPorts()[proxyRangeOffset];
                    b.IsDebug = false;

                    pageDataCollector.StartTest(b);
                }
                else
                {
                    tm_OnTestEnded(pageDataCollector, null, false, PageDataCollectorErrors.InvalidOrMissingArguments, -1);
                }
            })) == false)
            {
                tm_OnTestEnded(pageDataCollector, null, false, PageDataCollectorErrors.Unknown, -1);
            }
        }