-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPointerProfileTests.cs
More file actions
70 lines (59 loc) · 2.71 KB
/
Copy pathPointerProfileTests.cs
File metadata and controls
70 lines (59 loc) · 2.71 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using SwitchifyPc.Core.Input;
using SwitchifyPc.Protocol;
using InputPoint = SwitchifyPc.Core.Input.Point;
namespace SwitchifyPc.Tests;
public sealed class PointerProfileTests
{
[Fact]
public void CreatesStableBaselineDeltasForScaledDisplay()
{
PointerMovementProfile profile = PointerProfile.Create(new PointerProfileInput(
new InputPoint(100, 100),
new DisplayInfo(new Bounds(0, 0, 1280, 720), 1.5)));
Assert.Equal("0:0:1280:720:1.5", profile.DisplayId);
Assert.Equal(new RecommendedDeltas(32, 86, 187), profile.RecommendedDeltas);
Assert.True(profile.Capabilities.NoAckMouseMove);
Assert.Contains("keyboard.textStream.char", profile.Capabilities.NoAckCommands);
Assert.Contains("keyboard.textStream.open", profile.Capabilities.SupportedCommands);
}
[Fact]
public void PreservesCurrentFeelOn1080pAtOneX()
{
RecommendedDeltas deltas = PointerProfile.Create(new PointerProfileInput(
new InputPoint(100, 100),
new DisplayInfo(new Bounds(0, 0, 1920, 1080), 1))).RecommendedDeltas;
Assert.Equal(new RecommendedDeltas(49, 130, 281), deltas);
}
[Fact]
public void DividesStableBaselineDeltasByScaleFactor()
{
RecommendedDeltas deltas = PointerProfile.Create(new PointerProfileInput(
new InputPoint(100, 100),
new DisplayInfo(new Bounds(0, 0, 3840, 2160), 2))).RecommendedDeltas;
Assert.Equal(new RecommendedDeltas(24, 65, 140), deltas);
}
[Fact]
public void KeepsRecommendedDeltasBelowMax()
{
RecommendedDeltas deltas = PointerProfile.Create(new PointerProfileInput(
new InputPoint(100, 100),
new DisplayInfo(new Bounds(0, 0, 3840, 2160), 0.25),
ProtocolConstants.MaxPointerDelta)).RecommendedDeltas;
Assert.True(deltas.Small <= ProtocolConstants.MaxPointerDelta);
Assert.True(deltas.Medium <= ProtocolConstants.MaxPointerDelta);
Assert.True(deltas.Large <= ProtocolConstants.MaxPointerDelta);
}
[Fact]
public void FallsBackForInvalidScaleAndKeepsNegativeDisplayCoordinates()
{
PointerMovementProfile invalidScale = PointerProfile.Create(new PointerProfileInput(
new InputPoint(100, 100),
new DisplayInfo(new Bounds(0, 0, 1280, 720), 0)));
PointerMovementProfile negativeDisplay = PointerProfile.Create(new PointerProfileInput(
new InputPoint(-100, 100),
new DisplayInfo(new Bounds(-1920, 0, 1920, 1080), 1.25)));
Assert.Equal(1, invalidScale.ScaleFactor);
Assert.Equal("0:0:1280:720:1", invalidScale.DisplayId);
Assert.Equal("-1920:0:1920:1080:1.25", negativeDisplay.DisplayId);
}
}