Files
Chronos/tests/Titano.App.Tests/Infrastructure/StartWithWindowsTests.cs
T
Claude 97c6484c74 fix(app): Start with Windows belongs to the copy that set it; the uninstaller removes sign-in entries
The client's HKCU Run value now counts as on only when it starts this executable, so a portable copy, a
second install or a development build no longer shows the box ticked, and starting one no longer rewrites the
entry to itself. Refresh only follows an entry whose program an update renamed in this copy's folder, and
unticking removes only this copy's entry. Portable copies keep the choice in memory and hide the Startup row,
since they leave nothing in the registry.

The uninstaller removes the client's and the Uploader's sign-in entries when they start a program of the folder
it removes. StartupCommand in Titano.Core holds the Run key, the value names and the command parsing shared by
both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
2026-10-12 10:35:13 +00:00

46 lines
2.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Titano.App.Infrastructure;
using Titano.Core.IO;
using Titano.Testing;
namespace Titano.App.Tests.Infrastructure;
/// <summary>Settings › General › Startup: one sign-in entry shared by every copy of Titano, which no copy takes over by starting.</summary>
public sealed class StartWithWindowsTests
{
private const string Installed = @"C:\Users\ada\AppData\Local\Programs\Titano\Titano.exe";
[Test]
public void AStartFollowsOnlyAnEntryAnUpdateLeftBehindInItsOwnFolder()
{
static bool Gone(string path) => false;
static bool Present(string path) => true;
var installed = StartupCommand.Format(Installed, RunKeyStartWithWindows.MinimizedOption);
// The entry already starts this copy: nothing to write.
Assert.False(RunKeyStartWithWindows.Follows(installed, Installed, Gone));
// An update renamed the program in its folder: the entry follows it.
Assert.True(RunKeyStartWithWindows.Follows(StartupCommand.Format(@"C:\Users\ada\AppData\Local\Programs\Titano\Titano.old.exe", "--minimized"),
Installed, Gone));
// The installed copy is still there: a portable copy, a second install or a development build that starts leaves it alone.
Assert.False(RunKeyStartWithWindows.Follows(installed, @"E:\Titano\Titano.exe", Present));
Assert.False(RunKeyStartWithWindows.Follows(installed, @"C:\src\Titano\bin\Debug\Titano.exe", Present));
// Gone from another folder (a USB stick that is not plugged in): still not this copy's entry.
Assert.False(RunKeyStartWithWindows.Follows(installed, @"E:\Titano\Titano.exe", Gone));
// No entry, or no executable path: nothing to follow.
Assert.False(RunKeyStartWithWindows.Follows(null, Installed, Gone));
Assert.False(RunKeyStartWithWindows.Follows(installed, null, Gone));
}
[Test]
public void ScreenshotsAndPortableCopiesKeepTheChoiceInMemory()
{
var startup = new MemoryStartWithWindows();
Assert.False(startup.IsEnabled);
startup.SetEnabled(true);
startup.Refresh();
Assert.True(startup.IsEnabled);
startup.SetEnabled(false);
Assert.False(startup.IsEnabled);
}
}