KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > qa > form > options > GeneratedComponentsDestionationTest


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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.qa.form.options;
21
22 import org.netbeans.qa.form.*;
23 import org.netbeans.qa.form.visualDevelopment.*;
24 import org.netbeans.jellytools.modules.form.ComponentInspectorOperator;
25 import org.netbeans.jellytools.modules.form.FormDesignerOperator;
26 import org.netbeans.jellytools.properties.Property;
27 import org.netbeans.junit.NbTestSuite;
28 import org.netbeans.jellytools.actions.*;
29 import org.netbeans.jellytools.*;
30 import org.netbeans.jellytools.nodes.Node;
31 import org.netbeans.jellytools.properties.Property;
32 import org.netbeans.qa.form.ExtJellyTestCase;
33 import java.util.*;
34
35 /**
36  * Componentes declaration test
37  *
38  * @author Jiri Vagner
39  */

40 public class GeneratedComponentsDestionationTest extends ExtJellyTestCase {
41     
42     /** Constructor required by JUnit */
43     public GeneratedComponentsDestionationTest(String JavaDoc testName) {
44         super(testName);
45     }
46     
47     /** Method allowing to execute test directly from IDE. */
48     public static void main(java.lang.String JavaDoc[] args) {
49         junit.textui.TestRunner.run(suite());
50     }
51     
52     /** Creates suite from particular test cases. */
53     public static NbTestSuite suite() {
54         NbTestSuite suite = new NbTestSuite();
55         
56         suite.addTest(new GeneratedComponentsDestionationTest("testGeneratedComponentsDestionationLocal")); // NOI18N
57
suite.addTest(new GeneratedComponentsDestionationTest("testGeneratedComponentsDestionationClassField")); // NOI18N
58

59         return suite;
60     }
61     
62     /** Tests generation component declaration code with properties LocalVariables=true
63      * Test for issue 95518
64      */

65     public void testGeneratedComponentsDestionationLocal() {
66         testGeneratedComponentsDestionation(true);
67     }
68
69     /**
70      * Tests generation component declaration code with properties LocalVariables=false
71      */

72     public void testGeneratedComponentsDestionationClassField() {
73         testGeneratedComponentsDestionation(false);
74     }
75
76     /**
77      * Tests generation component declaration code with properties LocalVariables=false
78      *
79      * @param local "Local Variables" settings
80      */

81     private void testGeneratedComponentsDestionation(Boolean JavaDoc local) {
82         OptionsOperator.invoke();
83         OptionsOperator options = new OptionsOperator();
84         options.switchToClassicView();
85         waitAMoment();
86         
87         options.selectOption("Editing|GUI Builder"); // NOI18N
88
waitAMoment();
89
90         Property property = new Property(options.getPropertySheet("Editing|GUI Builder"), "Variables Modifier"); // NOI18N
91
property.setValue("private"); // NOI18N
92

93         property = new Property(options.getPropertySheet("Editing|GUI Builder"), "Local Variables"); // NOI18N
94
property.setValue(String.valueOf(local));
95         options.close();
96         waitAMoment();
97         
98         String JavaDoc name = createJFrameFile();
99         waitAMoment();
100         
101         FormDesignerOperator designer = new FormDesignerOperator(name);
102         ComponentInspectorOperator inspector = new ComponentInspectorOperator();
103         Node node = new Node(inspector.treeComponents(), "JFrame"); // NOI18N
104

105         runPopupOverNode("Add From Palette|Swing Controls|Label", node); // NOI18N
106
waitAMoment();
107         
108         String JavaDoc code = "private javax.swing.JLabel jLabel1"; // NOI18N
109
if (local)
110             missInCode(code, designer);
111         else
112             findInCode(code, designer);
113         
114         waitAMoment();
115         removeFile(name);
116     }
117 }
Popular Tags