1 19 20 package gui.propertyeditors; 21 22 import org.netbeans.jellytools.NbDialogOperator; 23 import org.netbeans.jellytools.properties.editors.StringArrayCustomEditorOperator; 24 25 import org.netbeans.jemmy.operators.JTextFieldOperator; 26 27 import org.netbeans.junit.NbTestSuite; 28 29 34 public class PropertyType_IdentifierArray extends PropertyEditorsTest { 35 36 public String propertyName_L; 37 public String propertyValue_L; 38 public String propertyValueExpectation_L; 39 40 public boolean waitDialog = false; 41 42 private final String ADD = "Add:"; 43 private final String REMOVE = "Remove:"; 44 private final String EDIT = "Edit:"; 45 private final String UP = "Up:"; 46 private final String DOWN = "Down:"; 47 48 private final String EE = "; "; 49 50 51 public PropertyType_IdentifierArray(String testName) { 52 super(testName); 53 } 54 55 56 public void setUp(){ 57 propertyName_L = "Identifier []"; 58 super.setUp(); 59 } 60 61 public static NbTestSuite suite() { 62 NbTestSuite suite = new NbTestSuite(); 63 suite.addTest(new PropertyType_IdentifierArray("testByInPlace")); 64 suite.addTest(new PropertyType_IdentifierArray("verifyCustomizer")); 65 suite.addTest(new PropertyType_IdentifierArray("testCustomizerCancel")); 66 suite.addTest(new PropertyType_IdentifierArray("testCustomizerAdd")); 67 suite.addTest(new PropertyType_IdentifierArray("testCustomizerRemove")); 68 suite.addTest(new PropertyType_IdentifierArray("testCustomizerEdit")); 69 suite.addTest(new PropertyType_IdentifierArray("testCustomizerUp")); 70 suite.addTest(new PropertyType_IdentifierArray("testCustomizerDown")); 71 return suite; 72 } 73 74 75 public void testCustomizerAdd() { 76 propertyValue_L = ADD + "add"; 77 propertyValueExpectation_L = "remove, down, up, edit, add"; 78 waitDialog = false; 79 setByCustomizerOk(propertyName_L, true); 80 } 81 82 public void testCustomizerRemove() { 83 propertyValue_L = REMOVE + "remove"; 84 propertyValueExpectation_L = "down, up, edit, add"; 85 waitDialog = false; 86 setByCustomizerOk(propertyName_L, true); 87 } 88 89 public void testCustomizerEdit() { 90 propertyValue_L = EDIT + "edit" + EE + "newEdit"; 91 propertyValueExpectation_L = "down, up, newEdit, add"; 92 waitDialog = false; 93 setByCustomizerOk(propertyName_L, true); 94 } 95 96 public void testCustomizerUp() { 97 propertyValue_L = UP + "up"; 98 propertyValueExpectation_L = "up, down, newEdit, add"; 99 waitDialog = false; 100 setByCustomizerOk(propertyName_L, true); 101 } 102 103 public void testCustomizerDown() { 104 propertyValue_L = DOWN + "down"; 105 propertyValueExpectation_L = "up, newEdit, down, add"; 106 waitDialog = false; 107 setByCustomizerOk(propertyName_L, true); 108 } 109 110 public void testCustomizerCancel(){ 111 propertyValue_L = ADD + "cancel"; 112 propertyValueExpectation_L = propertyValue_L; 113 waitDialog = false; 114 setByCustomizerCancel(propertyName_L, false); 115 } 116 117 public void testByInPlace(){ 118 propertyValue_L = "remove, down, up, edit"; 119 propertyValueExpectation_L = propertyValue_L; 120 waitDialog = false; 121 setByInPlace(propertyName_L, propertyValue_L, true); 122 } 123 124 public void verifyCustomizer() { 125 verifyCustomizer(propertyName_L); 126 } 127 128 public void setCustomizerValue() { 129 StringArrayCustomEditorOperator customizer = new StringArrayCustomEditorOperator(propertyCustomizer); 130 131 if(propertyValue_L.startsWith(ADD)){ 132 customizer.btAdd().pushNoBlock(); 133 NbDialogOperator dialog = new NbDialogOperator("Enter"); 134 new JTextFieldOperator(dialog).setText(getItem(propertyValue_L,ADD)); 135 dialog.ok(); 136 } 137 138 if(propertyValue_L.startsWith(REMOVE)){ 139 customizer.remove(getItem(propertyValue_L,REMOVE)); 140 } 141 142 if(propertyValue_L.startsWith(EDIT)){ 143 customizer.lstItemList().selectItem(getItem(propertyValue_L,EDIT)); 144 customizer.btEdit().pushNoBlock(); 145 NbDialogOperator dialog = new NbDialogOperator("Enter"); 146 new JTextFieldOperator(dialog).setText(getItem(propertyValue_L,EE)); 147 dialog.ok(); 148 } 149 150 if(propertyValue_L.startsWith(UP)){ 151 customizer.up(getItem(propertyValue_L,UP)); 152 } 153 154 if(propertyValue_L.startsWith(DOWN)){ 155 customizer.down(getItem(propertyValue_L,DOWN)); 156 } 157 158 } 159 160 public void verifyPropertyValue(boolean expectation) { 161 verifyExpectationValue(propertyName_L,expectation, propertyValueExpectation_L, propertyValue_L, waitDialog); 162 } 163 164 165 private String getItem(String str, String delim) { 166 int first = str.indexOf(delim); 167 int end = str.indexOf(EE); 168 169 if(end > 0 && !delim.equals(EE)){ 170 return str.substring(delim.length(), end); 171 } else { 172 return str.substring(first + delim.length()); 173 } 174 } 175 176 public void verifyCustomizerLayout() { 177 StringArrayCustomEditorOperator customizer = new StringArrayCustomEditorOperator(propertyCustomizer); 178 customizer.btAdd(); 179 customizer.btRemove(); 180 customizer.btEdit(); 181 customizer.btUp(); 182 customizer.btDown(); 183 customizer.lstItemList(); 184 customizer.btOK(); 185 customizer.btCancel(); 186 } 187 188 191 public static void main(String [] args) { 192 junit.textui.TestRunner.run(suite()); 194 } 195 196 } 197 | Popular Tags |