diff --git a/src/main/java/LoginGUI.java b/src/main/java/LoginGUI.java index 6a442b7..6d49398 100644 --- a/src/main/java/LoginGUI.java +++ b/src/main/java/LoginGUI.java @@ -14,7 +14,28 @@ public class LoginGUI extends JFrame implements ActionListener { private JButton loginButton; private JCheckBox stayLoggedInCheckbox; private JButton signUpButton; + + public JTextField getUsernameField() { + return usernameField; + } + + public JPasswordField getPasswordField() { + return passwordField; + } + + public JButton getLoginButton() { + return loginButton; + } + public JCheckBox getStayLoggedInCheckbox() { + return stayLoggedInCheckbox; + } + + public JButton getSignUpButton() { + return signUpButton; + } + + public LoginGUI() { setTitle("Login"); setSize(300, 220); diff --git a/src/test/java/LoginGUITest.java b/src/test/java/LoginGUITest.java new file mode 100644 index 0000000..ca931d2 --- /dev/null +++ b/src/test/java/LoginGUITest.java @@ -0,0 +1,21 @@ +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; +import java.awt.event.ActionEvent; + +class LoginGUITest { + + @Test + public void testActionPerformed_LoginButton() { + LoginGUI loginGUI = new LoginGUI(); + loginGUI.getUsernameField().setText("testUser"); + loginGUI.getPasswordField().setText("testPassword"); + loginGUI.getStayLoggedInCheckbox().setSelected(true); + + // Simulate action performed event on login button + loginGUI.actionPerformed(new ActionEvent(loginGUI.getLoginButton(), ActionEvent.ACTION_PERFORMED, null)); + + // Verify if login was successful + assertFalse(loginGUI.isVisible()); + } + +}