|
@ -71,24 +71,23 @@ public class TestEmojiPicker { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Test to verify the functionality of EmojiActionListener for each emoji button |
|
|
@Test |
|
|
@Test |
|
|
public void testEmojiPickerActionListenerFunctionality() { |
|
|
public void testEmojiPickerActionListenerFunctionality() { |
|
|
JTextField textField = new JTextField(); |
|
|
|
|
|
|
|
|
|
|
|
EmojiPicker emojiPicker = new EmojiPicker(textField); |
|
|
|
|
|
|
|
|
|
|
|
Component[] components = emojiPicker.getComponents(); |
|
|
|
|
|
for (Component component : components) { |
|
|
|
|
|
|
|
|
// Arrange |
|
|
|
|
|
JTextField textField = new JTextField(); |
|
|
|
|
|
EmojiPicker emojiPicker = new EmojiPicker(textField); |
|
|
|
|
|
Component[] components = emojiPicker.getComponents(); |
|
|
|
|
|
|
|
|
assertTrue(component instanceof JButton); |
|
|
|
|
|
JButton button = (JButton) component; |
|
|
|
|
|
|
|
|
// Act & Assert |
|
|
|
|
|
for (Component component : components) { |
|
|
|
|
|
assertTrue(component instanceof JButton); |
|
|
|
|
|
JButton button = (JButton) component; |
|
|
EmojiPicker.EmojiActionListener actionListener = (EmojiPicker.EmojiActionListener) button.getActionListeners()[0]; |
|
|
EmojiPicker.EmojiActionListener actionListener = (EmojiPicker.EmojiActionListener) button.getActionListeners()[0]; |
|
|
|
|
|
|
|
|
assertNotNull(actionListener); |
|
|
assertNotNull(actionListener); |
|
|
|
|
|
|
|
|
actionListener.actionPerformed(null); |
|
|
actionListener.actionPerformed(null); |
|
|
assertEquals(button.getText(), textField.getText()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
assertEquals(button.getText(), textField.getText()); // Check if emoji is appended to the text field |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|