71 lines
3 KiB
C#
71 lines
3 KiB
C#
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Media;
|
|
using VideoDownloader.App;
|
|
using VideoDownloader.Tests.Infrastructure;
|
|
|
|
namespace VideoDownloader.Tests.E2E;
|
|
|
|
/// <summary>
|
|
/// 아이콘 tofu 실결함(사용자 보고 "아이콘은 절대 안고쳐지네") 회귀 테스트 —
|
|
/// 근본 원인: Shared.xaml 의 암시적 TextBlock 스타일이 FontFamily 를 UiFont 로 강제해,
|
|
/// 버튼 ContentPresenter 가 만드는 자동 TextBlock 이 IconFont 상속을 잃고 PUA 글리프가 notdef 가 됐다.
|
|
/// 아이콘 버튼의 실제 콘텐츠 TextBlock 이 아이콘 폰트로 해석되는지 실창에서 검증한다.
|
|
/// </summary>
|
|
[Collection("E2E")]
|
|
public class IconContentFontTests
|
|
{
|
|
private static TextBlock? FindTextBlock(DependencyObject root)
|
|
{
|
|
if (root is TextBlock tb) return tb;
|
|
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(root); i++)
|
|
{
|
|
if (FindTextBlock(VisualTreeHelper.GetChild(root, i)) is { } found) return found;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
[Fact]
|
|
public async Task 아이콘_버튼의_콘텐츠_TextBlock_은_아이콘폰트로_렌더된다()
|
|
{
|
|
var dataDir = Path.Combine(Path.GetTempPath(), $"vd_iconfont_{Guid.NewGuid():N}");
|
|
Environment.SetEnvironmentVariable("VD_DATA_DIR", dataDir);
|
|
try
|
|
{
|
|
using var sta = StaDispatcher.Start();
|
|
WpfTestApp.Ensure(sta.Dispatcher);
|
|
var (navFamily, captionFamily, bodyFamily) = await sta.Dispatcher.InvokeAsync(() =>
|
|
{
|
|
// 앱과 동일 조건: 절대 pack URI 테마 재로드 후 실창
|
|
VideoDownloader.App.App.ApplyTheme("dark");
|
|
var win = new MainWindow { Left = 20, Top = 700, WindowStartupLocation = WindowStartupLocation.Manual };
|
|
win.Show();
|
|
win.UpdateLayout();
|
|
|
|
var nav = (Button)win.FindName("NavBack")!;
|
|
var navText = FindTextBlock(nav)!;
|
|
|
|
// 캡션(최대화/복원) 버튼 — CaptionButton 스타일 경유
|
|
var caption = win.FindName("MaxRestoreBtn") as Button;
|
|
var captionText = caption != null ? FindTextBlock(caption) : null;
|
|
|
|
// 일반 본문 TextBlock 은 여전히 UI 폰트를 따라야 한다(암시 스타일의 원래 목적)
|
|
var status = (TextBlock)win.FindName("StatusText")!;
|
|
|
|
var result = (navText.FontFamily.Source, captionText?.FontFamily.Source ?? "(캡션 버튼 없음)", status.FontFamily.Source);
|
|
win.Close();
|
|
return result;
|
|
});
|
|
|
|
Assert.Equal("Segoe Fluent Icons", navFamily);
|
|
if (captionFamily != "(캡션 버튼 없음)")
|
|
Assert.Equal("Segoe Fluent Icons", captionFamily);
|
|
Assert.Contains("Pretendard", bodyFamily); // 본문은 UI 폰트 유지
|
|
}
|
|
finally
|
|
{
|
|
Environment.SetEnvironmentVariable("VD_DATA_DIR", null);
|
|
try { Directory.Delete(dataDir, true); } catch { }
|
|
}
|
|
}
|
|
}
|