-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindowsInputMapperTests.cs
More file actions
61 lines (55 loc) · 2.8 KB
/
Copy pathWindowsInputMapperTests.cs
File metadata and controls
61 lines (55 loc) · 2.8 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
using SwitchifyPc.Windows.Input;
namespace SwitchifyPc.Tests;
public sealed class WindowsInputMapperTests
{
[Fact]
public void MapsProtocolKeysToWindowsVirtualKeys()
{
Assert.Equal(0x08, WindowsInputMapper.KeyboardVirtualKey("Backspace"));
Assert.Equal(0x2E, WindowsInputMapper.KeyboardVirtualKey("Delete"));
Assert.Equal(0x0D, WindowsInputMapper.KeyboardVirtualKey("Enter"));
Assert.Equal(0x1B, WindowsInputMapper.KeyboardVirtualKey("Escape"));
Assert.Equal(0x20, WindowsInputMapper.KeyboardVirtualKey("Space"));
Assert.Equal(0x09, WindowsInputMapper.KeyboardVirtualKey("Tab"));
Assert.Equal(0x21, WindowsInputMapper.KeyboardVirtualKey("PageUp"));
Assert.Equal(0x22, WindowsInputMapper.KeyboardVirtualKey("PageDown"));
Assert.Equal(0x70, WindowsInputMapper.KeyboardVirtualKey("F1"));
Assert.Equal(0x7B, WindowsInputMapper.KeyboardVirtualKey("F12"));
Assert.Equal(0x11, WindowsInputMapper.KeyboardVirtualKey("Ctrl"));
Assert.Equal(0x12, WindowsInputMapper.KeyboardVirtualKey("Alt"));
Assert.Equal(0x10, WindowsInputMapper.KeyboardVirtualKey("Shift"));
Assert.Equal(0x41, WindowsInputMapper.KeyboardVirtualKey("A"));
}
[Fact]
public void MapsMetaToWindowsKey()
{
Assert.Equal(0x5B, WindowsInputMapper.KeyboardVirtualKey("Meta"));
}
[Fact]
public void MapsMouseAndMediaValues()
{
Assert.Equal(0x01, WindowsInputMapper.MouseButtonVirtualKey("left"));
Assert.Equal(0x02, WindowsInputMapper.MouseButtonVirtualKey("right"));
Assert.Equal(0x04, WindowsInputMapper.MouseButtonVirtualKey("middle"));
Assert.Equal(0xB3, WindowsInputMapper.MediaVirtualKey("playPause"));
Assert.Equal(0xB0, WindowsInputMapper.MediaVirtualKey("nextTrack"));
Assert.Equal(0xB1, WindowsInputMapper.MediaVirtualKey("previousTrack"));
Assert.Equal(0xAF, WindowsInputMapper.MediaVirtualKey("volumeUp"));
Assert.Equal(0xAE, WindowsInputMapper.MediaVirtualKey("volumeDown"));
Assert.Equal(0xAD, WindowsInputMapper.MediaVirtualKey("mute"));
}
[Fact]
public void MapsWindowSwitchShortcuts()
{
Assert.Equal([0x12, 0x09], WindowsInputMapper.WindowControlShortcut("switchNext"));
Assert.Equal([0x12, 0x10, 0x09], WindowsInputMapper.WindowControlShortcut("switchPrevious"));
Assert.Empty(WindowsInputMapper.WindowControlShortcut("taskView"));
}
[Fact]
public void RejectsUnknownAliases()
{
Assert.Throws<ArgumentOutOfRangeException>(() => WindowsInputMapper.KeyboardVirtualKey("Win"));
Assert.Throws<ArgumentOutOfRangeException>(() => WindowsInputMapper.KeyboardVirtualKey("Windows"));
Assert.Throws<ArgumentOutOfRangeException>(() => WindowsInputMapper.KeyboardVirtualKey("Super"));
}
}