基于WebView2实现的Win11桌面框架,利用插件自定义
Moli
2026-08-12 df6a437518d89eebfa1a583e09ec99c462e64e47
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using Moli.Desktop.Configuration;
using Moli.Desktop.Interop;
 
namespace Moli.Desktop.Tests.Interop;
 
public class Win32InteropContractTests
{
    [Fact]
    public void FakeInterop_CapturesWindowBehaviorForWindowTests()
    {
        var interop = new FakeWin32InteropService();
        var hwnd = new IntPtr(42);
 
        interop.SetClickThrough(hwnd, true);
        interop.SetToolWindow(hwnd, true);
        interop.SetNoActivate(hwnd, true);
        interop.SetLayered(hwnd, true);
        var monitor = new MonitorInfo
        {
            Id = new Moli.Desktop.Layout.MonitorId("primary"),
            Bounds = new Moli.Desktop.Layout.RectD(0, 0, 1920, 1080),
            WorkArea = new Moli.Desktop.Layout.RectD(0, 0, 1920, 1040),
            IsPrimary = true,
            Scale = 1
        };
        interop.MoveToDesktopLayer(hwnd, DesktopLayerMode.WorkerW, monitor, new Moli.Desktop.Layout.RectD(10, 20, 300, 120));
        interop.RestoreTopLevelWindow(hwnd);
        interop.SetBottomMost(hwnd);
 
        Assert.True(interop.ClickThroughEnabled);
        Assert.True(interop.ToolWindowEnabled);
        Assert.True(interop.NoActivateEnabled);
        Assert.True(interop.LayeredEnabled);
        Assert.Equal(new Moli.Desktop.Layout.RectD(10, 20, 300, 120), interop.LayerBounds);
        Assert.True(interop.RestoredTopLevel);
        Assert.Single(interop.GetMonitors());
    }
}