Exemple #1
0
        private void TryCleanTempFolder(string tempFolder)
        {
            if (String.IsNullOrEmpty(tempFolder) || Directory.Exists(tempFolder) == false)
            {
                return;
            }

            long          s      = GetDirectorySize(tempFolder);
            IConfigGetter getter = ConfigProvider.Instance.GetConfigGetter("MSFast.Global");
            int           max    = Math.Min(1024, (Math.Max(16, getter.GetInt(MSFastGlobalConfigKeys.DUMP_MAX_SIZE))));

            max = max * 1024 * 1024;
            if (s > max)
            {
                string[] a = Directory.GetFiles(tempFolder, "*.*", SearchOption.TopDirectoryOnly);
                try
                {
                    foreach (string name in a)
                    {
                        File.Delete(name);
                    }
                }
                catch
                {
                }
            }
        }
Exemple #2
0
        private void ProcessResults(int collectionID)
        {
            SetTestStatus(TestEventType.ProcessingResults);

            IConfigGetter getter = ConfigProvider.Instance.GetConfigGetter("MSFast.Global");

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

            String DumpFolder = getter.GetString(MSFastGlobalConfigKeys.DUMP_FOLDER);

            ProcessedDataPackage package = ProcessedDataCollector.CollectAll(DumpFolder, collectionID);

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

            ProcessResults(package);
        }
Exemple #3
0
        private void UpdateAvailableCallback(String ver, String desc, String getUrl, DateTime versionDate)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new updateAvailableCallback(this.UpdateAvailableCallback), new object[] { ver, desc, getUrl, versionDate });
                return;
            }

            IConfigGetter getter = ConfigProvider.Instance.GetConfigGetter("MSFast.Global");
            IConfigSetter setter = ConfigProvider.Instance.GetConfigSetter("MSFast.Global");

            if (String.IsNullOrEmpty(ver) || getter.GetString(MSFastGlobalConfigKeys.CURRENT_PACKAGE_VERSION) == ver)
            {
                this.updatesReadyBtn.Visible     = false;
                this.toolStripSeparator5.Visible = false;
            }
            else
            {
                if (getter.GetString(MSFastGlobalConfigKeys.CURRENT_PACKAGE_VERSION_LATEST_ALERT) != ver)
                {
                    setter.SetString(MSFastGlobalConfigKeys.CURRENT_PACKAGE_VERSION_LATEST_ALERT, ver);
                    OpenNewVersionAvailable();
                }

                this.updatesReadyBtn.Visible     = true;
                this.toolStripSeparator5.Visible = true;
            }
        }
Exemple #4
0
        public MergeTreeGetter(
			IConfigGetter configGetter,
			ISvnInterface svnInterface,
			IUnmergedRevisionGetter unmergedRevisionGetter)
        {
            _configGetter = configGetter;
            _svnInterface = svnInterface;
            _unmergedRevisionGetter = unmergedRevisionGetter;
        }
Exemple #5
0
        public MergeRunner(
			IProjectMerger projectMerger,
			IConfigGetter configGetter,
			IConfigurationManager<ConfigKey> configManager,
			IReportGenerator reportGenerator,
			IEmailSender emailSender)
        {
            _projectMerger = projectMerger;
            _configGetter = configGetter;
            _configManager = configManager;
            _reportGenerator = reportGenerator;
            _emailSender = emailSender;
        }
Exemple #6
0
        public Creator(ProcessedDataPackage pacakge)
        {
            IConfigGetter getter = ConfigProvider.Instance.GetConfigGetter("MSFast.Global");

            if (getter != null && String.IsNullOrEmpty(getter.GetString(MSFastGlobalConfigKeys.CURRENT_PACKAGE_VERSION)))
            {
                Name    = "MSFast Test Harness";
                Version = getter.GetString(MSFastGlobalConfigKeys.CURRENT_PACKAGE_VERSION);
            }
            else
            {
                Name    = "MSFast Test Harness";
                Version = "0.0";
            }
        }
