001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.test.xml.schema;
043:
044: import org.netbeans.jellytools.JellyTestCase;
045: import org.netbeans.jellytools.ProjectsTabOperator;
046: import org.netbeans.jellytools.TopComponentOperator;
047: import org.netbeans.jellytools.actions.OpenAction;
048: import org.netbeans.jellytools.actions.SaveAllAction;
049: import org.netbeans.jellytools.nodes.Node;
050: import org.netbeans.jellytools.nodes.ProjectRootNode;
051: import org.netbeans.jemmy.operators.JListOperator;
052: import org.netbeans.test.xml.schema.lib.SchemaMultiView;
053: import org.netbeans.test.xml.schema.lib.util.Helpers;
054:
055: /**
056: *
057: * @author ca@netbeans.org
058: */
059:
060: public class NavigationTestCase extends JellyTestCase {
061:
062: static final String[] m_aTestMethods = { "selectDifferentKindsOfView",
063: // "selectColumnsRecursively"
064: // "countComponents"
065: };
066:
067: static final String SCHEMA_NAME = "Synt01";
068: static final String SCHEMA_EXTENSION = ".xsd";
069:
070: public NavigationTestCase(String arg0) {
071: super (arg0);
072: }
073:
074: public static junit.framework.TestSuite suite() {
075: junit.framework.TestSuite testSuite = new junit.framework.TestSuite(
076: "XSD Navigator");
077:
078: for (String strMethodName : m_aTestMethods) {
079: testSuite.addTest(new NavigationTestCase(strMethodName));
080: }
081:
082: return testSuite;
083: }
084:
085: public void countComponents() {
086: openSchema();
087:
088: TopComponentOperator opTopComponent = new TopComponentOperator(
089: SCHEMA_NAME + SCHEMA_EXTENSION);
090: Helpers.recurseComponent(0, opTopComponent.getSource());
091: }
092:
093: public void selectDifferentKindsOfView() {
094: openSchema();
095:
096: SchemaMultiView opMultiView = new SchemaMultiView(SCHEMA_NAME);
097:
098: opMultiView.switchToDesign();
099:
100: opMultiView.switchToSource();
101:
102: opMultiView.switchToSchema();
103:
104: opMultiView.switchToSchemaTree();
105: opMultiView.switchToSchemaColumns();
106:
107: opMultiView.switchToDesign();
108:
109: opMultiView.switchToSource();
110:
111: opMultiView.switchToSchema();
112: }
113:
114: public void selectColumnsRecursively() {
115: openSchema();
116:
117: SchemaMultiView opMultiView = new SchemaMultiView(SCHEMA_NAME);
118:
119: opMultiView.switchToSchema();
120:
121: opMultiView.switchToSchemaColumns();
122:
123: JListOperator opList = opMultiView.getColumnListOperator(0);
124:
125: recurseColumns(0, 0, opMultiView, opList);
126: }
127:
128: private void recurseColumns(int column, int row,
129: SchemaMultiView opView, JListOperator opList) {
130:
131: int listSize = opList.getModel().getSize();
132:
133: if (row >= listSize) {
134: return;
135: }
136:
137: Helpers.writeJemmyLog("col " + column + " row " + row);
138: opList.selectItem(row);
139: Helpers.waitNoEvent();
140:
141: String strValue = opList.getSelectedValue().toString();
142:
143: Helpers.writeJemmyLog("List item value [" + strValue + "]");
144:
145: if (column > 1 && strValue.indexOf("[Global") >= 0) {
146: // Nothing
147: } else {
148: JListOperator opList1 = opView
149: .getColumnListOperator(column + 1);
150: if (opList1 != null) {
151: if (opList1.getModel().getSize() > 0) {
152: recurseColumns(column + 1, 0, opView, opList1);
153: }
154: }
155: }
156:
157: recurseColumns(column, row + 1, opView, opList);
158: }
159:
160: private void openSchema() {
161: ProjectsTabOperator pto = ProjectsTabOperator.invoke();
162:
163: ProjectRootNode nodeProjectRoot = pto
164: .getProjectRootNode("XSDTestProject");
165: nodeProjectRoot.select();
166: Node nodeXSD = new Node(nodeProjectRoot,
167: "Source Packages|qa.xmltools.samples|" + SCHEMA_NAME
168: + SCHEMA_EXTENSION);
169:
170: new OpenAction().performPopup(nodeXSD);
171:
172: Helpers.waitNoEvent();
173: }
174:
175: public void tearDown() {
176: new SaveAllAction().performAPI();
177: }
178:
179: }
|