Phase 0 (T1-3/4/7/9/11): find bar w/ native Find API + search engine + site zoom + force reload + F11, wired into MainWindow, E2E smoke (39 tests)
This commit is contained in:
parent
470c9267f2
commit
00a822eaeb
11 changed files with 584 additions and 18 deletions
98
VideoDownloader.Tests/Browser/FindSessionTests.cs
Normal file
98
VideoDownloader.Tests/Browser/FindSessionTests.cs
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
using VideoDownloader.App.Browser;
|
||||
|
||||
namespace VideoDownloader.Tests.Browser;
|
||||
|
||||
// T1-3 페이지 내 검색: FindSession 은 네이티브 Find API(IFindApi) 위의 상태 머신.
|
||||
public class FindSessionTests
|
||||
{
|
||||
private sealed class FakeFindApi : IFindApi
|
||||
{
|
||||
public string? LastTerm;
|
||||
public int StartCount, NextCount, PrevCount, StopCount;
|
||||
public int MatchCount { get; set; }
|
||||
public int ActiveIndex { get; set; }
|
||||
|
||||
public event EventHandler<int>? MatchCountChanged;
|
||||
public event EventHandler<int>? ActiveMatchIndexChanged;
|
||||
|
||||
public Task StartAsync(string term, bool caseSensitive, bool matchWord, bool highlightAll)
|
||||
{
|
||||
StartCount++; LastTerm = term; return Task.CompletedTask;
|
||||
}
|
||||
public void FindNext() => NextCount++;
|
||||
public void FindPrevious() => PrevCount++;
|
||||
public void Stop() => StopCount++;
|
||||
|
||||
public void RaiseCount(int n) { MatchCount = n; MatchCountChanged?.Invoke(this, n); }
|
||||
public void RaiseActive(int n) { ActiveIndex = n; ActiveMatchIndexChanged?.Invoke(this, n); }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Start는_API로_용어를_전달하고_카운트_이벤트를_구독_반영한다()
|
||||
{
|
||||
var api = new FakeFindApi();
|
||||
var session = new FindSession(api);
|
||||
|
||||
session.StartAsync("hello").Wait();
|
||||
api.RaiseCount(7);
|
||||
|
||||
Assert.Equal(1, api.StartCount);
|
||||
Assert.Equal("hello", api.LastTerm);
|
||||
Assert.Equal(7, session.MatchCount);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Next_Previous는_API에_위임한다()
|
||||
{
|
||||
var api = new FakeFindApi();
|
||||
var session = new FindSession(api);
|
||||
session.StartAsync("x").Wait();
|
||||
|
||||
session.Next();
|
||||
session.Previous();
|
||||
|
||||
Assert.Equal(1, api.NextCount);
|
||||
Assert.Equal(1, api.PrevCount);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ActiveMatchIndex_이벤트가_상태에_반영된다()
|
||||
{
|
||||
var api = new FakeFindApi();
|
||||
var session = new FindSession(api);
|
||||
session.StartAsync("x").Wait();
|
||||
|
||||
api.RaiseActive(3);
|
||||
Assert.Equal(3, session.ActiveMatchIndex);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void 빈_용어로_Start하면_Stop만_호출된다()
|
||||
{
|
||||
var api = new FakeFindApi();
|
||||
var session = new FindSession(api);
|
||||
|
||||
session.StartAsync(" ").Wait();
|
||||
|
||||
Assert.Equal(0, api.StartCount);
|
||||
Assert.Equal(1, api.StopCount);
|
||||
Assert.Equal(0, session.MatchCount);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Close는_Stop을_호출하고_상태를_초기화한다()
|
||||
{
|
||||
var api = new FakeFindApi();
|
||||
var session = new FindSession(api);
|
||||
session.StartAsync("x").Wait();
|
||||
api.RaiseCount(5);
|
||||
api.RaiseActive(2);
|
||||
|
||||
session.Close();
|
||||
|
||||
Assert.Equal(1, api.StopCount);
|
||||
Assert.Equal(0, session.MatchCount);
|
||||
Assert.Equal(-1, session.ActiveMatchIndex); // -1 = 활성 매치 없음(Start 초기값과 동일 센티넬)
|
||||
Assert.Equal(string.Empty, session.Term);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue