diff --git a/tests/Chronos.App.Tests/Setup/ScratchRegistry.cs b/tests/Chronos.App.Tests/Setup/ScratchRegistry.cs
new file mode 100644
index 00000000..9da22335
--- /dev/null
+++ b/tests/Chronos.App.Tests/Setup/ScratchRegistry.cs
@@ -0,0 +1,35 @@
+using Microsoft.Win32;
+
+namespace Chronos.App.Tests.Setup;
+
+///
+/// Scratch keys under HKCU\Software\Chronos.Tests for the setup tests, which run in parallel: a key is created, and the
+/// shared parent removed once empty, under one lock, so one test's cleanup never deletes the parent while another test
+/// is creating its key under it.
+///
+internal static class ScratchRegistry
+{
+ private const string Root = @"Software\Chronos.Tests";
+
+ private static readonly Lock Gate = new();
+
+ /// Creates a new empty scratch key and returns its path under HKCU.
+ public static string Create()
+ {
+ var keyPath = Root + @"\" + Guid.NewGuid().ToString("N");
+ lock (Gate) Registry.CurrentUser.CreateSubKey(keyPath, writable: true).Dispose();
+ return keyPath;
+ }
+
+ /// Deletes a scratch key made by , and the shared parent too once it is empty.
+ public static void Delete(string keyPath)
+ {
+ lock (Gate)
+ {
+ Registry.CurrentUser.DeleteSubKeyTree(keyPath, throwOnMissingSubKey: false);
+ bool empty;
+ using (var tests = Registry.CurrentUser.OpenSubKey(Root)) empty = tests is { SubKeyCount: 0, ValueCount: 0 };
+ if (empty) Registry.CurrentUser.DeleteSubKey(Root, throwOnMissingSubKey: false);
+ }
+ }
+}
diff --git a/tests/Chronos.App.Tests/Setup/SetupEngineTests.cs b/tests/Chronos.App.Tests/Setup/SetupEngineTests.cs
index 31ea8386..1754e944 100644
--- a/tests/Chronos.App.Tests/Setup/SetupEngineTests.cs
+++ b/tests/Chronos.App.Tests/Setup/SetupEngineTests.cs
@@ -16,8 +16,6 @@ namespace Chronos.App.Tests.Setup;
///
public sealed class SetupEngineTests(TestContext context)
{
- private const string TestsKey = @"Software\Chronos.Tests";
-
/// The StartupApproved state Task Manager writes for an entry it turned off.
private static readonly byte[] TurnedOff = [0x03, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
@@ -64,7 +62,7 @@ public sealed class SetupEngineTests(TestContext context)
{
var folder = Path.Combine(context.CreateTempDirectory("services"), "Apps");
var owned = CommandProgram.FullPaths(folder, ["Chronos.Server.exe", "Chronos.exe", "lib/Chronos.Core.dll"]);
- var keyPath = TestsKey + @"\" + Guid.NewGuid().ToString("N");
+ var keyPath = ScratchRegistry.Create();
try
{
using var services = Registry.CurrentUser.CreateSubKey(keyPath, writable: true);
@@ -88,7 +86,7 @@ public sealed class SetupEngineTests(TestContext context)
}
finally
{
- DeleteTestKey(keyPath);
+ ScratchRegistry.Delete(keyPath);
}
static void Service(RegistryKey services, string name, int type, string imagePath)
@@ -158,7 +156,7 @@ public sealed class SetupEngineTests(TestContext context)
public void UninstallRemovesOnlyTheSignInEntriesOfTheProgramsItRemoves()
{
var folder = Path.Combine(context.CreateTempDirectory("startup"), "Apps");
- var keyPath = TestsKey + @"\" + Guid.NewGuid().ToString("N");
+ var keyPath = ScratchRegistry.Create();
try
{
using (var run = Registry.CurrentUser.CreateSubKey(keyPath + @"\Run", writable: true))
@@ -182,7 +180,7 @@ public sealed class SetupEngineTests(TestContext context)
}
finally
{
- DeleteTestKey(keyPath);
+ ScratchRegistry.Delete(keyPath);
}
}
@@ -191,7 +189,6 @@ public sealed class SetupEngineTests(TestContext context)
public void AnUpgradeMovesTheSignInEntryOfARenamedProgramAndRemovesThatOfADroppedOne()
{
var folder = Path.Combine(context.CreateTempDirectory("upgrade"), "Apps");
- var keyPath = TestsKey + @"\" + Guid.NewGuid().ToString("N");
// This version ships the client as Chronos.exe (the previous one as Chronos.old.exe), and the user left out the Uploader.
var manifest = Manifest();
manifest.Components.Add(new PayloadComponent { Id = "Uploader", DisplayName = "Chronos Uploader", DefaultSelected = true });
@@ -200,6 +197,7 @@ public sealed class SetupEngineTests(TestContext context)
var programs = InstallEngine.StartupPrograms(manifest, folder, ["Chronos", "Server"]);
Assert.SequenceEqual(["Chronos"], programs.Keys);
Assert.Equal(Path.Combine(folder, "Chronos.exe"), programs["Chronos"]);
+ var keyPath = ScratchRegistry.Create();
try
{
using (var run = Registry.CurrentUser.CreateSubKey(keyPath + @"\Run", writable: true))
@@ -226,7 +224,7 @@ public sealed class SetupEngineTests(TestContext context)
}
finally
{
- DeleteTestKey(keyPath);
+ ScratchRegistry.Delete(keyPath);
}
}
@@ -344,15 +342,6 @@ public sealed class SetupEngineTests(TestContext context)
Assert.Equal("Something else", InstallEngine.FileTypeName(unknown, CultureInfo.GetCultureInfo("it")));
}
- /// Deletes a scratch key under , and that key too once it is empty.
- private static void DeleteTestKey(string keyPath)
- {
- Registry.CurrentUser.DeleteSubKeyTree(keyPath, throwOnMissingSubKey: false);
- bool empty;
- using (var tests = Registry.CurrentUser.OpenSubKey(TestsKey)) empty = tests is { SubKeyCount: 0, ValueCount: 0 };
- if (empty) Registry.CurrentUser.DeleteSubKey(TestsKey, throwOnMissingSubKey: false);
- }
-
/// A manifest under a product name no machine has installed, so the registry holds no installation of it.
private static PayloadManifest Manifest() => new()
{
diff --git a/tests/Chronos.App.Tests/Setup/SingleSetupTests.cs b/tests/Chronos.App.Tests/Setup/SingleSetupTests.cs
index 65b4d3bf..d8333f68 100644
--- a/tests/Chronos.App.Tests/Setup/SingleSetupTests.cs
+++ b/tests/Chronos.App.Tests/Setup/SingleSetupTests.cs
@@ -19,8 +19,6 @@ namespace Chronos.App.Tests.Setup;
///
public sealed class SingleSetupTests(TestContext context)
{
- private const string TestsKey = @"Software\Chronos.Tests";
-
/// The StartupApproved state Task Manager writes for an entry it turned off.
private static readonly byte[] TurnedOff = [0x03, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
@@ -223,7 +221,7 @@ public sealed class SingleSetupTests(TestContext context)
var programs = LegacyProducts.StartupPrograms(Manifest(), directory);
Assert.SequenceEqual(["Chronos Uploader"], programs.Keys);
- var keyPath = TestsKey + @"\" + Guid.NewGuid().ToString("N");
+ var keyPath = ScratchRegistry.Create();
try
{
using var run = Registry.CurrentUser.CreateSubKey(keyPath + @"\Run", writable: true);
@@ -238,10 +236,7 @@ public sealed class SingleSetupTests(TestContext context)
}
finally
{
- Registry.CurrentUser.DeleteSubKeyTree(keyPath, throwOnMissingSubKey: false);
- bool empty;
- using (var tests = Registry.CurrentUser.OpenSubKey(TestsKey)) empty = tests is { SubKeyCount: 0, ValueCount: 0 };
- if (empty) Registry.CurrentUser.DeleteSubKey(TestsKey, throwOnMissingSubKey: false);
+ ScratchRegistry.Delete(keyPath);
}
}
diff --git a/tests/visual/baselines/server-copies-blocked-dark.png b/tests/visual/baselines/server-copies-blocked-dark.png
index 854d2d9b..e3faf6f9 100644
Binary files a/tests/visual/baselines/server-copies-blocked-dark.png and b/tests/visual/baselines/server-copies-blocked-dark.png differ
diff --git a/tests/visual/baselines/server-copies-blocked-light.png b/tests/visual/baselines/server-copies-blocked-light.png
index dcbff6ee..d7007aba 100644
Binary files a/tests/visual/baselines/server-copies-blocked-light.png and b/tests/visual/baselines/server-copies-blocked-light.png differ
diff --git a/tests/visual/baselines/server-copies-plan-dark.png b/tests/visual/baselines/server-copies-plan-dark.png
index bc95ed37..07e8bfe8 100644
Binary files a/tests/visual/baselines/server-copies-plan-dark.png and b/tests/visual/baselines/server-copies-plan-dark.png differ
diff --git a/tests/visual/baselines/server-copies-plan-light.png b/tests/visual/baselines/server-copies-plan-light.png
index 98984bcf..81913702 100644
Binary files a/tests/visual/baselines/server-copies-plan-light.png and b/tests/visual/baselines/server-copies-plan-light.png differ