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