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

Unified Diff: visual_studio/NativeClientVSAddIn/UnitTests/PluginDebuggerHelperTest.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/PluginDebuggerHelperTest.cs
diff --git a/visual_studio/NativeClientVSAddIn/UnitTests/PluginDebuggerHelperTest.cs b/visual_studio/NativeClientVSAddIn/UnitTests/PluginDebuggerHelperTest.cs
index 445a7268ebfa41743a9b2208766eb954ac567671..366e59118e998509a0ddce2d625b197afc864189 100644
--- a/visual_studio/NativeClientVSAddIn/UnitTests/PluginDebuggerHelperTest.cs
+++ b/visual_studio/NativeClientVSAddIn/UnitTests/PluginDebuggerHelperTest.cs
@@ -10,6 +10,7 @@ namespace UnitTests
using System.Reflection;
using System.Threading;
+ using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -23,12 +24,13 @@ namespace UnitTests
public class PluginDebuggerHelperTest
{
/// <summary>
- /// The dummy loop solution is a valid nacl/pepper plug-in VS solution.
+ /// This holds the path to the NaCl solution used in these tests.
+ /// The NaCl solution is a valid nacl/pepper plug-in VS solution.
/// It is copied into the testing deployment directory and opened in some tests.
/// Because unit-tests run in any order, the solution should not be written to
/// in any tests.
/// </summary>
- private const string DummyLoopSolution = @"\DummyLoop\DummyLoop.sln";
+ private static string naclSolution;
/// <summary>
/// The main visual studio object.
@@ -42,6 +44,19 @@ namespace UnitTests
public TestContext TestContext { get; set; }
/// <summary>
+ /// This is run one time before any test methods are called. Here we set-up a test-copy of a
+ /// new NaCl solution for use in the tests.
+ /// </summary>
+ /// <param name="testContext">Holds information about the current test run</param>
+ [ClassInitialize]
+ public static void ClassSetup(TestContext testContext)
+ {
+ naclSolution = TestUtilities.CreateBlankValidNaClSolution(
+ "PluginDebuggerHelperTest",
+ testContext);
+ }
+
+ /// <summary>
/// This is run before each test to create test resources.
/// </summary>
[TestInitialize]
@@ -111,7 +126,7 @@ namespace UnitTests
// Visual studio won't allow adding a breakpoint unless it is associated with
// an existing file and valid line number, so use DummyLoopSolution.
- dte_.Solution.Open(TestContext.DeploymentDirectory + DummyLoopSolution);
+ dte_.Solution.Open(naclSolution);
string fileName = "main.cpp";
string functionName = "DummyInstance::HandleMessage";
int lineNumber = 35;
@@ -309,67 +324,62 @@ namespace UnitTests
// This is expected for a correct implementation.
}
- dte_.Solution.Open(TestContext.DeploymentDirectory + DummyLoopSolution);
+ dte_.Solution.Open(naclSolution);
// Setting the start-up project to a non-cpp project should make loading fail.
- string badProjectUniqueName = @"NotNaCl\NotNaCl.csproj";
- object[] badStartupProj = { badProjectUniqueName };
+ object[] badStartupProj = { TestUtilities.NotNaClProjectUniqueName };
dte_.Solution.SolutionBuild.StartupProjects = badStartupProj;
Assert.IsFalse(target.LoadProjectSettings());
Assert.IsFalse(target.isProperlyInitialized_);
// Setting the start-up project to correct C++ project, but also setting the platform
// to non-nacl/pepper should make loading fail.
- string projectUniqueName = @"DummyLoop\DummyLoop.vcxproj";
- object[] startupProj = { projectUniqueName };
+ object[] startupProj = { TestUtilities.BlankNaClProjectUniqueName };
dte_.Solution.SolutionBuild.StartupProjects = startupProj;
- TestUtilities.SetSolutionConfiguration(dte_, projectUniqueName, "Debug", "Win32");
+ TestUtilities.SetSolutionConfiguration(
+ dte_, TestUtilities.BlankNaClProjectUniqueName, "Debug", "Win32");
Assert.IsFalse(target.LoadProjectSettings());
Assert.IsFalse(target.isProperlyInitialized_);
-
+
// Setting the platform to NaCl should make loading succeed.
TestUtilities.SetSolutionConfiguration(
- dte_, projectUniqueName, "Debug", Strings.NaClPlatformName);
+ dte_, TestUtilities.BlankNaClProjectUniqueName, "Debug", Strings.NaClPlatformName);
Assert.IsTrue(target.LoadProjectSettings());
Assert.IsTrue(target.isProperlyInitialized_);
Assert.AreEqual(
- target.projectPlatformType_,
- PluginDebuggerHelper_Accessor.ProjectPlatformType.NaCl);
- Assert.AreEqual(
- target.pluginProjectDirectory_,
- TestContext.DeploymentDirectory + @"\DummyLoop\DummyLoop\");
- Assert.AreEqual(
- target.pluginAssembly_,
- TestContext.DeploymentDirectory + @"\DummyLoop\DummyLoop\NaCl\Debug\DummyLoop.nexe");
- Assert.AreEqual(
- target.pluginOutputDirectory_,
- TestContext.DeploymentDirectory + @"\DummyLoop\DummyLoop\NaCl\Debug\");
- Assert.AreEqual(target.sdkRootDirectory_, expectedSDKRootDir);
- Assert.AreEqual(target.webServerExecutable_, "python.exe");
- ////Assert.AreEqual(target._webServerArguments, "");
- ////Assert.AreEqual(target._gdbPath, "");
+ PluginDebuggerHelper_Accessor.ProjectPlatformType.NaCl,
+ target.projectPlatformType_);
+
+ string projectDir = Path.Combine(
+ Path.GetDirectoryName(naclSolution),
+ Path.GetDirectoryName(TestUtilities.BlankNaClProjectUniqueName)) + @"\";
+ string outputDir = Path.Combine(projectDir, "newlib") + @"\";
+ string assembly = Path.Combine(outputDir, TestUtilities.BlankNaClProjectName + ".nexe");
+
+ Assert.AreEqual(projectDir, target.pluginProjectDirectory_);
+ Assert.AreEqual(outputDir, target.pluginOutputDirectory_);
+ Assert.AreEqual(assembly, target.pluginAssembly_);
+
+ Assert.AreEqual(expectedSDKRootDir, target.sdkRootDirectory_);
+ Assert.AreEqual("python.exe", target.webServerExecutable_);
// Setting platform to Pepper should make succeed.
TestUtilities.SetSolutionConfiguration(
- dte_, projectUniqueName, "Debug", Strings.PepperPlatformName);
+ dte_, TestUtilities.BlankNaClProjectUniqueName, "Debug", Strings.PepperPlatformName);
Assert.IsTrue(target.LoadProjectSettings());
Assert.IsTrue(target.isProperlyInitialized_);
Assert.AreEqual(
- target.projectPlatformType_,
- PluginDebuggerHelper_Accessor.ProjectPlatformType.Pepper);
- Assert.AreEqual(
- target.pluginProjectDirectory_,
- TestContext.DeploymentDirectory + @"\DummyLoop\DummyLoop\");
- Assert.AreEqual(
- target.pluginAssembly_,
- TestContext.DeploymentDirectory + @"\DummyLoop\Debug\PPAPI\DummyLoop.dll");
- Assert.AreEqual(
- target.pluginOutputDirectory_,
- TestContext.DeploymentDirectory + @"\DummyLoop\Debug\PPAPI\");
- Assert.AreEqual(target.sdkRootDirectory_, expectedSDKRootDir);
- Assert.AreEqual(target.webServerExecutable_, "python.exe");
- ////Assert.AreEqual(target._webServerArguments, "");
- ////Assert.AreEqual(target._gdbPath, "");
+ PluginDebuggerHelper_Accessor.ProjectPlatformType.Pepper,
+ target.projectPlatformType_);
+
+ outputDir = Path.Combine(projectDir, "win") + @"\";
+ assembly = Path.Combine(outputDir, TestUtilities.BlankNaClProjectName + ".dll");
+ Assert.AreEqual(projectDir, target.pluginProjectDirectory_);
+ Assert.AreEqual(outputDir, target.pluginOutputDirectory_);
+ Assert.AreEqual(assembly, target.pluginAssembly_);
+
+ Assert.AreEqual(expectedSDKRootDir, target.sdkRootDirectory_);
+ Assert.AreEqual("python.exe", target.webServerExecutable_);
}
/// <summary>
@@ -379,7 +389,8 @@ namespace UnitTests
[DeploymentItem("NativeClientVSAddIn.dll")]
public void AttachVSDebuggerTest()
{
- using (Process dummyProc = TestUtilities.StartProcessForKilling("DummyProc", 20))
+ using (System.Diagnostics.Process dummyProc = TestUtilities.StartProcessForKilling(
+ "DummyProc", 20))
{
try
{
@@ -387,9 +398,9 @@ namespace UnitTests
target.projectPlatformType_ = PluginDebuggerHelper_Accessor.ProjectPlatformType.Pepper;
target.isProperlyInitialized_ = true;
- target.AttachVSDebugger(
- null,
- new NativeClientVSAddIn.PluginDebuggerHelper.PluginFoundEventArgs((uint)dummyProc.Id));
+ var pluginFoundArgs = new NativeClientVSAddIn.PluginDebuggerHelper.PluginFoundEventArgs(
+ (uint)dummyProc.Id);
+ target.AttachVSDebugger(null, pluginFoundArgs);
bool isBeingDebugged = false;
foreach (EnvDTE.Process proc in dte_.Debugger.DebuggedProcesses)
@@ -511,7 +522,7 @@ namespace UnitTests
break;
}
- Thread.Sleep(500);
+ System.Threading.Thread.Sleep(500);
result = TestUtilities.GetPaneText(target.webServerOutputPane_);
}
@@ -597,7 +608,7 @@ namespace UnitTests
break;
}
- Thread.Sleep(500);
+ System.Threading.Thread.Sleep(500);
result = TestUtilities.GetPaneText(target.webServerOutputPane_);
}

Powered by Google App Engine
This is Rietveld 408576698