OLD | NEW |
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 /// The below string holds the path to a NaCl solution used in some tests. |
23 /// that has not had the custom platforms added (PPAPI and NaCl). Immediatel
y | 23 /// A 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 /// In this solution, NaCl and pepper settings are copied from 'Empty' initi
al settings. |
26 /// the project settings are based on the most recent template. Because unit
-tests | |
27 /// run in any order, the solution should not be written to in any test. | |
28 /// </summary> | 26 /// </summary> |
29 private const string ProjectSettingsTestSolution = | 27 private static string naclSolutionEmptyInitialization; |
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 | 28 |
38 /// <summary> | 29 /// <summary> |
39 /// The main visual studio object. | 30 /// The main visual studio object. |
40 /// </summary> | 31 /// </summary> |
41 private DTE2 dte_; | 32 private DTE2 dte_; |
42 | 33 |
43 /// <summary> | 34 /// <summary> |
44 /// The project configuration for debug settings of a test's platform. | 35 /// The project configuration for debug settings of a test's platform. |
45 /// </summary> | 36 /// </summary> |
46 private VCConfiguration debug_; | 37 private VCConfiguration debug_; |
47 | 38 |
48 /// <summary> | 39 /// <summary> |
49 /// The project configuration for release settings of a test's platform | 40 /// The project configuration for release settings of a test's platform |
50 /// </summary> | 41 /// </summary> |
51 private VCConfiguration release_; | 42 private VCConfiguration release_; |
52 | 43 |
53 /// <summary> | 44 /// <summary> |
54 /// Gets or sets the test context which provides information about, | 45 /// Gets or sets the test context which provides information about, |
55 /// and functionality for the current test run. | 46 /// and functionality for the current test run. |
56 /// </summary> | 47 /// </summary> |
57 public TestContext TestContext { get; set; } | 48 public TestContext TestContext { get; set; } |
58 | 49 |
59 /// <summary> | 50 /// <summary> |
60 /// This is run one time before any test methods are called. Here we set-up
the testing copy | 51 /// This is run one time before any test methods are called. Here we set-up
test-copies of |
61 /// of ProjectSettingsTest to use the most up-to-date custom project setting
s. | 52 /// new NaCl solutions for use in the tests. |
62 /// </summary> | 53 /// </summary> |
63 /// <param name="testContext">Holds information about the current test run</
param> | 54 /// <param name="testContext">Holds information about the current test run</
param> |
64 [ClassInitialize] | 55 [ClassInitialize] |
65 public static void ClassSetup(TestContext testContext) | 56 public static void ClassSetup(TestContext testContext) |
66 { | 57 { |
67 DTE2 dte = null; | 58 DTE2 dte = TestUtilities.StartVisualStudioInstance(); |
68 try | 59 try |
69 { | 60 { |
70 dte = TestUtilities.StartVisualStudioInstance(); | 61 naclSolutionEmptyInitialization = TestUtilities.CreateBlankValidNaClSolu
tion( |
71 dte.Solution.Open(testContext.DeploymentDirectory + ProjectSettingsTestS
olution); | 62 dte, |
72 Project proj = dte.Solution.Projects.Item(ProjectSettingsTestProject); | 63 "ProjectSettingsTestEmptyInit", |
73 | |
74 proj.ConfigurationManager.AddPlatform( | |
75 NativeClientVSAddIn.Strings.PepperPlatformName, | 64 NativeClientVSAddIn.Strings.PepperPlatformName, |
76 NativeClientVSAddIn.Strings.PepperPlatformName, | |
77 true); | |
78 | |
79 proj.ConfigurationManager.AddPlatform( | |
80 NativeClientVSAddIn.Strings.NaClPlatformName, | 65 NativeClientVSAddIn.Strings.NaClPlatformName, |
81 NativeClientVSAddIn.Strings.NaClPlatformName, | 66 testContext); |
82 true); | |
83 | |
84 proj.Save(); | |
85 dte.Solution.SaveAs(testContext.DeploymentDirectory + ProjectSettingsTes
tSolution); | |
86 } | 67 } |
87 finally | 68 finally |
88 { | 69 { |
89 TestUtilities.CleanUpVisualStudioInstance(dte); | 70 TestUtilities.CleanUpVisualStudioInstance(dte); |
90 } | 71 } |
91 } | 72 } |
92 | 73 |
93 /// <summary> | 74 /// <summary> |
94 /// This is run before each test to create test resources. | 75 /// This is run before each test to create test resources. |
95 /// </summary> | 76 /// </summary> |
96 [TestInitialize] | 77 [TestInitialize] |
97 public void TestSetup() | 78 public void TestSetup() |
98 { | 79 { |
99 dte_ = TestUtilities.StartVisualStudioInstance(); | 80 dte_ = TestUtilities.StartVisualStudioInstance(); |
100 } | 81 } |
101 | 82 |
102 /// <summary> | 83 /// <summary> |
103 /// This is run after each test to clean up things created in TestSetup(). | 84 /// This is run after each test to clean up things created in TestSetup(). |
104 /// </summary> | 85 /// </summary> |
105 [TestCleanup] | 86 [TestCleanup] |
106 public void TestCleanup() | 87 public void TestCleanup() |
107 { | 88 { |
108 TestUtilities.CleanUpVisualStudioInstance(dte_); | 89 TestUtilities.CleanUpVisualStudioInstance(dte_); |
109 } | 90 } |
110 | 91 |
111 /// <summary> | 92 /// <summary> |
112 /// Test method to check that the PPAPI platform template correctly sets def
ault values. | 93 /// Test method to check that the NaCl platform compiles a test project. |
113 /// </summary> | 94 /// </summary> |
114 [TestMethod] | 95 [TestMethod] |
115 public void VerifyDefaultPepperSettings() | 96 public void CheckNaClCompile() |
116 { | 97 { |
| 98 string naclPlatform = NativeClientVSAddIn.Strings.NaClPlatformName; |
| 99 TryCompile(naclSolutionEmptyInitialization, "Debug", naclPlatform); |
| 100 TryCompile(naclSolutionEmptyInitialization, "Release", naclPlatform); |
| 101 } |
| 102 |
| 103 /// <summary> |
| 104 /// Test method to check that the Pepper platform compiles a test project. |
| 105 /// </summary> |
| 106 [TestMethod] |
| 107 public void CheckPepperCompile() |
| 108 { |
| 109 string pepperPlatform = NativeClientVSAddIn.Strings.PepperPlatformName; |
| 110 TryCompile(naclSolutionEmptyInitialization, "Debug", pepperPlatform); |
| 111 TryCompile(naclSolutionEmptyInitialization, "Release", pepperPlatform); |
| 112 } |
| 113 |
| 114 /// <summary> |
| 115 /// Test method which verifies that NaCl and pepper platforms have correct d
efault properties |
| 116 /// when initialized from the Win32 platform. |
| 117 /// </summary> |
| 118 [TestMethod] |
| 119 public void VerifySettingsWin32Initialization() |
| 120 { |
| 121 string naclSolutionWin32Initialization = TestUtilities.CreateBlankValidNaC
lSolution( |
| 122 dte_, "ProjectSettingsTestWin32Init", "Win32", "Win32", TestContext)
; |
| 123 VerifyDefaultPepperSettings(naclSolutionWin32Initialization); |
| 124 VerifyDefaultNaClSettings(naclSolutionWin32Initialization); |
| 125 |
| 126 // Win32 inherit specific checks on the Pepper platform. |
| 127 OpenSolutionAndGetProperties( |
| 128 naclSolutionWin32Initialization, NativeClientVSAddIn.Strings.PepperPla
tformName); |
| 129 |
| 130 // When inheriting from Win32 preprocessor the PPAPI preprocessor definiti
on gets grouped |
| 131 // into the inherited %(PreprocessorDefinitions) variable. It still exists
but doesn't appear |
| 132 // in the property page, thus we can't check for it here. |
| 133 |
| 134 //// TODO(tysand): When inheriting from Win32 this won't set and the Win32
platform |
| 135 //// incorrectly(?) sets this to true in the Release config even for regul
ar win32 projects. |
| 136 ////TestUtilities.AssertPropertyEquals( |
| 137 //// release_, "Link", "GenerateDebugInformation", "false", false); |
| 138 dte_.Solution.Close(); |
| 139 |
| 140 // NaCl inherit specific checks on the NaCl platform. |
| 141 OpenSolutionAndGetProperties( |
| 142 naclSolutionWin32Initialization, NativeClientVSAddIn.Strings.NaClPlatf
ormName); |
| 143 AllConfigsAssertPropertyEquals("ConfigurationGeneral", "TargetExt", ".so",
true); |
| 144 AllConfigsAssertPropertyEquals( |
| 145 "ConfigurationGeneral", "ConfigurationType", "DynamicLibrary", true); |
| 146 dte_.Solution.Close(); |
| 147 } |
| 148 |
| 149 /// <summary> |
| 150 /// Test method which verifies that the NaCl platform has correct default pr
operties |
| 151 /// when initialized from the Pepper platform. And that the pepper platform
has the correct |
| 152 /// settings when initialized from the 'empty' settings. |
| 153 /// </summary> |
| 154 [TestMethod] |
| 155 public void VerifySettingsPepperInitialization() |
| 156 { |
| 157 string naclSolutionPepperInitialization = TestUtilities.CreateBlankValidNa
ClSolution( |
| 158 dte_, |
| 159 "ProjectSettingsTestPepperInit", |
| 160 NativeClientVSAddIn.Strings.PepperPlatformName, |
| 161 NativeClientVSAddIn.Strings.PepperPlatformName, |
| 162 TestContext); |
| 163 VerifyDefaultPepperSettings(naclSolutionPepperInitialization); |
| 164 VerifyDefaultNaClSettings(naclSolutionPepperInitialization); |
| 165 |
| 166 // Pepper inherit specific checks on the Pepper platform. |
| 167 OpenSolutionAndGetProperties( |
| 168 naclSolutionPepperInitialization, NativeClientVSAddIn.Strings.PepperPl
atformName); |
| 169 AllConfigsAssertPropertyContains("CL", "PreprocessorDefinitions", "PPAPI",
false); |
| 170 TestUtilities.AssertPropertyEquals( |
| 171 release_, "Link", "GenerateDebugInformation", "false", false); |
| 172 dte_.Solution.Close(); |
| 173 |
| 174 // NaCl inherit specific checks on the NaCl platform. |
| 175 OpenSolutionAndGetProperties( |
| 176 naclSolutionPepperInitialization, NativeClientVSAddIn.Strings.NaClPlat
formName); |
| 177 AllConfigsAssertPropertyEquals("ConfigurationGeneral", "TargetExt", ".nexe
", true); |
| 178 AllConfigsAssertPropertyEquals( |
| 179 "ConfigurationGeneral", "ConfigurationType", "Application", true); |
| 180 dte_.Solution.Close(); |
| 181 } |
| 182 |
| 183 /// <summary> |
| 184 /// Test method which verifies that the Pepper platform has correct default
properties |
| 185 /// when initialized from the NaCl platform. And that the NaCl platform has
the correct |
| 186 /// settings when initialized from the 'empty' settings. |
| 187 /// </summary> |
| 188 [TestMethod] |
| 189 public void VerifySettingsNaClInitialization() |
| 190 { |
| 191 string naclSolutionNaClInitialization = TestUtilities.CreateBlankValidNaCl
Solution( |
| 192 dte_, |
| 193 "ProjectSettingsTestNaClInit", |
| 194 NativeClientVSAddIn.Strings.NaClPlatformName, |
| 195 NativeClientVSAddIn.Strings.NaClPlatformName, |
| 196 TestContext); |
| 197 VerifyDefaultPepperSettings(naclSolutionNaClInitialization); |
| 198 VerifyDefaultNaClSettings(naclSolutionNaClInitialization); |
| 199 |
| 200 // NaCl inherit specific checks on the Pepper platform. |
| 201 OpenSolutionAndGetProperties( |
| 202 naclSolutionNaClInitialization, NativeClientVSAddIn.Strings.PepperPlat
formName); |
| 203 AllConfigsAssertPropertyContains("CL", "PreprocessorDefinitions", "PPAPI",
false); |
| 204 TestUtilities.AssertPropertyEquals( |
| 205 release_, "Link", "GenerateDebugInformation", "false", false); |
| 206 dte_.Solution.Close(); |
| 207 |
| 208 // NaCl inherit specific checks on the NaCl platform. |
| 209 OpenSolutionAndGetProperties( |
| 210 naclSolutionNaClInitialization, NativeClientVSAddIn.Strings.NaClPlatfo
rmName); |
| 211 AllConfigsAssertPropertyEquals("ConfigurationGeneral", "TargetExt", ".nexe
", true); |
| 212 AllConfigsAssertPropertyEquals( |
| 213 "ConfigurationGeneral", "ConfigurationType", "Application", true); |
| 214 dte_.Solution.Close(); |
| 215 } |
| 216 |
| 217 /// <summary> |
| 218 /// Method to run a battery of tests on a particular solution. Checks that
all Pepper platform |
| 219 /// settings are set correctly. |
| 220 /// </summary> |
| 221 /// <param name="naclSolution">Path to the solution file to verify.</param> |
| 222 private void VerifyDefaultPepperSettings(string naclSolution) |
| 223 { |
| 224 OpenSolutionAndGetProperties(naclSolution, NativeClientVSAddIn.Strings.Pep
perPlatformName); |
| 225 |
117 string page; | 226 string page; |
118 | 227 |
119 // Extract the debug and release configurations for Pepper from the projec
t. | |
120 dte_.Solution.Open(TestContext.DeploymentDirectory + ProjectSettingsTestSo
lution); | |
121 Project project = dte_.Solution.Projects.Item(ProjectSettingsTestProject); | |
122 Assert.IsNotNull(project, "Testing project was not found"); | |
123 string pepperPlatform = NativeClientVSAddIn.Strings.PepperPlatformName; | |
124 debug_ = TestUtilities.GetVCConfiguration(project, "Debug", pepperPlatform
); | |
125 release_ = TestUtilities.GetVCConfiguration(project, "Release", pepperPlat
form); | |
126 | |
127 // General | 228 // General |
128 page = "ConfigurationGeneral"; | 229 page = "ConfigurationGeneral"; |
129 AllConfigsAssertPropertyEquals(page, "OutDir", @"$(ProjectDir)Win\", true)
; | 230 AllConfigsAssertPropertyEquals(page, "OutDir", @"$(ProjectDir)Win\", true)
; |
130 AllConfigsAssertPropertyEquals(page, "IntDir", @"$(ProjectDir)Intermediate
\Win\", true); | 231 AllConfigsAssertPropertyEquals(page, "IntDir", @"$(ProjectDir)Intermediate
\Win\", true); |
131 AllConfigsAssertPropertyEquals(page, "TargetExt", ".dll", true); | 232 AllConfigsAssertPropertyEquals(page, "TargetExt", ".dll", true); |
132 AllConfigsAssertPropertyEquals(page, "ConfigurationType", "DynamicLibrary"
, true); | 233 AllConfigsAssertPropertyEquals(page, "ConfigurationType", "DynamicLibrary"
, true); |
133 AllConfigsAssertPropertyEquals(page, "VSNaClSDKRoot", @"$(NACL_SDK_ROOT)\"
, false); | 234 AllConfigsAssertPropertyEquals(page, "VSNaClSDKRoot", @"$(NACL_SDK_ROOT)\"
, false); |
134 | 235 AllConfigsAssertPropertyEquals(page, "CharacterSet", "Unicode", false); |
| 236 |
135 // Debugging | 237 // Debugging |
136 page = "WindowsLocalDebugger"; | 238 page = "WindowsLocalDebugger"; |
137 AllConfigsAssertPropertyEquals( | 239 AllConfigsAssertPropertyEquals( |
138 page, | 240 page, "LocalDebuggerCommand", @"$(CHROME_PATH)", true); |
139 "LocalDebuggerCommand", | 241 |
140 @"$(CHROME_PATH)\chrome.exe", | 242 string targetFlag = "--register-pepper-plugins=\"$(TargetPath)\";applicati
on/x-nacl"; |
141 true); | 243 string serverFlag = "localhost:5103"; |
142 AllConfigsAssertPropertyEquals( | 244 string debuggerFlag = "--wait-for-debugger-children"; |
| 245 TestUtilities.AssertPropertyEquals( |
| 246 debug_, |
143 page, | 247 page, |
144 "LocalDebuggerCommandArguments", | 248 "LocalDebuggerCommandArguments", |
145 "--register-pepper-plugins=\"$(TargetPath)\";application/x-nacl localh
ost:5103", | 249 string.Format("{0} {1} {2}", targetFlag, serverFlag, debuggerFlag), |
| 250 true); |
| 251 TestUtilities.AssertPropertyEquals( |
| 252 release_, |
| 253 page, |
| 254 "LocalDebuggerCommandArguments", |
| 255 string.Format("{0} {1}", targetFlag, serverFlag), |
146 true); | 256 true); |
147 | 257 |
148 // VC++ Directories | 258 // VC++ Directories |
149 page = "ConfigurationDirectories"; | 259 page = "ConfigurationDirectories"; |
150 AllConfigsAssertPropertyContains(page, "IncludePath", @"$(VSNaClSDKRoot)in
clude;", true); | 260 AllConfigsAssertPropertyContains(page, "IncludePath", @"$(VSNaClSDKRoot)in
clude;", true); |
151 AllConfigsAssertPropertyContains(page, "IncludePath", @"$(VCInstallDir)inc
lude", true); | 261 AllConfigsAssertPropertyContains(page, "IncludePath", @"$(VCInstallDir)inc
lude", true); |
152 AllConfigsAssertPropertyContains(page, "LibraryPath", @"$(VSNaClSDKRoot)li
b;", true); | 262 AllConfigsAssertPropertyContains( |
| 263 page, "LibraryPath", @"$(VSNaClSDKRoot)lib\win_x86_32_host;", true); |
153 AllConfigsAssertPropertyContains(page, "LibraryPath", @"$(VCInstallDir)lib
", true); | 264 AllConfigsAssertPropertyContains(page, "LibraryPath", @"$(VCInstallDir)lib
", true); |
154 | 265 |
155 // C/C++ Code Generation | 266 // C/C++ Code Generation |
156 page = "CL"; | 267 page = "CL"; |
| 268 TestUtilities.AssertPropertyEquals(release_, page, "RuntimeLibrary", "Mult
iThreaded", false); |
| 269 TestUtilities.AssertPropertyEquals( |
| 270 debug_, page, "RuntimeLibrary", "MultiThreadedDebug", false); |
| 271 TestUtilities.AssertPropertyEquals(release_, page, "BasicRuntimeChecks", "
Default", false); |
| 272 TestUtilities.AssertPropertyEquals( |
| 273 debug_, page, "BasicRuntimeChecks", "EnableFastChecks", false); |
| 274 TestUtilities.AssertPropertyEquals(release_, page, "MinimalRebuild", "fals
e", false); |
| 275 TestUtilities.AssertPropertyEquals(debug_, page, "MinimalRebuild", "true",
false); |
| 276 TestUtilities.AssertPropertyEquals( |
| 277 release_, page, "DebugInformationFormat", "ProgramDatabase", false); |
| 278 TestUtilities.AssertPropertyEquals( |
| 279 debug_, page, "DebugInformationFormat", "EditAndContinue", false); |
| 280 |
| 281 // C/C++ Optimization |
| 282 TestUtilities.AssertPropertyEquals(debug_, page, "Optimization", "Disabled
", false); |
| 283 TestUtilities.AssertPropertyEquals(release_, page, "Optimization", "MaxSpe
ed", false); |
| 284 |
| 285 // Linker Input |
| 286 page = "Link"; |
| 287 AllConfigsAssertPropertyContains(page, "AdditionalDependencies", "ppapi_cp
p.lib", true); |
| 288 AllConfigsAssertPropertyContains(page, "AdditionalDependencies", "ppapi.li
b", true); |
| 289 |
| 290 // Note: Release check of this property is specific to the platform settin
gs were inherited |
| 291 // from. Checks on release are done in the specific methods testing each i
nherit type. |
| 292 TestUtilities.AssertPropertyEquals(debug_, page, "GenerateDebugInformation
", "true", false); |
| 293 |
| 294 TestUtilities.AssertPropertyEquals(release_, page, "LinkIncremental", "fal
se", false); |
| 295 TestUtilities.AssertPropertyEquals(debug_, page, "LinkIncremental", "true"
, false); |
| 296 |
| 297 AllConfigsAssertPropertyEquals(page, "SubSystem", "Windows", false); |
| 298 |
| 299 dte_.Solution.Close(); |
| 300 } |
| 301 |
| 302 /// <summary> |
| 303 /// Method to run a battery of tests on a particular solution. Checks that
all NaCl platform |
| 304 /// settings are set correctly. |
| 305 /// </summary> |
| 306 /// <param name="naclSolution">Path to the solution file to verify.</param> |
| 307 private void VerifyDefaultNaClSettings(string naclSolution) |
| 308 { |
| 309 OpenSolutionAndGetProperties(naclSolution, NativeClientVSAddIn.Strings.NaC
lPlatformName); |
| 310 |
| 311 string page; |
| 312 |
| 313 // General |
| 314 page = "ConfigurationGeneral"; |
| 315 AllConfigsAssertPropertyEquals(page, "OutDir", @"$(ProjectDir)$(ToolchainN
ame)\", true); |
| 316 AllConfigsAssertPropertyEquals( |
| 317 page, "IntDir", @"$(ProjectDir)Intermediate\$(ToolchainName)\", true); |
| 318 AllConfigsAssertPropertyEquals(page, "ToolchainName", "newlib", true); |
| 319 AllConfigsAssertPropertyEquals(page, "PlatformToolset", "win_x86_$(Toolcha
inName)", true); |
| 320 AllConfigsAssertPropertyEquals(page, "TargetArchitecture", "x86_64", true)
; |
| 321 AllConfigsAssertPropertyEquals(page, "VSNaClSDKRoot", @"$(NACL_SDK_ROOT)\"
, false); |
| 322 |
| 323 // Debugging |
| 324 page = "WindowsLocalDebugger"; |
| 325 AllConfigsAssertPropertyEquals( |
| 326 page, "LocalDebuggerCommand", @"$(CHROME_PATH)", true); |
157 TestUtilities.AssertPropertyEquals( | 327 TestUtilities.AssertPropertyEquals( |
158 debug_, | 328 debug_, |
159 page, | 329 page, |
160 "RuntimeLibrary", | 330 "LocalDebuggerCommandArguments", |
161 "MultiThreadedDebug", | 331 "--enable-nacl-debug --no-sandbox localhost:5103", |
162 false); | 332 true); |
163 TestUtilities.AssertPropertyEquals(release_, page, "RuntimeLibrary", "Mult
iThreaded", false); | 333 TestUtilities.AssertPropertyEquals( |
| 334 release_, page, "LocalDebuggerCommandArguments", "localhost:5103", tru
e); |
| 335 |
| 336 // VC++ Directories |
| 337 page = "ConfigurationDirectories"; |
| 338 AllConfigsAssertPropertyContains(page, "IncludePath", @"$(VSNaClSDKRoot)in
clude;", true); |
| 339 AllConfigsAssertPropertyContains(page, "LibraryPath", @"$(VSNaClSDKRoot)li
b;", true); |
| 340 |
| 341 // C/C++ General |
| 342 page = "CL"; |
| 343 TestUtilities.AssertPropertyEquals( |
| 344 debug_, page, "GenerateDebuggingInformation", "true", false); |
| 345 TestUtilities.AssertPropertyEquals( |
| 346 release_, page, "GenerateDebuggingInformation", "false", false); |
| 347 |
| 348 AllConfigsAssertPropertyEquals(page, "Warnings", "NormalWarnings", true); |
| 349 AllConfigsAssertPropertyEquals(page, "WarningsAsErrors", "false", true); |
| 350 AllConfigsAssertPropertyEquals(page, "ConfigurationType", "$(Configuration
Type)", true); |
| 351 AllConfigsAssertPropertyEquals(page, "UserHeaderDependenciesOnly", "true",
true); |
| 352 AllConfigsAssertPropertyEquals(page, "OutputCommandLine", "true", false); |
| 353 |
| 354 // C/C++ Optimization |
| 355 TestUtilities.AssertPropertyEquals(debug_, page, "OptimizationLevel", "O0"
, false); |
| 356 TestUtilities.AssertPropertyEquals(release_, page, "OptimizationLevel", "O
3", false); |
| 357 |
| 358 // C/C++ Preprocessor |
| 359 AllConfigsAssertPropertyContains(page, "PreprocessorDefinitions", "NACL",
false); |
| 360 |
| 361 // C/C++ Code Generation |
| 362 AllConfigsAssertPropertyEquals(page, "ExceptionHandling", "true", false); |
| 363 |
| 364 // C/C++ Output Files |
| 365 AllConfigsAssertPropertyEquals(page, "ObjectFileName", @"$(IntDir)%(FileNa
me).o", false); |
| 366 |
| 367 // C/C++ Advanced |
| 368 AllConfigsAssertPropertyEquals(page, "CompileAs", "Default", true); |
164 | 369 |
165 // Linker Input | 370 // Linker Input |
166 page = "Link"; | 371 page = "Link"; |
167 AllConfigsAssertPropertyContains(page, "AdditionalDependencies", "ppapi_cp
p.lib", false); | 372 AllConfigsAssertPropertyContains(page, "AdditionalDependencies", "ppapi_cp
p;ppapi", true); |
168 AllConfigsAssertPropertyContains(page, "AdditionalDependencies", "ppapi.li
b", false); | 373 dte_.Solution.Close(); |
169 } | 374 } |
170 | 375 |
171 /// <summary> | 376 /// <summary> |
| 377 /// Helper function which opens the given solution, sets the configuration a
nd platform and |
| 378 /// tries to compile, failing the test if the build does not succeed. |
| 379 /// </summary> |
| 380 /// <param name="solutionPath">Path to the solution to open.</param> |
| 381 /// <param name="configName">Solution Configuration name (Debug or Release).
</param> |
| 382 /// <param name="platformName">Platform name.</param> |
| 383 private void TryCompile(string solutionPath, string configName, string platf
ormName) |
| 384 { |
| 385 string failFormat = "Project compile failed for {0} platform {1} config. B
uild output: {2}"; |
| 386 |
| 387 // Open Debug configuration and build. |
| 388 dte_.Solution.Open(solutionPath); |
| 389 TestUtilities.SetSolutionConfiguration( |
| 390 dte_, TestUtilities.BlankNaClProjectUniqueName, configName, platformNa
me); |
| 391 dte_.Solution.SolutionBuild.Build(true); |
| 392 |
| 393 string compileOutput = TestUtilities.GetPaneText( |
| 394 dte_.ToolWindows.OutputWindow.OutputWindowPanes.Item("Build")); |
| 395 Assert.IsTrue( |
| 396 compileOutput.Contains("Build succeeded.", StringComparison.InvariantC
ultureIgnoreCase), |
| 397 string.Format(failFormat, platformName, configName, compileOutput)); |
| 398 dte_.Solution.Close(); |
| 399 } |
| 400 |
| 401 /// <summary> |
| 402 /// Helper function to reduce repeated code. Opens the given solution and s
ets the debug_ |
| 403 /// and release_ member variables to point to the given platform type. |
| 404 /// </summary> |
| 405 /// <param name="solutionPath">Path to the solution to open.</param> |
| 406 /// <param name="platformName">Platform type to load.</param> |
| 407 private void OpenSolutionAndGetProperties(string solutionPath, string platfo
rmName) |
| 408 { |
| 409 // Extract the debug and release configurations for Pepper from the projec
t. |
| 410 dte_.Solution.Open(solutionPath); |
| 411 Project project = dte_.Solution.Projects.Item(TestUtilities.BlankNaClProje
ctUniqueName); |
| 412 Assert.IsNotNull(project, "Testing project was not found"); |
| 413 debug_ = TestUtilities.GetVCConfiguration(project, "Debug", platformName); |
| 414 release_ = TestUtilities.GetVCConfiguration(project, "Release", platformNa
me); |
| 415 } |
| 416 |
| 417 /// <summary> |
172 /// Tests that a given property has a specific value for both Debug and Rele
ase | 418 /// Tests that a given property has a specific value for both Debug and Rele
ase |
173 /// configurations under the current test's platform. | 419 /// configurations under the current test's platform. |
174 /// </summary> | 420 /// </summary> |
175 /// <param name="pageName">Property page name where property resides.</param
> | 421 /// <param name="pageName">Property page name where property resides.</param
> |
176 /// <param name="propertyName">Name of the property to check.</param> | 422 /// <param name="propertyName">Name of the property to check.</param> |
177 /// <param name="expectedValue">Expected value of the property.</param> | 423 /// <param name="expectedValue">Expected value of the property.</param> |
178 /// <param name="ignoreCase">Ignore case when comparing the expected and act
ual values.</param> | 424 /// <param name="ignoreCase">Ignore case when comparing the expected and act
ual values.</param> |
179 private void AllConfigsAssertPropertyEquals( | 425 private void AllConfigsAssertPropertyEquals( |
180 string pageName, | 426 string pageName, |
181 string propertyName, | 427 string propertyName, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 ignoreCase); | 464 ignoreCase); |
219 TestUtilities.AssertPropertyContains( | 465 TestUtilities.AssertPropertyContains( |
220 release_, | 466 release_, |
221 pageName, | 467 pageName, |
222 propertyName, | 468 propertyName, |
223 expectedValue, | 469 expectedValue, |
224 ignoreCase); | 470 ignoreCase); |
225 } | 471 } |
226 } | 472 } |
227 } | 473 } |
OLD | NEW |