diff options
Diffstat (limited to 'src/test/burn/TestBA/TestBA.cs')
-rw-r--r-- | src/test/burn/TestBA/TestBA.cs | 91 |
1 files changed, 60 insertions, 31 deletions
diff --git a/src/test/burn/TestBA/TestBA.cs b/src/test/burn/TestBA/TestBA.cs index 3688e028..c219ce9c 100644 --- a/src/test/burn/TestBA/TestBA.cs +++ b/src/test/burn/TestBA/TestBA.cs | |||
@@ -21,7 +21,7 @@ namespace WixToolset.Test.BA | |||
21 | private Form dummyWindow; | 21 | private Form dummyWindow; |
22 | private IntPtr windowHandle; | 22 | private IntPtr windowHandle; |
23 | private LaunchAction action; | 23 | private LaunchAction action; |
24 | private ManualResetEvent wait; | 24 | private readonly ManualResetEvent wait; |
25 | private int result; | 25 | private int result; |
26 | 26 | ||
27 | private string updateBundlePath; | 27 | private string updateBundlePath; |
@@ -397,6 +397,35 @@ namespace WixToolset.Test.BA | |||
397 | } | 397 | } |
398 | } | 398 | } |
399 | 399 | ||
400 | protected override void OnExecutePackageComplete(ExecutePackageCompleteEventArgs args) | ||
401 | { | ||
402 | bool logTestRegistryValue; | ||
403 | string recordTestRegistryValue = this.ReadPackageAction(args.PackageId, "RecordTestRegistryValue"); | ||
404 | if (!String.IsNullOrEmpty(recordTestRegistryValue) && Boolean.TryParse(recordTestRegistryValue, out logTestRegistryValue) && logTestRegistryValue) | ||
405 | { | ||
406 | var value = this.ReadTestRegistryValue(args.PackageId); | ||
407 | this.Log("TestRegistryValue: {0}, Version, '{1}'", args.PackageId, value); | ||
408 | } | ||
409 | } | ||
410 | |||
411 | protected override void OnExecuteProcessCancel(ExecuteProcessCancelEventArgs args) | ||
412 | { | ||
413 | BOOTSTRAPPER_EXECUTEPROCESSCANCEL_ACTION action; | ||
414 | string actionValue = this.ReadPackageAction(args.PackageId, "ProcessCancelAction"); | ||
415 | if (actionValue != null && TryParseEnum<BOOTSTRAPPER_EXECUTEPROCESSCANCEL_ACTION>(actionValue, out action)) | ||
416 | { | ||
417 | args.Action = action; | ||
418 | } | ||
419 | |||
420 | if (args.Action == BOOTSTRAPPER_EXECUTEPROCESSCANCEL_ACTION.Abandon) | ||
421 | { | ||
422 | // Give time to the process to start before its files are deleted. | ||
423 | Thread.Sleep(2000); | ||
424 | } | ||
425 | |||
426 | this.Log("OnExecuteProcessCancel({0})", args.Action); | ||
427 | } | ||
428 | |||
400 | protected override void OnExecuteFilesInUse(ExecuteFilesInUseEventArgs args) | 429 | protected override void OnExecuteFilesInUse(ExecuteFilesInUseEventArgs args) |
401 | { | 430 | { |
402 | this.Log("OnExecuteFilesInUse() - package: {0}, source: {1}, retries remaining: {2}, data: {3}", args.PackageId, args.Source, this.retryExecuteFilesInUse, String.Join(", ", args.Files.ToArray())); | 431 | this.Log("OnExecuteFilesInUse() - package: {0}, source: {1}, retries remaining: {2}, data: {3}", args.PackageId, args.Source, this.retryExecuteFilesInUse, String.Join(", ", args.Files.ToArray())); |
@@ -488,43 +517,34 @@ namespace WixToolset.Test.BA | |||
488 | private void TestVariables() | 517 | private void TestVariables() |
489 | { | 518 | { |
490 | // First make sure we can check and get standard variables of each type. | 519 | // First make sure we can check and get standard variables of each type. |
520 | if (this.Engine.ContainsVariable("WindowsFolder")) | ||
491 | { | 521 | { |
492 | string value = null; | 522 | string value = this.Engine.GetVariableString("WindowsFolder"); |
493 | if (this.Engine.ContainsVariable("WindowsFolder")) | 523 | this.Engine.Log(LogLevel.Verbose, String.Format("TEST: Successfully retrieved a string variable: WindowsFolder '{0}'", value)); |
494 | { | 524 | } |
495 | value = this.Engine.GetVariableString("WindowsFolder"); | 525 | else |
496 | this.Engine.Log(LogLevel.Verbose, "TEST: Successfully retrieved a string variable: WindowsFolder"); | 526 | { |
497 | } | 527 | throw new Exception("Engine did not define a standard variable: WindowsFolder"); |
498 | else | ||
499 | { | ||
500 | throw new Exception("Engine did not define a standard variable: WindowsFolder"); | ||
501 | } | ||
502 | } | 528 | } |
503 | 529 | ||
530 | if (this.Engine.ContainsVariable("NTProductType")) | ||
504 | { | 531 | { |
505 | long value = 0; | 532 | long value = this.Engine.GetVariableNumeric("NTProductType"); |
506 | if (this.Engine.ContainsVariable("NTProductType")) | 533 | this.Engine.Log(LogLevel.Verbose, String.Format("TEST: Successfully retrieved a numeric variable: NTProductType '{0}'", value)); |
507 | { | 534 | } |
508 | value = this.Engine.GetVariableNumeric("NTProductType"); | 535 | else |
509 | this.Engine.Log(LogLevel.Verbose, "TEST: Successfully retrieved a numeric variable: NTProductType"); | 536 | { |
510 | } | 537 | throw new Exception("Engine did not define a standard variable: NTProductType"); |
511 | else | ||
512 | { | ||
513 | throw new Exception("Engine did not define a standard variable: NTProductType"); | ||
514 | } | ||
515 | } | 538 | } |
516 | 539 | ||
540 | if (this.Engine.ContainsVariable("VersionMsi")) | ||
517 | { | 541 | { |
518 | string value = null; | 542 | string value = this.Engine.GetVariableVersion("VersionMsi"); |
519 | if (this.Engine.ContainsVariable("VersionMsi")) | 543 | this.Engine.Log(LogLevel.Verbose, String.Format("TEST: Successfully retrieved a version variable: VersionMsi '{0}'", value)); |
520 | { | 544 | } |
521 | value = this.Engine.GetVariableVersion("VersionMsi"); | 545 | else |
522 | this.Engine.Log(LogLevel.Verbose, "TEST: Successfully retrieved a version variable: VersionMsi"); | 546 | { |
523 | } | 547 | throw new Exception("Engine did not define a standard variable: VersionMsi"); |
524 | else | ||
525 | { | ||
526 | throw new Exception("Engine did not define a standard variable: VersionMsi"); | ||
527 | } | ||
528 | } | 548 | } |
529 | 549 | ||
530 | // Now validate that Contians returns false for non-existant variables of each type. | 550 | // Now validate that Contians returns false for non-existant variables of each type. |
@@ -596,6 +616,15 @@ namespace WixToolset.Test.BA | |||
596 | } | 616 | } |
597 | } | 617 | } |
598 | 618 | ||
619 | private string ReadTestRegistryValue(string name) | ||
620 | { | ||
621 | string testName = this.Engine.GetVariableString("TestGroupName"); | ||
622 | using (RegistryKey testKey = Registry.LocalMachine.OpenSubKey(String.Format(@"Software\WiX\Tests\{0}\{1}", testName, name))) | ||
623 | { | ||
624 | return testKey == null ? null : testKey.GetValue("Version") as string; | ||
625 | } | ||
626 | } | ||
627 | |||
599 | private static bool TryParseEnum<T>(string value, out T t) | 628 | private static bool TryParseEnum<T>(string value, out T t) |
600 | { | 629 | { |
601 | try | 630 | try |