Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6dea3ac129
|
||
|
|
2639a655a0
|
No files matched your search
+4
-2
@@ -43,8 +43,8 @@ numeric core and does not move; the heading is the full version — corrected 20
|
||||
- **A game you uninstalled leaves the library by itself** when it has no sessions: the agent removes an entry whose `.exe`
|
||||
has been gone for ten minutes, if its drive is connected and the folder it was installed in is still there — an
|
||||
unplugged or re-lettered drive never counts — and never one where anti-cheat was found. A game with sessions stays, with
|
||||
them, and reads *Not installed* as before. The Games page says so when it happens; **Settings ▸ Data ▸ Remove uninstalled
|
||||
games** turns it off (`docs/02_SPEC.md` FR-1.8).
|
||||
them, and reads *Not installed* as before. The Games page says so when it happens — once, naming them, for all the games
|
||||
one check removes; **Settings ▸ Data ▸ Remove uninstalled games** turns it off (`docs/02_SPEC.md` FR-1.8).
|
||||
|
||||
### Changed
|
||||
|
||||
@@ -63,6 +63,8 @@ numeric core and does not move; the heading is the full version — corrected 20
|
||||
that draws (`css\Game.exe` there; its launcher asks for administrator, so it is measured with *Run the agent as
|
||||
administrator* on). The import also no longer offers a store's game again when the library has it at another
|
||||
executable: an entry already there is re-pointed with *Change executable…* (`docs/05_DETECTION.md` §Library import).
|
||||
- **The Games page shows its newest read of the library.** When two reads overlapped — a session ending while an import
|
||||
added games — the one that started first could finish last and be shown, an older list until the next read.
|
||||
|
||||
## [0.1.0-beta.18] - 2026-10-07
|
||||
|
||||
|
||||
+7
-1
@@ -276,7 +276,13 @@ All screens are `Page`s registered with the navigation page provider and navigat
|
||||
> *since beta.19 (D55) the Agent removes such an entry by itself after ten minutes when it has no session and no
|
||||
> anti-cheat block or exception, and its drive is connected — Settings ▸ Data ▸ Remove uninstalled games, on by default; the
|
||||
> page on screen hears `GameRemoved`, reloads and says so in the snackbar (`Games_Removed_Format`); one with sessions keeps
|
||||
> its pill*). **The page reloads by itself** while it is on screen when a session ends (`SessionCompleted`) or an
|
||||
> its pill. One check removes its games in one event each, milliseconds apart: the page waits `GamesViewModel.RemovalSettle`
|
||||
> (one second) after the first, then reads the library once and says them all in one notice — the count, five names and
|
||||
> how many more, `Games_Removed_Many_Format`. It said each and reloaded each, and WPF UI 4.3.0's `SnackbarService` shows every
|
||||
> message at once in its one snackbar, so only the last name stayed on screen. And only the newest read of the library is
|
||||
> shown: reads overlap — a session that ends, an import, a removal — and the one that started first could finish last,
|
||||
> its executable checks waiting on a slow drive, and put back a removed game's card (`GamesViewModel.LoadAsync`,
|
||||
> `GamesViewModelTests.AnOlderReadThatFinishesLastIsNotShownOverANewerOne`)*). **The page reloads by itself** while it is on screen when a session ends (`SessionCompleted`) or an
|
||||
> import adds games (`LibraryChanges` — navigating to the page already on screen does nothing in WPF UI 4.3.0, so an
|
||||
> import from the menu never showed until the page was left). **Import** (FR-1.2): the games already in the library — at
|
||||
> this path or under another drive letter — are hidden by default (*Show the N games already in the library* brings them
|
||||
|
||||
Generated
+6
@@ -520,6 +520,8 @@ public static class Strings
|
||||
nameof(Games_Refresh),
|
||||
nameof(Games_Refresh_ToolTip),
|
||||
nameof(Games_Removed_Format),
|
||||
nameof(Games_Removed_Many_Format),
|
||||
nameof(Games_Removed_More_Format),
|
||||
nameof(Games_Removed_Title),
|
||||
nameof(Games_Search_Placeholder),
|
||||
nameof(Games_Sort_Label),
|
||||
@@ -2056,6 +2058,10 @@ public static class Strings
|
||||
|
||||
public static string Games_Removed_Format => ResourceManager.GetString(nameof(Games_Removed_Format), Culture) ?? nameof(Games_Removed_Format);
|
||||
|
||||
public static string Games_Removed_Many_Format => ResourceManager.GetString(nameof(Games_Removed_Many_Format), Culture) ?? nameof(Games_Removed_Many_Format);
|
||||
|
||||
public static string Games_Removed_More_Format => ResourceManager.GetString(nameof(Games_Removed_More_Format), Culture) ?? nameof(Games_Removed_More_Format);
|
||||
|
||||
public static string Games_Removed_Title => ResourceManager.GetString(nameof(Games_Removed_Title), Culture) ?? nameof(Games_Removed_Title);
|
||||
|
||||
public static string Games_Search_Placeholder => ResourceManager.GetString(nameof(Games_Search_Placeholder), Culture) ?? nameof(Games_Search_Placeholder);
|
||||
|
||||
@@ -2045,6 +2045,14 @@
|
||||
<value>{0} はインストールされておらずセッションもないため、キャプチャエージェントが削除しました。「設定 ▸ データ」でオフにできます。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Games_Removed_Many_Format" xml:space="preserve">
|
||||
<value>{0} 本のゲームはインストールされておらずセッションもないため、キャプチャエージェントが削除しました: {1}。「設定 ▸ データ」でオフにできます。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Games_Removed_More_Format" xml:space="preserve">
|
||||
<value>{0} ほか {1} 本</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_DeleteSessions_Label" xml:space="preserve">
|
||||
<value>すべてのセッションを削除</value>
|
||||
<comment>review</comment>
|
||||
|
||||
@@ -1539,6 +1539,12 @@
|
||||
<data name="Games_Removed_Format" xml:space="preserve">
|
||||
<value>{0} is no longer installed and had no sessions, so the capture agent removed it. Settings ▸ Data turns this off.</value>
|
||||
</data>
|
||||
<data name="Games_Removed_Many_Format" xml:space="preserve">
|
||||
<value>{0} games are no longer installed and had no sessions, so the capture agent removed them: {1}. Settings ▸ Data turns this off.</value>
|
||||
</data>
|
||||
<data name="Games_Removed_More_Format" xml:space="preserve">
|
||||
<value>{0} and {1} more</value>
|
||||
</data>
|
||||
<data name="Settings_DeleteSessions_Label" xml:space="preserve">
|
||||
<value>Delete all sessions</value>
|
||||
</data>
|
||||
|
||||
@@ -1534,6 +1534,12 @@
|
||||
<data name="Games_Removed_Format" xml:space="preserve">
|
||||
<value>{0} không còn được cài đặt và chưa có phiên nào, nên capture agent đã xoá nó. Tắt việc này trong Cài đặt ▸ Dữ liệu.</value>
|
||||
</data>
|
||||
<data name="Games_Removed_Many_Format" xml:space="preserve">
|
||||
<value>{0} game không còn được cài đặt và chưa có phiên nào, nên capture agent đã xoá chúng: {1}. Tắt việc này trong Cài đặt ▸ Dữ liệu.</value>
|
||||
</data>
|
||||
<data name="Games_Removed_More_Format" xml:space="preserve">
|
||||
<value>{0} và {1} game khác</value>
|
||||
</data>
|
||||
<data name="Settings_DeleteSessions_Label" xml:space="preserve">
|
||||
<value>Xoá mọi phiên</value>
|
||||
</data>
|
||||
|
||||
@@ -25,6 +25,9 @@ public sealed partial class GamesViewModel : ObservableObject
|
||||
private const string _listValue = "list";
|
||||
private const string _gridValue = "grid";
|
||||
|
||||
/// <summary>How many removed games one notice names; the rest are counted (<c>Games_Removed_More_Format</c>).</summary>
|
||||
private const int _removedNamed = 5;
|
||||
|
||||
private readonly GameLibrary _library;
|
||||
private readonly GameSelection _selection;
|
||||
private readonly IPageNavigator _navigator;
|
||||
@@ -34,8 +37,12 @@ public sealed partial class GamesViewModel : ObservableObject
|
||||
private readonly IAgentLink? _agent;
|
||||
private readonly LibraryChanges? _changes;
|
||||
private readonly IMessageStrip? _strip;
|
||||
private readonly TimeProvider _clock;
|
||||
private readonly Func<string, bool> _exists;
|
||||
private readonly UiThread _ui = new();
|
||||
private readonly List<string> _removed = [];
|
||||
private IReadOnlyList<GameCardViewModel> _all = [];
|
||||
private int _reads;
|
||||
private bool _viewRead;
|
||||
private bool _attached;
|
||||
|
||||
@@ -59,9 +66,12 @@ public sealed partial class GamesViewModel : ObservableObject
|
||||
private bool _listView;
|
||||
|
||||
public GamesViewModel(GameLibrary library, GameSelection selection, IPageNavigator navigator, AddGameFlow addGame, ImportLibraryFlow? import = null,
|
||||
RegisteredSettings? settings = null, IAgentLink? agent = null, LibraryChanges? changes = null, IMessageStrip? strip = null)
|
||||
RegisteredSettings? settings = null, IAgentLink? agent = null, LibraryChanges? changes = null, IMessageStrip? strip = null, TimeProvider? clock = null,
|
||||
Func<string, bool>? executableExists = null)
|
||||
{
|
||||
_strip = strip;
|
||||
_clock = clock ?? TimeProvider.System;
|
||||
_exists = executableExists ?? GameLibrary.ExecutableExists;
|
||||
_library = library ?? throw new ArgumentNullException(nameof(library));
|
||||
_selection = selection ?? throw new ArgumentNullException(nameof(selection));
|
||||
_navigator = navigator ?? throw new ArgumentNullException(nameof(navigator));
|
||||
@@ -91,6 +101,12 @@ public sealed partial class GamesViewModel : ObservableObject
|
||||
|
||||
public static string ListText => Strings.Games_View_List;
|
||||
|
||||
/// <summary>
|
||||
/// How long the page waits after the Agent says it removed a game (D55) for the rest of the same check before it reloads
|
||||
/// and says what went (beta.19). One check removes its games a few milliseconds apart, each in its own event.
|
||||
/// </summary>
|
||||
public static TimeSpan RemovalSettle { get; } = TimeSpan.FromSeconds(1);
|
||||
|
||||
/// <summary>The sort orders, labelled in the language this page opened in (beta.15: a static list kept the first language).</summary>
|
||||
public IReadOnlyList<Choice<GamesSort>> Sorts { get; } =
|
||||
[
|
||||
@@ -104,14 +120,26 @@ public sealed partial class GamesViewModel : ObservableObject
|
||||
/// <summary>The load in flight, for a test to await.</summary>
|
||||
public Task Pending { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The library read and listed. Reads overlap — a session that ends, an import, a removal — and the one that started first
|
||||
/// can finish last, its checks waiting on a drive that is slow to answer: only the newest read is shown (beta.19 — an
|
||||
/// older one put back the card of a game the Agent had just removed, until the next read).
|
||||
/// </summary>
|
||||
public async Task LoadAsync(CancellationToken ct = default)
|
||||
{
|
||||
int read = Interlocked.Increment(ref _reads);
|
||||
await ReadViewAsync(ct).ConfigureAwait(true);
|
||||
IReadOnlyList<GameCard> cards = await _library.ListCardsAsync(ct).ConfigureAwait(true);
|
||||
// Whether each executable is on disk is a file-system question per entry — a drive that is gone can take a moment
|
||||
// to say so — so it is asked off the UI thread, the game page's own way (GameLibrary.ExecutableExists).
|
||||
bool[] installed = await Task.Run(() => cards.Select(static c => GameLibrary.ExecutableExists(c.Row.Fingerprint.ExePath)).ToArray(), ct)
|
||||
Func<string, bool> exists = _exists;
|
||||
bool[] installed = await Task.Run(() => cards.Select(c => exists(c.Row.Fingerprint.ExePath)).ToArray(), ct)
|
||||
.ConfigureAwait(true);
|
||||
if (read != Volatile.Read(ref _reads))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_all = [.. cards.Select((c, i) => new GameCardViewModel(c, installed[i]))];
|
||||
HeaderText = string.Format(CultureInfo.CurrentCulture, Strings.Games_Header_Count_Format, _all.Count);
|
||||
Apply();
|
||||
@@ -251,11 +279,38 @@ public sealed partial class GamesViewModel : ObservableObject
|
||||
&& IpcCodec.Payload<GameRemovedEvent>(e.Envelope) is { } removed)
|
||||
{
|
||||
// D55 (beta.19): the Agent removed an entry whose game is no longer installed; the card goes, and the page says why.
|
||||
_strip?.Info(Strings.Games_Removed_Title, string.Format(CultureInfo.CurrentCulture, Strings.Games_Removed_Format, removed.GameName ?? removed.ExePath));
|
||||
Pending = LoadAsync();
|
||||
// A check that removes five says it in five events: the first waits for the rest, then one reload and one notice.
|
||||
_removed.Add(removed.GameName ?? removed.ExePath);
|
||||
if (_removed.Count == 1)
|
||||
{
|
||||
Pending = SayRemovedAsync();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// The games the Agent removed since the first of them, after <see cref="RemovalSettle"/>: the library read once, then one
|
||||
/// notice — the game's name, or how many went and which. A removal heard during the read starts the next notice.
|
||||
/// </summary>
|
||||
private async Task SayRemovedAsync()
|
||||
{
|
||||
await Task.Delay(RemovalSettle, _clock).ConfigureAwait(true);
|
||||
string[] names = [.. _removed];
|
||||
_removed.Clear();
|
||||
await LoadAsync().ConfigureAwait(true);
|
||||
if (_strip is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string listed = names.Length <= _removedNamed
|
||||
? string.Join(", ", names)
|
||||
: string.Format(CultureInfo.CurrentCulture, Strings.Games_Removed_More_Format, string.Join(", ", names.Take(_removedNamed)), names.Length - _removedNamed);
|
||||
_strip.Info(Strings.Games_Removed_Title, names.Length == 1
|
||||
? string.Format(CultureInfo.CurrentCulture, Strings.Games_Removed_Format, names[0])
|
||||
: string.Format(CultureInfo.CurrentCulture, Strings.Games_Removed_Many_Format, names.Length, listed));
|
||||
}
|
||||
|
||||
private void OnLibraryChanged(object? sender, EventArgs e) => _ui.Post(() => Pending = LoadAsync());
|
||||
|
||||
private void Apply()
|
||||
|
||||
@@ -103,9 +103,44 @@ public sealed class GamesViewModelTests
|
||||
public void Warn(string title, string body) => Lines.Add(title + ": " + body);
|
||||
}
|
||||
|
||||
/// <summary>A clock whose timers fire when the test says so (beta.19): the page's wait for the rest of a check, held.</summary>
|
||||
private sealed class HeldTimers : TimeProvider
|
||||
{
|
||||
private readonly List<(TimerCallback Callback, object? State)> _due = [];
|
||||
|
||||
public int Waiting => _due.Count;
|
||||
|
||||
public override ITimer CreateTimer(TimerCallback callback, object? state, TimeSpan dueTime, TimeSpan period)
|
||||
{
|
||||
_due.Add((callback, state));
|
||||
return new Held();
|
||||
}
|
||||
|
||||
public void Fire()
|
||||
{
|
||||
(TimerCallback Callback, object? State)[] due = [.. _due];
|
||||
_due.Clear();
|
||||
foreach ((TimerCallback callback, object? state) in due)
|
||||
{
|
||||
callback(state);
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class Held : ITimer
|
||||
{
|
||||
public bool Change(TimeSpan dueTime, TimeSpan period) => true;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public ValueTask DisposeAsync() => ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// beta.19, D55: the Agent removed an entry whose game is no longer installed — the page on screen drops its card at once
|
||||
/// and says why, in words that name the switch that turns it off.
|
||||
/// beta.19, D55: the Agent removed an entry whose game is no longer installed — the page on screen drops its card and says
|
||||
/// why, in words that name the switch that turns it off, once it has waited a moment for the rest of the same check.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task AnEntryTheAgentRemovedLeavesThePageOnScreenWithAWord()
|
||||
@@ -121,7 +156,8 @@ public sealed class GamesViewModelTests
|
||||
var nav = new NoNavigation();
|
||||
var link = new FakeAgentLink();
|
||||
var strip = new RecordingStrip();
|
||||
var vm = new GamesViewModel(s.Library, selection, nav, new AddGameFlow(s.Library, new NoPicker(), selection, nav, new NoStrip()), agent: link, strip: strip);
|
||||
var clock = new HeldTimers();
|
||||
var vm = new GamesViewModel(s.Library, selection, nav, new AddGameFlow(s.Library, new NoPicker(), selection, nav, new NoStrip()), agent: link, strip: strip, clock: clock);
|
||||
Task loaded = vm.Pending;
|
||||
await loaded;
|
||||
vm.Attach();
|
||||
@@ -129,8 +165,10 @@ public sealed class GamesViewModelTests
|
||||
// What the Agent did, then said.
|
||||
await s.Db.WriteAsync((c, tx, ct) => Dapper.SqlMapper.ExecuteAsync(c, new Dapper.CommandDefinition("DELETE FROM games WHERE id = @id", new { id = gone.Id }, tx, cancellationToken: ct)), Ct);
|
||||
link.Raise(IpcMessageType.GameRemoved, new GameRemovedEvent(gone.Id, "Gone", gone.Fingerprint.ExePath, GameRemovedEvent.Uninstalled));
|
||||
Task reloaded = vm.Pending;
|
||||
await reloaded;
|
||||
Task said = vm.Pending;
|
||||
strip.Lines.Should().BeEmpty("the page waits a moment for the rest of the same check");
|
||||
clock.Fire();
|
||||
await said;
|
||||
|
||||
vm.Games.Should().ContainSingle().Which.Name.Should().Be("Kept");
|
||||
strip.Lines.Should().ContainSingle().Which.Should().StartWith("Removed from the library: Gone is no longer installed").And.Contain("Settings ▸ Data");
|
||||
@@ -141,6 +179,70 @@ public sealed class GamesViewModelTests
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// beta.19: a check that removes several entries says each in its own event, milliseconds apart. The page read the library
|
||||
/// and spoke once per event, and the shell's one snackbar kept only the last name; it now waits once, reads the library
|
||||
/// once and says them all in one notice — the count, and five names at most.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task OneCheckThatRemovesSeveralEntriesIsSaidOnceAfterOneRead()
|
||||
{
|
||||
CultureInfo? previous = Strings.Culture;
|
||||
Strings.Culture = CultureInfo.GetCultureInfo("en");
|
||||
try
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
GameRow[] gone = [await s.GameAsync("Alpha"), await s.GameAsync("Bravo"), await s.GameAsync("Charlie")];
|
||||
_ = await s.GameAsync("Kept");
|
||||
var selection = new GameSelection();
|
||||
var nav = new NoNavigation();
|
||||
var link = new FakeAgentLink();
|
||||
var strip = new RecordingStrip();
|
||||
var clock = new HeldTimers();
|
||||
var vm = new GamesViewModel(s.Library, selection, nav, new AddGameFlow(s.Library, new NoPicker(), selection, nav, new NoStrip()), agent: link, strip: strip, clock: clock);
|
||||
Task loaded = vm.Pending;
|
||||
await loaded;
|
||||
vm.Attach();
|
||||
|
||||
foreach (GameRow row in gone)
|
||||
{
|
||||
await s.Db.WriteAsync((c, tx, ct) => Dapper.SqlMapper.ExecuteAsync(c, new Dapper.CommandDefinition("DELETE FROM games WHERE id = @id", new { id = row.Id }, tx, cancellationToken: ct)), Ct);
|
||||
}
|
||||
|
||||
foreach (GameRow row in gone)
|
||||
{
|
||||
link.Raise(IpcMessageType.GameRemoved, new GameRemovedEvent(row.Id, row.Name, row.Fingerprint.ExePath, GameRemovedEvent.Uninstalled));
|
||||
}
|
||||
|
||||
Task said = vm.Pending;
|
||||
clock.Waiting.Should().Be(1, "one wait for the whole check, not one per entry");
|
||||
clock.Fire();
|
||||
await said;
|
||||
|
||||
vm.Games.Should().ContainSingle().Which.Name.Should().Be("Kept");
|
||||
strip.Lines.Should().ContainSingle().Which.Should().Be("Removed from the library: 3 games are no longer installed and had no sessions, so the capture "
|
||||
+ "agent removed them: Alpha, Bravo, Charlie. Settings ▸ Data turns this off.");
|
||||
|
||||
// Six in one check: the count, five names and how many more.
|
||||
for (int i = 1; i <= 6; i++)
|
||||
{
|
||||
link.Raise(IpcMessageType.GameRemoved, new GameRemovedEvent(1000 + i, "G" + i.ToString(CultureInfo.InvariantCulture), @"Q:\G\g.exe", GameRemovedEvent.Uninstalled));
|
||||
}
|
||||
|
||||
Task again = vm.Pending;
|
||||
clock.Waiting.Should().Be(1);
|
||||
clock.Fire();
|
||||
await again;
|
||||
|
||||
strip.Lines.Should().HaveCount(2);
|
||||
strip.Lines[^1].Should().Contain("6 games").And.Contain(": G1, G2, G3, G4, G5 and 1 more. ").And.NotContain("G6");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Strings.Culture = previous;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ACardSaysWhetherItsExecutableIsThereAndWhy()
|
||||
{
|
||||
@@ -156,6 +258,8 @@ public sealed class GamesViewModelTests
|
||||
await using ScratchLedger s2 = await ScratchLedger.OpenAsync();
|
||||
var listed = new GamesViewModel(s2.Library, new GameSelection(), new NoNavigation(),
|
||||
new AddGameFlow(s2.Library, new NoPicker(), new GameSelection(), new NoNavigation(), new NoStrip()));
|
||||
Task opened = listed.Pending;
|
||||
await opened; // the page's own first read, of an empty library, before the games below are added
|
||||
string here = typeof(GamesViewModelTests).Assembly.Location;
|
||||
_ = await s2.GameAsync("Here", here);
|
||||
_ = await s2.GameAsync("Gone", Path.Combine(AppContext.BaseDirectory, "no-such-game.exe"));
|
||||
@@ -164,6 +268,55 @@ public sealed class GamesViewModelTests
|
||||
listed.Games.Single(static g => string.Equals(g.Name, "Gone", StringComparison.Ordinal)).NotInstalled.Should().BeTrue();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// beta.19: reads of the library overlap, and the one that started first can finish last — its checks waiting on a drive
|
||||
/// that is slow to answer. It used to be shown over the newer one: a game the Agent had just removed came back until the
|
||||
/// next read. One local run in about 165 failed <see cref="ACardSaysWhetherItsExecutableIsThereAndWhy"/> that way, its
|
||||
/// own two reads racing.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task AnOlderReadThatFinishesLastIsNotShownOverANewerOne()
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
_ = await s.GameAsync("Alpha");
|
||||
var bound = TimeSpan.FromSeconds(30);
|
||||
using var firstBegan = new ManualResetEventSlim();
|
||||
using var firstMayEnd = new ManualResetEventSlim();
|
||||
int checks = 0;
|
||||
bool Exists(string path)
|
||||
{
|
||||
if (Interlocked.Increment(ref checks) == 1)
|
||||
{
|
||||
// The first read's check waits, as on a drive that is slow to answer.
|
||||
firstBegan.Set();
|
||||
_ = firstMayEnd.Wait(bound, Ct);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
var selection = new GameSelection();
|
||||
var nav = new NoNavigation();
|
||||
var vm = new GamesViewModel(s.Library, selection, nav, new AddGameFlow(s.Library, new NoPicker(), selection, nav, new NoStrip()), executableExists: Exists);
|
||||
Task first = vm.Pending;
|
||||
try
|
||||
{
|
||||
// Only once the first read is held in its check does the second begin: its checks are then never the held one.
|
||||
firstBegan.Wait(bound, Ct).Should().BeTrue("the page's first read checks its one game");
|
||||
_ = await s.GameAsync("Bravo");
|
||||
await vm.LoadAsync(Ct);
|
||||
vm.Games.Should().HaveCount(2, "the newer read lists both");
|
||||
}
|
||||
finally
|
||||
{
|
||||
firstMayEnd.Set();
|
||||
}
|
||||
|
||||
await first;
|
||||
vm.Games.Should().HaveCount(2, "the older read, of one game, finished last and is not shown");
|
||||
vm.HeaderText.Should().EndWith("2");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(1200, 3)]
|
||||
[InlineData(1248, 4)]
|
||||
|
||||
Reference in new issue
Block a user