| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
| 2 | |
| 3 | namespace WixToolsetTest.CoreIntegration |
| 4 | { |
| 5 | using System.IO; |
| 6 | using System.Linq; |
| 7 | using WixInternal.Core.TestPackage; |
| 8 | using WixInternal.TestSupport; |
| 9 | using WixToolset.Data; |
| 10 | using Xunit; |
| 11 | |
| 12 | public class UIFixture |
| 13 | { |
| 14 | [Fact] |
| 15 | public void PopulatesControlTables() |
| 16 | { |
| 17 | var folder = TestData.Get(@"TestData"); |
| 18 | |
| 19 | using (var fs = new DisposableFileSystem()) |
| 20 | { |
| 21 | var baseFolder = fs.GetFolder(); |
| 22 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 23 | var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); |
| 24 | |
| 25 | var result = WixRunner.Execute(new[] |
| 26 | { |
| 27 | "build", |
| 28 | Path.Combine(folder, "UI", "DialogsInInstallUISequence.wxs"), |
| 29 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), |
| 30 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), |
| 31 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), |
| 32 | "-intermediateFolder", intermediateFolder, |
| 33 | "-o", msiPath, |
| 34 | }); |
| 35 | |
| 36 | result.AssertSuccess(); |
| 37 | |
| 38 | Assert.True(File.Exists(msiPath)); |
| 39 | |
| 40 | var results = Query.QueryDatabase(msiPath, new[] { "CheckBox", "Control", "ControlCondition", "InstallUISequence" }); |
| 41 | WixAssert.CompareLineByLine(new[] |
| 42 | { |
| 43 | "CheckBox:WIXUI_EXITDIALOGOPTIONALCHECKBOX\t1", |
| 44 | "Control:FirstDialog\tHeader\tText\t0\t13\t90\t13\t3\t\tFirstDialogHeader\tTitle\t", |
| 45 | "Control:FirstDialog\tTitle\tText\t0\t0\t90\t13\t3\t\tFirstDialogTitle\tHeader\t", |
| 46 | "Control:SecondDialog\tOptionalCheckBox\tCheckBox\t0\t13\t100\t40\t2\tWIXUI_EXITDIALOGOPTIONALCHECKBOX\t[WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT]\tTitle\tOptional checkbox|Check this box for fun", |
| 47 | "Control:SecondDialog\tTitle\tText\t0\t0\t90\t13\t3\t\tSecondDialogTitle\tOptionalCheckBox\t", |
| 48 | "ControlCondition:FirstDialog\tHeader\tDisable\tInstalled", |
| 49 | "ControlCondition:FirstDialog\tHeader\tHide\tInstalled", |
| 50 | "ControlCondition:SecondDialog\tOptionalCheckBox\tShow\tWIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT AND NOT Installed", |
| 51 | "InstallUISequence:CostFinalize\t\t1000", |
| 52 | "InstallUISequence:CostInitialize\t\t800", |
| 53 | "InstallUISequence:ExecuteAction\t\t1300", |
| 54 | "InstallUISequence:FileCost\t\t900", |
| 55 | "InstallUISequence:FindRelatedProducts\t\t25", |
| 56 | "InstallUISequence:FirstDialog\tInstalled AND PATCH\t1298", |
| 57 | "InstallUISequence:LaunchConditions\t\t100", |
| 58 | "InstallUISequence:MigrateFeatureStates\t\t1200", |
| 59 | "InstallUISequence:SecondDialog\tNOT Installed\t1299", |
| 60 | "InstallUISequence:ValidateProductID\t\t700", |
| 61 | }, results); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | [Fact] |
| 66 | public void CanErrorWithInvalidControlType() |
| 67 | { |
| 68 | var folder = TestData.Get(@"TestData"); |
| 69 | |
| 70 | using (var fs = new DisposableFileSystem()) |
| 71 | { |
| 72 | var baseFolder = fs.GetFolder(); |
| 73 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 74 | var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); |
| 75 | |
| 76 | var result = WixRunner.Execute(new[] |
| 77 | { |
| 78 | "build", |
| 79 | Path.Combine(folder, "UI", "DialogWithInvalidControlType.wxs"), |
| 80 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), |
| 81 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), |
| 82 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), |
| 83 | "-intermediateFolder", intermediateFolder, |
| 84 | "-o", msiPath, |
| 85 | }); |
| 86 | |
| 87 | var errors = result.Messages.Where(m => m.Level == MessageLevel.Error).ToList(); |
| 88 | Assert.Equal(new[] |
| 89 | { |
| 90 | 21, |
| 91 | 52 |
| 92 | }, errors.Select(e => e.Id).ToArray()); |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | } |