001: /*
002: * CommitUiTest.java
003: *
004: * Created on 15 May 2006, 16:58
005: *
006: * To change this template, choose Tools | Template Manager
007: * and open the template in the editor.
008: */
009:
010: package org.netbeans.test.mercurial.main.commit;
011:
012: import java.io.File;
013: import javax.swing.table.TableModel;
014: import junit.textui.TestRunner;
015: import org.netbeans.jellytools.JellyTestCase;
016: import org.netbeans.jellytools.ProjectsTabOperator;
017: import org.netbeans.jellytools.nodes.Node;
018: import org.netbeans.jellytools.nodes.SourcePackagesNode;
019: import org.netbeans.jemmy.JemmyProperties;
020: import org.netbeans.jemmy.operators.JTableOperator;
021: import org.netbeans.junit.NbTestSuite;
022: import org.netbeans.test.mercurial.operators.CommitOperator;
023: import org.netbeans.test.mercurial.utils.RepositoryMaintenance;
024: import org.netbeans.test.mercurial.utils.TestKit;
025:
026: /**
027: *
028: * @author peter
029: */
030: public class CommitUiTest extends JellyTestCase {
031:
032: public static final String PROJECT_NAME = "JavaApp";
033: public File projectPath;
034:
035: String os_name;
036:
037: /** Creates a new instance of CheckoutUITest */
038: public CommitUiTest(String name) {
039: super (name);
040: }
041:
042: protected void setUp() throws Exception {
043: os_name = System.getProperty("os.name");
044: //System.out.println(os_name);
045: System.out.println("### " + getName() + " ###");
046:
047: }
048:
049: protected boolean isUnix() {
050: boolean unix = false;
051: if (os_name.indexOf("Windows") == -1) {
052: unix = true;
053: }
054: return unix;
055: }
056:
057: public static void main(String[] args) {
058: // TODO code application logic here
059: TestRunner.run(suite());
060: }
061:
062: public static NbTestSuite suite() {
063: NbTestSuite suite = new NbTestSuite();
064: suite.addTest(new CommitUiTest("testInvokeCloseCommit"));
065: return suite;
066: }
067:
068: public void testInvokeCloseCommit() throws Exception {
069: long timeout = JemmyProperties
070: .getCurrentTimeout("ComponentOperator.WaitComponentTimeout");
071: try {
072: JemmyProperties.setCurrentTimeout(
073: "ComponentOperator.WaitComponentTimeout", 30000);
074: } finally {
075: JemmyProperties.setCurrentTimeout(
076: "ComponentOperator.WaitComponentTimeout", timeout);
077: }
078:
079: timeout = JemmyProperties
080: .getCurrentTimeout("DialogWaiter.WaitDialogTimeout");
081: try {
082: JemmyProperties.setCurrentTimeout(
083: "DialogWaiter.WaitDialogTimeout", 30000);
084: } finally {
085: JemmyProperties.setCurrentTimeout(
086: "DialogWaiter.WaitDialogTimeout", timeout);
087: }
088:
089: try {
090: TestKit.closeProject(PROJECT_NAME);
091:
092: TestKit.loadOpenProject(PROJECT_NAME, getDataDir());
093: TestKit.createNewElements(PROJECT_NAME, "xx", "NewClass");
094: TestKit.createNewElement(PROJECT_NAME, "xx", "NewClass2");
095: TestKit.createNewElement(PROJECT_NAME, "xx", "NewClass3");
096: Node packNode = new Node(new SourcePackagesNode(
097: PROJECT_NAME), "xx");
098: CommitOperator co = CommitOperator.invoke(packNode);
099:
100: co.selectCommitAction("NewClass.java", "Commit");
101: co.selectCommitAction("NewClass.java", "Commit");
102: co.selectCommitAction("NewClass.java",
103: "Exclude from Commit");
104: co.selectCommitAction(2, "Commit");
105: co.selectCommitAction(2, "Commit");
106: co.selectCommitAction(2, "Exclude from Commit");
107:
108: JTableOperator table = co.tabFiles();
109: TableModel model = table.getModel();
110: String[] expected = { "NewClass.java", "NewClass2.java",
111: "NewClass3.java" };
112: String[] actual = new String[model.getRowCount()];
113: for (int i = 0; i < model.getRowCount(); i++) {
114: actual[i] = model.getValueAt(i, 0).toString();
115: }
116: int result = TestKit.compareThem(expected, actual, false);
117: assertEquals("Commit table doesn't contain all files!!!",
118: expected.length, result);
119:
120: co.verify();
121: co.cancel();
122: //TestKit.removeAllData(PROJECT_NAME);
123:
124: } catch (Exception e) {
125: throw new Exception("Test failed: " + e);
126: } finally {
127: TestKit.closeProject(PROJECT_NAME);
128: }
129: }
130: }
|