|
@ -1,8 +1,11 @@ |
|
|
import static org.junit.Assert.assertEquals; |
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
|
|
import static org.junit.Assert.assertTrue; |
|
|
|
|
|
|
|
|
import java.awt.Color; |
|
|
import java.awt.Color; |
|
|
import java.awt.Font; |
|
|
import java.awt.Font; |
|
|
import java.awt.event.ActionEvent; |
|
|
import java.awt.event.ActionEvent; |
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
|
import org.junit.Before; |
|
|
import org.junit.Before; |
|
|
import org.junit.Test; |
|
|
import org.junit.Test; |
|
@ -59,9 +62,11 @@ public class ChatGUITest { |
|
|
chatGUI.inputTextField.setText("Testnachricht"); |
|
|
chatGUI.inputTextField.setText("Testnachricht"); |
|
|
chatGUI.sendButton.doClick(); |
|
|
chatGUI.sendButton.doClick(); |
|
|
|
|
|
|
|
|
String expectedOutput = "Testnachricht\n"; |
|
|
|
|
|
|
|
|
String timeStamp = new SimpleDateFormat("HH:mm:ss").format(new Date()); |
|
|
|
|
|
String expectedOutput = "[" + timeStamp + "] Testnachricht\n"; |
|
|
assertEquals(expectedOutput, chatGUI.outputTextArea.getText()); |
|
|
assertEquals(expectedOutput, chatGUI.outputTextArea.getText()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
public void testInputTextFieldActionPerformed() { |
|
|
public void testInputTextFieldActionPerformed() { |
|
|
|
|
|
|
|
@ -69,12 +74,24 @@ public class ChatGUITest { |
|
|
chatGUI.actionPerformed(new ActionEvent(chatGUI.inputTextField, ActionEvent.ACTION_PERFORMED, "")); |
|
|
chatGUI.actionPerformed(new ActionEvent(chatGUI.inputTextField, ActionEvent.ACTION_PERFORMED, "")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String expectedOutput = "Testnachricht\n"; |
|
|
|
|
|
|
|
|
String timeStamp = new SimpleDateFormat("HH:mm:ss").format(new Date()); |
|
|
|
|
|
String expectedOutput = "[" + timeStamp + "] Testnachricht\n"; |
|
|
assertEquals(expectedOutput, chatGUI.outputTextArea.getText()); |
|
|
assertEquals(expectedOutput, chatGUI.outputTextArea.getText()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals("", chatGUI.inputTextField.getText()); |
|
|
assertEquals("", chatGUI.inputTextField.getText()); |
|
|
} |
|
|
} |
|
|
|
|
|
@Test |
|
|
|
|
|
public void testAddMessage() { |
|
|
|
|
|
|
|
|
|
|
|
String message = "Testnachricht"; |
|
|
|
|
|
chatGUI.addMessage(message); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String timeStamp = new SimpleDateFormat("HH:mm:ss").format(new Date()); |
|
|
|
|
|
String expectedMessage = "[" + timeStamp + "] " + message + "\n"; |
|
|
|
|
|
|
|
|
|
|
|
assertTrue(chatGUI.outputTextArea.getText().contains(expectedMessage)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|