KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > xml > schema > core > NavigationTestCase


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.test.xml.schema.core;
21
22 import java.awt.Point JavaDoc;
23 import java.util.zip.CRC32 JavaDoc;
24 import javax.swing.tree.TreePath JavaDoc;
25 import org.netbeans.jellytools.EditorOperator;
26 import org.netbeans.jellytools.JellyTestCase;
27 import org.netbeans.jellytools.NewFileNameLocationStepOperator;
28 import org.netbeans.jellytools.NewFileWizardOperator;
29 import org.netbeans.jellytools.OutputOperator;
30 import org.netbeans.jellytools.ProjectsTabOperator;
31 import org.netbeans.jellytools.TopComponentOperator;
32 import org.netbeans.jellytools.WizardOperator;
33 import org.netbeans.jellytools.actions.OpenAction;
34 import org.netbeans.jellytools.actions.SaveAllAction;
35 import org.netbeans.jellytools.nodes.Node;
36 import org.netbeans.jellytools.nodes.ProjectRootNode;
37 import org.netbeans.jemmy.operators.JButtonOperator;
38 import org.netbeans.jemmy.operators.JCheckBoxOperator;
39 import org.netbeans.jemmy.operators.JDialogOperator;
40 import org.netbeans.jemmy.operators.JListOperator;
41 import org.netbeans.jemmy.operators.JPopupMenuOperator;
42 import org.netbeans.jemmy.operators.JRadioButtonOperator;
43 import org.netbeans.jemmy.operators.JTextFieldOperator;
44 import org.netbeans.jemmy.operators.JTreeOperator;
45 import org.netbeans.test.xml.schema.core.lib.SchemaMultiView;
46 import org.netbeans.test.xml.schema.core.lib.util.Helpers;
47
48 /**
49  *
50  * @author ca@netbeans.org
51  */

52
53 public class NavigationTestCase extends JellyTestCase {
54     
55     static final String JavaDoc [] m_aTestMethods = {
56         "selectDifferentKindsOfView",
57 // "selectColumnsRecursively"
58
// "countComponents"
59
};
60     
61     static final String JavaDoc SCHEMA_NAME = "Synt01";
62     static final String JavaDoc SCHEMA_EXTENSION = ".xsd";
63     
64     public NavigationTestCase(String JavaDoc arg0) {
65         super(arg0);
66     }
67     
68     public static junit.framework.TestSuite suite() {
69         junit.framework.TestSuite testSuite = new junit.framework.TestSuite("XSD Navigator");
70         
71         for (String JavaDoc strMethodName : m_aTestMethods) {
72             testSuite.addTest(new NavigationTestCase(strMethodName));
73         }
74         
75         return testSuite;
76     }
77     
78     public void countComponents() {
79         openSchema();
80         
81         TopComponentOperator opTopComponent = new TopComponentOperator(SCHEMA_NAME + SCHEMA_EXTENSION);
82         Helpers.recurseComponent(0, opTopComponent.getSource());
83     }
84     
85     public void selectDifferentKindsOfView() {
86         openSchema();
87         
88         SchemaMultiView opMultiView = new SchemaMultiView(SCHEMA_NAME);
89         
90         opMultiView.switchToDesign();
91         
92         opMultiView.switchToSource();
93         
94         opMultiView.switchToSchema();
95         
96         opMultiView.switchToSchemaTree();
97         opMultiView.switchToSchemaColumns();
98         
99         opMultiView.switchToDesign();
100         
101         opMultiView.switchToSource();
102         
103         opMultiView.switchToSchema();
104     }
105     
106     public void selectColumnsRecursively() {
107         openSchema();
108         
109         SchemaMultiView opMultiView = new SchemaMultiView(SCHEMA_NAME);
110         
111         opMultiView.switchToSchema();
112         
113         opMultiView.switchToSchemaColumns();
114         
115         JListOperator opList = opMultiView.getColumnListOperator(0);
116         
117         recurseColumns(0, 0, opMultiView, opList);
118     }
119     
120     private void recurseColumns(int column, int row, SchemaMultiView opView, JListOperator opList) {
121         
122         int listSize = opList.getModel().getSize();
123         
124         if (row >= listSize) {
125             return;
126         }
127         
128         Helpers.writeJemmyLog("col " + column + " row " + row);
129         opList.selectItem(row);
130         Helpers.waitNoEvent();
131         
132         String JavaDoc strValue = opList.getSelectedValue().toString();
133         
134         Helpers.writeJemmyLog("List item value [" + strValue + "]");
135         
136         if (column > 1 && strValue.indexOf("[Global") >= 0) {
137             // Nothing
138
} else {
139             JListOperator opList1 = opView.getColumnListOperator(column + 1);
140             if (opList1 != null) {
141                 if (opList1.getModel().getSize() > 0) {
142                     recurseColumns(column + 1, 0, opView, opList1);
143                 }
144             }
145         }
146         
147         recurseColumns(column, row+1, opView, opList);
148     }
149     
150     private void openSchema() {
151         ProjectsTabOperator pto = ProjectsTabOperator.invoke();
152         
153         ProjectRootNode nodeProjectRoot = pto.getProjectRootNode("XSDTestProject");
154         nodeProjectRoot.select();
155         Node nodeXSD = new Node(nodeProjectRoot, "Source Packages|qa.xmltools.samples|" + SCHEMA_NAME + SCHEMA_EXTENSION);
156         
157         new OpenAction().performPopup(nodeXSD);
158         
159         Helpers.waitNoEvent();
160     }
161     
162     public void tearDown() {
163         new SaveAllAction().performAPI();
164     }
165     
166 }
167
Popular Tags