summaryrefslogtreecommitdiff
path: root/src/test/burn/WixToolsetTest.BurnE2E/Utilities
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-06-09 15:30:48 -0500
committerSean Hall <r.sean.hall@gmail.com>2022-06-13 09:28:49 -0500
commit6f6e4ced9f398ff37a44b91fdba62479cde29d06 (patch)
tree8cef5b123df7ff11cdc9be79d2e981d9d567d65d /src/test/burn/WixToolsetTest.BurnE2E/Utilities
parent68ec803fc7f48bb0e0463dc45f6ce40e1f07dbf5 (diff)
downloadwix-6f6e4ced9f398ff37a44b91fdba62479cde29d06.tar.gz
wix-6f6e4ced9f398ff37a44b91fdba62479cde29d06.tar.bz2
wix-6f6e4ced9f398ff37a44b91fdba62479cde29d06.zip
Implement ArpEntry flavored ExePackage.
6772
Diffstat (limited to 'src/test/burn/WixToolsetTest.BurnE2E/Utilities')
-rw-r--r--src/test/burn/WixToolsetTest.BurnE2E/Utilities/IWebServer.cs23
-rw-r--r--src/test/burn/WixToolsetTest.BurnE2E/Utilities/TestBAController.cs217
-rw-r--r--src/test/burn/WixToolsetTest.BurnE2E/Utilities/TestExeTool.cs17
3 files changed, 257 insertions, 0 deletions
diff --git a/src/test/burn/WixToolsetTest.BurnE2E/Utilities/IWebServer.cs b/src/test/burn/WixToolsetTest.BurnE2E/Utilities/IWebServer.cs
new file mode 100644
index 00000000..a4d46d48
--- /dev/null
+++ b/src/test/burn/WixToolsetTest.BurnE2E/Utilities/IWebServer.cs
@@ -0,0 +1,23 @@
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
3namespace WixToolsetTest.BurnE2E
4{
5 using System;
6 using System.Collections.Generic;
7
8 public interface IWebServer : IDisposable
9 {
10 bool DisableHeadResponses { get; set; }
11 bool DisableRangeRequests { get; set; }
12
13 /// <summary>
14 /// Registers a collection of relative URLs (the key) with its absolute path to the file (the value).
15 /// </summary>
16 void AddFiles(Dictionary<string, string> physicalPathsByRelativeUrl);
17
18 /// <summary>
19 /// Starts the web server on a new thread.
20 /// </summary>
21 void Start();
22 }
23} \ No newline at end of file
diff --git a/src/test/burn/WixToolsetTest.BurnE2E/Utilities/TestBAController.cs b/src/test/burn/WixToolsetTest.BurnE2E/Utilities/TestBAController.cs
new file mode 100644
index 00000000..8e6611a2
--- /dev/null
+++ b/src/test/burn/WixToolsetTest.BurnE2E/Utilities/TestBAController.cs
@@ -0,0 +1,217 @@
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
3namespace WixToolsetTest.BurnE2E
4{
5 using System;
6 using Microsoft.Win32;
7 using WixTestTools;
8 using WixToolset.Mba.Core;
9
10 public class TestBAController : IDisposable
11 {
12 public TestBAController(WixTestContext testContext, bool x64 = false)
13 {
14 this.TestGroupName = testContext.TestGroupName;
15 this.BaseRegKeyPath = x64 ? @"Software\WiX\Tests" : @"Software\WOW6432Node\WiX\Tests";
16 this.TestBaseRegKeyPath = String.Format(@"{0}\TestBAControl\{1}", this.BaseRegKeyPath, this.TestGroupName);
17 }
18
19 private string BaseRegKeyPath { get; }
20
21 private string TestBaseRegKeyPath { get; }
22
23 public string TestGroupName { get; }
24
25 /// <summary>
26 /// Sets a test value in the registry to communicate with the TestBA.
27 /// </summary>
28 /// <param name="name">Name of the value to set.</param>
29 /// <param name="value">Value to set. If this is null, the value is removed.</param>
30 public void SetBurnTestValue(string name, string value)
31 {
32 using (var testKey = Registry.LocalMachine.CreateSubKey(this.TestBaseRegKeyPath))
33 {
34 if (String.IsNullOrEmpty(value))
35 {
36 testKey.DeleteValue(name, false);
37 }
38 else
39 {
40 testKey.SetValue(name, value);
41 }
42 }
43 }
44
45 public void SetExplicitlyElevateAndPlanFromOnElevateBegin(string value = "true")
46 {
47 this.SetBurnTestValue("ExplicitlyElevateAndPlanFromOnElevateBegin", value);
48 }
49
50 public void SetForceKeepRegistration(string value = "true")
51 {
52 this.SetBurnTestValue("ForceKeepRegistration", value);
53 }
54
55 public void SetImmediatelyQuit(string value = "true")
56 {
57 this.SetBurnTestValue("ImmediatelyQuit", value);
58 }
59
60 public void SetQuitAfterDetect(string value = "true")
61 {
62 this.SetBurnTestValue("QuitAfterDetect", value);
63 }
64
65 /// <summary>
66 /// Slows the cache progress of a package.
67 /// </summary>
68 /// <param name="packageId">Package identity.</param>
69 /// <param name="delay">Sets or removes the delay on a package being cached.</param>
70 public void SetPackageSlowCache(string packageId, int? delay)
71 {
72 this.SetPackageState(packageId, "SlowCache", delay.HasValue ? delay.ToString() : null);
73 }
74
75 /// <summary>
76 /// Cancels the cache of a package at a particular progress point.
77 /// </summary>
78 /// <param name="packageId">Package identity.</param>
79 /// <param name="cancelPoint">Sets or removes the cancel progress on a package being cached.</param>
80 public void SetPackageCancelCacheAtProgress(string packageId, int? cancelPoint)
81 {
82 this.SetPackageState(packageId, "CancelCacheAtProgress", cancelPoint.HasValue ? cancelPoint.ToString() : null);
83 }
84
85 /// <summary>
86 /// Slows the execute progress of a package.
87 /// </summary>
88 /// <param name="packageId">Package identity.</param>
89 /// <param name="delay">Sets or removes the delay on a package being executed.</param>
90 public void SetPackageSlowExecute(string packageId, int? delay)
91 {
92 this.SetPackageState(packageId, "SlowExecute", delay.HasValue ? delay.ToString() : null);
93 }
94
95 /// <summary>
96 /// Cancels the execute of a package at a particular progress point.
97 /// </summary>
98 /// <param name="packageId">Package identity.</param>
99 /// <param name="cancelPoint">Sets or removes the cancel progress on a package being executed.</param>
100 public void SetPackageCancelExecuteAtProgress(string packageId, int? cancelPoint)
101 {
102 this.SetPackageState(packageId, "CancelExecuteAtProgress", cancelPoint.HasValue ? cancelPoint.ToString() : null);
103 }
104
105 /// <summary>
106 /// Cancels the execute of a package at the next progess after the specified MSI action start.
107 /// </summary>
108 /// <param name="packageId">Package identity.</param>
109 /// <param name="actionName">Sets or removes the cancel progress on a package being executed.</param>
110 public void SetPackageCancelExecuteAtActionStart(string packageId, string actionName)
111 {
112 this.SetPackageState(packageId, "CancelExecuteAtActionStart", actionName);
113 }
114
115 /// <summary>
116 /// Cancels the execute of a package at a particular OnProgress point.
117 /// </summary>
118 /// <param name="packageId">Package identity.</param>
119 /// <param name="cancelPoint">Sets or removes the cancel OnProgress point on a package being executed.</param>
120 public void SetPackageCancelOnProgressAtProgress(string packageId, int? cancelPoint)
121 {
122 this.SetPackageState(packageId, "CancelOnProgressAtProgress", cancelPoint.HasValue ? cancelPoint.ToString() : null);
123 }
124
125 /// <summary>
126 /// Retries the files in use one or more times before canceling.
127 /// </summary>
128 /// <param name="packageId">Package identity.</param>
129 /// <param name="cancelPoint">Sets or removes the retry count on a package's file in use message.</param>
130 public void SetPackageRetryExecuteFilesInUse(string packageId, int? retryCount)
131 {
132 this.SetPackageState(packageId, "RetryExecuteFilesInUse", retryCount.HasValue ? retryCount.ToString() : null);
133 }
134
135 /// <summary>
136 /// Sets the requested state for a package that the TestBA will return to the engine during plan.
137 /// </summary>
138 /// <param name="packageId">Package identity.</param>
139 /// <param name="state">State to request.</param>
140 public void SetPackageRequestedState(string packageId, RequestState state)
141 {
142 this.SetPackageState(packageId, "Requested", state.ToString());
143 }
144
145 /// <summary>
146 /// Sets the requested state for a package that the TestBA will return to the engine during plan.
147 /// </summary>
148 /// <param name="packageId">Package identity.</param>
149 /// <param name="state">State to request.</param>
150 public void SetPackageFeatureState(string packageId, string featureId, FeatureState state)
151 {
152 this.SetPackageState(packageId, String.Concat(featureId, "Requested"), state.ToString());
153 }
154
155 /// <summary>
156 /// Requests the BA to log the test registry value for the specified package.
157 /// </summary>
158 /// <param name="packageId"></param>
159 /// <param name="value"></param>
160 public void SetPackageRecordTestRegistryValue(string packageId, string value = "true")
161 {
162 this.SetPackageState(packageId, "RecordTestRegistryValue", value);
163 }
164
165 public void SetPackageProcessCancelAction(string packageId, BOOTSTRAPPER_EXECUTEPROCESSCANCEL_ACTION action)
166 {
167 this.SetPackageState(packageId, "ProcessCancelAction", action.ToString());
168 }
169
170 /// <summary>
171 /// Sets the number of times to re-run the Detect phase.
172 /// </summary>
173 /// <param name="state">Number of times to run Detect (after the first, normal, Detect).</param>
174 public void SetRedetectCount(int redetectCount)
175 {
176 this.SetPackageState(null, "RedetectCount", redetectCount.ToString());
177 }
178
179 /// <summary>
180 /// Resets the state for a package that the TestBA will return to the engine during plan.
181 /// </summary>
182 /// <param name="packageId">Package identity.</param>
183 public void ResetPackageStates(string packageId)
184 {
185 var key = String.Format(@"{0}\{1}", this.TestBaseRegKeyPath, packageId ?? String.Empty);
186 Registry.LocalMachine.DeleteSubKey(key);
187 }
188
189 public void SetVerifyArguments(string verifyArguments)
190 {
191 this.SetBurnTestValue("VerifyArguments", verifyArguments);
192
193 }
194
195 private void SetPackageState(string packageId, string name, string value)
196 {
197 var key = String.Format(@"{0}\{1}", this.TestBaseRegKeyPath, packageId ?? String.Empty);
198 using (var packageKey = Registry.LocalMachine.CreateSubKey(key))
199 {
200 if (String.IsNullOrEmpty(value))
201 {
202 packageKey.DeleteValue(name, false);
203 }
204 else
205 {
206 packageKey.SetValue(name, value);
207 }
208 }
209 }
210
211 public void Dispose()
212 {
213 Registry.LocalMachine.DeleteSubKeyTree($@"{this.BaseRegKeyPath}\{this.TestGroupName}", false);
214 Registry.LocalMachine.DeleteSubKeyTree($@"{this.BaseRegKeyPath}\TestBAControl", false);
215 }
216 }
217}
diff --git a/src/test/burn/WixToolsetTest.BurnE2E/Utilities/TestExeTool.cs b/src/test/burn/WixToolsetTest.BurnE2E/Utilities/TestExeTool.cs
new file mode 100644
index 00000000..a02299d7
--- /dev/null
+++ b/src/test/burn/WixToolsetTest.BurnE2E/Utilities/TestExeTool.cs
@@ -0,0 +1,17 @@
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
3namespace WixTestTools
4{
5 using System.IO;
6 using WixBuildTools.TestSupport;
7
8 public class TestExeTool : TestTool
9 {
10 private static readonly string TestExePath32 = Path.Combine(TestData.Get(), "win-x86", "TestExe.exe");
11
12 public TestExeTool()
13 : base(TestExePath32)
14 {
15 }
16 }
17}