2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6 * The contents of this file are subject to the terms of either the GNU
7 * General Public License Version 2 only ("GPL") or the Common
8 * Development and Distribution License("CDDL") (collectively, the
9 * "License"). You may not use this file except in compliance with the
10 * License. You can obtain a copy of the License at
11 * http://www.netbeans.org/cddl-gplv2.html
12 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13 * specific language governing permissions and limitations under the
14 * License. When distributing the software, include this License Header
15 * Notice in each file and include the License file at
16 * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17 * particular file as subject to the "Classpath" exception as provided
18 * by Sun in the GPL Version 2 section of the License file that
19 * accompanied this code. If applicable, add the following below the
20 * License Header, with the fields enclosed by brackets [] replaced by
21 * your own identifying information:
22 * "Portions Copyrighted [year] [name of copyright owner]"
26 * The Original Software is NetBeans. The Initial Developer of the Original
27 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
28 * Microsystems, Inc. All Rights Reserved.
30 * If you wish your version of this file to be governed by only the CDDL
31 * or only the GPL Version 2, indicate your decision by adding
32 * "[Contributor] elects to include this software in this distribution
33 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34 * single choice of license, a recipient has the option to distribute
35 * your version of this file under either the CDDL, the GPL Version 2 or
36 * to extend the choice of license to its licensees as provided above.
37 * However, if you add GPL Version 2 code and therefore, elected the GPL
38 * Version 2 license, then the option applies only if the new code is
39 * made subject to such option by the copyright holder.
41 package org.netbeans.test.cnd;
43 import org.netbeans.jellytools.Bundle;
44 import org.netbeans.jellytools.JellyTestCase;
45 import org.netbeans.jellytools.MainWindowOperator;
46 import org.netbeans.jellytools.NbDialogOperator;
47 import org.netbeans.jellytools.NewProjectNameLocationStepOperator;
48 import org.netbeans.jellytools.NewProjectWizardOperator;
49 import org.netbeans.jellytools.ProjectsTabOperator;
50 import org.netbeans.jellytools.TopComponentOperator;
51 import org.netbeans.jellytools.actions.Action;
52 import org.netbeans.jellytools.actions.ActionNoBlock;
53 import org.netbeans.jellytools.nodes.Node;
54 import org.netbeans.jemmy.TimeoutExpiredException;
55 import org.netbeans.jemmy.operators.JTreeOperator;
56 import org.netbeans.junit.NbTestSuite;
57 import org.netbeans.junit.NbModuleSuite;
59 /** CND commit validation suite.
63 public class CNDValidation extends JellyTestCase {
65 static final String [] tests = {
66 "testCreateSampleProject",
71 /** Creates a new instance of CNDValidation */
72 public CNDValidation(String name) {
76 /** Defines order of test cases.
77 * @return NbTestSuite instance
79 // public static NbTestSuite suite() {
80 // NbTestSuite suite = new NbTestSuite();
81 // suite.addTest(new CNDValidation("testCreateSampleProject"));
82 // suite.addTest(new CNDValidation("testClassView"));
83 // suite.addTest(new CNDValidation("testBuildProject"));
87 public static junit.framework.Test suite() {
88 return NbModuleSuite.create(
89 NbModuleSuite.createConfiguration(CNDValidation.class)
97 /** Setup before every test case. */
99 System.out.println("######## " + getName() + " #######");
102 /** Clean up after every test case. */
103 public void tearDown() {
106 private static final String SAMPLE_PROJECT_NAME = "Welcome";
109 * - open new project wizard
110 * - select Samples|C/C++ Development|C/C++ category
111 * - select Welcome project
112 * - wait until wizard and Opening projects dialogs are closed
113 * - close possible error dialogs when compiler is not found
114 * - check project node appears in project view
116 public void testCreateSampleProject() {
117 NewProjectWizardOperator npwo = NewProjectWizardOperator.invoke();
119 String samplesLabel = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.Bundle", "Templates/Project/Samples");
120 String develLabel = Bundle.getStringTrimmed("org.netbeans.modules.cnd.makeproject.ui.wizards.Bundle", "Templates/Project/Samples/Native");
121 String ccLabel = Bundle.getStringTrimmed("org.netbeans.modules.cnd.makeproject.ui.wizards.Bundle", "Templates/Project/Samples/Native/Applications");
122 npwo.selectCategory(samplesLabel + "|" + develLabel + "|" + ccLabel);
123 npwo.selectProject(SAMPLE_PROJECT_NAME);
125 NewProjectNameLocationStepOperator npnlso = new NewProjectNameLocationStepOperator();
126 npnlso.txtProjectName().setText(SAMPLE_PROJECT_NAME);
127 npnlso.txtProjectLocation().setText(System.getProperty("netbeans.user")); // NOI18N
128 npnlso.btFinish().pushNoBlock();
129 npnlso.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 120000);
132 String openingProjectsTitle = Bundle.getString("org.netbeans.modules.project.ui.Bundle", "LBL_Opening_Projects_Progress");
134 // wait at most 120 second until progress dialog dismiss
135 NbDialogOperator openingOper = new NbDialogOperator(openingProjectsTitle);
136 openingOper.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 120000);
137 openingOper.waitClosed();
138 } catch (TimeoutExpiredException e) {
139 // ignore when progress dialog was closed before we started to wait for it
143 // wait for error dialog if compiler is not set
144 NbDialogOperator errorOper = new NbDialogOperator("Error");
146 } catch (TimeoutExpiredException e) {
147 // no more error dialog => we can continue
151 // wait project appear in projects view
152 new ProjectsTabOperator().getProjectRootNode(SAMPLE_PROJECT_NAME);
156 * - open Window|Class View
157 * - check Welcome|main node is available
159 public void testClassView() {
160 new Action(null, "Window|Classes").perform(); // NOI18N
161 TopComponentOperator classView = new TopComponentOperator("Classes"); // NOI18N
162 new Node(new JTreeOperator(classView), SAMPLE_PROJECT_NAME+"|main");
165 /** Test build project
166 * - call Clean and Build on project node
167 * - if compiler is not set, close 'Resolve Missing...' dialog
168 * - otherwise wait for clean and build finished
170 public void testBuildProject() {
171 Node projectNode = new ProjectsTabOperator().getProjectRootNode(SAMPLE_PROJECT_NAME);
173 String buildItem = Bundle.getString("org.netbeans.modules.cnd.makeproject.ui.Bundle", "LBL_RebuildAction_Name");
174 // start to track Main Window status bar
175 MainWindowOperator.StatusTextTracer stt = MainWindowOperator.getDefault().getStatusTextTracer();
177 new ActionNoBlock(null, buildItem).perform(projectNode);
179 // wait for possible dialog when compiler are not set
180 NbDialogOperator resolveOper = new NbDialogOperator("Resolve Missing Native Build Tools");
181 // close and finish the test
184 } catch (TimeoutExpiredException e) {
185 // ignore when it doesn't appear
187 // wait message "Clean successful"
188 stt.waitText("Clean successful", true); // NOI18N
189 // wait message "Build successful."
190 stt.waitText(Bundle.getString("org.netbeans.modules.cnd.builds.Bundle", "MSG_BuildFinishedOK"), true);