Problem in taking the control of my application in the test class

Hi,

I am calling an application(Login) from the test class. This test class tests for blank fields entered for the login application.

Once i get the login screen, my program is getting hanged, i mean its not executing the test case unless i press the cancel button in that login screen. Only when i press the cancel button,my test case is executing in the background & is successful.

Can anyone tell me why is this happening & is there a better way to handle this situation.

Thanks & Regards,

Vishal

[549 byte] By [vishal_vja] at [2007-11-26 21:51:04]
# 1
Post a short, compilable code.
watfora at 2007-7-10 3:44:05 > top of Java-index,Desktop,Core GUI APIs...
# 2

Well here is the Test class that i have written,

/*-

* LoginScreenTest1

*

* Created on Mar 9, 2007 by vishal

*

*/

package unittest.com.erp;

import junit.extensions.TestSetup;

import junit.extensions.jfcunit.*;

import junit.extensions.jfcunit.finder.*;

import junit.extensions.jfcunit.eventdata.*;

import junit.framework.Test;

import junit.framework.TestSuite;

import junit.textui.TestRunner;

import com.erp.client.swing.ClientLoginDialog;

import com.erp.client.swing.workspace.ClientWorkspaceFrame;

import com.erp.client.swing.workspace.data.LoginResults;

import javax.swing.*;

import junit.extensions.jfcunit.finder.Finder;

import java.awt.Window;

import java.awt.Robot;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.InputEvent;

import java.util.List;

import java.util.ArrayList;

/**

* MISSING_JAVADOC Vishal Class LoginScreenTest1 description.

*

* @author Vishal

*/

public class LoginScreenTest1

extends JFCTestCase {

private ClientLoginDialog loginScreen ;

private static JFCTestHelper s_helper = null;

private LoginResults lr;

public LoginScreenTest1(String name) {

super(name);

s_helper = new JFCTestHelper();

System.out.println("Calling Login dialog");

loginScreen = ClientLoginDialog.login(new JFrame(),true); // Returns the login dialog

loginScreen.setVisible(true); // Its getting hanged here,only when i press the cancel button my test case gets executed

}

public static Test suite() {

System.out.println("I am in Suite");

TestSuite suite = new TestSuite(LoginScreenTest1.class);

return suite;

}

public void testUserAndPasswordEmpty() {

JDialog dialog;

System.out.println("In Test case ");

JTextField userNameField = (JTextField)s_helper.findNamedComponent("LoginTextField",loginScreen, 0);

JTextField passwordField = (JTextField)s_helper.findNamedComponent("PasswordField",loginScreen, 0);

JButton CancelButton = (JButton)s_helper.findNamedComponent("Cancelbutton",loginScreen, 0);

userNameField.setText("");

passwordField.setText("");

JButton LoginButton = (JButton)s_helper.findNamedComponent("Loginbutton",loginScreen, 0);

System.out.println("Clicking Login button");

LoginButton.doClick();

System.out.println("Login button clicked");

}

public static final void main(String[] args)

{

junit.textui.TestRunner.run(suite());

try

{

Thread.sleep(1000000);

}

catch (Exception e)

{

}

}

}

Message was edited by:

vishal_vj

vishal_vja at 2007-7-10 3:44:05 > top of Java-index,Desktop,Core GUI APIs...
# 3
Please can anyone help is solving my problem, i have been trying it out for the past 2 days.Regards,Vishal
vishal_vja at 2007-7-10 3:44:05 > top of Java-index,Desktop,Core GUI APIs...