| | |
| | | |
| | | Assert.False(result.Succeeded); |
| | | Assert.Equal("WidgetLayoutLocked", result.ErrorCode); |
| | | Assert.Null(fixture.Surface.LastAppliedLayout); |
| | | Assert.Equal(2, fixture.Surface.AppliedLayoutCount); |
| | | Assert.True(fixture.Surface.LastAppliedLayout?.IsLocked); |
| | | Assert.Equal(new RectD(100, 100, 320, 160), fixture.Surface.LastAppliedLayout?.Bounds); |
| | | } |
| | | |
| | | [Fact] |
| | | public async Task StartAsync_RestoresRuntimeFlagsBeforeCreatingWidgetSurfaces() |
| | | { |
| | | var fixture = await RuntimeFixture.CreateAsync(new RuntimeSettings |
| | | { |
| | | EditMode = true, |
| | | SafeInputMode = true |
| | | }); |
| | | |
| | | var result = await fixture.Runtime.StartAsync(); |
| | | |
| | | Assert.True(result.Succeeded); |
| | | Assert.True(fixture.Surface.EditModeEnabled); |
| | | Assert.True(fixture.Surface.SafeInputModeEnabled); |
| | | Assert.Equal(1, fixture.Surface.AppliedLayoutCount); |
| | | } |
| | | |
| | | private sealed class RuntimeFixture |
| | |
| | | public FakeRuntimeSurfaceController Surface { get; } |
| | | public WidgetInstanceId WidgetId { get; } |
| | | |
| | | public static async Task<RuntimeFixture> CreateAsync() |
| | | public static async Task<RuntimeFixture> CreateAsync(RuntimeSettings? runtimeSettings = null) |
| | | { |
| | | var root = Path.Combine(Path.GetTempPath(), "Moli.Desktop.Tests", Guid.NewGuid().ToString("N")); |
| | | var paths = new DesktopPaths(Path.Combine(root, "app"), Path.Combine(root, "local")); |
| | |
| | | var widgetId = new WidgetInstanceId("widget-01"); |
| | | |
| | | await CreatePluginAsync(paths); |
| | | if (runtimeSettings is not null) |
| | | { |
| | | await configuration.SaveAppSettingsAsync(new AppSettingsDocument |
| | | { |
| | | Runtime = runtimeSettings |
| | | }); |
| | | } |
| | | |
| | | await configuration.SaveLayoutAsync(new LayoutDocument |
| | | { |
| | | Monitors = |
| | |
| | | private sealed class FakeRuntimeSurfaceController : IRuntimeSurfaceController |
| | | { |
| | | public bool EditModeEnabled { get; private set; } |
| | | public bool SafeInputModeEnabled { get; private set; } |
| | | public WidgetLayout? LastAppliedLayout { get; private set; } |
| | | public int AppliedLayoutCount { get; private set; } |
| | | |
| | | public Task ApplyEditModeAsync(bool enabled, CancellationToken cancellationToken = default) |
| | | { |
| | |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | | public Task ApplySafeInputModeAsync(bool enabled, CancellationToken cancellationToken = default) => Task.CompletedTask; |
| | | public Task ApplySafeInputModeAsync(bool enabled, CancellationToken cancellationToken = default) |
| | | { |
| | | SafeInputModeEnabled = enabled; |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | | public Task ApplyWidgetLayoutAsync(WidgetLayout layout, CancellationToken cancellationToken = default) |
| | | { |
| | | LastAppliedLayout = layout; |
| | | AppliedLayoutCount++; |
| | | return Task.CompletedTask; |
| | | } |
| | | |