releases/tests/Paca.Tests/Browser/ChromeParityMilestone6Tests.cs

74 lines
3.3 KiB
C#

using System;
using System.IO;
using System.Windows;
using Paca.App;
using Paca.Browser;
using Paca.Tests.Infrastructure;
using Xunit;
namespace Paca.Tests.Browser;
public class ChromeParityMilestone6Tests
{
[Theory]
[InlineData("chrome://history", ChromeInternalAction.History)]
[InlineData("paca://history", ChromeInternalAction.History)]
[InlineData("chrome://downloads", ChromeInternalAction.Downloads)]
[InlineData("paca://downloads", ChromeInternalAction.Downloads)]
[InlineData("chrome://bookmarks", ChromeInternalAction.Bookmarks)]
[InlineData("paca://bookmarks", ChromeInternalAction.Bookmarks)]
[InlineData("chrome://settings", ChromeInternalAction.Settings)]
[InlineData("paca://settings", ChromeInternalAction.Settings)]
[InlineData("chrome://extensions", ChromeInternalAction.Extensions)]
[InlineData("paca://extensions", ChromeInternalAction.Extensions)]
[InlineData("chrome://clear-browsing-data", ChromeInternalAction.ClearBrowsingData)]
[InlineData("paca://clear-browsing-data", ChromeInternalAction.ClearBrowsingData)]
[InlineData("chrome://task-manager", ChromeInternalAction.TaskManager)]
[InlineData("paca://task-manager", ChromeInternalAction.TaskManager)]
[InlineData("chrome://version", ChromeInternalAction.Version)]
[InlineData("paca://version", ChromeInternalAction.Version)]
[InlineData("https://google.com", ChromeInternalAction.None)]
[InlineData("about:blank", ChromeInternalAction.None)]
public void ChromeInternalUrlRouter_크롬_표준_내부URL을_올바른_액션으로_매핑한다(string url, ChromeInternalAction expectedAction)
{
var action = ChromeInternalUrlRouter.Route(url);
Assert.Equal(expectedAction, action);
}
[Fact]
public void DownloadCompleteShelf_다운로드_완료시_노출되고_닫기시_숨겨진다()
{
using var sta = StaDispatcher.Start();
WpfTestApp.Ensure(sta.Dispatcher);
sta.Invoke(() =>
{
var dataDir = Path.Combine(Path.GetTempPath(), $"vd_shelf_{Guid.NewGuid():N}");
Environment.SetEnvironmentVariable("VD_DATA_DIR", dataDir);
try
{
var win = new MainWindow();
Assert.NotNull(win.DownloadShelfBar);
Assert.NotNull(win.DownloadShelfFileName);
Assert.NotNull(win.DownloadShelfOpenBtn);
Assert.NotNull(win.DownloadShelfRevealBtn);
Assert.NotNull(win.DownloadShelfCloseBtn);
// 초기 상태: 숨김
Assert.Equal(Visibility.Collapsed, win.DownloadShelfBar.Visibility);
// 다운로드 완료 표시
win.ShowDownloadCompleteShelf("test_video.mp4", 15 * 1024 * 1024, @"C:\Downloads\test_video.mp4");
Assert.Equal(Visibility.Visible, win.DownloadShelfBar.Visibility);
Assert.Equal("test_video.mp4", win.DownloadShelfFileName.Text);
// 닫기 클릭 시 숨김
win.DownloadShelfCloseBtn.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Primitives.ButtonBase.ClickEvent));
Assert.Equal(Visibility.Collapsed, win.DownloadShelfBar.Visibility);
}
finally
{
try { if (Directory.Exists(dataDir)) Directory.Delete(dataDir, true); } catch { }
}
});
}
}