| Index: visual_studio/NativeClientVSAddIn/UnitTests/TestUtilities.cs
|
| diff --git a/visual_studio/NativeClientVSAddIn/UnitTests/TestUtilities.cs b/visual_studio/NativeClientVSAddIn/UnitTests/TestUtilities.cs
|
| index 570d8f3cb304ebed3041096f10422e9022920990..fa0866fba4fed5c786e5df5e538aa6ebcc715b91 100644
|
| --- a/visual_studio/NativeClientVSAddIn/UnitTests/TestUtilities.cs
|
| +++ b/visual_studio/NativeClientVSAddIn/UnitTests/TestUtilities.cs
|
| @@ -6,6 +6,7 @@ namespace UnitTests
|
| {
|
| using System;
|
| using System.Collections.Generic;
|
| + using System.IO;
|
| using System.Linq;
|
| using System.Management;
|
|
|
| @@ -20,6 +21,21 @@ namespace UnitTests
|
| public static class TestUtilities
|
| {
|
| /// <summary>
|
| + /// Name of the NaCl project in BlankValidSolution.
|
| + /// </summary>
|
| + public const string BlankNaClProjectName = @"NaClProject";
|
| +
|
| + /// <summary>
|
| + /// Uniquename of the NaCl project in BlankValidSolution.
|
| + /// </summary>
|
| + public const string BlankNaClProjectUniqueName = @"NaClProject\NaClProject.vcxproj";
|
| +
|
| + /// <summary>
|
| + /// Uniquename of the non-NaCl project in BlankValidSolution.
|
| + /// </summary>
|
| + public const string NotNaClProjectUniqueName = @"NotNaCl\NotNaCl.csproj";
|
| +
|
| + /// <summary>
|
| /// This starts an instance of Visual Studio and get it's DTE object.
|
| /// </summary>
|
| /// <returns>DTE of the started instance.</returns>
|
| @@ -61,6 +77,48 @@ namespace UnitTests
|
| }
|
|
|
| /// <summary>
|
| + /// Creates a blank valid NaCl project with up-to-date settings. The path to the new solution
|
| + /// is returned.
|
| + /// </summary>
|
| + /// <param name="name">Name to give newly created solution.</param>
|
| + /// <param name="testContext">Test context used for finding deployment directory.</param>
|
| + /// <returns>Path to the newly created solution.</returns>
|
| + public static string CreateBlankValidNaClSolution(string name, TestContext testContext)
|
| + {
|
| + const string BlankSolution = "BlankValidSolution";
|
| + string newSolutionDir = Path.Combine(testContext.DeploymentDirectory, name);
|
| + string newSolution = Path.Combine(newSolutionDir, BlankSolution + ".sln");
|
| + CopyDirectory(Path.Combine(testContext.DeploymentDirectory, BlankSolution), newSolutionDir);
|
| +
|
| + DTE2 dte = null;
|
| + try
|
| + {
|
| + dte = TestUtilities.StartVisualStudioInstance();
|
| + dte.Solution.Open(newSolution);
|
| + Project proj = dte.Solution.Projects.Item(BlankNaClProjectUniqueName);
|
| +
|
| + proj.ConfigurationManager.AddPlatform(
|
| + NativeClientVSAddIn.Strings.PepperPlatformName,
|
| + NativeClientVSAddIn.Strings.PepperPlatformName,
|
| + true);
|
| +
|
| + proj.ConfigurationManager.AddPlatform(
|
| + NativeClientVSAddIn.Strings.NaClPlatformName,
|
| + NativeClientVSAddIn.Strings.NaClPlatformName,
|
| + true);
|
| +
|
| + proj.Save();
|
| + dte.Solution.SaveAs(newSolution);
|
| + }
|
| + finally
|
| + {
|
| + TestUtilities.CleanUpVisualStudioInstance(dte);
|
| + }
|
| +
|
| + return newSolution;
|
| + }
|
| +
|
| + /// <summary>
|
| /// This returns the text contained in the given output window pane.
|
| /// </summary>
|
| /// <param name="pane">Pane to get text from.</param>
|
| @@ -279,5 +337,38 @@ namespace UnitTests
|
| {
|
| return source.IndexOf(toCheck, comparison) != -1;
|
| }
|
| +
|
| + /// <summary>
|
| + /// Copies the entire contents of a directory and sub directories.
|
| + /// </summary>
|
| + /// <param name="source">Directory to copy from.</param>
|
| + /// <param name="dest">Directory to copy to.</param>
|
| + public static void CopyDirectory(string source, string dest)
|
| + {
|
| + DirectoryInfo dir = new DirectoryInfo(source);
|
| +
|
| + if (!dir.Exists)
|
| + {
|
| + throw new DirectoryNotFoundException(source);
|
| + }
|
| +
|
| + if (!Directory.Exists(dest))
|
| + {
|
| + Directory.CreateDirectory(dest);
|
| + }
|
| +
|
| + FileInfo[] files = dir.GetFiles();
|
| + foreach (FileInfo file in files)
|
| + {
|
| + string path = Path.Combine(dest, file.Name);
|
| + file.CopyTo(path, false);
|
| + }
|
| +
|
| + foreach (DirectoryInfo subdir in dir.GetDirectories())
|
| + {
|
| + string path = Path.Combine(dest, subdir.Name);
|
| + CopyDirectory(subdir.FullName, path);
|
| + }
|
| + }
|
| }
|
| }
|
|
|