Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Unified Diff: visual_studio/NativeClientVSAddIn/UnitTests/TestUtilities.cs

Issue 10831030: NaCl settings and completed install scripts. (Closed) Base URL: https://nativeclient-sdk.googlecode.com/svn/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..6bc311029378cde0d518845e806515c5e7aabc05 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,7 +21,22 @@ namespace UnitTests
public static class TestUtilities
{
/// <summary>
- /// This starts an instance of Visual Studio and get it's DTE object.
+ /// 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 its DTE object.
/// </summary>
/// <returns>DTE of the started instance.</returns>
public static DTE2 StartVisualStudioInstance()
@@ -61,6 +77,59 @@ 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="dte">Interface to an open Visual Studio instance to use.</param>
+ /// <param name="name">Name to give newly created solution.</param>
+ /// <param name="pepperCopyFrom">Platform name to copy existing settings from to pepper.</param>
+ /// <param name="naclCopyFrom">Platform name to copy existing settings from to NaCl.</param>
+ /// <param name="testContext">Test context used for finding deployment directory.</param>
+ /// <returns>Path to the newly created solution.</returns>
+ public static string CreateBlankValidNaClSolution(
+ DTE2 dte, string name, string pepperCopyFrom, string naclCopyFrom, 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);
+
+ try
+ {
+ dte.Solution.Open(newSolution);
+ Project proj = dte.Solution.Projects.Item(BlankNaClProjectUniqueName);
+
+ // Order matters if copying from the other Native Client type.
+ if (pepperCopyFrom.Equals(NativeClientVSAddIn.Strings.NaClPlatformName))
+ {
+ proj.ConfigurationManager.AddPlatform(
+ NativeClientVSAddIn.Strings.NaClPlatformName, naclCopyFrom, true);
+ proj.ConfigurationManager.AddPlatform(
+ NativeClientVSAddIn.Strings.PepperPlatformName, pepperCopyFrom, true);
+ }
+ else
+ {
+ proj.ConfigurationManager.AddPlatform(
+ NativeClientVSAddIn.Strings.PepperPlatformName, pepperCopyFrom, true);
+ proj.ConfigurationManager.AddPlatform(
+ NativeClientVSAddIn.Strings.NaClPlatformName, naclCopyFrom, true);
+ }
+
+ proj.Save();
+ dte.Solution.SaveAs(newSolution);
+ }
+ finally
+ {
+ if (dte.Solution != null)
+ {
+ dte.Solution.Close();
+ }
+ }
+
+ 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 +348,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);
+ }
+ }
}
}
« no previous file with comments | « visual_studio/NativeClientVSAddIn/UnitTests/ProjectSettingsTest.cs ('k') | visual_studio/NativeClientVSAddIn/build.bat » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698