public void LaunchFileInBrowser(string file, string browserName = null, IDictionary <string, string> browserArgs = null)
        {
            file = FileProbe.GenerateFileUrl(file);
            var browserAppPath = BrowserPathHelper.GetBrowserPath(browserName);

            var startInfo = new ProcessStartInfo();

            if (!string.IsNullOrEmpty(browserAppPath))
            {
                startInfo.UseShellExecute = true;
                startInfo.FileName        = browserAppPath;
                startInfo.Arguments       =
                    GetArguments(browserName ?? Path.GetFileNameWithoutExtension(browserAppPath),
                                 file,
                                 browserArgs);
            }
            else
            {
                startInfo.UseShellExecute = true;
                startInfo.Verb            = "Open";
                startInfo.FileName        = file;
            }

            Process.Start(startInfo);
        }
Exemple #2
0
        public string CreateHtmlText(string testHtmlTemplate, Dictionary <string, string> frameworkReplacements)
        {
            var testJsReplacement                = new StringBuilder();
            var testFrameworkDependencies        = new StringBuilder();
            var codeCoverageDependencies         = new StringBuilder();
            var referenceJsReplacement           = new StringBuilder();
            var referenceCssReplacement          = new StringBuilder();
            var referenceHtmlTemplateReplacement = new StringBuilder();

            BuildReferenceHtml(testFrameworkDependencies,
                               referenceCssReplacement,
                               testJsReplacement,
                               referenceJsReplacement,
                               referenceHtmlTemplateReplacement,
                               codeCoverageDependencies);


            string amdTestFilePathArrayString = "";
            string amdModuleMap = "";

            if (chutzpahTestSettings.TestHarnessReferenceMode == TestHarnessReferenceMode.AMD)
            {
                amdTestFilePathArrayString = BuildAmdTestFileArrayString();
                amdModuleMap = BuildModuleMapForGeneratedFiles();
            }

            var amdBasePathUrl = "";

            if (!string.IsNullOrEmpty(chutzpahTestSettings.AMDBasePath))
            {
                amdBasePathUrl = FileProbe.GenerateFileUrl(chutzpahTestSettings.AMDBasePath);
            }
            else if (!string.IsNullOrEmpty(chutzpahTestSettings.AMDBaseUrlOverride))
            {
                amdBasePathUrl = FileProbe.GenerateFileUrl(chutzpahTestSettings.AMDBaseUrlOverride);
            }

            var replacements = new Dictionary <string, string>
            {
                { "TestFrameworkDependencies", testFrameworkDependencies.ToString() },
                { "CodeCoverageDependencies", codeCoverageDependencies.ToString() },
                { "TestJSFile", testJsReplacement.ToString() },
                { "ReferencedJSFiles", referenceJsReplacement.ToString() },
                { "ReferencedCSSFiles", referenceCssReplacement.ToString() },
                { "TestHtmlTemplateFiles", referenceHtmlTemplateReplacement.ToString() },
                { "AMDTestPath", amdTestFilePathArrayString },
                { "AMDModuleMap", amdModuleMap },
                { "AMDBasePath", amdBasePathUrl }
            };

            var testHtmlStringBuilder = new StringBuilder(testHtmlTemplate);

            foreach (var replacement in replacements.Union(frameworkReplacements))
            {
                testHtmlStringBuilder.Replace("@@" + replacement.Key + "@@", replacement.Value);
            }

            return(testHtmlStringBuilder.ToString());
        }
 private static string BuildHarnessUrl(string absolutePath, bool isRemoteHarness)
 {
     if (isRemoteHarness)
     {
         return(absolutePath);
     }
     else
     {
         return(string.Format("\"{0}\"", FileProbe.GenerateFileUrl(absolutePath)));
     }
 }
        protected static string GetAbsoluteFileUrl(ReferencedFile referencedFile)
        {
            string referencePath = string.IsNullOrEmpty(referencedFile.GeneratedFilePath)
                        ? referencedFile.Path
                        : referencedFile.GeneratedFilePath;

            if (!RegexPatterns.SchemePrefixRegex.IsMatch(referencePath))
            {
                // Encode the reference path and then decode / (forward slash) and \ (back slash) into / (forward slash)
                return(FileProbe.GenerateFileUrl(referencePath));
            }

            return(referencePath);
        }
Exemple #5
0
        public void LaunchFileInBrowser(string file, string browserName = null)
        {
            file = FileProbe.GenerateFileUrl(file);
            var browserAppPath = BrowserPathHelper.GetBrowserPath(browserName);

            var startInfo = new ProcessStartInfo();

            if (!string.IsNullOrEmpty(browserAppPath))
            {
                startInfo.UseShellExecute = true;
                startInfo.FileName        = browserAppPath;
                startInfo.Arguments       = file;
            }
            else
            {
                startInfo.UseShellExecute = true;
                startInfo.Verb            = "Open";
                startInfo.FileName        = file;
            }

            Process.Start(startInfo);
        }