Exemple #7
0
        private static void RefreshVesion()
        {
            IConfigGetter getter = ConfigProvider.Instance.GetConfigGetter("MSFast.Global");
            String        url_s  = getter.GetString(MSFastGlobalConfigKeys.VERSION_UPDATE_URL);

            String   version     = null;
            DateTime versionDate = DateTime.MinValue;

            String versionDesc = null;
            String versionURL  = null;

            if (String.IsNullOrEmpty(url_s) == false)
            {
                try
                {
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url_s);
                    // execute the request
                    HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                    // we will read data via the response stream
                    StreamReader resStream = new StreamReader(response.GetResponseStream());

                    try
                    {
                        version = resStream.ReadLine();
                        string versionDateValue = resStream.ReadLine();
                        if (!DateTime.TryParse(versionDateValue, out versionDate))
                        {
                        }

                        versionURL  = resStream.ReadLine();
                        versionDesc = resStream.ReadToEnd();
                    }
                    catch { }

                    resStream.Close();
                    response.Close();
                }
                catch
                {
                }
            }
            latestVersionURL     = versionURL;
            latestVersionDetails = versionDesc;
            latestVersion        = version;
            latestVersionDate    = versionDate;
            nextCheck            = DateTime.Now.AddHours(2);
        }
Exemple #8
0
        private int[] GetProxyPorts()
        {
            IConfigGetter getter = ConfigProvider.Instance.GetConfigGetter("MSFast.Global");
            String        ports  = getter.GetString(MSFastGlobalConfigKeys.DEFAULT_PROXY_PORT);

            if (String.IsNullOrEmpty(ports))
            {
                ports = "8080";
            }

            MatchCollection mc = portsRegex.Matches(ports);

            if (mc.Count > 0)
            {
                LinkedList <int> ll = new LinkedList <int>();

                foreach (Match m in mc)
                {
                    if (String.IsNullOrEmpty(m.Value) == false)
                    {
                        try
                        {
                            ll.AddLast(int.Parse(m.Value));
                        }
                        catch { }
                    }
                }
                int[] l = new int[ll.Count];
                int   i = 0;
                foreach (int inn in ll)
                {
                    l[i] = inn;
                    i++;
                }
                if (l.Length > 0)
                {
                    return(l);
                }
            }


            MessageBox.Show("Invalid configuration detected.\r\nInvalid proxy ports!", "Test Aborted", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return(null);
        }
Exemple #9
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();
        }
        private void Reset()
        {
            IConfigGetter getter = ConfigProvider.Instance.GetConfigGetter("MSFast.Global");

            if (getter != null)
            {
                String ndid  = getter.GetString(MSFastGlobalConfigKeys.DEVICE_ID);
                String ports = getter.GetString(MSFastGlobalConfigKeys.PORTS);

                /*NetworkDevice[] availableNetworkDevice = WinPcapWrapper.GetNetworkDeviceList();
                 *
                 * this.comboBox1.Items.Clear();
                 * this.comboBox1.Items.Add("Select network device");
                 *
                 * int selectedNDID = 0;
                 * int c = 1;
                 * for (int i = 0; i < availableNetworkDevice.Length; i++)
                 * {
                 *      if (String.IsNullOrEmpty(availableNetworkDevice[i].Name) == false)
                 *      {
                 *              this.comboBox1.Items.Add(availableNetworkDevice[i].Description);
                 *              if (ndid == availableNetworkDevice[i].Name)
                 *              {
                 *                      selectedNDID = c;
                 *              }
                 *              c++;
                 *      }
                 * }
                 * this.label4.Text = "";
                 * this.comboBox1.SelectedIndex = selectedNDID;
                 * this.textBox1.Text = ports;*/
            }

            this.button1.Enabled = false;
            this.button2.Enabled = false;
        }
Exemple #11
0
 public EmailSender(IConfigurationManager<ConfigKey> configManager, IConfigGetter configGetter)
 {
     _sendEmails = configManager.GetBoolValue(ConfigKey.SendEmails);
     _settings = configGetter.GetConfig().EmailSettings;
 }
Exemple #12
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);
        }
Exemple #13
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);
            }
        }