| Index: visual_studio/NativeClientVSAddIn/UnitTests/ProjectSettingsTest.cs
|
| diff --git a/visual_studio/NativeClientVSAddIn/UnitTests/ProjectSettingsTest.cs b/visual_studio/NativeClientVSAddIn/UnitTests/ProjectSettingsTest.cs
|
| index be0b611fc0c88b35f76b1e4232bd245df552739c..f86f92bc30281d50af3f386f87588937a138bb9f 100644
|
| --- a/visual_studio/NativeClientVSAddIn/UnitTests/ProjectSettingsTest.cs
|
| +++ b/visual_studio/NativeClientVSAddIn/UnitTests/ProjectSettingsTest.cs
|
| @@ -19,21 +19,12 @@ namespace UnitTests
|
| public class ProjectSettingsTest
|
| {
|
| /// <summary>
|
| - /// The ProjectSettingsTest solution is a valid nacl/pepper plug-in VS solution
|
| - /// that has not had the custom platforms added (PPAPI and NaCl). Immediately
|
| - /// before these unit tests are run the project is copied into the testing
|
| - /// deployment directory, and the custom platforms are added to this copy so that
|
| - /// the project settings are based on the most recent template. Because unit-tests
|
| - /// run in any order, the solution should not be written to in any test.
|
| + /// The below string holds the path to a NaCl solution used in some tests.
|
| + /// A NaCl solution is a valid nacl/pepper plug-in VS solution.
|
| + /// It is copied into the testing deployment directory and opened in some tests.
|
| + /// In this solution, NaCl and pepper settings are copied from 'Empty' initial settings.
|
| /// </summary>
|
| - private const string ProjectSettingsTestSolution =
|
| - @"\ProjectSettingsTest\ProjectSettingsTest.sln";
|
| -
|
| - /// <summary>
|
| - /// This is the project corresponding to ProjectSettingsTestSolution.
|
| - /// </summary>
|
| - private const string ProjectSettingsTestProject =
|
| - @"ProjectSettingsTest\ProjectSettingsTest.vcxproj";
|
| + private static string naclSolutionEmptyInitialization;
|
|
|
| /// <summary>
|
| /// The main visual studio object.
|
| @@ -57,32 +48,22 @@ namespace UnitTests
|
| public TestContext TestContext { get; set; }
|
|
|
| /// <summary>
|
| - /// This is run one time before any test methods are called. Here we set-up the testing copy
|
| - /// of ProjectSettingsTest to use the most up-to-date custom project settings.
|
| + /// This is run one time before any test methods are called. Here we set-up test-copies of
|
| + /// new NaCl solutions for use in the tests.
|
| /// </summary>
|
| /// <param name="testContext">Holds information about the current test run</param>
|
| [ClassInitialize]
|
| public static void ClassSetup(TestContext testContext)
|
| {
|
| - DTE2 dte = null;
|
| + DTE2 dte = TestUtilities.StartVisualStudioInstance();
|
| try
|
| {
|
| - dte = TestUtilities.StartVisualStudioInstance();
|
| - dte.Solution.Open(testContext.DeploymentDirectory + ProjectSettingsTestSolution);
|
| - Project proj = dte.Solution.Projects.Item(ProjectSettingsTestProject);
|
| -
|
| - proj.ConfigurationManager.AddPlatform(
|
| + naclSolutionEmptyInitialization = TestUtilities.CreateBlankValidNaClSolution(
|
| + dte,
|
| + "ProjectSettingsTestEmptyInit",
|
| NativeClientVSAddIn.Strings.PepperPlatformName,
|
| - NativeClientVSAddIn.Strings.PepperPlatformName,
|
| - true);
|
| -
|
| - proj.ConfigurationManager.AddPlatform(
|
| NativeClientVSAddIn.Strings.NaClPlatformName,
|
| - NativeClientVSAddIn.Strings.NaClPlatformName,
|
| - true);
|
| -
|
| - proj.Save();
|
| - dte.Solution.SaveAs(testContext.DeploymentDirectory + ProjectSettingsTestSolution);
|
| + testContext);
|
| }
|
| finally
|
| {
|
| @@ -109,20 +90,140 @@ namespace UnitTests
|
| }
|
|
|
| /// <summary>
|
| - /// Test method to check that the PPAPI platform template correctly sets default values.
|
| + /// Test method to check that the NaCl platform compiles a test project.
|
| /// </summary>
|
| [TestMethod]
|
| - public void VerifyDefaultPepperSettings()
|
| + public void CheckNaClCompile()
|
| {
|
| - string page;
|
| + string naclPlatform = NativeClientVSAddIn.Strings.NaClPlatformName;
|
| + TryCompile(naclSolutionEmptyInitialization, "Debug", naclPlatform);
|
| + TryCompile(naclSolutionEmptyInitialization, "Release", naclPlatform);
|
| + }
|
|
|
| - // Extract the debug and release configurations for Pepper from the project.
|
| - dte_.Solution.Open(TestContext.DeploymentDirectory + ProjectSettingsTestSolution);
|
| - Project project = dte_.Solution.Projects.Item(ProjectSettingsTestProject);
|
| - Assert.IsNotNull(project, "Testing project was not found");
|
| + /// <summary>
|
| + /// Test method to check that the Pepper platform compiles a test project.
|
| + /// </summary>
|
| + [TestMethod]
|
| + public void CheckPepperCompile()
|
| + {
|
| string pepperPlatform = NativeClientVSAddIn.Strings.PepperPlatformName;
|
| - debug_ = TestUtilities.GetVCConfiguration(project, "Debug", pepperPlatform);
|
| - release_ = TestUtilities.GetVCConfiguration(project, "Release", pepperPlatform);
|
| + TryCompile(naclSolutionEmptyInitialization, "Debug", pepperPlatform);
|
| + TryCompile(naclSolutionEmptyInitialization, "Release", pepperPlatform);
|
| + }
|
| +
|
| + /// <summary>
|
| + /// Test method which verifies that NaCl and pepper platforms have correct default properties
|
| + /// when initialized from the Win32 platform.
|
| + /// </summary>
|
| + [TestMethod]
|
| + public void VerifySettingsWin32Initialization()
|
| + {
|
| + string naclSolutionWin32Initialization = TestUtilities.CreateBlankValidNaClSolution(
|
| + dte_, "ProjectSettingsTestWin32Init", "Win32", "Win32", TestContext);
|
| + VerifyDefaultPepperSettings(naclSolutionWin32Initialization);
|
| + VerifyDefaultNaClSettings(naclSolutionWin32Initialization);
|
| +
|
| + // Win32 inherit specific checks on the Pepper platform.
|
| + OpenSolutionAndGetProperties(
|
| + naclSolutionWin32Initialization, NativeClientVSAddIn.Strings.PepperPlatformName);
|
| +
|
| + // When inheriting from Win32 preprocessor the PPAPI preprocessor definition gets grouped
|
| + // into the inherited %(PreprocessorDefinitions) variable. It still exists but doesn't appear
|
| + // in the property page, thus we can't check for it here.
|
| +
|
| + //// TODO(tysand): When inheriting from Win32 this won't set and the Win32 platform
|
| + //// incorrectly(?) sets this to true in the Release config even for regular win32 projects.
|
| + ////TestUtilities.AssertPropertyEquals(
|
| + //// release_, "Link", "GenerateDebugInformation", "false", false);
|
| + dte_.Solution.Close();
|
| +
|
| + // NaCl inherit specific checks on the NaCl platform.
|
| + OpenSolutionAndGetProperties(
|
| + naclSolutionWin32Initialization, NativeClientVSAddIn.Strings.NaClPlatformName);
|
| + AllConfigsAssertPropertyEquals("ConfigurationGeneral", "TargetExt", ".so", true);
|
| + AllConfigsAssertPropertyEquals(
|
| + "ConfigurationGeneral", "ConfigurationType", "DynamicLibrary", true);
|
| + dte_.Solution.Close();
|
| + }
|
| +
|
| + /// <summary>
|
| + /// Test method which verifies that the NaCl platform has correct default properties
|
| + /// when initialized from the Pepper platform. And that the pepper platform has the correct
|
| + /// settings when initialized from the 'empty' settings.
|
| + /// </summary>
|
| + [TestMethod]
|
| + public void VerifySettingsPepperInitialization()
|
| + {
|
| + string naclSolutionPepperInitialization = TestUtilities.CreateBlankValidNaClSolution(
|
| + dte_,
|
| + "ProjectSettingsTestPepperInit",
|
| + NativeClientVSAddIn.Strings.PepperPlatformName,
|
| + NativeClientVSAddIn.Strings.PepperPlatformName,
|
| + TestContext);
|
| + VerifyDefaultPepperSettings(naclSolutionPepperInitialization);
|
| + VerifyDefaultNaClSettings(naclSolutionPepperInitialization);
|
| +
|
| + // Pepper inherit specific checks on the Pepper platform.
|
| + OpenSolutionAndGetProperties(
|
| + naclSolutionPepperInitialization, NativeClientVSAddIn.Strings.PepperPlatformName);
|
| + AllConfigsAssertPropertyContains("CL", "PreprocessorDefinitions", "PPAPI", false);
|
| + TestUtilities.AssertPropertyEquals(
|
| + release_, "Link", "GenerateDebugInformation", "false", false);
|
| + dte_.Solution.Close();
|
| +
|
| + // NaCl inherit specific checks on the NaCl platform.
|
| + OpenSolutionAndGetProperties(
|
| + naclSolutionPepperInitialization, NativeClientVSAddIn.Strings.NaClPlatformName);
|
| + AllConfigsAssertPropertyEquals("ConfigurationGeneral", "TargetExt", ".nexe", true);
|
| + AllConfigsAssertPropertyEquals(
|
| + "ConfigurationGeneral", "ConfigurationType", "Application", true);
|
| + dte_.Solution.Close();
|
| + }
|
| +
|
| + /// <summary>
|
| + /// Test method which verifies that the Pepper platform has correct default properties
|
| + /// when initialized from the NaCl platform. And that the NaCl platform has the correct
|
| + /// settings when initialized from the 'empty' settings.
|
| + /// </summary>
|
| + [TestMethod]
|
| + public void VerifySettingsNaClInitialization()
|
| + {
|
| + string naclSolutionNaClInitialization = TestUtilities.CreateBlankValidNaClSolution(
|
| + dte_,
|
| + "ProjectSettingsTestNaClInit",
|
| + NativeClientVSAddIn.Strings.NaClPlatformName,
|
| + NativeClientVSAddIn.Strings.NaClPlatformName,
|
| + TestContext);
|
| + VerifyDefaultPepperSettings(naclSolutionNaClInitialization);
|
| + VerifyDefaultNaClSettings(naclSolutionNaClInitialization);
|
| +
|
| + // NaCl inherit specific checks on the Pepper platform.
|
| + OpenSolutionAndGetProperties(
|
| + naclSolutionNaClInitialization, NativeClientVSAddIn.Strings.PepperPlatformName);
|
| + AllConfigsAssertPropertyContains("CL", "PreprocessorDefinitions", "PPAPI", false);
|
| + TestUtilities.AssertPropertyEquals(
|
| + release_, "Link", "GenerateDebugInformation", "false", false);
|
| + dte_.Solution.Close();
|
| +
|
| + // NaCl inherit specific checks on the NaCl platform.
|
| + OpenSolutionAndGetProperties(
|
| + naclSolutionNaClInitialization, NativeClientVSAddIn.Strings.NaClPlatformName);
|
| + AllConfigsAssertPropertyEquals("ConfigurationGeneral", "TargetExt", ".nexe", true);
|
| + AllConfigsAssertPropertyEquals(
|
| + "ConfigurationGeneral", "ConfigurationType", "Application", true);
|
| + dte_.Solution.Close();
|
| + }
|
| +
|
| + /// <summary>
|
| + /// Method to run a battery of tests on a particular solution. Checks that all Pepper platform
|
| + /// settings are set correctly.
|
| + /// </summary>
|
| + /// <param name="naclSolution">Path to the solution file to verify.</param>
|
| + private void VerifyDefaultPepperSettings(string naclSolution)
|
| + {
|
| + OpenSolutionAndGetProperties(naclSolution, NativeClientVSAddIn.Strings.PepperPlatformName);
|
| +
|
| + string page;
|
|
|
| // General
|
| page = "ConfigurationGeneral";
|
| @@ -131,41 +232,186 @@ namespace UnitTests
|
| AllConfigsAssertPropertyEquals(page, "TargetExt", ".dll", true);
|
| AllConfigsAssertPropertyEquals(page, "ConfigurationType", "DynamicLibrary", true);
|
| AllConfigsAssertPropertyEquals(page, "VSNaClSDKRoot", @"$(NACL_SDK_ROOT)\", false);
|
| -
|
| + AllConfigsAssertPropertyEquals(page, "CharacterSet", "Unicode", false);
|
| +
|
| // Debugging
|
| page = "WindowsLocalDebugger";
|
| AllConfigsAssertPropertyEquals(
|
| + page, "LocalDebuggerCommand", @"$(CHROME_PATH)", true);
|
| +
|
| + string targetFlag = "--register-pepper-plugins=\"$(TargetPath)\";application/x-nacl";
|
| + string serverFlag = "localhost:5103";
|
| + string debuggerFlag = "--wait-for-debugger-children";
|
| + TestUtilities.AssertPropertyEquals(
|
| + debug_,
|
| page,
|
| - "LocalDebuggerCommand",
|
| - @"$(CHROME_PATH)\chrome.exe",
|
| + "LocalDebuggerCommandArguments",
|
| + string.Format("{0} {1} {2}", targetFlag, serverFlag, debuggerFlag),
|
| true);
|
| - AllConfigsAssertPropertyEquals(
|
| + TestUtilities.AssertPropertyEquals(
|
| + release_,
|
| page,
|
| "LocalDebuggerCommandArguments",
|
| - "--register-pepper-plugins=\"$(TargetPath)\";application/x-nacl localhost:5103",
|
| + string.Format("{0} {1}", targetFlag, serverFlag),
|
| true);
|
|
|
| // VC++ Directories
|
| page = "ConfigurationDirectories";
|
| AllConfigsAssertPropertyContains(page, "IncludePath", @"$(VSNaClSDKRoot)include;", true);
|
| AllConfigsAssertPropertyContains(page, "IncludePath", @"$(VCInstallDir)include", true);
|
| - AllConfigsAssertPropertyContains(page, "LibraryPath", @"$(VSNaClSDKRoot)lib;", true);
|
| + AllConfigsAssertPropertyContains(
|
| + page, "LibraryPath", @"$(VSNaClSDKRoot)lib\win_x86_32_host;", true);
|
| AllConfigsAssertPropertyContains(page, "LibraryPath", @"$(VCInstallDir)lib", true);
|
|
|
| // C/C++ Code Generation
|
| page = "CL";
|
| + TestUtilities.AssertPropertyEquals(release_, page, "RuntimeLibrary", "MultiThreaded", false);
|
| + TestUtilities.AssertPropertyEquals(
|
| + debug_, page, "RuntimeLibrary", "MultiThreadedDebug", false);
|
| + TestUtilities.AssertPropertyEquals(release_, page, "BasicRuntimeChecks", "Default", false);
|
| + TestUtilities.AssertPropertyEquals(
|
| + debug_, page, "BasicRuntimeChecks", "EnableFastChecks", false);
|
| + TestUtilities.AssertPropertyEquals(release_, page, "MinimalRebuild", "false", false);
|
| + TestUtilities.AssertPropertyEquals(debug_, page, "MinimalRebuild", "true", false);
|
| + TestUtilities.AssertPropertyEquals(
|
| + release_, page, "DebugInformationFormat", "ProgramDatabase", false);
|
| + TestUtilities.AssertPropertyEquals(
|
| + debug_, page, "DebugInformationFormat", "EditAndContinue", false);
|
| +
|
| + // C/C++ Optimization
|
| + TestUtilities.AssertPropertyEquals(debug_, page, "Optimization", "Disabled", false);
|
| + TestUtilities.AssertPropertyEquals(release_, page, "Optimization", "MaxSpeed", false);
|
| +
|
| + // Linker Input
|
| + page = "Link";
|
| + AllConfigsAssertPropertyContains(page, "AdditionalDependencies", "ppapi_cpp.lib", true);
|
| + AllConfigsAssertPropertyContains(page, "AdditionalDependencies", "ppapi.lib", true);
|
| +
|
| + // Note: Release check of this property is specific to the platform settings were inherited
|
| + // from. Checks on release are done in the specific methods testing each inherit type.
|
| + TestUtilities.AssertPropertyEquals(debug_, page, "GenerateDebugInformation", "true", false);
|
| +
|
| + TestUtilities.AssertPropertyEquals(release_, page, "LinkIncremental", "false", false);
|
| + TestUtilities.AssertPropertyEquals(debug_, page, "LinkIncremental", "true", false);
|
| +
|
| + AllConfigsAssertPropertyEquals(page, "SubSystem", "Windows", false);
|
| +
|
| + dte_.Solution.Close();
|
| + }
|
| +
|
| + /// <summary>
|
| + /// Method to run a battery of tests on a particular solution. Checks that all NaCl platform
|
| + /// settings are set correctly.
|
| + /// </summary>
|
| + /// <param name="naclSolution">Path to the solution file to verify.</param>
|
| + private void VerifyDefaultNaClSettings(string naclSolution)
|
| + {
|
| + OpenSolutionAndGetProperties(naclSolution, NativeClientVSAddIn.Strings.NaClPlatformName);
|
| +
|
| + string page;
|
| +
|
| + // General
|
| + page = "ConfigurationGeneral";
|
| + AllConfigsAssertPropertyEquals(page, "OutDir", @"$(ProjectDir)$(ToolchainName)\", true);
|
| + AllConfigsAssertPropertyEquals(
|
| + page, "IntDir", @"$(ProjectDir)Intermediate\$(ToolchainName)\", true);
|
| + AllConfigsAssertPropertyEquals(page, "ToolchainName", "newlib", true);
|
| + AllConfigsAssertPropertyEquals(page, "PlatformToolset", "win_x86_$(ToolchainName)", true);
|
| + AllConfigsAssertPropertyEquals(page, "TargetArchitecture", "x86_64", true);
|
| + AllConfigsAssertPropertyEquals(page, "VSNaClSDKRoot", @"$(NACL_SDK_ROOT)\", false);
|
| +
|
| + // Debugging
|
| + page = "WindowsLocalDebugger";
|
| + AllConfigsAssertPropertyEquals(
|
| + page, "LocalDebuggerCommand", @"$(CHROME_PATH)", true);
|
| TestUtilities.AssertPropertyEquals(
|
| debug_,
|
| page,
|
| - "RuntimeLibrary",
|
| - "MultiThreadedDebug",
|
| - false);
|
| - TestUtilities.AssertPropertyEquals(release_, page, "RuntimeLibrary", "MultiThreaded", false);
|
| + "LocalDebuggerCommandArguments",
|
| + "--enable-nacl-debug --no-sandbox localhost:5103",
|
| + true);
|
| + TestUtilities.AssertPropertyEquals(
|
| + release_, page, "LocalDebuggerCommandArguments", "localhost:5103", true);
|
| +
|
| + // VC++ Directories
|
| + page = "ConfigurationDirectories";
|
| + AllConfigsAssertPropertyContains(page, "IncludePath", @"$(VSNaClSDKRoot)include;", true);
|
| + AllConfigsAssertPropertyContains(page, "LibraryPath", @"$(VSNaClSDKRoot)lib;", true);
|
| +
|
| + // C/C++ General
|
| + page = "CL";
|
| + TestUtilities.AssertPropertyEquals(
|
| + debug_, page, "GenerateDebuggingInformation", "true", false);
|
| + TestUtilities.AssertPropertyEquals(
|
| + release_, page, "GenerateDebuggingInformation", "false", false);
|
| +
|
| + AllConfigsAssertPropertyEquals(page, "Warnings", "NormalWarnings", true);
|
| + AllConfigsAssertPropertyEquals(page, "WarningsAsErrors", "false", true);
|
| + AllConfigsAssertPropertyEquals(page, "ConfigurationType", "$(ConfigurationType)", true);
|
| + AllConfigsAssertPropertyEquals(page, "UserHeaderDependenciesOnly", "true", true);
|
| + AllConfigsAssertPropertyEquals(page, "OutputCommandLine", "true", false);
|
| +
|
| + // C/C++ Optimization
|
| + TestUtilities.AssertPropertyEquals(debug_, page, "OptimizationLevel", "O0", false);
|
| + TestUtilities.AssertPropertyEquals(release_, page, "OptimizationLevel", "O3", false);
|
| +
|
| + // C/C++ Preprocessor
|
| + AllConfigsAssertPropertyContains(page, "PreprocessorDefinitions", "NACL", false);
|
| +
|
| + // C/C++ Code Generation
|
| + AllConfigsAssertPropertyEquals(page, "ExceptionHandling", "true", false);
|
| +
|
| + // C/C++ Output Files
|
| + AllConfigsAssertPropertyEquals(page, "ObjectFileName", @"$(IntDir)%(FileName).o", false);
|
| +
|
| + // C/C++ Advanced
|
| + AllConfigsAssertPropertyEquals(page, "CompileAs", "Default", true);
|
|
|
| // Linker Input
|
| page = "Link";
|
| - AllConfigsAssertPropertyContains(page, "AdditionalDependencies", "ppapi_cpp.lib", false);
|
| - AllConfigsAssertPropertyContains(page, "AdditionalDependencies", "ppapi.lib", false);
|
| + AllConfigsAssertPropertyContains(page, "AdditionalDependencies", "ppapi_cpp;ppapi", true);
|
| + dte_.Solution.Close();
|
| + }
|
| +
|
| + /// <summary>
|
| + /// Helper function which opens the given solution, sets the configuration and platform and
|
| + /// tries to compile, failing the test if the build does not succeed.
|
| + /// </summary>
|
| + /// <param name="solutionPath">Path to the solution to open.</param>
|
| + /// <param name="configName">Solution Configuration name (Debug or Release).</param>
|
| + /// <param name="platformName">Platform name.</param>
|
| + private void TryCompile(string solutionPath, string configName, string platformName)
|
| + {
|
| + string failFormat = "Project compile failed for {0} platform {1} config. Build output: {2}";
|
| +
|
| + // Open Debug configuration and build.
|
| + dte_.Solution.Open(solutionPath);
|
| + TestUtilities.SetSolutionConfiguration(
|
| + dte_, TestUtilities.BlankNaClProjectUniqueName, configName, platformName);
|
| + dte_.Solution.SolutionBuild.Build(true);
|
| +
|
| + string compileOutput = TestUtilities.GetPaneText(
|
| + dte_.ToolWindows.OutputWindow.OutputWindowPanes.Item("Build"));
|
| + Assert.IsTrue(
|
| + compileOutput.Contains("Build succeeded.", StringComparison.InvariantCultureIgnoreCase),
|
| + string.Format(failFormat, platformName, configName, compileOutput));
|
| + dte_.Solution.Close();
|
| + }
|
| +
|
| + /// <summary>
|
| + /// Helper function to reduce repeated code. Opens the given solution and sets the debug_
|
| + /// and release_ member variables to point to the given platform type.
|
| + /// </summary>
|
| + /// <param name="solutionPath">Path to the solution to open.</param>
|
| + /// <param name="platformName">Platform type to load.</param>
|
| + private void OpenSolutionAndGetProperties(string solutionPath, string platformName)
|
| + {
|
| + // Extract the debug and release configurations for Pepper from the project.
|
| + dte_.Solution.Open(solutionPath);
|
| + Project project = dte_.Solution.Projects.Item(TestUtilities.BlankNaClProjectUniqueName);
|
| + Assert.IsNotNull(project, "Testing project was not found");
|
| + debug_ = TestUtilities.GetVCConfiguration(project, "Debug", platformName);
|
| + release_ = TestUtilities.GetVCConfiguration(project, "Release", platformName);
|
| }
|
|
|
| /// <summary>
|
|
|