80 lines
2.7 KiB
C#
80 lines
2.7 KiB
C#
using VideoDownloader.Browser;
|
|
|
|
namespace VideoDownloader.Tests.Browser;
|
|
|
|
/// <summary>T3-15: 파라미터 제거 복사 + 주소창 진행 상태.</summary>
|
|
public class UrlCleanerTests
|
|
{
|
|
[Theory]
|
|
[InlineData("https://x.com/a?utm_source=1&b=2", "https://x.com/a")] // 쿼리 제거
|
|
[InlineData("https://x.com/a#frag", "https://x.com/a")] // 프래그먼트 제거
|
|
[InlineData("https://x.com/a?b=1#f", "https://x.com/a")] // 둘 다
|
|
[InlineData("https://x.com/a/", "https://x.com/a/")] // 없으면 무변경
|
|
[InlineData("https://x.com/a?q=한글", "https://x.com/a")] // 유니코드 쿼리
|
|
[InlineData("x.com/a?b=1", "x.com/a")] // 스킴 없어도 동작
|
|
public void StripQuery_파라미터와_프래그먼트를_제거(string input, string expected)
|
|
=> Assert.Equal(expected, UrlCleaner.StripQuery(input));
|
|
|
|
[Fact]
|
|
public void StripQuery_빈값_null_안전()
|
|
{
|
|
Assert.Equal("", UrlCleaner.StripQuery(""));
|
|
Assert.Null(UrlCleaner.StripQuery(null));
|
|
}
|
|
}
|
|
|
|
/// <summary>T3-15: 탭 전체 네비게이션 진행 집계 — 주소창 진행 바 표시 상태.</summary>
|
|
public class NavProgressTrackerTests
|
|
{
|
|
[Fact]
|
|
public void 초기값은_비진행()
|
|
=> Assert.False(new NavProgressTracker().IsNavigating);
|
|
|
|
[Fact]
|
|
public void 시작하면_진행()
|
|
{
|
|
var t = new NavProgressTracker();
|
|
t.Started();
|
|
Assert.True(t.IsNavigating);
|
|
}
|
|
|
|
[Fact]
|
|
public void 완료되면_비진행()
|
|
{
|
|
var t = new NavProgressTracker();
|
|
t.Started();
|
|
t.Completed();
|
|
Assert.False(t.IsNavigating);
|
|
}
|
|
|
|
[Fact]
|
|
public void 동시_내비게이션은_마지막_완료까지_진행() // 프레임 리다이렉트·중복 시작
|
|
{
|
|
var t = new NavProgressTracker();
|
|
t.Started(); t.Started();
|
|
t.Completed();
|
|
Assert.True(t.IsNavigating);
|
|
t.Completed();
|
|
Assert.False(t.IsNavigating);
|
|
}
|
|
|
|
[Fact]
|
|
public void 과잉_완료로_음수_되지_않음()
|
|
{
|
|
var t = new NavProgressTracker();
|
|
t.Completed();
|
|
Assert.False(t.IsNavigating);
|
|
}
|
|
|
|
[Fact]
|
|
public void IsNavigating_변경_시_INPC_발화()
|
|
{
|
|
var t = new NavProgressTracker();
|
|
var fired = new List<string?>();
|
|
t.PropertyChanged += (_, e) => fired.Add(e.PropertyName);
|
|
t.Started();
|
|
t.Completed();
|
|
t.Completed(); // false→false → 이벤트 없음
|
|
Assert.Equal(new[] { nameof(NavProgressTracker.IsNavigating), nameof(NavProgressTracker.IsNavigating) }, fired);
|
|
}
|
|
}
|