1 19 20 package org.netbeans.test.java.gui.customizers; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.io.PrintStream ; 25 import java.io.PrintWriter ; 26 import junit.textui.TestRunner; 27 import org.netbeans.jellytools.EditorOperator; 28 import org.netbeans.jellytools.JellyTestCase; 29 import org.netbeans.jellytools.ProjectsTabOperator; 30 import org.netbeans.jellytools.actions.OpenAction; 31 import org.netbeans.jellytools.modules.java.FieldCustomizerOperator; 32 import org.netbeans.jellytools.nodes.Node; 33 import org.netbeans.jellytools.properties.Property; 34 import org.netbeans.jellytools.properties.PropertySheetOperator; 35 import org.netbeans.jemmy.JemmyProperties; 36 import org.netbeans.jemmy.TestOut; 37 import org.netbeans.jemmy.operators.JEditorPaneOperator; 38 import org.netbeans.junit.NbTestSuite; 39 import org.netbeans.test.java.gui.GuiUtilities; 40 41 42 46 public class FieldCustomizer extends JellyTestCase { 47 48 private static final String TEST_PROJECT_NAME = "default"; 50 51 private static final String TEST_PACKAGE_PATH = 53 "org.netbeans.test.java.gui.customizers"; 54 55 private static final String TEST_PACKAGE_NAME = TEST_PACKAGE_PATH+".test"; 57 58 private static final String TEST_CLASS_NAME = "FieldCustomizer"; 60 61 private static final String TEST_FIELD_NAME = "TestField"; 63 64 67 protected static PrintStream err; 68 69 72 protected static PrintStream log; 73 74 private String workDir = "/tmp"; 76 77 private static String projectDir; 79 80 81 85 public FieldCustomizer(String name) { 86 super(name); 87 } 88 89 93 public static NbTestSuite suite() { 94 NbTestSuite suite = new NbTestSuite(); 95 suite.addTest(new FieldCustomizer("testCustomizeField")); 96 return suite; 97 } 98 99 103 public static void main(java.lang.String [] args) { 104 TestRunner.run(suite()); 105 } 106 107 110 public void setUp() { 111 System.out.println("######## "+getName()+" #######"); 112 err = getLog(); 113 log = getRef(); 114 JemmyProperties.getProperties().setOutput(new TestOut(null, 115 new PrintWriter (err, true), new PrintWriter (err, false), null)); 116 try { 117 File wd = getWorkDir(); 118 workDir = wd.toString(); 119 } catch (IOException e) { } 120 } 121 122 125 public void testCustomizeField() { 126 Node pn = new ProjectsTabOperator().getProjectRootNode( 127 TEST_PROJECT_NAME); 128 pn.select(); 129 130 Node n = new Node(pn, org.netbeans.jellytools.Bundle.getString( 131 "org.netbeans.modules.java.j2seproject.Bundle", 132 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME+"|" 133 +TEST_CLASS_NAME); 134 135 n.select(); 136 new OpenAction().perform(); 137 138 EditorOperator editor = new EditorOperator(TEST_CLASS_NAME); 139 140 editor.insert("String "+TEST_FIELD_NAME+";\n", 14, 5); 142 143 GuiUtilities.waitForChildNode(TEST_PROJECT_NAME, 145 org.netbeans.jellytools.Bundle.getString( 146 "org.netbeans.modules.java.j2seproject.Bundle", 147 "NAME_src.dir")+"|" 148 +TEST_PACKAGE_NAME+"|"+TEST_CLASS_NAME+"|"+TEST_CLASS_NAME+"|" 149 +org.netbeans.jellytools.Bundle.getString( 150 "org.netbeans.modules.java.ui.nodes.elements.Bundle", 151 "Fields"), TEST_FIELD_NAME); 152 153 Node n2 = new Node(pn, org.netbeans.jellytools.Bundle.getString( 154 "org.netbeans.modules.java.j2seproject.Bundle", 155 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME+"|" 156 +TEST_CLASS_NAME+"|"+TEST_CLASS_NAME+"|" 157 +org.netbeans.jellytools.Bundle.getString( 158 "org.netbeans.modules.java.ui.nodes.elements.Bundle", "Fields") 159 +"|"+TEST_FIELD_NAME); 160 161 n2.select(); 162 n2.performPopupActionNoBlock(org.netbeans.jellytools.Bundle.getString( 163 "org.netbeans.core.Bundle", "CTL_PropertiesWindow")); 164 165 FieldCustomizerOperator cco = new FieldCustomizerOperator( 166 TEST_FIELD_NAME+" - "+org.netbeans.jellytools.Bundle.getString( 167 "org.netbeans.core.Bundle", "CTL_PropertiesWindow")); 168 169 PropertySheetOperator pso = new PropertySheetOperator(TEST_FIELD_NAME 170 +" - "+org.netbeans.jellytools.Bundle.getString( 171 "org.netbeans.core.Bundle", "CTL_PropertiesWindow")); 172 173 new Property(pso, "Modifiers").setValue("private"); 175 new Property(pso, "Initial value").setValue("\"xxx\""); 176 new Property(pso, "Type").setValue("Integer"); 177 new Property(pso, "Initial value").setValue("12345"); 178 179 cco.btClose().clickMouse(); 180 181 ref(editor.txtEditorPane().getText()); 183 compareReferenceFiles(); 184 185 EditorOperator.closeDiscardAll(); 186 } 187 188 } 189 | Popular Tags |