From a73279496a01d9d10bef8438dd7b324e7bfef124 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 03:49:02 +0100 Subject: [PATCH] test_Inputfield-Test --- src/test/java/ChatGUITest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/java/ChatGUITest.java b/src/test/java/ChatGUITest.java index 04fa7d0..47cc055 100644 --- a/src/test/java/ChatGUITest.java +++ b/src/test/java/ChatGUITest.java @@ -2,6 +2,7 @@ import static org.junit.Assert.assertEquals; import java.awt.Color; import java.awt.Font; +import java.awt.event.ActionEvent; import org.junit.Before; import org.junit.Test; @@ -61,6 +62,19 @@ public class ChatGUITest { String expectedOutput = "Testnachricht\n"; assertEquals(expectedOutput, chatGUI.outputTextArea.getText()); } + @Test + public void testInputTextFieldActionPerformed() { + + chatGUI.inputTextField.setText("Testnachricht"); + chatGUI.actionPerformed(new ActionEvent(chatGUI.inputTextField, ActionEvent.ACTION_PERFORMED, "")); + + + String expectedOutput = "Testnachricht\n"; + assertEquals(expectedOutput, chatGUI.outputTextArea.getText()); + + + assertEquals("", chatGUI.inputTextField.getText()); + } }