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

Side by Side Diff: visual_studio/NativeClientVSAddIn/UnitTests/ProjectSettingsTest.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, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 namespace UnitTests 5 namespace UnitTests
6 { 6 {
7 using System; 7 using System;
8 8
9 using EnvDTE; 9 using EnvDTE;
10 using EnvDTE80; 10 using EnvDTE80;
11 using Microsoft.VisualStudio.TestTools.UnitTesting; 11 using Microsoft.VisualStudio.TestTools.UnitTesting;
12 using Microsoft.VisualStudio.VCProjectEngine; 12 using Microsoft.VisualStudio.VCProjectEngine;
13 13
14 /// <summary> 14 /// <summary>
15 /// This test class contains tests related to the custom project settings 15 /// This test class contains tests related to the custom project settings
16 /// and property pages for PPAPI and NaCl configurations. 16 /// and property pages for PPAPI and NaCl configurations.
17 /// </summary> 17 /// </summary>
18 [TestClass] 18 [TestClass]
19 public class ProjectSettingsTest 19 public class ProjectSettingsTest
20 { 20 {
21 /// <summary> 21 /// <summary>
22 /// The ProjectSettingsTest solution is a valid nacl/pepper plug-in VS solut ion 22 /// This holds the path to the NaCl solution used in these tests.
23 /// that has not had the custom platforms added (PPAPI and NaCl). Immediatel y 23 /// The NaCl solution is a valid nacl/pepper plug-in VS solution.
24 /// before these unit tests are run the project is copied into the testing 24 /// It is copied into the testing deployment directory and opened in some te sts.
25 /// deployment directory, and the custom platforms are added to this copy so that 25 /// Because unit-tests run in any order, the solution should not be written to
26 /// the project settings are based on the most recent template. Because unit -tests 26 /// in any tests.
27 /// run in any order, the solution should not be written to in any test.
28 /// </summary> 27 /// </summary>
29 private const string ProjectSettingsTestSolution = 28 private static string naclSolution;
30 @"\ProjectSettingsTest\ProjectSettingsTest.sln";
31
32 /// <summary>
33 /// This is the project corresponding to ProjectSettingsTestSolution.
34 /// </summary>
35 private const string ProjectSettingsTestProject =
36 @"ProjectSettingsTest\ProjectSettingsTest.vcxproj";
37 29
38 /// <summary> 30 /// <summary>
39 /// The main visual studio object. 31 /// The main visual studio object.
40 /// </summary> 32 /// </summary>
41 private DTE2 dte_; 33 private DTE2 dte_;
42 34
43 /// <summary> 35 /// <summary>
44 /// The project configuration for debug settings of a test's platform. 36 /// The project configuration for debug settings of a test's platform.
45 /// </summary> 37 /// </summary>
46 private VCConfiguration debug_; 38 private VCConfiguration debug_;
47 39
48 /// <summary> 40 /// <summary>
49 /// The project configuration for release settings of a test's platform 41 /// The project configuration for release settings of a test's platform
50 /// </summary> 42 /// </summary>
51 private VCConfiguration release_; 43 private VCConfiguration release_;
52 44
53 /// <summary> 45 /// <summary>
54 /// Gets or sets the test context which provides information about, 46 /// Gets or sets the test context which provides information about,
55 /// and functionality for the current test run. 47 /// and functionality for the current test run.
56 /// </summary> 48 /// </summary>
57 public TestContext TestContext { get; set; } 49 public TestContext TestContext { get; set; }
58 50
59 /// <summary> 51 /// <summary>
60 /// This is run one time before any test methods are called. Here we set-up the testing copy 52 /// This is run one time before any test methods are called. Here we set-up a test-copy of a
61 /// of ProjectSettingsTest to use the most up-to-date custom project setting s. 53 /// new NaCl solution for use in the tests.
62 /// </summary> 54 /// </summary>
63 /// <param name="testContext">Holds information about the current test run</ param> 55 /// <param name="testContext">Holds information about the current test run</ param>
64 [ClassInitialize] 56 [ClassInitialize]
65 public static void ClassSetup(TestContext testContext) 57 public static void ClassSetup(TestContext testContext)
66 { 58 {
67 DTE2 dte = null; 59 naclSolution = TestUtilities.CreateBlankValidNaClSolution(
68 try 60 "ProjectSettingsTest",
69 { 61 testContext);
70 dte = TestUtilities.StartVisualStudioInstance();
71 dte.Solution.Open(testContext.DeploymentDirectory + ProjectSettingsTestS olution);
72 Project proj = dte.Solution.Projects.Item(ProjectSettingsTestProject);
73
74 proj.ConfigurationManager.AddPlatform(
75 NativeClientVSAddIn.Strings.PepperPlatformName,
76 NativeClientVSAddIn.Strings.PepperPlatformName,
77 true);
78
79 proj.ConfigurationManager.AddPlatform(
80 NativeClientVSAddIn.Strings.NaClPlatformName,
81 NativeClientVSAddIn.Strings.NaClPlatformName,
82 true);
83
84 proj.Save();
85 dte.Solution.SaveAs(testContext.DeploymentDirectory + ProjectSettingsTes tSolution);
86 }
87 finally
88 {
89 TestUtilities.CleanUpVisualStudioInstance(dte);
90 }
91 } 62 }
92 63
93 /// <summary> 64 /// <summary>
94 /// This is run before each test to create test resources. 65 /// This is run before each test to create test resources.
95 /// </summary> 66 /// </summary>
96 [TestInitialize] 67 [TestInitialize]
97 public void TestSetup() 68 public void TestSetup()
98 { 69 {
99 dte_ = TestUtilities.StartVisualStudioInstance(); 70 dte_ = TestUtilities.StartVisualStudioInstance();
100 } 71 }
101 72
102 /// <summary> 73 /// <summary>
103 /// This is run after each test to clean up things created in TestSetup(). 74 /// This is run after each test to clean up things created in TestSetup().
104 /// </summary> 75 /// </summary>
105 [TestCleanup] 76 [TestCleanup]
106 public void TestCleanup() 77 public void TestCleanup()
107 { 78 {
108 TestUtilities.CleanUpVisualStudioInstance(dte_); 79 TestUtilities.CleanUpVisualStudioInstance(dte_);
109 } 80 }
110 81
111 /// <summary> 82 /// <summary>
112 /// Test method to check that the PPAPI platform template correctly sets def ault values. 83 /// Test method to check that the PPAPI platform template correctly sets def ault values.
113 /// </summary> 84 /// </summary>
114 [TestMethod] 85 [TestMethod]
115 public void VerifyDefaultPepperSettings() 86 public void VerifyDefaultPepperSettings()
116 { 87 {
117 string page; 88 string page;
118 89
119 // Extract the debug and release configurations for Pepper from the projec t. 90 // Extract the debug and release configurations for Pepper from the projec t.
120 dte_.Solution.Open(TestContext.DeploymentDirectory + ProjectSettingsTestSo lution); 91 dte_.Solution.Open(naclSolution);
121 Project project = dte_.Solution.Projects.Item(ProjectSettingsTestProject); 92 Project project = dte_.Solution.Projects.Item(TestUtilities.BlankNaClProje ctUniqueName);
122 Assert.IsNotNull(project, "Testing project was not found"); 93 Assert.IsNotNull(project, "Testing project was not found");
123 string pepperPlatform = NativeClientVSAddIn.Strings.PepperPlatformName; 94 string pepperPlatform = NativeClientVSAddIn.Strings.PepperPlatformName;
124 debug_ = TestUtilities.GetVCConfiguration(project, "Debug", pepperPlatform ); 95 debug_ = TestUtilities.GetVCConfiguration(project, "Debug", pepperPlatform );
125 release_ = TestUtilities.GetVCConfiguration(project, "Release", pepperPlat form); 96 release_ = TestUtilities.GetVCConfiguration(project, "Release", pepperPlat form);
126 97
127 // General 98 // General
128 page = "ConfigurationGeneral"; 99 page = "ConfigurationGeneral";
129 AllConfigsAssertPropertyEquals(page, "OutDir", @"$(ProjectDir)Win\", true) ; 100 AllConfigsAssertPropertyEquals(page, "OutDir", @"$(ProjectDir)Win\", true) ;
130 AllConfigsAssertPropertyEquals(page, "IntDir", @"$(ProjectDir)Intermediate \Win\", true); 101 AllConfigsAssertPropertyEquals(page, "IntDir", @"$(ProjectDir)Intermediate \Win\", true);
131 AllConfigsAssertPropertyEquals(page, "TargetExt", ".dll", true); 102 AllConfigsAssertPropertyEquals(page, "TargetExt", ".dll", true);
132 AllConfigsAssertPropertyEquals(page, "ConfigurationType", "DynamicLibrary" , true); 103 AllConfigsAssertPropertyEquals(page, "ConfigurationType", "DynamicLibrary" , true);
133 AllConfigsAssertPropertyEquals(page, "VSNaClSDKRoot", @"$(NACL_SDK_ROOT)\" , false); 104 AllConfigsAssertPropertyEquals(page, "VSNaClSDKRoot", @"$(NACL_SDK_ROOT)\" , false);
134 105
135 // Debugging 106 // Debugging
136 page = "WindowsLocalDebugger"; 107 page = "WindowsLocalDebugger";
137 AllConfigsAssertPropertyEquals( 108 AllConfigsAssertPropertyEquals(
138 page, 109 page, "LocalDebuggerCommand", @"$(CHROME_PATH)\chrome.exe", true);
139 "LocalDebuggerCommand",
140 @"$(CHROME_PATH)\chrome.exe",
141 true);
142 AllConfigsAssertPropertyEquals( 110 AllConfigsAssertPropertyEquals(
143 page, 111 page,
144 "LocalDebuggerCommandArguments", 112 "LocalDebuggerCommandArguments",
145 "--register-pepper-plugins=\"$(TargetPath)\";application/x-nacl localh ost:5103", 113 "--register-pepper-plugins=\"$(TargetPath)\";application/x-nacl localh ost:5103",
146 true); 114 true);
147 115
148 // VC++ Directories 116 // VC++ Directories
149 page = "ConfigurationDirectories"; 117 page = "ConfigurationDirectories";
150 AllConfigsAssertPropertyContains(page, "IncludePath", @"$(VSNaClSDKRoot)in clude;", true); 118 AllConfigsAssertPropertyContains(page, "IncludePath", @"$(VSNaClSDKRoot)in clude;", true);
151 AllConfigsAssertPropertyContains(page, "IncludePath", @"$(VCInstallDir)inc lude", true); 119 AllConfigsAssertPropertyContains(page, "IncludePath", @"$(VCInstallDir)inc lude", true);
152 AllConfigsAssertPropertyContains(page, "LibraryPath", @"$(VSNaClSDKRoot)li b;", true); 120 AllConfigsAssertPropertyContains(
121 page, "LibraryPath", @"$(VSNaClSDKRoot)lib\win_x86_32_host;", true);
153 AllConfigsAssertPropertyContains(page, "LibraryPath", @"$(VCInstallDir)lib ", true); 122 AllConfigsAssertPropertyContains(page, "LibraryPath", @"$(VCInstallDir)lib ", true);
154 123
155 // C/C++ Code Generation 124 // C/C++ Code Generation
156 page = "CL"; 125 page = "CL";
157 TestUtilities.AssertPropertyEquals( 126 TestUtilities.AssertPropertyEquals(
158 debug_, 127 debug_,
159 page, 128 page,
160 "RuntimeLibrary", 129 "RuntimeLibrary",
161 "MultiThreadedDebug", 130 "MultiThreadedDebug",
162 false); 131 false);
163 TestUtilities.AssertPropertyEquals(release_, page, "RuntimeLibrary", "Mult iThreaded", false); 132 TestUtilities.AssertPropertyEquals(release_, page, "RuntimeLibrary", "Mult iThreaded", false);
164 133
134 // C/C++ Preprocessor
135 AllConfigsAssertPropertyContains(page, "PreprocessorDefinitions", "PPAPI", false);
136
165 // Linker Input 137 // Linker Input
166 page = "Link"; 138 page = "Link";
167 AllConfigsAssertPropertyContains(page, "AdditionalDependencies", "ppapi_cp p.lib", false); 139 AllConfigsAssertPropertyContains(page, "AdditionalDependencies", "ppapi_cp p.lib", true);
168 AllConfigsAssertPropertyContains(page, "AdditionalDependencies", "ppapi.li b", false); 140 AllConfigsAssertPropertyContains(page, "AdditionalDependencies", "ppapi.li b", true);
169 } 141 }
170 142
171 /// <summary> 143 /// <summary>
144 /// Test method to check that the NaCl platform template correctly sets defa ult values.
145 /// </summary>
146 [TestMethod]
147 public void VerifyDefaultNaClSettings()
148 {
149 string page;
150
151 // Extract the debug and release configurations for NaCl from the project.
152 dte_.Solution.Open(naclSolution);
153 Project project = dte_.Solution.Projects.Item(TestUtilities.BlankNaClProje ctUniqueName);
154 Assert.IsNotNull(project, "Testing project was not found");
155 string naclPlatform = NativeClientVSAddIn.Strings.NaClPlatformName;
156 debug_ = TestUtilities.GetVCConfiguration(project, "Debug", naclPlatform);
157 release_ = TestUtilities.GetVCConfiguration(project, "Release", naclPlatfo rm);
158
159 // General
160 page = "ConfigurationGeneral";
161 AllConfigsAssertPropertyEquals(page, "OutDir", @"$(ProjectDir)$(ToolchainN ame)\", true);
162 AllConfigsAssertPropertyEquals(
163 page, "IntDir", @"$(ProjectDir)Intermediate\$(ToolchainName)\", true);
164 AllConfigsAssertPropertyEquals(page, "TargetExt", ".nexe", true);
165 AllConfigsAssertPropertyEquals(page, "ToolchainName", "newlib", true);
166 AllConfigsAssertPropertyEquals(page, "PlatformToolset", "win_x86_$(Toolcha inName)", true);
167 AllConfigsAssertPropertyEquals(page, "ConfigurationType", "Application", t rue);
168 AllConfigsAssertPropertyEquals(page, "TargetArchitecture", "x86_64", true) ;
169 AllConfigsAssertPropertyEquals(page, "VSNaClSDKRoot", @"$(NACL_SDK_ROOT)\" , false);
170
171 // Debugging
172 page = "WindowsLocalDebugger";
173 AllConfigsAssertPropertyEquals(
174 page, "LocalDebuggerCommand", @"$(CHROME_PATH)\chrome.exe", true);
175 AllConfigsAssertPropertyEquals(
176 page, "LocalDebuggerCommandArguments", @"--enable-nacl-debug localhost :5103", true);
177
178 // VC++ Directories
179 page = "ConfigurationDirectories";
180 AllConfigsAssertPropertyContains(page, "IncludePath", @"$(VSNaClSDKRoot)in clude;", true);
181 AllConfigsAssertPropertyContains(page, "LibraryPath", @"$(VSNaClSDKRoot)li b;", true);
182
183 // C/C++ General
184 page = "CL";
185 TestUtilities.AssertPropertyEquals(
186 debug_,
187 page,
188 "GenerateDebuggingInformation",
189 "true",
190 false);
191 TestUtilities.AssertPropertyEquals(
192 release_,
193 page,
194 "GenerateDebuggingInformation",
195 "false",
196 false);
197
198 AllConfigsAssertPropertyEquals(page, "Warnings", "NormalWarnings", true);
199 AllConfigsAssertPropertyEquals(page, "WarningsAsErrors", "false", true);
200 AllConfigsAssertPropertyEquals(page, "OutputCommandLine", "false", true);
201 AllConfigsAssertPropertyEquals(page, "ConfigurationType", "$(Configuration Type)", true);
202 AllConfigsAssertPropertyEquals(page, "UserHeaderDependenciesOnly", "true", true);
203
204 // C/C++ Optimization
205 TestUtilities.AssertPropertyEquals(debug_, page, "OptimizationLevel", "O0" , false);
206 TestUtilities.AssertPropertyEquals(release_, page, "OptimizationLevel", "O 3", false);
207
208 // C/C++ Preprocessor
209 AllConfigsAssertPropertyContains(page, "PreprocessorDefinitions", "NaCl", false);
210
211 // C/C++ Code Generation
212 AllConfigsAssertPropertyEquals(page, "ExceptionHandling", "true", false);
213
214 // C/C++ Output Files
215 AllConfigsAssertPropertyEquals(page, "ObjectFileName", @"$(IntDir)%(FileNa me).o", false);
216
217 // C/C++ Advanced
218 AllConfigsAssertPropertyEquals(page, "CompileAs", "Default", true);
219
220 // Linker Input
221 page = "Link";
222 AllConfigsAssertPropertyContains(page, "AdditionalDependencies", "ppapi_cp p;ppapi", true);
223 }
224
225 /// <summary>
226 /// Test method to check that the NaCl platform compiles a test project.
227 /// </summary>
228 [TestMethod]
229 public void CheckNaClCompile()
230 {
231 dte_.Solution.Open(naclSolution);
232 TestUtilities.SetSolutionConfiguration(
233 dte_,
234 TestUtilities.BlankNaClProjectUniqueName,
235 "Debug",
236 NativeClientVSAddIn.Strings.NaClPlatformName);
237 dte_.Solution.SolutionBuild.Build(true);
238 string compileOutput = TestUtilities.GetPaneText(
239 dte_.ToolWindows.OutputWindow.OutputWindowPanes.Item("Build"));
240 Assert.IsTrue(
241 compileOutput.Contains("Build succeeded.", StringComparison.InvariantC ultureIgnoreCase),
242 "Project compile failed for NaCl platform. Build output: " + compileOu tput);
243 }
244
245 /// <summary>
246 /// Test method to check that the Pepper platform compiles a test project.
247 /// </summary>
248 [TestMethod]
249 public void CheckPepperCompile()
250 {
251 dte_.Solution.Open(naclSolution);
252 TestUtilities.SetSolutionConfiguration(
253 dte_,
254 TestUtilities.BlankNaClProjectUniqueName,
255 "Debug",
256 NativeClientVSAddIn.Strings.PepperPlatformName);
257 dte_.Solution.SolutionBuild.Build(true);
258
259 string compileOutput = TestUtilities.GetPaneText(
260 dte_.ToolWindows.OutputWindow.OutputWindowPanes.Item("Build"));
261 Assert.IsTrue(
262 compileOutput.Contains("Build succeeded.", StringComparison.InvariantC ultureIgnoreCase),
263 "Project compile failed for Pepper platform. Build output: " + compile Output);
264 }
265
266 /// <summary>
172 /// Tests that a given property has a specific value for both Debug and Rele ase 267 /// Tests that a given property has a specific value for both Debug and Rele ase
173 /// configurations under the current test's platform. 268 /// configurations under the current test's platform.
174 /// </summary> 269 /// </summary>
175 /// <param name="pageName">Property page name where property resides.</param > 270 /// <param name="pageName">Property page name where property resides.</param >
176 /// <param name="propertyName">Name of the property to check.</param> 271 /// <param name="propertyName">Name of the property to check.</param>
177 /// <param name="expectedValue">Expected value of the property.</param> 272 /// <param name="expectedValue">Expected value of the property.</param>
178 /// <param name="ignoreCase">Ignore case when comparing the expected and act ual values.</param> 273 /// <param name="ignoreCase">Ignore case when comparing the expected and act ual values.</param>
179 private void AllConfigsAssertPropertyEquals( 274 private void AllConfigsAssertPropertyEquals(
180 string pageName, 275 string pageName,
181 string propertyName, 276 string propertyName,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 ignoreCase); 313 ignoreCase);
219 TestUtilities.AssertPropertyContains( 314 TestUtilities.AssertPropertyContains(
220 release_, 315 release_,
221 pageName, 316 pageName,
222 propertyName, 317 propertyName,
223 expectedValue, 318 expectedValue,
224 ignoreCase); 319 ignoreCase);
225 } 320 }
226 } 321 }
227 } 322 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698