|
@ -12,6 +12,7 @@ class LoginGUITest { |
|
|
loginGUI = new LoginGUI(); |
|
|
loginGUI = new LoginGUI(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Tests initial state of the GUI |
|
|
@Test |
|
|
@Test |
|
|
public void testInitialState() { |
|
|
public void testInitialState() { |
|
|
assertNotNull(loginGUI.getUsernameField()); |
|
|
assertNotNull(loginGUI.getUsernameField()); |
|
@ -21,6 +22,7 @@ class LoginGUITest { |
|
|
assertNotNull(loginGUI.getSignUpButton()); |
|
|
assertNotNull(loginGUI.getSignUpButton()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Tests the login button |
|
|
@Test |
|
|
@Test |
|
|
public void testActionPerformed_LoginButton() { |
|
|
public void testActionPerformed_LoginButton() { |
|
|
LoginGUI loginGUI = new LoginGUI(); |
|
|
LoginGUI loginGUI = new LoginGUI(); |
|
@ -28,25 +30,18 @@ class LoginGUITest { |
|
|
loginGUI.getPasswordField().setText("testPassword"); |
|
|
loginGUI.getPasswordField().setText("testPassword"); |
|
|
loginGUI.getStayLoggedInCheckbox().setSelected(true); |
|
|
loginGUI.getStayLoggedInCheckbox().setSelected(true); |
|
|
|
|
|
|
|
|
// Simulate action performed event on login button |
|
|
|
|
|
loginGUI.actionPerformed(new ActionEvent(loginGUI.getLoginButton(), ActionEvent.ACTION_PERFORMED, null)); |
|
|
loginGUI.actionPerformed(new ActionEvent(loginGUI.getLoginButton(), ActionEvent.ACTION_PERFORMED, null)); |
|
|
|
|
|
|
|
|
// Verify if login was successful |
|
|
|
|
|
assertFalse(loginGUI.isVisible()); |
|
|
assertFalse(loginGUI.isVisible()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Tests the check-box for staying logged in |
|
|
@Test |
|
|
@Test |
|
|
public void testStayLoggedInCheckbox() { |
|
|
public void testStayLoggedInCheckbox() { |
|
|
// Initially, checkbox should be unchecked |
|
|
|
|
|
assertFalse(loginGUI.getStayLoggedInCheckbox().isSelected()); |
|
|
assertFalse(loginGUI.getStayLoggedInCheckbox().isSelected()); |
|
|
|
|
|
|
|
|
// Simulate checking the checkbox |
|
|
|
|
|
loginGUI.getStayLoggedInCheckbox().doClick(); |
|
|
loginGUI.getStayLoggedInCheckbox().doClick(); |
|
|
|
|
|
|
|
|
assertTrue(loginGUI.getStayLoggedInCheckbox().isSelected()); |
|
|
assertTrue(loginGUI.getStayLoggedInCheckbox().isSelected()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |