From 12c80a6668a835025256b85066f5432563a7cd86 Mon Sep 17 00:00:00 2001 From: Valentin Spiroski Date: Fri, 9 Feb 2024 22:34:48 +0100 Subject: [PATCH] test_testEmojiPickerActionListenerFunctionality --- src/test/java/TestEmojiPicker.java | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/test/java/TestEmojiPicker.java b/src/test/java/TestEmojiPicker.java index 5fe2c94..ad5aa2e 100644 --- a/src/test/java/TestEmojiPicker.java +++ b/src/test/java/TestEmojiPicker.java @@ -70,4 +70,24 @@ public class TestEmojiPicker { } } -} \ No newline at end of file + @Test + public void testEmojiPickerActionListenerFunctionality() { + JTextField textField = new JTextField(); + + EmojiPicker emojiPicker = new EmojiPicker(textField); + + Component[] components = emojiPicker.getComponents(); + for (Component component : components) { + + assertTrue(component instanceof JButton); + JButton button = (JButton) component; + EmojiPicker.EmojiActionListener actionListener = (EmojiPicker.EmojiActionListener) button.getActionListeners()[0]; + + assertNotNull(actionListener); + + actionListener.actionPerformed(null); + assertEquals(button.getText(), textField.getText()); + } + } +} +