From 67cc25537ac612d9883b37a244ca058dcbcb7e6d Mon Sep 17 00:00:00 2001 From: Greg Spencer Date: Fri, 27 Oct 2023 15:51:13 -0700 Subject: [PATCH] Fix more tests --- lib/web_ui/lib/key.dart | 2 +- .../android/KeyboardManagerTest.java | 446 +++++++++++++++--- 2 files changed, 373 insertions(+), 75 deletions(-) diff --git a/lib/web_ui/lib/key.dart b/lib/web_ui/lib/key.dart index 9e733498980eb..a2873656f80a1 100644 --- a/lib/web_ui/lib/key.dart +++ b/lib/web_ui/lib/key.dart @@ -198,7 +198,7 @@ class KeyData { 'physical: 0x${physical.toRadixString(16)}, ' 'logical: ${_logicalToString()}, ' 'character: ${_escapeCharacter()}${_quotedCharCode()}' - '${synthesized ? ', synthesized' : ''}'; + '${synthesized ? ', synthesized' : ''})'; } /// Returns a complete textual description of the information in this object. diff --git a/shell/platform/android/test/io/flutter/embedding/android/KeyboardManagerTest.java b/shell/platform/android/test/io/flutter/embedding/android/KeyboardManagerTest.java index 1d9adbeff06ba..cba360192240e 100644 --- a/shell/platform/android/test/io/flutter/embedding/android/KeyboardManagerTest.java +++ b/shell/platform/android/test/io/flutter/embedding/android/KeyboardManagerTest.java @@ -458,6 +458,7 @@ public void serializeAndDeserializeKeyData() { + "0a00000000000000" + "0b00000000000000" + "0100000000000000" + + "0000000000000000" + "41", printBufferBytes(data1Buffer)); // `position` is considered as the message size. @@ -475,7 +476,7 @@ public void serializeAndDeserializeKeyData() { data2.type = Type.kUp; data2.character = null; data2.synthesized = false; - data1.deviceType = DeviceType.kKeyboard; + data1.deviceType = DeviceType.kDirectionalPad; final ByteBuffer data2Buffer = data2.toBytes(); @@ -486,7 +487,8 @@ public void serializeAndDeserializeKeyData() { + "0100000000000000" + "ccccbbbbaaaa0000" + "8888777766660000" - + "0000000000000000", + + "0000000000000000" + + "0100000000000000", printBufferBytes(data2Buffer)); data2Buffer.rewind(); @@ -577,7 +579,13 @@ public void embedderReponderHandlesEvents() { assertEquals(true, result); assertEquals(calls.size(), 1); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kDown, PHYSICAL_KEY_A, LOGICAL_KEY_A, "a", false); + calls.get(0).keyData, + Type.kDown, + PHYSICAL_KEY_A, + LOGICAL_KEY_A, + "a", + false, + DeviceType.kKeyboard); // Don't send the key event to the text plugin if the only primary responder // hasn't responded. @@ -607,7 +615,13 @@ public void bothRespondersHandlesEvents() { assertEquals(true, result); assertEquals(calls.size(), 2); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kDown, PHYSICAL_KEY_A, LOGICAL_KEY_A, "a", false); + calls.get(0).keyData, + Type.kDown, + PHYSICAL_KEY_A, + LOGICAL_KEY_A, + "a", + false, + DeviceType.kKeyboard); assertChannelEventEquals(calls.get(1).channelObject, "keydown", KEYCODE_A); verify(tester.mockView, times(0)).onTextInputKeyEvent(any(KeyEvent.class)); @@ -725,7 +739,7 @@ public void tapLowerA() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kDown, PHYSICAL_KEY_A, LOGICAL_KEY_A, "a", false), + buildKeyData(Type.kDown, PHYSICAL_KEY_A, LOGICAL_KEY_A, "a", false, DeviceType.kKeyboard), }); calls.clear(); @@ -736,7 +750,8 @@ public void tapLowerA() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kRepeat, PHYSICAL_KEY_A, LOGICAL_KEY_A, "a", false), + buildKeyData( + Type.kRepeat, PHYSICAL_KEY_A, LOGICAL_KEY_A, "a", false, DeviceType.kKeyboard), }); calls.clear(); @@ -747,7 +762,7 @@ public void tapLowerA() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kUp, PHYSICAL_KEY_A, LOGICAL_KEY_A, null, false), + buildKeyData(Type.kUp, PHYSICAL_KEY_A, LOGICAL_KEY_A, null, false, DeviceType.kKeyboard), }); calls.clear(); } @@ -768,7 +783,13 @@ public void tapUpperA() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kDown, PHYSICAL_SHIFT_LEFT, LOGICAL_SHIFT_LEFT, null, false), + buildKeyData( + Type.kDown, + PHYSICAL_SHIFT_LEFT, + LOGICAL_SHIFT_LEFT, + null, + false, + DeviceType.kKeyboard), }); calls.clear(); @@ -779,7 +800,7 @@ public void tapUpperA() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kDown, PHYSICAL_KEY_A, LOGICAL_KEY_A, "A", false), + buildKeyData(Type.kDown, PHYSICAL_KEY_A, LOGICAL_KEY_A, "A", false, DeviceType.kKeyboard), }); calls.clear(); @@ -790,7 +811,7 @@ public void tapUpperA() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kUp, PHYSICAL_KEY_A, LOGICAL_KEY_A, null, false), + buildKeyData(Type.kUp, PHYSICAL_KEY_A, LOGICAL_KEY_A, null, false, DeviceType.kKeyboard), }); calls.clear(); @@ -802,7 +823,8 @@ public void tapUpperA() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kUp, PHYSICAL_SHIFT_LEFT, LOGICAL_SHIFT_LEFT, null, false), + buildKeyData( + Type.kUp, PHYSICAL_SHIFT_LEFT, LOGICAL_SHIFT_LEFT, null, false, DeviceType.kKeyboard), }); calls.clear(); } @@ -823,7 +845,7 @@ public void eventsWithMintedCodes() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kDown, 0x1100000042L, LOGICAL_ENTER, "\n", false), + buildKeyData(Type.kDown, 0x1100000042L, LOGICAL_ENTER, "\n", false, DeviceType.kKeyboard), }); calls.clear(); @@ -833,7 +855,7 @@ public void eventsWithMintedCodes() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kDown, 0, 0, null, true), + buildKeyData(Type.kDown, 0, 0, null, true, DeviceType.kKeyboard), }); calls.clear(); @@ -845,7 +867,7 @@ public void eventsWithMintedCodes() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kDown, 0x11DEADBEEFL, 0x1100000000L, null, false), + buildKeyData(Type.kDown, 0x11DEADBEEFL, 0x1100000000L, null, false, DeviceType.kKeyboard), }); calls.clear(); @@ -857,7 +879,8 @@ public void eventsWithMintedCodes() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kDown, PHYSICAL_ARROW_LEFT, 0x1100000000L, null, false), + buildKeyData( + Type.kDown, PHYSICAL_ARROW_LEFT, 0x1100000000L, null, false, DeviceType.kKeyboard), }); calls.clear(); @@ -869,7 +892,8 @@ public void eventsWithMintedCodes() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kDown, PHYSICAL_ARROW_RIGHT, 0x11DEADBEEFL, null, false), + buildKeyData( + Type.kDown, PHYSICAL_ARROW_RIGHT, 0x11DEADBEEFL, null, false, DeviceType.kKeyboard), }); calls.clear(); } @@ -889,7 +913,7 @@ public void duplicateDownEventsArePrecededBySynthesizedUpEvents() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kDown, PHYSICAL_KEY_A, LOGICAL_KEY_A, "a", false), + buildKeyData(Type.kDown, PHYSICAL_KEY_A, LOGICAL_KEY_A, "a", false, DeviceType.kKeyboard), }); calls.clear(); @@ -899,9 +923,21 @@ public void duplicateDownEventsArePrecededBySynthesizedUpEvents() { new FakeKeyEvent(ACTION_DOWN, SCAN_KEY_A, KEYCODE_A, 0, 'a', 0))); assertEquals(calls.size(), 2); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kUp, PHYSICAL_KEY_A, LOGICAL_KEY_A, null, true); + calls.get(0).keyData, + Type.kUp, + PHYSICAL_KEY_A, + LOGICAL_KEY_A, + null, + true, + DeviceType.kKeyboard); assertEmbedderEventEquals( - calls.get(1).keyData, Type.kDown, PHYSICAL_KEY_A, LOGICAL_KEY_A, "a", false); + calls.get(1).keyData, + Type.kDown, + PHYSICAL_KEY_A, + LOGICAL_KEY_A, + "a", + false, + DeviceType.kKeyboard); calls.clear(); } @@ -920,7 +956,7 @@ public void abruptUpEventsAreIgnored() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kDown, 0l, 0l, null, true), + buildKeyData(Type.kDown, 0l, 0l, null, true, DeviceType.kKeyboard), }); calls.clear(); } @@ -939,7 +975,13 @@ public void modifierKeys() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kDown, PHYSICAL_SHIFT_LEFT, LOGICAL_SHIFT_LEFT, null, false), + buildKeyData( + Type.kDown, + PHYSICAL_SHIFT_LEFT, + LOGICAL_SHIFT_LEFT, + null, + false, + DeviceType.kKeyboard), }); calls.clear(); @@ -948,7 +990,8 @@ public void modifierKeys() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kUp, PHYSICAL_SHIFT_LEFT, LOGICAL_SHIFT_LEFT, null, false), + buildKeyData( + Type.kUp, PHYSICAL_SHIFT_LEFT, LOGICAL_SHIFT_LEFT, null, false, DeviceType.kKeyboard), }); calls.clear(); @@ -958,7 +1001,13 @@ public void modifierKeys() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kDown, PHYSICAL_SHIFT_RIGHT, LOGICAL_SHIFT_RIGHT, null, false), + buildKeyData( + Type.kDown, + PHYSICAL_SHIFT_RIGHT, + LOGICAL_SHIFT_RIGHT, + null, + false, + DeviceType.kKeyboard), }); calls.clear(); @@ -967,7 +1016,13 @@ public void modifierKeys() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kUp, PHYSICAL_SHIFT_RIGHT, LOGICAL_SHIFT_RIGHT, null, false), + buildKeyData( + Type.kUp, + PHYSICAL_SHIFT_RIGHT, + LOGICAL_SHIFT_RIGHT, + null, + false, + DeviceType.kKeyboard), }); calls.clear(); @@ -977,7 +1032,13 @@ public void modifierKeys() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kDown, PHYSICAL_CONTROL_LEFT, LOGICAL_CONTROL_LEFT, null, false), + buildKeyData( + Type.kDown, + PHYSICAL_CONTROL_LEFT, + LOGICAL_CONTROL_LEFT, + null, + false, + DeviceType.kKeyboard), }); calls.clear(); @@ -986,7 +1047,13 @@ public void modifierKeys() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kUp, PHYSICAL_CONTROL_LEFT, LOGICAL_CONTROL_LEFT, null, false), + buildKeyData( + Type.kUp, + PHYSICAL_CONTROL_LEFT, + LOGICAL_CONTROL_LEFT, + null, + false, + DeviceType.kKeyboard), }); calls.clear(); @@ -996,7 +1063,13 @@ public void modifierKeys() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kDown, PHYSICAL_CONTROL_RIGHT, LOGICAL_CONTROL_RIGHT, null, false), + buildKeyData( + Type.kDown, + PHYSICAL_CONTROL_RIGHT, + LOGICAL_CONTROL_RIGHT, + null, + false, + DeviceType.kKeyboard), }); calls.clear(); @@ -1005,7 +1078,13 @@ public void modifierKeys() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kUp, PHYSICAL_CONTROL_RIGHT, LOGICAL_CONTROL_RIGHT, null, false), + buildKeyData( + Type.kUp, + PHYSICAL_CONTROL_RIGHT, + LOGICAL_CONTROL_RIGHT, + null, + false, + DeviceType.kKeyboard), }); calls.clear(); @@ -1015,7 +1094,8 @@ public void modifierKeys() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kDown, PHYSICAL_ALT_LEFT, LOGICAL_ALT_LEFT, null, false), + buildKeyData( + Type.kDown, PHYSICAL_ALT_LEFT, LOGICAL_ALT_LEFT, null, false, DeviceType.kKeyboard), }); calls.clear(); @@ -1024,7 +1104,8 @@ public void modifierKeys() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kUp, PHYSICAL_ALT_LEFT, LOGICAL_ALT_LEFT, null, false), + buildKeyData( + Type.kUp, PHYSICAL_ALT_LEFT, LOGICAL_ALT_LEFT, null, false, DeviceType.kKeyboard), }); calls.clear(); @@ -1034,7 +1115,8 @@ public void modifierKeys() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kDown, PHYSICAL_ALT_RIGHT, LOGICAL_ALT_RIGHT, null, false), + buildKeyData( + Type.kDown, PHYSICAL_ALT_RIGHT, LOGICAL_ALT_RIGHT, null, false, DeviceType.kKeyboard), }); calls.clear(); @@ -1043,7 +1125,8 @@ public void modifierKeys() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kUp, PHYSICAL_ALT_RIGHT, LOGICAL_ALT_RIGHT, null, false), + buildKeyData( + Type.kUp, PHYSICAL_ALT_RIGHT, LOGICAL_ALT_RIGHT, null, false, DeviceType.kKeyboard), }); calls.clear(); } @@ -1062,7 +1145,8 @@ public void nonUsKeys() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kDown, PHYSICAL_DIGIT1, LOGICAL_DIGIT1, "1", false), + buildKeyData( + Type.kDown, PHYSICAL_DIGIT1, LOGICAL_DIGIT1, "1", false, DeviceType.kKeyboard), }); calls.clear(); @@ -1071,7 +1155,8 @@ public void nonUsKeys() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kUp, PHYSICAL_DIGIT1, LOGICAL_DIGIT1, null, false), + buildKeyData( + Type.kUp, PHYSICAL_DIGIT1, LOGICAL_DIGIT1, null, false, DeviceType.kKeyboard), }); calls.clear(); @@ -1085,7 +1170,8 @@ public void nonUsKeys() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kDown, PHYSICAL_DIGIT1, LOGICAL_DIGIT1, "&", false), + buildKeyData( + Type.kDown, PHYSICAL_DIGIT1, LOGICAL_DIGIT1, "&", false, DeviceType.kKeyboard), }); calls.clear(); @@ -1094,7 +1180,8 @@ public void nonUsKeys() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kUp, PHYSICAL_DIGIT1, LOGICAL_DIGIT1, null, false), + buildKeyData( + Type.kUp, PHYSICAL_DIGIT1, LOGICAL_DIGIT1, null, false, DeviceType.kKeyboard), }); calls.clear(); @@ -1108,7 +1195,7 @@ public void nonUsKeys() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kDown, PHYSICAL_KEY_A, LOGICAL_KEY_A, "ф", false), + buildKeyData(Type.kDown, PHYSICAL_KEY_A, LOGICAL_KEY_A, "ф", false, DeviceType.kKeyboard), }); calls.clear(); @@ -1117,7 +1204,7 @@ public void nonUsKeys() { verifyEmbedderEvents( calls, new KeyData[] { - buildKeyData(Type.kUp, PHYSICAL_KEY_A, LOGICAL_KEY_A, null, false), + buildKeyData(Type.kUp, PHYSICAL_KEY_A, LOGICAL_KEY_A, null, false, DeviceType.kKeyboard), }); calls.clear(); } @@ -1140,7 +1227,13 @@ public void synchronizeShiftLeftDuringForeignKeyEvents() { ACTION_DOWN, SCAN_ARROW_LEFT, KEYCODE_DPAD_LEFT, 0, '\0', SHIFT_LEFT_ON))); assertEquals(calls.size(), 2); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kDown, PHYSICAL_SHIFT_LEFT, LOGICAL_SHIFT_LEFT, null, true); + calls.get(0).keyData, + Type.kDown, + PHYSICAL_SHIFT_LEFT, + LOGICAL_SHIFT_LEFT, + null, + true, + DeviceType.kKeyboard); calls.clear(); assertEquals( @@ -1149,7 +1242,13 @@ public void synchronizeShiftLeftDuringForeignKeyEvents() { new FakeKeyEvent(ACTION_UP, SCAN_ARROW_LEFT, KEYCODE_DPAD_LEFT, 0, '\0', 0))); assertEquals(calls.size(), 2); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kUp, PHYSICAL_SHIFT_LEFT, LOGICAL_SHIFT_LEFT, null, true); + calls.get(0).keyData, + Type.kUp, + PHYSICAL_SHIFT_LEFT, + LOGICAL_SHIFT_LEFT, + null, + true, + DeviceType.kKeyboard); calls.clear(); } @@ -1174,7 +1273,13 @@ public void synchronizeShiftLeftDuringSelfKeyEvents() { ACTION_DOWN, SCAN_SHIFT_LEFT, KEYCODE_SHIFT_LEFT, 1, '\0', SHIFT_LEFT_ON))); assertEquals(calls.size(), 1); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kDown, PHYSICAL_SHIFT_LEFT, LOGICAL_SHIFT_LEFT, null, false); + calls.get(0).keyData, + Type.kDown, + PHYSICAL_SHIFT_LEFT, + LOGICAL_SHIFT_LEFT, + null, + false, + DeviceType.kKeyboard); calls.clear(); // Down event when the current state is 1. @@ -1185,9 +1290,21 @@ public void synchronizeShiftLeftDuringSelfKeyEvents() { ACTION_DOWN, SCAN_SHIFT_LEFT, KEYCODE_SHIFT_LEFT, 0, '\0', SHIFT_LEFT_ON))); assertEquals(calls.size(), 2); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kUp, PHYSICAL_SHIFT_LEFT, LOGICAL_SHIFT_LEFT, null, true); + calls.get(0).keyData, + Type.kUp, + PHYSICAL_SHIFT_LEFT, + LOGICAL_SHIFT_LEFT, + null, + true, + DeviceType.kKeyboard); assertEmbedderEventEquals( - calls.get(1).keyData, Type.kDown, PHYSICAL_SHIFT_LEFT, LOGICAL_SHIFT_LEFT, null, false); + calls.get(1).keyData, + Type.kDown, + PHYSICAL_SHIFT_LEFT, + LOGICAL_SHIFT_LEFT, + null, + false, + DeviceType.kKeyboard); calls.clear(); // Up event when the current state is 1. @@ -1197,7 +1314,13 @@ public void synchronizeShiftLeftDuringSelfKeyEvents() { new FakeKeyEvent(ACTION_UP, SCAN_SHIFT_LEFT, KEYCODE_SHIFT_LEFT, 0, '\0', 0))); assertEquals(calls.size(), 1); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kUp, PHYSICAL_SHIFT_LEFT, LOGICAL_SHIFT_LEFT, null, false); + calls.get(0).keyData, + Type.kUp, + PHYSICAL_SHIFT_LEFT, + LOGICAL_SHIFT_LEFT, + null, + false, + DeviceType.kKeyboard); calls.clear(); // Up event when the current state is 0. @@ -1206,7 +1329,8 @@ public void synchronizeShiftLeftDuringSelfKeyEvents() { tester.keyboardManager.handleEvent( new FakeKeyEvent(ACTION_UP, SCAN_SHIFT_LEFT, KEYCODE_SHIFT_LEFT, 0, '\0', 0))); assertEquals(calls.size(), 1); - assertEmbedderEventEquals(calls.get(0).keyData, Type.kDown, 0l, 0l, null, true); + assertEmbedderEventEquals( + calls.get(0).keyData, Type.kDown, 0l, 0l, null, true, DeviceType.kKeyboard); calls.clear(); // Down event when the current state is 0. @@ -1217,7 +1341,13 @@ public void synchronizeShiftLeftDuringSelfKeyEvents() { ACTION_DOWN, SCAN_SHIFT_LEFT, KEYCODE_SHIFT_LEFT, 0, '\0', SHIFT_LEFT_ON))); assertEquals(calls.size(), 1); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kDown, PHYSICAL_SHIFT_LEFT, LOGICAL_SHIFT_LEFT, null, false); + calls.get(0).keyData, + Type.kDown, + PHYSICAL_SHIFT_LEFT, + LOGICAL_SHIFT_LEFT, + null, + false, + DeviceType.kKeyboard); calls.clear(); // Repeat event when the current state is 1. @@ -1228,7 +1358,13 @@ public void synchronizeShiftLeftDuringSelfKeyEvents() { ACTION_DOWN, SCAN_SHIFT_LEFT, KEYCODE_SHIFT_LEFT, 1, '\0', SHIFT_LEFT_ON))); assertEquals(calls.size(), 1); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kRepeat, PHYSICAL_SHIFT_LEFT, LOGICAL_SHIFT_LEFT, null, false); + calls.get(0).keyData, + Type.kRepeat, + PHYSICAL_SHIFT_LEFT, + LOGICAL_SHIFT_LEFT, + null, + false, + DeviceType.kKeyboard); calls.clear(); } @@ -1323,7 +1459,13 @@ public void synchronizeOtherModifiers() { ACTION_DOWN, SCAN_ARROW_LEFT, KEYCODE_DPAD_LEFT, 0, '\0', META_CTRL_ON))); assertEquals(calls.size(), 2); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kDown, PHYSICAL_CONTROL_LEFT, LOGICAL_CONTROL_LEFT, null, true); + calls.get(0).keyData, + Type.kDown, + PHYSICAL_CONTROL_LEFT, + LOGICAL_CONTROL_LEFT, + null, + true, + DeviceType.kKeyboard); calls.clear(); assertEquals( @@ -1332,7 +1474,13 @@ public void synchronizeOtherModifiers() { new FakeKeyEvent(ACTION_UP, SCAN_ARROW_LEFT, KEYCODE_DPAD_LEFT, 0, '\0', 0))); assertEquals(calls.size(), 2); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kUp, PHYSICAL_CONTROL_LEFT, LOGICAL_CONTROL_LEFT, null, true); + calls.get(0).keyData, + Type.kUp, + PHYSICAL_CONTROL_LEFT, + LOGICAL_CONTROL_LEFT, + null, + true, + DeviceType.kKeyboard); calls.clear(); assertEquals( @@ -1342,7 +1490,13 @@ public void synchronizeOtherModifiers() { ACTION_DOWN, SCAN_ARROW_LEFT, KEYCODE_DPAD_LEFT, 0, '\0', META_ALT_ON))); assertEquals(calls.size(), 2); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kDown, PHYSICAL_ALT_LEFT, LOGICAL_ALT_LEFT, null, true); + calls.get(0).keyData, + Type.kDown, + PHYSICAL_ALT_LEFT, + LOGICAL_ALT_LEFT, + null, + true, + DeviceType.kKeyboard); calls.clear(); assertEquals( @@ -1351,7 +1505,13 @@ public void synchronizeOtherModifiers() { new FakeKeyEvent(ACTION_UP, SCAN_ARROW_LEFT, KEYCODE_DPAD_LEFT, 0, '\0', 0))); assertEquals(calls.size(), 2); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kUp, PHYSICAL_ALT_LEFT, LOGICAL_ALT_LEFT, null, true); + calls.get(0).keyData, + Type.kUp, + PHYSICAL_ALT_LEFT, + LOGICAL_ALT_LEFT, + null, + true, + DeviceType.kKeyboard); calls.clear(); } @@ -1376,9 +1536,21 @@ public void synchronizeModifiersForConflictingMetaState() { new FakeKeyEvent(ACTION_DOWN, SCAN_SHIFT_LEFT, KEYCODE_SHIFT_LEFT, 0, '\0', 0))); assertEquals(calls.size(), 2); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kDown, PHYSICAL_SHIFT_LEFT, LOGICAL_SHIFT_LEFT, null, false); + calls.get(0).keyData, + Type.kDown, + PHYSICAL_SHIFT_LEFT, + LOGICAL_SHIFT_LEFT, + null, + false, + DeviceType.kKeyboard); assertEmbedderEventEquals( - calls.get(1).keyData, Type.kUp, PHYSICAL_SHIFT_LEFT, LOGICAL_SHIFT_LEFT, null, true); + calls.get(1).keyData, + Type.kUp, + PHYSICAL_SHIFT_LEFT, + LOGICAL_SHIFT_LEFT, + null, + true, + DeviceType.kKeyboard); calls.clear(); // A normal down event. @@ -1389,7 +1561,13 @@ public void synchronizeModifiersForConflictingMetaState() { ACTION_DOWN, SCAN_SHIFT_LEFT, KEYCODE_SHIFT_LEFT, 0, '\0', SHIFT_LEFT_ON))); assertEquals(calls.size(), 1); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kDown, PHYSICAL_SHIFT_LEFT, LOGICAL_SHIFT_LEFT, null, false); + calls.get(0).keyData, + Type.kDown, + PHYSICAL_SHIFT_LEFT, + LOGICAL_SHIFT_LEFT, + null, + false, + DeviceType.kKeyboard); calls.clear(); // Test: Repeat event when the current state is 0. @@ -1399,9 +1577,21 @@ public void synchronizeModifiersForConflictingMetaState() { new FakeKeyEvent(ACTION_DOWN, SCAN_SHIFT_LEFT, KEYCODE_SHIFT_LEFT, 1, '\0', 0))); assertEquals(calls.size(), 2); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kRepeat, PHYSICAL_SHIFT_LEFT, LOGICAL_SHIFT_LEFT, null, false); + calls.get(0).keyData, + Type.kRepeat, + PHYSICAL_SHIFT_LEFT, + LOGICAL_SHIFT_LEFT, + null, + false, + DeviceType.kKeyboard); assertEmbedderEventEquals( - calls.get(1).keyData, Type.kUp, PHYSICAL_SHIFT_LEFT, LOGICAL_SHIFT_LEFT, null, true); + calls.get(1).keyData, + Type.kUp, + PHYSICAL_SHIFT_LEFT, + LOGICAL_SHIFT_LEFT, + null, + true, + DeviceType.kKeyboard); calls.clear(); } @@ -1424,9 +1614,21 @@ public void synchronizeModifiersForZeroedScanCode() { assertEquals(tester.keyboardManager.handleEvent(keyEvent), true); assertEquals(calls.size(), 2); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kDown, physicalKey, LOGICAL_SHIFT_LEFT, null, false); + calls.get(0).keyData, + Type.kDown, + physicalKey, + LOGICAL_SHIFT_LEFT, + null, + false, + DeviceType.kKeyboard); assertEmbedderEventEquals( - calls.get(1).keyData, Type.kUp, physicalKey, LOGICAL_SHIFT_LEFT, null, true); + calls.get(1).keyData, + Type.kUp, + physicalKey, + LOGICAL_SHIFT_LEFT, + null, + true, + DeviceType.kKeyboard); calls.clear(); } @@ -1448,7 +1650,13 @@ public void normalCapsLockEvents() { ACTION_DOWN, SCAN_CAPS_LOCK, KEYCODE_CAPS_LOCK, 0, '\0', META_CAPS_LOCK_ON))); assertEquals(calls.size(), 1); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kDown, PHYSICAL_CAPS_LOCK, LOGICAL_CAPS_LOCK, null, false); + calls.get(0).keyData, + Type.kDown, + PHYSICAL_CAPS_LOCK, + LOGICAL_CAPS_LOCK, + null, + false, + DeviceType.kKeyboard); calls.clear(); assertEquals( @@ -1457,7 +1665,13 @@ public void normalCapsLockEvents() { new FakeKeyEvent(ACTION_UP, SCAN_CAPS_LOCK, KEYCODE_CAPS_LOCK, 0, '\0', 0))); assertEquals(calls.size(), 1); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kUp, PHYSICAL_CAPS_LOCK, LOGICAL_CAPS_LOCK, null, false); + calls.get(0).keyData, + Type.kUp, + PHYSICAL_CAPS_LOCK, + LOGICAL_CAPS_LOCK, + null, + false, + DeviceType.kKeyboard); calls.clear(); assertEquals( @@ -1467,7 +1681,13 @@ public void normalCapsLockEvents() { ACTION_DOWN, SCAN_ARROW_LEFT, KEYCODE_DPAD_LEFT, 0, '\0', META_CAPS_LOCK_ON))); assertEquals(calls.size(), 1); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kDown, PHYSICAL_ARROW_LEFT, LOGICAL_ARROW_LEFT, null, false); + calls.get(0).keyData, + Type.kDown, + PHYSICAL_ARROW_LEFT, + LOGICAL_ARROW_LEFT, + null, + false, + DeviceType.kKeyboard); calls.clear(); assertEquals( @@ -1477,7 +1697,13 @@ public void normalCapsLockEvents() { ACTION_UP, SCAN_ARROW_LEFT, KEYCODE_DPAD_LEFT, 0, '\0', META_CAPS_LOCK_ON))); assertEquals(calls.size(), 1); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kUp, PHYSICAL_ARROW_LEFT, LOGICAL_ARROW_LEFT, null, false); + calls.get(0).keyData, + Type.kUp, + PHYSICAL_ARROW_LEFT, + LOGICAL_ARROW_LEFT, + null, + false, + DeviceType.kKeyboard); calls.clear(); assertEquals( @@ -1487,7 +1713,13 @@ public void normalCapsLockEvents() { ACTION_DOWN, SCAN_CAPS_LOCK, KEYCODE_CAPS_LOCK, 0, '\0', META_CAPS_LOCK_ON))); assertEquals(calls.size(), 1); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kDown, PHYSICAL_CAPS_LOCK, LOGICAL_CAPS_LOCK, null, false); + calls.get(0).keyData, + Type.kDown, + PHYSICAL_CAPS_LOCK, + LOGICAL_CAPS_LOCK, + null, + false, + DeviceType.kKeyboard); calls.clear(); assertEquals( @@ -1496,7 +1728,13 @@ public void normalCapsLockEvents() { new FakeKeyEvent(ACTION_UP, SCAN_CAPS_LOCK, KEYCODE_CAPS_LOCK, 0, '\0', 0))); assertEquals(calls.size(), 1); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kUp, PHYSICAL_CAPS_LOCK, LOGICAL_CAPS_LOCK, null, false); + calls.get(0).keyData, + Type.kUp, + PHYSICAL_CAPS_LOCK, + LOGICAL_CAPS_LOCK, + null, + false, + DeviceType.kKeyboard); calls.clear(); assertEquals( @@ -1505,7 +1743,13 @@ public void normalCapsLockEvents() { new FakeKeyEvent(ACTION_DOWN, SCAN_ARROW_LEFT, KEYCODE_DPAD_LEFT, 0, '\0', 0))); assertEquals(calls.size(), 1); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kDown, PHYSICAL_ARROW_LEFT, LOGICAL_ARROW_LEFT, null, false); + calls.get(0).keyData, + Type.kDown, + PHYSICAL_ARROW_LEFT, + LOGICAL_ARROW_LEFT, + null, + false, + DeviceType.kKeyboard); calls.clear(); assertEquals( @@ -1514,7 +1758,13 @@ public void normalCapsLockEvents() { new FakeKeyEvent(ACTION_UP, SCAN_ARROW_LEFT, KEYCODE_DPAD_LEFT, 0, '\0', 0))); assertEquals(calls.size(), 1); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kUp, PHYSICAL_ARROW_LEFT, LOGICAL_ARROW_LEFT, null, false); + calls.get(0).keyData, + Type.kUp, + PHYSICAL_ARROW_LEFT, + LOGICAL_ARROW_LEFT, + null, + false, + DeviceType.kKeyboard); calls.clear(); } @@ -1533,11 +1783,29 @@ public void synchronizeCapsLock() { ACTION_DOWN, SCAN_ARROW_LEFT, KEYCODE_DPAD_LEFT, 0, '\0', META_CAPS_LOCK_ON))); assertEquals(calls.size(), 3); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kDown, PHYSICAL_CAPS_LOCK, LOGICAL_CAPS_LOCK, null, true); + calls.get(0).keyData, + Type.kDown, + PHYSICAL_CAPS_LOCK, + LOGICAL_CAPS_LOCK, + null, + true, + DeviceType.kKeyboard); assertEmbedderEventEquals( - calls.get(1).keyData, Type.kUp, PHYSICAL_CAPS_LOCK, LOGICAL_CAPS_LOCK, null, true); + calls.get(1).keyData, + Type.kUp, + PHYSICAL_CAPS_LOCK, + LOGICAL_CAPS_LOCK, + null, + true, + DeviceType.kKeyboard); assertEmbedderEventEquals( - calls.get(2).keyData, Type.kDown, PHYSICAL_ARROW_LEFT, LOGICAL_ARROW_LEFT, null, false); + calls.get(2).keyData, + Type.kDown, + PHYSICAL_ARROW_LEFT, + LOGICAL_ARROW_LEFT, + null, + false, + DeviceType.kKeyboard); calls.clear(); assertEquals( @@ -1547,7 +1815,13 @@ public void synchronizeCapsLock() { ACTION_DOWN, SCAN_CAPS_LOCK, KEYCODE_CAPS_LOCK, 0, '\0', META_CAPS_LOCK_ON))); assertEquals(calls.size(), 1); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kDown, PHYSICAL_CAPS_LOCK, LOGICAL_CAPS_LOCK, null, false); + calls.get(0).keyData, + Type.kDown, + PHYSICAL_CAPS_LOCK, + LOGICAL_CAPS_LOCK, + null, + false, + DeviceType.kKeyboard); calls.clear(); assertEquals( @@ -1557,11 +1831,29 @@ public void synchronizeCapsLock() { ACTION_UP, SCAN_ARROW_LEFT, KEYCODE_DPAD_LEFT, 0, '\0', META_CAPS_LOCK_ON))); assertEquals(calls.size(), 3); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kUp, PHYSICAL_CAPS_LOCK, LOGICAL_CAPS_LOCK, null, true); + calls.get(0).keyData, + Type.kUp, + PHYSICAL_CAPS_LOCK, + LOGICAL_CAPS_LOCK, + null, + true, + DeviceType.kKeyboard); assertEmbedderEventEquals( - calls.get(1).keyData, Type.kDown, PHYSICAL_CAPS_LOCK, LOGICAL_CAPS_LOCK, null, true); + calls.get(1).keyData, + Type.kDown, + PHYSICAL_CAPS_LOCK, + LOGICAL_CAPS_LOCK, + null, + true, + DeviceType.kKeyboard); assertEmbedderEventEquals( - calls.get(2).keyData, Type.kUp, PHYSICAL_ARROW_LEFT, LOGICAL_ARROW_LEFT, null, false); + calls.get(2).keyData, + Type.kUp, + PHYSICAL_ARROW_LEFT, + LOGICAL_ARROW_LEFT, + null, + false, + DeviceType.kKeyboard); calls.clear(); assertEquals( @@ -1570,7 +1862,13 @@ public void synchronizeCapsLock() { new FakeKeyEvent(ACTION_UP, SCAN_CAPS_LOCK, KEYCODE_CAPS_LOCK, 0, '\0', 0))); assertEquals(calls.size(), 1); assertEmbedderEventEquals( - calls.get(0).keyData, Type.kUp, PHYSICAL_CAPS_LOCK, LOGICAL_CAPS_LOCK, null, false); + calls.get(0).keyData, + Type.kUp, + PHYSICAL_CAPS_LOCK, + LOGICAL_CAPS_LOCK, + null, + false, + DeviceType.kKeyboard); calls.clear(); }