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

Side by Side Diff: visual_studio/NativeClientVSAddIn/UnitTests/ProjectSettingsTest.cs

Issue 10830151: VS Add-in more properties and improvements (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;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 } 72 }
73 73
74 /// <summary> 74 /// <summary>
75 /// This is run before each test to create test resources. 75 /// This is run before each test to create test resources.
76 /// </summary> 76 /// </summary>
77 [TestInitialize] 77 [TestInitialize]
78 public void TestSetup() 78 public void TestSetup()
79 { 79 {
80 dte_ = TestUtilities.StartVisualStudioInstance(); 80 dte_ = TestUtilities.StartVisualStudioInstance();
81 try
82 {
83 TestUtilities.AssertAddinLoaded(dte_, NativeClientVSAddIn.Strings.AddInN ame);
84 }
85 catch
86 {
87 TestUtilities.CleanUpVisualStudioInstance(dte_);
88 throw;
89 }
81 } 90 }
82 91
83 /// <summary> 92 /// <summary>
84 /// This is run after each test to clean up things created in TestSetup(). 93 /// This is run after each test to clean up things created in TestSetup().
85 /// </summary> 94 /// </summary>
86 [TestCleanup] 95 [TestCleanup]
87 public void TestCleanup() 96 public void TestCleanup()
88 { 97 {
89 TestUtilities.CleanUpVisualStudioInstance(dte_); 98 TestUtilities.CleanUpVisualStudioInstance(dte_);
90 } 99 }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 /// </summary> 229 /// </summary>
221 /// <param name="naclSolution">Path to the solution file to verify.</param> 230 /// <param name="naclSolution">Path to the solution file to verify.</param>
222 private void VerifyDefaultPepperSettings(string naclSolution) 231 private void VerifyDefaultPepperSettings(string naclSolution)
223 { 232 {
224 OpenSolutionAndGetProperties(naclSolution, NativeClientVSAddIn.Strings.Pep perPlatformName); 233 OpenSolutionAndGetProperties(naclSolution, NativeClientVSAddIn.Strings.Pep perPlatformName);
225 234
226 string page; 235 string page;
227 236
228 // General 237 // General
229 page = "ConfigurationGeneral"; 238 page = "ConfigurationGeneral";
230 AllConfigsAssertPropertyEquals(page, "OutDir", @"$(ProjectDir)Win\", true) ; 239 AllConfigsAssertPropertyEquals(page, "OutDir", @"$(ProjectDir)win\", true) ;
231 AllConfigsAssertPropertyEquals(page, "IntDir", @"$(ProjectDir)Intermediate \Win\", true); 240 AllConfigsAssertPropertyEquals(page, "IntDir", @"$(ProjectDir)win\$(Config uration)\", true);
232 AllConfigsAssertPropertyEquals(page, "TargetExt", ".dll", true); 241 AllConfigsAssertPropertyEquals(page, "TargetExt", ".dll", true);
233 AllConfigsAssertPropertyEquals(page, "ConfigurationType", "DynamicLibrary" , true); 242 AllConfigsAssertPropertyEquals(page, "ConfigurationType", "DynamicLibrary" , true);
234 AllConfigsAssertPropertyEquals(page, "VSNaClSDKRoot", @"$(NACL_SDK_ROOT)\" , false); 243 AllConfigsAssertPropertyEquals(page, "VSNaClSDKRoot", @"$(NACL_SDK_ROOT)\" , false);
244 AllConfigsAssertPropertyEquals(page, "NaClWebServerPort", "5103", false);
235 AllConfigsAssertPropertyEquals(page, "CharacterSet", "Unicode", false); 245 AllConfigsAssertPropertyEquals(page, "CharacterSet", "Unicode", false);
246 AllConfigsAssertPropertyIsNotNullOrEmpty(page, "NaClAddInVersion");
236 247
237 // Debugging 248 // Debugging
238 page = "WindowsLocalDebugger"; 249 page = "WindowsLocalDebugger";
250 string chromePath = System.Environment.GetEnvironmentVariable(
251 NativeClientVSAddIn.Strings.ChromePathEnvironmentVariable);
239 AllConfigsAssertPropertyEquals( 252 AllConfigsAssertPropertyEquals(
240 page, "LocalDebuggerCommand", @"$(CHROME_PATH)", true); 253 page, "LocalDebuggerCommand", chromePath, true);
241 254
255 string propName = "LocalDebuggerCommandArguments";
256 string dataDir = "--user-data-dir=\"$(ProjectDir)/chrome_data\"";
257 string address = "localhost:$(NaClWebServerPort)";
258 string naclFlag = "--enable-nacl";
242 string targetFlag = "--register-pepper-plugins=\"$(TargetPath)\";applicati on/x-nacl"; 259 string targetFlag = "--register-pepper-plugins=\"$(TargetPath)\";applicati on/x-nacl";
243 string serverFlag = "localhost:5103"; 260 string noSandBoxFlag = "--no-sandbox";
244 string debuggerFlag = "--wait-for-debugger-children"; 261 string debugChildrenFlag = "--wait-for-debugger-children";
245 TestUtilities.AssertPropertyEquals( 262 AllConfigsAssertPropertyContains(page, propName, dataDir, true);
246 debug_, 263 AllConfigsAssertPropertyContains(page, propName, address, true);
247 page, 264 AllConfigsAssertPropertyContains(page, propName, naclFlag, true);
248 "LocalDebuggerCommandArguments", 265 AllConfigsAssertPropertyContains(page, propName, targetFlag, true);
249 string.Format("{0} {1} {2}", targetFlag, serverFlag, debuggerFlag), 266 TestUtilities.AssertPropertyContains(debug_, page, propName, debugChildren Flag, true);
250 true); 267 TestUtilities.AssertPropertyContains(debug_, page, propName, noSandBoxFlag , true);
251 TestUtilities.AssertPropertyEquals(
252 release_,
253 page,
254 "LocalDebuggerCommandArguments",
255 string.Format("{0} {1}", targetFlag, serverFlag),
256 true);
257 268
258 // VC++ Directories 269 // VC++ Directories
259 page = "ConfigurationDirectories"; 270 page = "ConfigurationDirectories";
260 AllConfigsAssertPropertyContains(page, "IncludePath", @"$(VSNaClSDKRoot)in clude;", true); 271 AllConfigsAssertPropertyContains(page, "IncludePath", @"$(VSNaClSDKRoot)in clude;", true);
261 AllConfigsAssertPropertyContains(page, "IncludePath", @"$(VCInstallDir)inc lude", true); 272 AllConfigsAssertPropertyContains(page, "IncludePath", @"$(VCInstallDir)inc lude", true);
262 AllConfigsAssertPropertyContains( 273 AllConfigsAssertPropertyContains(
263 page, "LibraryPath", @"$(VSNaClSDKRoot)lib\win_x86_32_host;", true); 274 page, "LibraryPath", @"$(VSNaClSDKRoot)lib\win_x86_32_host\$(Configura tion);", true);
264 AllConfigsAssertPropertyContains(page, "LibraryPath", @"$(VCInstallDir)lib ", true); 275 AllConfigsAssertPropertyContains(page, "LibraryPath", @"$(VCInstallDir)lib ", true);
265 276
266 // C/C++ Code Generation 277 // C/C++ Code Generation
267 page = "CL"; 278 page = "CL";
268 TestUtilities.AssertPropertyEquals(release_, page, "RuntimeLibrary", "Mult iThreaded", false); 279 TestUtilities.AssertPropertyEquals(release_, page, "RuntimeLibrary", "Mult iThreaded", false);
269 TestUtilities.AssertPropertyEquals( 280 TestUtilities.AssertPropertyEquals(
270 debug_, page, "RuntimeLibrary", "MultiThreadedDebug", false); 281 debug_, page, "RuntimeLibrary", "MultiThreadedDebug", false);
271 TestUtilities.AssertPropertyEquals(release_, page, "BasicRuntimeChecks", " Default", false); 282 TestUtilities.AssertPropertyEquals(release_, page, "BasicRuntimeChecks", " Default", false);
272 TestUtilities.AssertPropertyEquals( 283 TestUtilities.AssertPropertyEquals(
273 debug_, page, "BasicRuntimeChecks", "EnableFastChecks", false); 284 debug_, page, "BasicRuntimeChecks", "EnableFastChecks", false);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 private void VerifyDefaultNaClSettings(string naclSolution) 318 private void VerifyDefaultNaClSettings(string naclSolution)
308 { 319 {
309 OpenSolutionAndGetProperties(naclSolution, NativeClientVSAddIn.Strings.NaC lPlatformName); 320 OpenSolutionAndGetProperties(naclSolution, NativeClientVSAddIn.Strings.NaC lPlatformName);
310 321
311 string page; 322 string page;
312 323
313 // General 324 // General
314 page = "ConfigurationGeneral"; 325 page = "ConfigurationGeneral";
315 AllConfigsAssertPropertyEquals(page, "OutDir", @"$(ProjectDir)$(ToolchainN ame)\", true); 326 AllConfigsAssertPropertyEquals(page, "OutDir", @"$(ProjectDir)$(ToolchainN ame)\", true);
316 AllConfigsAssertPropertyEquals( 327 AllConfigsAssertPropertyEquals(
317 page, "IntDir", @"$(ProjectDir)Intermediate\$(ToolchainName)\", true); 328 page, "IntDir", @"$(ProjectDir)$(ToolchainName)\$(Configuration)\", tr ue);
318 AllConfigsAssertPropertyEquals(page, "ToolchainName", "newlib", true); 329 AllConfigsAssertPropertyEquals(page, "ToolchainName", "newlib", true);
319 AllConfigsAssertPropertyEquals(page, "PlatformToolset", "win_x86_$(Toolcha inName)", true); 330 AllConfigsAssertPropertyEquals(page, "PlatformToolset", "win_x86_$(Toolcha inName)", true);
320 AllConfigsAssertPropertyEquals(page, "TargetArchitecture", "x86_64", true) ; 331 AllConfigsAssertPropertyEquals(page, "TargetArchitecture", "x86_64", true) ;
321 AllConfigsAssertPropertyEquals(page, "VSNaClSDKRoot", @"$(NACL_SDK_ROOT)\" , false); 332 AllConfigsAssertPropertyEquals(page, "VSNaClSDKRoot", @"$(NACL_SDK_ROOT)\" , false);
322 AllConfigsAssertPropertyEquals(page, "NaClManifestPath", string.Empty, fal se); 333 AllConfigsAssertPropertyEquals(page, "NaClManifestPath", string.Empty, fal se);
323 AllConfigsAssertPropertyEquals( 334 AllConfigsAssertPropertyEquals(
324 page, "NaClIrtPath", @"$(VSNaClSDKRoot)\tools\irt_x86_64.nexe", false) ; 335 page, "NaClIrtPath", @"$(VSNaClSDKRoot)\tools\irt_x86_64.nexe", false) ;
336 AllConfigsAssertPropertyEquals(page, "NaClWebServerPort", "5103", false);
337 AllConfigsAssertPropertyIsNotNullOrEmpty(page, "NaClAddInVersion");
325 338
326 // Debugging 339 // Debugging
327 page = "WindowsLocalDebugger"; 340 page = "WindowsLocalDebugger";
341 string chromePath = System.Environment.GetEnvironmentVariable(
342 NativeClientVSAddIn.Strings.ChromePathEnvironmentVariable);
328 AllConfigsAssertPropertyEquals( 343 AllConfigsAssertPropertyEquals(
329 page, "LocalDebuggerCommand", @"$(CHROME_PATH)", true); 344 page, "LocalDebuggerCommand", chromePath, true);
330 TestUtilities.AssertPropertyEquals( 345
331 debug_, 346 string propName = "LocalDebuggerCommandArguments";
332 page, 347 string dataDir = "--user-data-dir=\"$(ProjectDir)/chrome_data\"";
333 "LocalDebuggerCommandArguments", 348 string address = "localhost:$(NaClWebServerPort)";
334 "--enable-nacl-debug --no-sandbox localhost:5103", 349 string naclFlag = "--enable-nacl";
335 true); 350 string naclDebugFlag = "--enable-nacl-debug";
336 TestUtilities.AssertPropertyEquals( 351 string noSandBoxFlag = "--no-sandbox";
337 release_, page, "LocalDebuggerCommandArguments", "localhost:5103", tru e); 352 TestUtilities.AssertPropertyContains(debug_, page, propName, dataDir, true );
353 TestUtilities.AssertPropertyContains(debug_, page, propName, address, true );
354 TestUtilities.AssertPropertyContains(debug_, page, propName, naclFlag, tru e);
355 TestUtilities.AssertPropertyContains(debug_, page, propName, naclDebugFlag , true);
356 TestUtilities.AssertPropertyContains(debug_, page, propName, noSandBoxFlag , true);
357 TestUtilities.AssertPropertyContains(release_, page, propName, dataDir, tr ue);
358 TestUtilities.AssertPropertyContains(release_, page, propName, address, tr ue);
359 TestUtilities.AssertPropertyContains(release_, page, propName, naclFlag, t rue);
338 360
339 // VC++ Directories 361 // VC++ Directories
340 page = "ConfigurationDirectories"; 362 page = "ConfigurationDirectories";
341 AllConfigsAssertPropertyContains(page, "IncludePath", @"$(VSNaClSDKRoot)in clude;", true); 363 AllConfigsAssertPropertyContains(page, "IncludePath", @"$(VSNaClSDKRoot)in clude;", true);
342 AllConfigsAssertPropertyContains(page, "LibraryPath", @"$(VSNaClSDKRoot)li b;", true); 364 AllConfigsAssertPropertyContains(page, "LibraryPath", @"$(VSNaClSDKRoot)li b;", true);
343 365
344 // C/C++ General 366 // C/C++ General
345 page = "CL"; 367 page = "CL";
346 TestUtilities.AssertPropertyEquals( 368 TestUtilities.AssertPropertyEquals(
347 debug_, page, "GenerateDebuggingInformation", "true", false); 369 debug_, page, "GenerateDebuggingInformation", "true", false);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 /// <summary> 401 /// <summary>
380 /// Helper function which opens the given solution, sets the configuration a nd platform and 402 /// Helper function which opens the given solution, sets the configuration a nd platform and
381 /// tries to compile, failing the test if the build does not succeed. 403 /// tries to compile, failing the test if the build does not succeed.
382 /// </summary> 404 /// </summary>
383 /// <param name="solutionPath">Path to the solution to open.</param> 405 /// <param name="solutionPath">Path to the solution to open.</param>
384 /// <param name="configName">Solution Configuration name (Debug or Release). </param> 406 /// <param name="configName">Solution Configuration name (Debug or Release). </param>
385 /// <param name="platformName">Platform name.</param> 407 /// <param name="platformName">Platform name.</param>
386 private void TryCompile(string solutionPath, string configName, string platf ormName) 408 private void TryCompile(string solutionPath, string configName, string platf ormName)
387 { 409 {
388 string failFormat = "Project compile failed for {0} platform {1} config. B uild output: {2}"; 410 string failFormat = "Project compile failed for {0} platform {1} config. B uild output: {2}";
389 411 string cygwinWarningFormat = "Did not pass cygwin nodosfilewarning environ ment var to tools"
412 + " Platform: {0}, configuration: {1}";
413 StringComparison ignoreCase = StringComparison.InvariantCultureIgnoreCase;
414
390 // Open Debug configuration and build. 415 // Open Debug configuration and build.
391 dte_.Solution.Open(solutionPath); 416 dte_.Solution.Open(solutionPath);
392 TestUtilities.SetSolutionConfiguration( 417 TestUtilities.SetSolutionConfiguration(
393 dte_, TestUtilities.BlankNaClProjectUniqueName, configName, platformNa me); 418 dte_, TestUtilities.BlankNaClProjectUniqueName, configName, platformNa me);
394 dte_.Solution.SolutionBuild.Build(true); 419 dte_.Solution.SolutionBuild.Build(true);
395 420
396 string compileOutput = TestUtilities.GetPaneText( 421 string compileOutput = TestUtilities.GetPaneText(
397 dte_.ToolWindows.OutputWindow.OutputWindowPanes.Item("Build")); 422 dte_.ToolWindows.OutputWindow.OutputWindowPanes.Item("Build"));
398 Assert.IsTrue( 423 Assert.IsTrue(
399 compileOutput.Contains("Build succeeded.", StringComparison.InvariantC ultureIgnoreCase), 424 compileOutput.Contains("Build succeeded.", ignoreCase),
400 string.Format(failFormat, platformName, configName, compileOutput)); 425 string.Format(failFormat, platformName, configName, compileOutput));
426 Assert.IsFalse(
427 compileOutput.Contains("MS-DOS style path detected", ignoreCase),
428 string.Format(cygwinWarningFormat, platformName, configName));
429
401 dte_.Solution.Close(); 430 dte_.Solution.Close();
402 } 431 }
403 432
404 /// <summary> 433 /// <summary>
405 /// Helper function to reduce repeated code. Opens the given solution and s ets the debug_ 434 /// Helper function to reduce repeated code. Opens the given solution and s ets the debug_
406 /// and release_ member variables to point to the given platform type. 435 /// and release_ member variables to point to the given platform type.
407 /// </summary> 436 /// </summary>
408 /// <param name="solutionPath">Path to the solution to open.</param> 437 /// <param name="solutionPath">Path to the solution to open.</param>
409 /// <param name="platformName">Platform type to load.</param> 438 /// <param name="platformName">Platform type to load.</param>
410 private void OpenSolutionAndGetProperties(string solutionPath, string platfo rmName) 439 private void OpenSolutionAndGetProperties(string solutionPath, string platfo rmName)
(...skipping 29 matching lines...) Expand all
440 TestUtilities.AssertPropertyEquals( 469 TestUtilities.AssertPropertyEquals(
441 release_, 470 release_,
442 pageName, 471 pageName,
443 propertyName, 472 propertyName,
444 expectedValue, 473 expectedValue,
445 ignoreCase); 474 ignoreCase);
446 } 475 }
447 476
448 /// <summary> 477 /// <summary>
449 /// Tests that a given property contains a specific string for both Debug an d Release 478 /// Tests that a given property contains a specific string for both Debug an d Release
450 /// configurations under the NaCl platform. 479 /// configurations under the current test's platform.
451 /// </summary> 480 /// </summary>
452 /// <param name="pageName">Property page name where property resides.</param > 481 /// <param name="pageName">Property page name where property resides.</param >
453 /// <param name="propertyName">Name of the property to check.</param> 482 /// <param name="propertyName">Name of the property to check.</param>
454 /// <param name="expectedValue">Expected value of the property.</param> 483 /// <param name="expectedValue">Expected value of the property.</param>
455 /// <param name="ignoreCase">Ignore case when comparing the expected and act ual values.</param> 484 /// <param name="ignoreCase">Ignore case when comparing the expected and act ual values.</param>
456 private void AllConfigsAssertPropertyContains( 485 private void AllConfigsAssertPropertyContains(
457 string pageName, 486 string pageName,
458 string propertyName, 487 string propertyName,
459 string expectedValue, 488 string expectedValue,
460 bool ignoreCase) 489 bool ignoreCase)
461 { 490 {
462 TestUtilities.AssertPropertyContains( 491 TestUtilities.AssertPropertyContains(
463 debug_, 492 debug_,
464 pageName, 493 pageName,
465 propertyName, 494 propertyName,
466 expectedValue, 495 expectedValue,
467 ignoreCase); 496 ignoreCase);
468 TestUtilities.AssertPropertyContains( 497 TestUtilities.AssertPropertyContains(
469 release_, 498 release_,
470 pageName, 499 pageName,
471 propertyName, 500 propertyName,
472 expectedValue, 501 expectedValue,
473 ignoreCase); 502 ignoreCase);
474 } 503 }
504
505 /// <summary>
506 /// Tests that a given property's value is not null or empty for both Debug and Release
507 /// configurations under the current test's platform.
508 /// </summary>
509 /// <param name="pageName">Property page name where property resides.</param >
510 /// <param name="propertyName">Name of the property to check.</param>
511 private void AllConfigsAssertPropertyIsNotNullOrEmpty(
512 string pageName,
513 string propertyName)
514 {
515 TestUtilities.AssertPropertyIsNotNullOrEmpty(
516 debug_,
517 pageName,
518 propertyName);
519 TestUtilities.AssertPropertyIsNotNullOrEmpty(
520 release_,
521 pageName,
522 propertyName);
523 }
475 } 524 }
476 } 525 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698