Browse Source

Merge branch 'client-handler'

main^2
Valentin Spiroski 11 months ago
parent
commit
8b487cefaf
  1. 53
      src/test/java/TestEmojiPicker.java

53
src/test/java/TestEmojiPicker.java

@ -1,7 +1,7 @@
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.util.Arrays;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
public class TestEmojiPicker { public class TestEmojiPicker {
@ -72,7 +72,7 @@ public class TestEmojiPicker {
} }
//Test to verify the functionality of EmojiActionListener for each emoji button //Test to verify the functionality of EmojiActionListener for each emoji button
/* @Test
@Test
public void testEmojiPickerActionListenerFunctionality() { public void testEmojiPickerActionListenerFunctionality() {
// Arrange // Arrange
JTextField textField = new JTextField(); // Initialize JTextField JTextField textField = new JTextField(); // Initialize JTextField
@ -89,5 +89,50 @@ public class TestEmojiPicker {
String expectedText = textField.getText() + button.getText(); // Expected text after appending emoji String expectedText = textField.getText() + button.getText(); // Expected text after appending emoji
assertEquals(expectedText, textField.getText(), "Failed for emoji: " + button.getText()); // Check if emoji is appended to the text field assertEquals(expectedText, textField.getText(), "Failed for emoji: " + button.getText()); // Check if emoji is appended to the text field
} }
}*/
}
}
@Test
public void testEmojiPickerNotNull() {
JTextField textField = new JTextField();
EmojiPicker emojiPicker = new EmojiPicker(textField);
assertNotNull(emojiPicker);
}
@Test
public void testEmojiPickerLayout() {
JTextField textField = new JTextField();
EmojiPicker emojiPicker = new EmojiPicker(textField);
LayoutManager layoutManager = emojiPicker.getLayout();
assertTrue(layoutManager instanceof GridLayout);
GridLayout gridLayout = (GridLayout) layoutManager;
assertEquals(4, gridLayout.getRows());
assertEquals(3, gridLayout.getColumns());
}
@Test
public void testEmojiPickerButtonCount1() {
JTextField textField = new JTextField();
EmojiPicker emojiPicker = new EmojiPicker(textField);
Component[] components = emojiPicker.getComponents();
assertEquals(12, components.length);
}
@Test
public void testEmojiPickerButtonFont() {
JTextField textField = new JTextField();
EmojiPicker emojiPicker = new EmojiPicker(textField);
Component[] components = emojiPicker.getComponents();
for (Component component : components) {
if (component instanceof JButton) {
JButton button = (JButton) component;
Font buttonFont = button.getFont();
assertEquals("Segoe UI Emoji", buttonFont.getFontName());
assertEquals(Font.PLAIN, buttonFont.getStyle());
assertEquals(20, buttonFont.getSize());
}
}
}
}
Loading…
Cancel
Save