@joebigelow / wix / commits / 1fa3b2f3

Update tests to validate Shortcut Name/ShortName handling

Resolves wixtoolset/issues#4227

Rob Mensching committed Mar 19, 2021 at 11:15 UTC 1fa3b2f3c3e1380a5ae5ed76cdf028f221473da3
5 files changed +91 -35
src/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs
-34
@@ -715,40 +715,6 @@ namespace WixToolsetTest.CoreIntegration
715 }
716 }
717
718 - [Fact]
719 - public void PopulatesMsiShortcutPropertyTable()
720 - {
721 - var folder = TestData.Get(@"TestData");
722 -
723 - using (var fs = new DisposableFileSystem())
724 - {
725 - var baseFolder = fs.GetFolder();
726 - var intermediateFolder = Path.Combine(baseFolder, "obj");
727 - var msiPath = Path.Combine(baseFolder, @"bin\test.msi");
728 -
729 - var result = WixRunner.Execute(new[]
730 - {
731 - "build",
732 - Path.Combine(folder, "Shortcut", "ShortcutProperty.wxs"),
733 - Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"),
734 - Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"),
735 - "-bindpath", Path.Combine(folder, "SingleFile", "data"),
736 - "-intermediateFolder", intermediateFolder,
737 - "-o", msiPath
738 - });
739 -
740 - result.AssertSuccess();
741 -
742 - Assert.True(File.Exists(msiPath));
743 - var results = Query.QueryDatabase(msiPath, new[] { "MsiShortcutProperty", "Shortcut" });
744 - WixAssert.CompareLineByLine(new[]
745 - {
746 - "MsiShortcutProperty:scp4GOCIx4Eskci4nBG1MV_vSUOZt4\tTheShortcut\tCustomShortcutKey\tCustomShortcutValue",
747 - "Shortcut:TheShortcut\tINSTALLFOLDER\td\tShortcutComp\t[#filcV1yrx0x8wJWj4qMzcH21jwkPko]\t\t\t\t\t\t\t\t\t\t\t",
748 - }, results);
749 - }
750 - }
751 -
718 [Fact]
719 public void PopulatesReserveCostTable()
720 {
src/test/WixToolsetTest.CoreIntegration/ShortcutFixture.cs new
+78
@@ -0,0 +1,78 @@
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 WixBuildTools.TestSupport;
7 + using WixToolset.Core.TestPackage;
8 + using Xunit;
9 +
10 + public class ShortcutFixture
11 + {
12 + [Fact]
13 + public void CanBuildShortcutNameWithShortname()
14 + {
15 + var folder = TestData.Get(@"TestData");
16 +
17 + using (var fs = new DisposableFileSystem())
18 + {
19 + var baseFolder = fs.GetFolder();
20 + var intermediateFolder = Path.Combine(baseFolder, "obj");
21 + var msiPath = Path.Combine(baseFolder, @"bin\test.msi");
22 +
23 + var result = WixRunner.Execute(new[]
24 + {
25 + "build",
26 + Path.Combine(folder, "Shortcut", "ShortcutSameNameShortName.wxs"),
27 + Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"),
28 + Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"),
29 + "-bindpath", Path.Combine(folder, "SingleFile", "data"),
30 + "-intermediateFolder", intermediateFolder,
31 + "-o", msiPath
32 + });
33 +
34 + result.AssertSuccess();
35 +
36 + var results = Query.QueryDatabase(msiPath, new[] { "Shortcut" });
37 + WixAssert.CompareLineByLine(new[]
38 + {
39 + "Shortcut:sctzJpBYlrhdx4Mm9Xh41X0KPWYiX0\tINSTALLFOLDER\tDaName\tShortcutComp\t[#filcV1yrx0x8wJWj4qMzcH21jwkPko]\t\t\t\t\t\t\t\t\t\t\t",
40 + }, results);
41 + }
42 + }
43 +
44 + [Fact]
45 + public void PopulatesMsiShortcutPropertyTable()
46 + {
47 + var folder = TestData.Get(@"TestData");
48 +
49 + using (var fs = new DisposableFileSystem())
50 + {
51 + var baseFolder = fs.GetFolder();
52 + var intermediateFolder = Path.Combine(baseFolder, "obj");
53 + var msiPath = Path.Combine(baseFolder, @"bin\test.msi");
54 +
55 + var result = WixRunner.Execute(new[]
56 + {
57 + "build",
58 + Path.Combine(folder, "Shortcut", "ShortcutProperty.wxs"),
59 + Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"),
60 + Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"),
61 + "-bindpath", Path.Combine(folder, "SingleFile", "data"),
62 + "-intermediateFolder", intermediateFolder,
63 + "-o", msiPath
64 + });
65 +
66 + result.AssertSuccess();
67 +
68 + Assert.True(File.Exists(msiPath));
69 + var results = Query.QueryDatabase(msiPath, new[] { "MsiShortcutProperty", "Shortcut" });
70 + WixAssert.CompareLineByLine(new[]
71 + {
72 + "MsiShortcutProperty:scp4GOCIx4Eskci4nBG1MV_vSUOZt4\tTheShortcut\tCustomShortcutKey\tCustomShortcutValue",
73 + "Shortcut:TheShortcut\tINSTALLFOLDER\td\tShortcutComp\t[#filcV1yrx0x8wJWj4qMzcH21jwkPko]\t\t\t\t\t\t\t\t\t\t\t",
74 + }, results);
75 + }
76 + }
77 + }
78 +}
src/test/WixToolsetTest.CoreIntegration/TestData/Shortcut/DecompiledShortcuts.wxs
+1 -1
@@ -6,7 +6,7 @@
6 <Component Id="ShortcutComp" Guid="{5B3B3FC1-533D-4C29-BFB3-0E88B51E59D8}" Bitness="always32">
7 <File Id="test.txt" Name="test.txt" KeyPath="yes" Source="SourceDir\\MsiPackage\test.txt" />
8 <Shortcut Id="FileTargetShortcut" Directory="INSTALLFOLDER" Name="FileTargetShortcut" ShortName="lm2tdtqp" Target="[#test.txt]" />
9 - <Shortcut Id="CustomTargetShortcut" Directory="INSTALLFOLDER" Name="CustomTargetShortcut" ShortName="treusbt_" Target="[INSTALLFOLDER]custom.target" />
9 + <Shortcut Id="CustomTargetShortcut" Directory="INSTALLFOLDER" Name="Planner" ShortName="PLANNER" Target="[INSTALLFOLDER]custom.target" />
10 <Shortcut Id="AdvtShortcut" Directory="INSTALLFOLDER" Name="AdvtShortcut" ShortName="mdbqel9r" Advertise="yes" />
11 </Component>
12 </Directory>
src/test/WixToolsetTest.CoreIntegration/TestData/Shortcut/ShortcutSameNameShortName.wxs new
+12
@@ -0,0 +1,12 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 + <Fragment>
4 + <ComponentGroup Id="ProductComponents">
5 + <Component Id="ShortcutComp" Directory="INSTALLFOLDER" Guid="5B3B3FC1-533D-4C29-BFB3-0E88B51E59D8">
6 + <File Source="test.txt">
7 + <Shortcut Name="DaName" ShortName="DANAME" Directory="INSTALLFOLDER" />
8 + </File>
9 + </Component>
10 + </ComponentGroup>
11 + </Fragment>
12 +</Wix>
src/test/WixToolsetTest.CoreIntegration/TestData/Shortcut/shortcuts.msi
Binary files a/src/test/WixToolsetTest.CoreIntegration/TestData/Shortcut/shortcuts.msi and b/src/test/WixToolsetTest.CoreIntegration/TestData/Shortcut/shortcuts.msi differ