KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Automatic insternationalization test
37  *
38  * @author Jiri Vagner
39  */

40 public class AutomaticInternationalizationTest extends ExtJellyTestCase {
41     
42     /** Constructor required by JUnit */
43     public AutomaticInternationalizationTest(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 AutomaticInternationalizationTest("testAutomaticInternationalizationEnabled")); // NOI18N
57
suite.addTest(new AutomaticInternationalizationTest("testAutomaticInternationalizationDisabled")); // NOI18N
58

59         return suite;
60     }
61     
62     /**
63      * Tests component code with properties Automatic Internationalization = true
64      */

65     public void testAutomaticInternationalizationEnabled() {
66         testAutomaticInternationalization(true);
67     }
68
69     /**
70      * Tests component code with properties Automatic Internationalization = false
71      */

72     public void testAutomaticInternationalizationDisabled() {
73         testAutomaticInternationalization(false);
74     }
75
76     /**
77      * Tests component code with different value of properties Automatic Internationalization
78      *
79      * @param local "Automatic Internationalization" settings
80      */

81     private void testAutomaticInternationalization(Boolean JavaDoc enabled) {
82         OptionsOperator.invoke();
83         OptionsOperator options = new OptionsOperator();
84         options.switchToClassicView();
85         
86         options.selectOption("Editing|GUI Builder"); // NOI18N
87

88         Property property = new Property(options.getPropertySheet("Editing|GUI Builder"), "Automatic Internationalization"); // NOI18N
89
property.setValue(String.valueOf( enabled ? "On" : "Off"));
90         options.close();
91         waitAMoment();
92
93         String JavaDoc name = createJFrameFile();
94         FormDesignerOperator designer = new FormDesignerOperator(name);
95         ComponentInspectorOperator inspector = new ComponentInspectorOperator();
96         Node node = new Node(inspector.treeComponents(), "JFrame"); // NOI18N
97

98         runPopupOverNode("Add From Palette|Swing Controls|Button", node); // NOI18N
99

100         String JavaDoc baseName = "[JFrame]"; // NOI18N
101
Node dialogNode = new Node(inspector.treeComponents(), baseName);
102         String JavaDoc[] names = dialogNode.getChildren();
103         
104         inspector.selectComponent("[JFrame]|jButton1");
105             
106         Property prop = new Property(inspector.properties(), "text"); // NOI18N
107
prop.setValue("Lancia Lybra");
108         
109         if (enabled)
110             findInCode("jButton1.setText(bundle.getString(\"MyJFrame", designer);
111         else
112             findInCode("jButton1.setText(\"Lancia Lybra\");", designer);
113         
114         removeFile(name);
115     }
116 }
Popular Tags