Browse Source

Merge branch 'server' into 'main'

Server

See merge request fdai7332/java-chat!16
remotes/origin/hotfix/client/improve-chat-window-appearence
fdai7599 11 months ago
parent
commit
c7632d789c
  1. 4
      src/main/java/ChatGUI.java
  2. 10
      src/test/java/ChatGUITest.java

4
src/main/java/ChatGUI.java

@ -136,8 +136,10 @@ public class ChatGUI implements ActionListener {
if (e.getSource() == inputTextField || e.getSource() == sendButton) { if (e.getSource() == inputTextField || e.getSource() == sendButton) {
String inputText = inputTextField.getText(); String inputText = inputTextField.getText();
inputTextField.setText(""); inputTextField.setText("");
if (!inputText.isEmpty()) {
addMessage(inputText); addMessage(inputText);
} }
}
if (e.getSource() == red) { if (e.getSource() == red) {
outputTextArea.setForeground(Color.RED); outputTextArea.setForeground(Color.RED);
@ -161,8 +163,10 @@ public class ChatGUI implements ActionListener {
String message = inputTextField.getText(); String message = inputTextField.getText();
inputTextField.setText(""); inputTextField.setText("");
addMessage(message); addMessage(message);
if(!message.isEmpty()) {
sendPopupMessage(message); sendPopupMessage(message);
} }
}
} }

10
src/test/java/ChatGUITest.java

@ -107,6 +107,14 @@ public class ChatGUITest {
chatGUI.sendPopupMessage(testMessage); chatGUI.sendPopupMessage(testMessage);
} }
}
@Test
public void testNoInputEntered() {
chatGUI.inputTextField.setText("");
chatGUI.sendButton.doClick();
assertEquals("", chatGUI.outputTextArea.getText());
}
}
Loading…
Cancel
Save