feat: restore legacy modal and drag behavior
This commit is contained in:
@@ -448,35 +448,44 @@ public sealed class LegacyBridgeProtocolTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseNamedPlaylistIntents_AcceptsOnlyOpaqueIdsTitlesAndEmptyCommands()
|
||||
public void ParseNamedPlaylistIntents_AcceptsOnlyOpaqueIdsTitlesAndDispatchIds()
|
||||
{
|
||||
Assert.True(LegacyBridgeProtocol.TryParseIntent(
|
||||
"{\"type\":\"refresh-named-playlists\",\"payload\":{}}",
|
||||
"{\"type\":\"refresh-named-playlists\",\"payload\":{\"requestId\":\"named-ui-1\"}}",
|
||||
out var refresh,
|
||||
out _));
|
||||
Assert.IsType<LegacyRefreshNamedPlaylistsIntent>(refresh);
|
||||
Assert.Equal(
|
||||
"named-ui-1",
|
||||
Assert.IsType<LegacyRefreshNamedPlaylistsIntent>(refresh).RequestId);
|
||||
|
||||
Assert.True(LegacyBridgeProtocol.TryParseIntent(
|
||||
"{\"type\":\"select-named-playlist\",\"payload\":{\"definitionId\":\"named-definition-AAAAAAAAAAAB\"}}",
|
||||
"{\"type\":\"select-named-playlist\",\"payload\":{\"definitionId\":\"named-definition-AAAAAAAAAAAB\",\"requestId\":\"named-ui-2\"}}",
|
||||
out var selection,
|
||||
out _));
|
||||
Assert.Equal(
|
||||
"named-definition-AAAAAAAAAAAB",
|
||||
Assert.IsType<LegacySelectNamedPlaylistIntent>(selection).DefinitionId);
|
||||
var selectionIntent = Assert.IsType<LegacySelectNamedPlaylistIntent>(selection);
|
||||
Assert.Equal("named-definition-AAAAAAAAAAAB", selectionIntent.DefinitionId);
|
||||
Assert.Equal("named-ui-2", selectionIntent.RequestId);
|
||||
|
||||
Assert.True(LegacyBridgeProtocol.TryParseIntent(
|
||||
"{\"type\":\"create-named-playlist\",\"payload\":{\"title\":\"아침 방송 A^B\"}}",
|
||||
"{\"type\":\"create-named-playlist\",\"payload\":{\"title\":\"아침 방송 A^B\",\"requestId\":\"named-ui-2\"}}",
|
||||
out var create,
|
||||
out _));
|
||||
var createIntent = Assert.IsType<LegacyCreateNamedPlaylistIntent>(create);
|
||||
Assert.Equal("아침 방송 A^B", createIntent.Title);
|
||||
Assert.Equal("named-ui-2", createIntent.RequestId);
|
||||
|
||||
Assert.True(LegacyBridgeProtocol.TryParseIntent(
|
||||
"{\"type\":\"delete-selected-named-playlist\",\"payload\":{\"requestId\":\"named-ui-3\"}}",
|
||||
out var delete,
|
||||
out _));
|
||||
Assert.Equal(
|
||||
"아침 방송 A^B",
|
||||
Assert.IsType<LegacyCreateNamedPlaylistIntent>(create).Title);
|
||||
"named-ui-3",
|
||||
Assert.IsType<LegacyDeleteSelectedNamedPlaylistIntent>(delete).RequestId);
|
||||
|
||||
foreach (var type in new[]
|
||||
{
|
||||
"load-selected-named-playlist",
|
||||
"save-current-named-playlist",
|
||||
"delete-selected-named-playlist"
|
||||
"save-current-named-playlist"
|
||||
})
|
||||
{
|
||||
Assert.True(LegacyBridgeProtocol.TryParseIntent(
|
||||
@@ -490,12 +499,24 @@ public sealed class LegacyBridgeProtocolTests
|
||||
"{\"type\":\"select-named-playlist\",\"payload\":{\"definitionId\":\"named-definition-AAAAAAAAAAAB\",\"programCode\":\"00000001\"}}",
|
||||
out _,
|
||||
out _));
|
||||
Assert.False(LegacyBridgeProtocol.TryParseIntent(
|
||||
"{\"type\":\"select-named-playlist\",\"payload\":{\"definitionId\":\"named-definition-AAAAAAAAAAAB\"}}",
|
||||
out _,
|
||||
out _));
|
||||
Assert.False(LegacyBridgeProtocol.TryParseIntent(
|
||||
"{\"type\":\"save-current-named-playlist\",\"payload\":{\"rows\":[]}}",
|
||||
out _,
|
||||
out _));
|
||||
Assert.False(LegacyBridgeProtocol.TryParseIntent(
|
||||
"{\"type\":\"create-named-playlist\",\"payload\":{\"title\":\" padded \"}}",
|
||||
"{\"type\":\"create-named-playlist\",\"payload\":{\"title\":\" padded \",\"requestId\":\"named-ui-4\"}}",
|
||||
out _,
|
||||
out _));
|
||||
Assert.False(LegacyBridgeProtocol.TryParseIntent(
|
||||
"{\"type\":\"refresh-named-playlists\",\"payload\":{}}",
|
||||
out _,
|
||||
out _));
|
||||
Assert.False(LegacyBridgeProtocol.TryParseIntent(
|
||||
"{\"type\":\"delete-selected-named-playlist\",\"payload\":{}}",
|
||||
out _,
|
||||
out _));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
using System.Text.Json;
|
||||
using MBN_STOCK_WEBVIEW.LegacyApplication;
|
||||
using MBN_STOCK_WEBVIEW.LegacyBridge;
|
||||
|
||||
namespace MBN_STOCK_WEBVIEW.LegacyBridge.Tests;
|
||||
|
||||
public sealed class LegacyInteractionMetricsBridgeTests
|
||||
{
|
||||
[Fact]
|
||||
public void SerializeState_ProjectsExplicitSystemDragMetricsWithCamelCaseNames()
|
||||
{
|
||||
var json = LegacyBridgeProtocol.SerializeState(
|
||||
CreateSnapshot(),
|
||||
interactionMetrics: new LegacyInteractionMetrics(7, 9, 96, 1.5));
|
||||
|
||||
using var document = JsonDocument.Parse(json);
|
||||
var payload = document.RootElement.GetProperty("payload");
|
||||
var metrics = payload.GetProperty("interactionMetrics");
|
||||
|
||||
Assert.Equal(7, metrics.GetProperty("cutDragWidthDips").GetInt32());
|
||||
Assert.Equal(9, metrics.GetProperty("cutDragHeightDips").GetInt32());
|
||||
Assert.Equal("host-dip", metrics.GetProperty("coordinateSpace").GetString());
|
||||
Assert.Equal(96u, metrics.GetProperty("sourceDpi").GetUInt32());
|
||||
Assert.Equal(1.5d, metrics.GetProperty("hostRasterizationScale").GetDouble());
|
||||
Assert.False(metrics.TryGetProperty("CutDragWidthDips", out _));
|
||||
Assert.False(metrics.TryGetProperty("CutDragHeightDips", out _));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(6, 9, 144u, 4, 6)]
|
||||
[InlineData(5, 5, 120u, 4, 4)]
|
||||
[InlineData(7, 7, 168u, 4, 4)]
|
||||
public void FromPixelsAtDpi_ConvertsWindowsPixelsToCssPixelCoordinates(
|
||||
int physicalWidth,
|
||||
int physicalHeight,
|
||||
uint dpi,
|
||||
int expectedCssWidth,
|
||||
int expectedCssHeight)
|
||||
{
|
||||
var metrics = LegacyInteractionMetrics.FromPixelsAtDpi(
|
||||
physicalWidth,
|
||||
physicalHeight,
|
||||
dpi);
|
||||
|
||||
Assert.Equal(expectedCssWidth, metrics.CutDragWidthDips);
|
||||
Assert.Equal(expectedCssHeight, metrics.CutDragHeightDips);
|
||||
Assert.Equal(dpi, metrics.SourceDpi);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FromPixelsAtDpi_RejectsUnknownDpiAndInvalidAxesSafely()
|
||||
{
|
||||
var unknownDpi = LegacyInteractionMetrics.FromPixelsAtDpi(8, 8, 0, 1.5);
|
||||
Assert.Equal(4, unknownDpi.CutDragWidthDips);
|
||||
Assert.Equal(4, unknownDpi.CutDragHeightDips);
|
||||
Assert.Equal(1.5d, unknownDpi.HostRasterizationScale);
|
||||
|
||||
var metrics = LegacyInteractionMetrics.FromPixelsAtDpi(0, -1, 192);
|
||||
Assert.Equal(4, metrics.CutDragWidthDips);
|
||||
Assert.Equal(4, metrics.CutDragHeightDips);
|
||||
Assert.Equal(192u, metrics.SourceDpi);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SerializeState_NormalizesInvalidSystemMetricsPerAxisToFourPixels()
|
||||
{
|
||||
var json = LegacyBridgeProtocol.SerializeState(
|
||||
CreateSnapshot(),
|
||||
interactionMetrics: new LegacyInteractionMetrics(0, -1, 0, double.NaN));
|
||||
|
||||
using var document = JsonDocument.Parse(json);
|
||||
var metrics = document.RootElement
|
||||
.GetProperty("payload")
|
||||
.GetProperty("interactionMetrics");
|
||||
|
||||
Assert.Equal(4, metrics.GetProperty("cutDragWidthDips").GetInt32());
|
||||
Assert.Equal(4, metrics.GetProperty("cutDragHeightDips").GetInt32());
|
||||
Assert.Equal("host-dip", metrics.GetProperty("coordinateSpace").GetString());
|
||||
Assert.Equal(96u, metrics.GetProperty("sourceDpi").GetUInt32());
|
||||
Assert.Equal(1d, metrics.GetProperty("hostRasterizationScale").GetDouble());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SerializeState_ExistingCallShapeReceivesSafeDefaultMetrics()
|
||||
{
|
||||
var json = LegacyBridgeProtocol.SerializeState(CreateSnapshot());
|
||||
|
||||
using var document = JsonDocument.Parse(json);
|
||||
var metrics = document.RootElement
|
||||
.GetProperty("payload")
|
||||
.GetProperty("interactionMetrics");
|
||||
|
||||
Assert.Equal(4, metrics.GetProperty("cutDragWidthDips").GetInt32());
|
||||
Assert.Equal(4, metrics.GetProperty("cutDragHeightDips").GetInt32());
|
||||
Assert.Equal("host-dip", metrics.GetProperty("coordinateSpace").GetString());
|
||||
Assert.Equal(96u, metrics.GetProperty("sourceDpi").GetUInt32());
|
||||
Assert.Equal(1d, metrics.GetProperty("hostRasterizationScale").GetDouble());
|
||||
}
|
||||
|
||||
private static LegacyOperatorSnapshot CreateSnapshot() => new(
|
||||
1,
|
||||
string.Empty,
|
||||
[],
|
||||
null,
|
||||
[],
|
||||
[],
|
||||
null,
|
||||
string.Empty,
|
||||
LegacyOperatorStatusKind.Neutral);
|
||||
}
|
||||
Reference in New Issue
Block a user