- Mica 베이스 + 왼쪽 위 8px 라운드 콘텐츠 레이어 (탐색기·설정 앱 2계층 구조) - 시스템 라이트/다크·강조색 자동 추종 (FsThemeService, FsPalette.Light/Dark) - 강조색은 시스템 강조색에서 WCAG AA 대비를 보정해 파생 (FsAccentPalette) - Segoe UI Variable 타입 램프, 최소 12px, 반경 4/8px, 카드 중첩 제거 - 네온 시안·더블 베젤·그라디언트 버튼·Inter 서체 폐기 - 전 창 적용: 메인·빠른 옵션/진행·설정·도구 설치·진단, 광고는 중립 카드로 - 결함 수정: 사이드바 체크박스 라벨 잘림, 행 체크박스 잘림, 입력란 이중 여백, 제목 표시줄 아이콘 검게 렌더, '큐'/'대기열' 용어 혼용 - Google AdMob 광고 단위 연동 (AdHtmlBuilder, 설정 창 AdMob 카드) - Win11NativeDesignTests 계약 테스트, VisualCaptureHarness 시각 E2E 캡처
106 lines
5.1 KiB
C#
106 lines
5.1 KiB
C#
using System.IO;
|
|
using System.Windows;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using Everything2Everything.App.Theming;
|
|
using Everything2Everything.App.Views;
|
|
using Everything2Everything.Core;
|
|
using Xunit;
|
|
|
|
namespace Everything2Everything.Tests;
|
|
|
|
/// <summary>
|
|
/// 상태별 시각 E2E 캡처 (designpaca 5단계 렌더 감사).
|
|
/// E2E_CAPTURE_DIR 이 지정된 경우에만 동작하고, 평소 테스트 실행에서는 즉시 끝난다.
|
|
/// $env:E2E_CAPTURE_DIR="C:\temp\e2e"; dotnet test --filter FullyQualifiedName~VisualCaptureHarness
|
|
/// 창마다 라이트/다크 PNG를 남긴다. Mica는 오프스크린에서 렌더되지 않으므로 WinUI 기준 근사색을 깔고 그린다.
|
|
/// 구조 테스트가 통과해도 캡처는 사람이 직접 열어 위계·잘림·대비를 판정한다.
|
|
/// </summary>
|
|
public class VisualCaptureHarness
|
|
{
|
|
private sealed class Store : ISettingsStore
|
|
{
|
|
private readonly Dictionary<string, string> _d = new();
|
|
public string? Get(string key) => _d.TryGetValue(key, out var v) ? v : null;
|
|
public void Set(string key, string value) => _d[key] = value;
|
|
public void Remove(string key) => _d.Remove(key);
|
|
public bool Contains(string key) => _d.ContainsKey(key);
|
|
}
|
|
|
|
[Fact]
|
|
public void Capture()
|
|
{
|
|
var outDir = Environment.GetEnvironmentVariable("E2E_CAPTURE_DIR");
|
|
if (string.IsNullOrEmpty(outDir)) return;
|
|
Directory.CreateDirectory(outDir);
|
|
|
|
Exception? error = null;
|
|
var t = new Thread(() =>
|
|
{
|
|
try { CaptureAll(outDir); } catch (Exception e) { error = e; }
|
|
});
|
|
t.SetApartmentState(ApartmentState.STA);
|
|
t.Start();
|
|
t.Join();
|
|
if (error != null) throw error;
|
|
}
|
|
|
|
private static void CaptureAll(string outDir)
|
|
{
|
|
var app = Application.Current ?? new Application();
|
|
var root = Directory.GetCurrentDirectory();
|
|
while (!File.Exists(Path.Combine(root, "Everything2Everything.slnx"))) root = Directory.GetParent(root)!.FullName;
|
|
var assets = Path.Combine(root, "test_assets");
|
|
var engine = Everything2EverythingBootstrap.CreateDefault();
|
|
var files = new List<string> { Path.Combine(assets, "test_icon.png"), Path.Combine(assets, "test_art.png"), Path.Combine(assets, "sample_image.png") };
|
|
|
|
foreach (var mode in new[] { FsThemeMode.Dark, FsThemeMode.Light })
|
|
{
|
|
UseTheme(app, mode);
|
|
var mica = mode == FsThemeMode.Dark ? Color.FromRgb(0x20, 0x20, 0x20) : Color.FromRgb(0xF3, 0xF3, 0xF3);
|
|
var tag = mode.ToString().ToLowerInvariant();
|
|
|
|
Render(new MainWindow(engine, new Store(), files).Content, 1280, 860, mica, Path.Combine(outDir, $"main-queue-{tag}.png"));
|
|
Render(new MainWindow(engine, new Store()).Content, 1280, 860, mica, Path.Combine(outDir, $"main-empty-{tag}.png"));
|
|
Render(new SettingsWindow(new Store()).Content, 560, 720, mica, Path.Combine(outDir, $"settings-{tag}.png"));
|
|
Render(new QuickOptionsWindow(".jpg", 3, new Store()).Content, 380, 360, mica, Path.Combine(outDir, $"quick-options-{tag}.png"));
|
|
Render(new QuickProgressWindow(3, new CancellationTokenSource(), ".jpg").Content, 560, 240, mica, Path.Combine(outDir, $"quick-progress-{tag}.png"));
|
|
Render(new ToolSetupWindow().Content, 640, 680, mica, Path.Combine(outDir, $"tool-setup-{tag}.png"));
|
|
}
|
|
}
|
|
|
|
private static void UseTheme(Application app, FsThemeMode mode)
|
|
{
|
|
var merged = app.Resources.MergedDictionaries;
|
|
merged.Clear();
|
|
merged.Add(new Wpf.Ui.Markup.ThemesDictionary
|
|
{
|
|
Theme = mode == FsThemeMode.Dark ? Wpf.Ui.Appearance.ApplicationTheme.Dark : Wpf.Ui.Appearance.ApplicationTheme.Light,
|
|
});
|
|
merged.Add(new Wpf.Ui.Markup.ControlsDictionary());
|
|
merged.Add(new ResourceDictionary { Source = FsThemeService.PaletteUri(mode) });
|
|
merged.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/Everything2Everything;component/Views/FormatShiftTheme.xaml") });
|
|
FsThemeService.Apply(app, mode, Color.FromRgb(0x00, 0x78, 0xD4)); // Windows 기본 강조색
|
|
}
|
|
|
|
private static void Render(object? content, int w, int h, Color mica, string path)
|
|
{
|
|
if (content is not FrameworkElement element) return;
|
|
element.Measure(new Size(w, h));
|
|
element.Arrange(new Rect(0, 0, w, h));
|
|
element.UpdateLayout();
|
|
|
|
var visual = new DrawingVisual();
|
|
using (var dc = visual.RenderOpen())
|
|
{
|
|
dc.DrawRectangle(new SolidColorBrush(mica), null, new Rect(0, 0, w, h));
|
|
dc.DrawRectangle(new VisualBrush(element) { Stretch = Stretch.None, AlignmentX = AlignmentX.Left, AlignmentY = AlignmentY.Top }, null, new Rect(0, 0, w, h));
|
|
}
|
|
var bitmap = new RenderTargetBitmap(w, h, 96, 96, PixelFormats.Pbgra32);
|
|
bitmap.Render(visual);
|
|
var encoder = new PngBitmapEncoder();
|
|
encoder.Frames.Add(BitmapFrame.Create(bitmap));
|
|
using var fs = File.Create(path);
|
|
encoder.Save(fs);
|
|
}
|
|
}
|