|
@ -18,16 +18,19 @@ public class ChatGUITest { |
|
|
public void setUp() { |
|
|
public void setUp() { |
|
|
chatGUI = new ChatGUI(); |
|
|
chatGUI = new ChatGUI(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
public void testSetOutputTextColorRed() { |
|
|
public void testSetOutputTextColorRed() { |
|
|
chatGUI.actionPerformed(new TestActionEvent(chatGUI.red)); |
|
|
chatGUI.actionPerformed(new TestActionEvent(chatGUI.red)); |
|
|
assertEquals(Color.RED, chatGUI.outputTextArea.getForeground()); |
|
|
assertEquals(Color.RED, chatGUI.outputTextArea.getForeground()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
public void testSetOutputTextColorBlue() { |
|
|
public void testSetOutputTextColorBlue() { |
|
|
chatGUI.actionPerformed(new TestActionEvent(chatGUI.blue)); |
|
|
chatGUI.actionPerformed(new TestActionEvent(chatGUI.blue)); |
|
|
assertEquals(Color.BLUE, chatGUI.outputTextArea.getForeground()); |
|
|
assertEquals(Color.BLUE, chatGUI.outputTextArea.getForeground()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
public void testSetOutputTextColorBlack() { |
|
|
public void testSetOutputTextColorBlack() { |
|
|
chatGUI.actionPerformed(new TestActionEvent(chatGUI.black)); |
|
|
chatGUI.actionPerformed(new TestActionEvent(chatGUI.black)); |
|
@ -39,24 +42,28 @@ public class ChatGUITest { |
|
|
chatGUI.actionPerformed(new TestActionEvent(chatGUI.green)); |
|
|
chatGUI.actionPerformed(new TestActionEvent(chatGUI.green)); |
|
|
assertEquals(Color.GREEN, chatGUI.outputTextArea.getForeground()); |
|
|
assertEquals(Color.GREEN, chatGUI.outputTextArea.getForeground()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
public void testSetOutputTextFontSizeSmall() { |
|
|
public void testSetOutputTextFontSizeSmall() { |
|
|
chatGUI.actionPerformed(new TestActionEvent(chatGUI.small)); |
|
|
chatGUI.actionPerformed(new TestActionEvent(chatGUI.small)); |
|
|
Font expectedFont = chatGUI.outputTextArea.getFont().deriveFont(Font.PLAIN, 12); |
|
|
Font expectedFont = chatGUI.outputTextArea.getFont().deriveFont(Font.PLAIN, 12); |
|
|
assertEquals(expectedFont, chatGUI.outputTextArea.getFont()); |
|
|
assertEquals(expectedFont, chatGUI.outputTextArea.getFont()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
public void testSetOutputTextFontSizeMedium() { |
|
|
public void testSetOutputTextFontSizeMedium() { |
|
|
chatGUI.actionPerformed(new TestActionEvent(chatGUI.medium)); |
|
|
chatGUI.actionPerformed(new TestActionEvent(chatGUI.medium)); |
|
|
Font expectedFont = chatGUI.outputTextArea.getFont().deriveFont(Font.PLAIN, 16); |
|
|
Font expectedFont = chatGUI.outputTextArea.getFont().deriveFont(Font.PLAIN, 16); |
|
|
assertEquals(expectedFont, chatGUI.outputTextArea.getFont()); |
|
|
assertEquals(expectedFont, chatGUI.outputTextArea.getFont()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
public void testSetOutputTextFontSizeLarge() { |
|
|
public void testSetOutputTextFontSizeLarge() { |
|
|
chatGUI.actionPerformed(new TestActionEvent(chatGUI.large)); |
|
|
chatGUI.actionPerformed(new TestActionEvent(chatGUI.large)); |
|
|
Font expectedFont = chatGUI.outputTextArea.getFont().deriveFont(Font.PLAIN, 20); |
|
|
Font expectedFont = chatGUI.outputTextArea.getFont().deriveFont(Font.PLAIN, 20); |
|
|
assertEquals(expectedFont, chatGUI.outputTextArea.getFont()); |
|
|
assertEquals(expectedFont, chatGUI.outputTextArea.getFont()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
public void testSendButtonActionPerformed() { |
|
|
public void testSendButtonActionPerformed() { |
|
|
chatGUI.inputTextField.setText("Testnachricht"); |
|
|
chatGUI.inputTextField.setText("Testnachricht"); |
|
@ -73,33 +80,31 @@ public class ChatGUITest { |
|
|
chatGUI.inputTextField.setText("Testnachricht"); |
|
|
chatGUI.inputTextField.setText("Testnachricht"); |
|
|
chatGUI.actionPerformed(new ActionEvent(chatGUI.inputTextField, ActionEvent.ACTION_PERFORMED, "")); |
|
|
chatGUI.actionPerformed(new ActionEvent(chatGUI.inputTextField, ActionEvent.ACTION_PERFORMED, "")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String timeStamp = new SimpleDateFormat("HH:mm:ss").format(new Date()); |
|
|
String timeStamp = new SimpleDateFormat("HH:mm:ss").format(new Date()); |
|
|
String expectedOutput = "[" + timeStamp + "] Testnachricht\n"; |
|
|
String expectedOutput = "[" + timeStamp + "] Testnachricht\n"; |
|
|
assertEquals(expectedOutput, chatGUI.outputTextArea.getText()); |
|
|
assertEquals(expectedOutput, chatGUI.outputTextArea.getText()); |
|
|
|
|
|
|
|
|
assertEquals("", chatGUI.inputTextField.getText()); |
|
|
assertEquals("", chatGUI.inputTextField.getText()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
public void testAddMessage() { |
|
|
public void testAddMessage() { |
|
|
|
|
|
|
|
|
String message = "Testnachricht"; |
|
|
String message = "Testnachricht"; |
|
|
chatGUI.addMessage(message); |
|
|
chatGUI.addMessage(message); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String timeStamp = new SimpleDateFormat("HH:mm:ss").format(new Date()); |
|
|
String timeStamp = new SimpleDateFormat("HH:mm:ss").format(new Date()); |
|
|
String expectedMessage = "[" + timeStamp + "] " + message + "\n"; |
|
|
String expectedMessage = "[" + timeStamp + "] " + message + "\n"; |
|
|
|
|
|
|
|
|
assertTrue(chatGUI.outputTextArea.getText().contains(expectedMessage)); |
|
|
assertTrue(chatGUI.outputTextArea.getText().contains(expectedMessage)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
public void testSendPopupMessage() { |
|
|
public void testSendPopupMessage() { |
|
|
ChatGUI chatGUI = new ChatGUI(); |
|
|
ChatGUI chatGUI = new ChatGUI(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String testMessage = "Test Popup-Nachricht"; |
|
|
String testMessage = "Test Popup-Nachricht"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
chatGUI.sendPopupMessage(testMessage); |
|
|
chatGUI.sendPopupMessage(testMessage); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|