Skip to content

Commit f35ca7f

Browse files
committed
windows: add GetKeyboardLayout and ToUnicodeEx tests
1 parent 710cded commit f35ca7f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

windows/syscall_windows_test.go

+29
Original file line numberDiff line numberDiff line change
@@ -1275,3 +1275,32 @@ uintptr_t beep(void) {
12751275
t.Fatal("LoadLibraryEx unexpectedly found beep.dll")
12761276
}
12771277
}
1278+
1279+
func TestGetKeyboardLayout(t *testing.T) {
1280+
fg := windows.GetForegroundWindow()
1281+
tid, err := windows.GetWindowThreadProcessId(fg, nil)
1282+
if err != nil {
1283+
t.Fatalf("GetWindowThreadProcessId failed: %v", err)
1284+
}
1285+
1286+
_ = windows.GetKeyboardLayout(tid)
1287+
}
1288+
1289+
func TestToUnicodeEx(t *testing.T) {
1290+
var utf16Buf [16]uint16
1291+
const araLayout = windows.Handle(0x401)
1292+
ret := windows.ToUnicodeEx(
1293+
0x41, // 'A' vkCode
1294+
0x1e, // 'A' scanCode
1295+
utf16Buf[:],
1296+
0,
1297+
araLayout,
1298+
)
1299+
1300+
if ret != 1 {
1301+
t.Errorf("ToUnicodeEx failed, wanted 1, got %d", ret)
1302+
}
1303+
if utf16Buf[0] != 'ش' {
1304+
t.Errorf("ToUnicodeEx failed, wanted 'ش', got %q", utf16Buf[0])
1305+
}
1306+
}

0 commit comments

Comments
 (0)