refactor(1): detection App->Core + AppPaths (VD_DATA_DIR isolation for deterministic E2E)
This commit is contained in:
parent
1aab8729fa
commit
9eb988440f
5 changed files with 29 additions and 7 deletions
14
VideoDownloader.App/AppPaths.cs
Normal file
14
VideoDownloader.App/AppPaths.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
namespace VideoDownloader.App;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 앱 데이터 디렉터리 결정. 기본 %AppData%/VideoDownloader.
|
||||||
|
/// 환경변수 VD_DATA_DIR 로 오버라이드 — E2E 테스트가 실사용자 프로필/설정/세션과
|
||||||
|
/// 격리된 임시 디렉터리에서 실행되도록 한다(결정적 테스트를 위한 공식 후크).
|
||||||
|
/// </summary>
|
||||||
|
public static class AppPaths
|
||||||
|
{
|
||||||
|
public static string DataDir =>
|
||||||
|
Environment.GetEnvironmentVariable("VD_DATA_DIR") is { Length: > 0 } env
|
||||||
|
? env
|
||||||
|
: Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "VideoDownloader");
|
||||||
|
}
|
||||||
|
|
@ -7,8 +7,7 @@ namespace VideoDownloader.App.Browser;
|
||||||
/// 손상 파일은 백업 후 빈 목록을 반환(다음 저장이 원본을 덮어쓰는 데이터 손실 방지).</summary>
|
/// 손상 파일은 백업 후 빈 목록을 반환(다음 저장이 원본을 덮어쓰는 데이터 손실 방지).</summary>
|
||||||
public static class BrowserStore
|
public static class BrowserStore
|
||||||
{
|
{
|
||||||
private static string Dir => Path.Combine(
|
private static string Dir => AppPaths.DataDir;
|
||||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "VideoDownloader");
|
|
||||||
private static string BookmarksPath => Path.Combine(Dir, "bookmarks.json");
|
private static string BookmarksPath => Path.Combine(Dir, "bookmarks.json");
|
||||||
private static string HistoryPath => Path.Combine(Dir, "history.json");
|
private static string HistoryPath => Path.Combine(Dir, "history.json");
|
||||||
private static readonly JsonSerializerOptions JsonOpts = new() { WriteIndented = true };
|
private static readonly JsonSerializerOptions JsonOpts = new() { WriteIndented = true };
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,7 @@ namespace VideoDownloader.App.Core;
|
||||||
/// <summary>%AppData%/VideoDownloader/config.json 으로 설정 영속화</summary>
|
/// <summary>%AppData%/VideoDownloader/config.json 으로 설정 영속화</summary>
|
||||||
public static class ConfigStore
|
public static class ConfigStore
|
||||||
{
|
{
|
||||||
private static string Dir => Path.Combine(
|
private static string Dir => AppPaths.DataDir;
|
||||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "VideoDownloader");
|
|
||||||
private static string FilePath => Path.Combine(Dir, "config.json");
|
private static string FilePath => Path.Combine(Dir, "config.json");
|
||||||
|
|
||||||
private static readonly JsonSerializerOptions JsonOpts = new() { WriteIndented = true };
|
private static readonly JsonSerializerOptions JsonOpts = new() { WriteIndented = true };
|
||||||
|
|
|
||||||
|
|
@ -145,9 +145,8 @@ public partial class MainWindow : Window
|
||||||
[DllImport("dwmapi.dll")]
|
[DllImport("dwmapi.dll")]
|
||||||
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attribute, ref int pvAttribute, int cbAttribute);
|
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attribute, ref int pvAttribute, int cbAttribute);
|
||||||
|
|
||||||
/// <summary>WebView2 영속 프로필 경로. 쿠키·세션·localStorage·캐시가 여기 보존되어 앱/빌드 재시작에도 유지.</summary>
|
/// <summary>앱 데이터 디렉터리(AppPaths.DataDir — VD_DATA_DIR 오버라이드 지원).</summary>
|
||||||
internal static string AppDataDir => Path.Combine(
|
internal static string AppDataDir => AppPaths.DataDir;
|
||||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "VideoDownloader");
|
|
||||||
|
|
||||||
internal static string ProfileFolder => Path.Combine(AppDataDir, "webview");
|
internal static string ProfileFolder => Path.Combine(AppDataDir, "webview");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,11 @@ public class MainWindowSmokeE2ETests
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task MainWindow_기동_탐색_탭전환_닫기_복원_검색바_전체화면_E2E()
|
public async Task MainWindow_기동_탐색_탭전환_닫기_복원_검색바_전체화면_E2E()
|
||||||
|
{
|
||||||
|
// VD_DATA_DIR 격리: 실사용자 설정/세션/프로필과 분리된 임시 데이터 디렉터리 (결정적 테스트)
|
||||||
|
var dataDir = Path.Combine(Path.GetTempPath(), $"vd_e2e_data_{Guid.NewGuid():N}");
|
||||||
|
Environment.SetEnvironmentVariable("VD_DATA_DIR", dataDir);
|
||||||
|
try
|
||||||
{
|
{
|
||||||
using var sta = StaDispatcher.Start();
|
using var sta = StaDispatcher.Start();
|
||||||
WpfTestApp.Ensure(sta.Dispatcher);
|
WpfTestApp.Ensure(sta.Dispatcher);
|
||||||
|
|
@ -78,6 +83,12 @@ public class MainWindowSmokeE2ETests
|
||||||
Assert.True(ok.toolbarHidden, "전체화면에서 크롬 미숨김");
|
Assert.True(ok.toolbarHidden, "전체화면에서 크롬 미숨김");
|
||||||
Assert.True(ok.toolbarBack, "전체화면 복원 실패");
|
Assert.True(ok.toolbarBack, "전체화면 복원 실패");
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Environment.SetEnvironmentVariable("VD_DATA_DIR", null);
|
||||||
|
try { Directory.Delete(dataDir, true); } catch { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Task WaitUntilNavCompleted(Microsoft.Web.WebView2.Core.CoreWebView2 cv)
|
private static Task WaitUntilNavCompleted(Microsoft.Web.WebView2.Core.CoreWebView2 cv)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue