package StockTradeWindows;
import junit.framework.TestCase;
import net.helipilot50.stocktrade.windows.LogonWindow;
import org.fest.swing.core.ComponentFinder;
import org.fest.swing.fixture.FrameFixture;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import DisplayProject.DisplayProjectTestUtils;
public class LogonWindowTest extends TestCase {
private FrameFixture rootWindow;
protected ComponentFinder finder;
@Before
public void setUp() {
finder = DisplayProjectTestUtils.initialiseNewThread(new Runnable() {
public void run() {
LogonWindow.launch();
}
});
rootWindow = LogonWindowWidgets.getWindow(finder);
}
@After
public void tearDown() {
if (rootWindow != null) {
rootWindow.cleanUp();
}
}
@Test
public void test1() {
rootWindow.moveToFront();
rootWindow.robot.cleanUpWithoutDisposingWindows();
// TODO: Create unit test code, eg
LogonWindowWidgets.enterLoginName(rootWindow, "Bill");
LogonWindowWidgets.enterPassword(rootWindow, "Robinson");
assertEquals("Bill", LogonWindowWidgets.getActualWindow(rootWindow).getLoginName().toString());
LogonWindowWidgets.clickAsCustomerBtn(rootWindow);
FrameFixture custWin1 = CustomerWindowWidgets.getWindowAsAsyncChildOf(rootWindow);
CustomerWindowWidgets.clickExitBtn(custWin1);
DisplayProjectTestUtils.finishWithAsyncWindow();
LogonWindowWidgets.clickAsCustomerBtn(rootWindow);
// Find the window (started asynchronously)
FrameFixture custWin = CustomerWindowWidgets.getWindowAsAsyncChildOf(rootWindow);
assertEquals("Customer Stock Holdings", custWin.target.getTitle());
CustomerWindowWidgets.checkCustomerGrid_CustomerNameIs(custWin, "Bill");
CustomerWindowWidgets.clickBuyBtn(custWin);
// Find the window, started synchronously
FrameFixture orderWin = OrderWindowWidgets.getWindowAsChildOf(custWin);
OrderWindowWidgets.checkNewOrderGrid_CustomerNameIs(orderWin, "Bill");
OrderWindowWidgets.enterNewOrderGrid_Price(orderWin, "10");
OrderWindowWidgets.enterNewOrderGrid_Quantity(orderWin, "5");
OrderWindowWidgets.clickSubmitBtn(orderWin);
orderWin.optionPane().okButton().click();
CustomerWindowWidgets.clickExitBtn(custWin);
DisplayProjectTestUtils.finishWithAsyncWindow();
}
}