79 lines
2.5 KiB
C#
79 lines
2.5 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using Paca.Core.QuickActions;
|
|
using Xunit;
|
|
|
|
namespace Paca.Tests.App;
|
|
|
|
public class QuickActionLauncherIntegrationGateTests
|
|
{
|
|
private static readonly string SolutionRoot = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..", ".."));
|
|
|
|
[Fact]
|
|
public void Gate_MainWindow_IntegratesQuickActionServicesAndTray()
|
|
{
|
|
var mwPath = Path.Combine(SolutionRoot, "src", "Paca.App", "MainWindow.xaml.cs");
|
|
Assert.True(File.Exists(mwPath), $"MainWindow.xaml.cs must exist at {mwPath}");
|
|
var code = File.ReadAllText(mwPath);
|
|
|
|
// Global hotkey integration
|
|
Assert.Contains("InitializeQuickActionServices", code);
|
|
Assert.Contains("Shift+Ctrl+Alt+P", code);
|
|
Assert.Contains("ShowQuickActionLauncher", code);
|
|
|
|
// Windows tray daemon integration
|
|
Assert.Contains("WindowsTrayDaemon", code);
|
|
Assert.Contains("CloseToTray", code);
|
|
Assert.Contains("ForceClose", code);
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate_QuickActionLauncher_ExecuteAction_ExecutesHandlerWithContext()
|
|
{
|
|
var catalog = new QuickActionCatalog();
|
|
bool actionRan = false;
|
|
string? passedQuery = null;
|
|
|
|
var customAction = new QuickActionItem(
|
|
"test.custom_action",
|
|
"테스트 액션",
|
|
QuickActionCategory.Developer,
|
|
"test custom action",
|
|
"Ctrl+Alt+T",
|
|
"\uE710",
|
|
ctx =>
|
|
{
|
|
actionRan = true;
|
|
passedQuery = ctx.SelectedText;
|
|
}
|
|
);
|
|
|
|
catalog.RegisterAction(customAction);
|
|
|
|
var retrieved = catalog.FindById("test.custom_action");
|
|
Assert.NotNull(retrieved);
|
|
|
|
var context = new QuickActionContext(SelectedText: "hello world");
|
|
retrieved.Handler?.Invoke(context);
|
|
|
|
Assert.True(actionRan);
|
|
Assert.Equal("hello world", passedQuery);
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate_QuickActionCatalog_Contains200PlusActionsAcross8Categories()
|
|
{
|
|
var catalog = new QuickActionCatalog();
|
|
var all = catalog.GetAllActions();
|
|
|
|
Assert.True(all.Count >= 200, $"Expected >= 200 actions, but got {all.Count}");
|
|
|
|
// Verify all 8 categories are populated
|
|
foreach (QuickActionCategory cat in Enum.GetValues<QuickActionCategory>())
|
|
{
|
|
var catItems = catalog.GetByCategory(cat);
|
|
Assert.True(catItems.Count > 0, $"Category {cat} must contain at least 1 action.");
|
|
}
|
|
}
|
|
}
|