From a19ce6122e37ee23eadc8aef3d2787c8af1f47cc Mon Sep 17 00:00:00 2001 From: Aleksandras Kostarevas Date: Sat, 31 Aug 2024 18:13:27 +0300 Subject: [PATCH] Fix KeyboardLayoutTest --- .../inputmethod/keyboard/KeyboardLayout.java | 4 +-- ...KeyboardLayoutSetNavigateMoreKeysTest.java | 2 -- .../keyboard/KeyboardLayoutTest.kt | 32 +++++++++---------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/java/src/org/futo/inputmethod/keyboard/KeyboardLayout.java b/java/src/org/futo/inputmethod/keyboard/KeyboardLayout.java index 5362c842f..61c14ac6a 100644 --- a/java/src/org/futo/inputmethod/keyboard/KeyboardLayout.java +++ b/java/src/org/futo/inputmethod/keyboard/KeyboardLayout.java @@ -58,9 +58,9 @@ public class KeyboardLayout { for (int i = 0; i < layoutKeys.size(); i++) { Key key = layoutKeys.get(i); mKeyCodes[i] = Character.toLowerCase(key.getCode()); - mKeyXCoordinates[i] = key.getX(); + mKeyXCoordinates[i] = key.getDrawX(); mKeyYCoordinates[i] = key.getY(); - mKeyWidths[i] = key.getWidth(); + mKeyWidths[i] = key.getDrawWidth(); mKeyHeights[i] = key.getHeight(); } } diff --git a/tests/src/org/futo/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysTest.java b/tests/src/org/futo/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysTest.java index 7e09202e0..edccdd315 100644 --- a/tests/src/org/futo/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysTest.java +++ b/tests/src/org/futo/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysTest.java @@ -35,7 +35,6 @@ import java.util.Locale; @SmallTest public class KeyboardLayoutSetNavigateMoreKeysTest extends KeyboardLayoutSetTestsBase { - // !icon/action_clipboard_history|!code/action_clipboard_history,!icon/action_emoji|!code/action_emoji,!icon/previous_key|!code/key_action_previous,!icon/next_key|!code/key_action_next,!icon/action_undo|!code/action_undo,!icon/action_redo|!code/action_redo private ExpectedMoreKey mSwitchLanguageMoreKey = new ExpectedMoreKey("action_switch_language"); private ExpectedMoreKey mTextEditMoreKey = new ExpectedMoreKey("action_text_edit"); private ExpectedMoreKey mClipboardHistoryMoreKey = new ExpectedMoreKey("action_clipboard_history"); @@ -90,7 +89,6 @@ public class KeyboardLayoutSetNavigateMoreKeysTest extends KeyboardLayoutSetTest } else { assertTrue(tag + " fixedOrder", actualKey.isMoreKeysFixedOrder()); assertTrue(tag + " fixedColumn", actualKey.isMoreKeysFixedColumn()); - // TODO: Can't handle multiple rows of more keys. assertEquals(tag + " column", mEnterMoreKeysExpectedColumnCount, actualKey.getMoreKeysColumnNumber()); } diff --git a/tests/src/org/futo/inputmethod/keyboard/KeyboardLayoutTest.kt b/tests/src/org/futo/inputmethod/keyboard/KeyboardLayoutTest.kt index 88705cd30..6b0823391 100644 --- a/tests/src/org/futo/inputmethod/keyboard/KeyboardLayoutTest.kt +++ b/tests/src/org/futo/inputmethod/keyboard/KeyboardLayoutTest.kt @@ -42,39 +42,39 @@ class KeyboardLayoutTest { Assert.assertEquals(0, keyboardLayout.keyYCoordinates.size.toLong()) val key1 = Key( - code = 101, + code = 102, label = "label1", hintLabel = "101hint", - width = 1100, - height = 1101, - horizontalGap = 10, - verticalGap = 10, actionFlags = 102, labelFlags = 103, visualStyle = KeyVisualStyle.Normal, x = 105, - y = 106 + y = 106, + + // Note: The old Key constructor subtracted width automatically, the new one + // requires the caller to provide dimensions with gap subtracted + width = 1100 - 10, + height = 1101 - 10, + horizontalGap = 10, + verticalGap = 10, ) val key2 = Key( - code = 201, + code = 103, label = "label2", hintLabel = "201hint", - width = 2100, - height = 2101, - horizontalGap = 10, - verticalGap = 10, actionFlags = 202, labelFlags = 203, visualStyle = KeyVisualStyle.Normal, x = 205, - y = 206 + y = 206, + + width = 2100 - 10, + height = 2101 - 10, + horizontalGap = 10, + verticalGap = 10, ) - //Key key1 = new Key("label1", 101, 102, "101", "101hint", 103, 104, 105, 106, 1100, 1101, - // 10, 10); - //Key key2 = new Key("label2", 201, 103, "201", "201hint", 203, 204, 205, 206, 2100, 2101, - // 10, 10); val sortedKeys = ArrayList(2) sortedKeys.add(key1) sortedKeys.add(key2)