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
46 lines
2.2 KiB
C#
46 lines
2.2 KiB
C#
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);
|
||
}
|
||
}
|