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_ExtensionList 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_ExtensionList(String testName) { 49 super(testName); 50 } 51 52 53 public void setUp(){ 54 propertyName_L = "Extension List"; 55 super.setUp(); 56 } 57 58 public static NbTestSuite suite() { 59 NbTestSuite suite = new NbTestSuite(); 60 suite.addTest(new PropertyType_ExtensionList("testByInPlace")); 61 suite.addTest(new PropertyType_ExtensionList("verifyCustomizer")); 62 suite.addTest(new PropertyType_ExtensionList("testCustomizerCancel")); 63 suite.addTest(new PropertyType_ExtensionList("testCustomizerAdd")); 64 suite.addTest(new PropertyType_ExtensionList("testCustomizerRemove")); 65 suite.addTest(new PropertyType_ExtensionList("testCustomizerEdit")); 66 return suite; 67 } 68 69 70 public void testCustomizerAdd() { 71 propertyValue_L = ADD + "java"; 72 propertyValueExpectation_L = "gif, html, java, jpg, png"; 73 waitDialog = false; 74 setByCustomizerOk(propertyName_L, true); 75 } 76 77 public void testCustomizerEdit() { 78 propertyValue_L = EDIT + "html" + EE + "newHtml"; 79 propertyValueExpectation_L = "java, jpg, newHtml, png"; 80 waitDialog = false; 81 setByCustomizerOk(propertyName_L, true); 82 } 83 84 public void testCustomizerRemove() { 85 propertyValue_L = REMOVE + "gif"; 86 propertyValueExpectation_L = "html, java, jpg, png"; 87 waitDialog = false; 88 setByCustomizerOk(propertyName_L, true); 89 } 90 91 public void testCustomizerCancel(){ 92 propertyValue_L = ADD + "cancel"; 93 propertyValueExpectation_L = propertyValue_L; 94 waitDialog = false; 95 setByCustomizerCancel(propertyName_L, false); 96 } 97 98 public void testByInPlace(){ 99 propertyValue_L = "gif, jpg, png, html"; 100 propertyValueExpectation_L = "gif, html, jpg, png"; 101 waitDialog = false; 102 setByInPlace(propertyName_L, propertyValue_L, true); 103 } 104 105 public void verifyCustomizer() { 106 verifyCustomizer(propertyName_L); 107 } 108 109 public void setCustomizerValue() { 110 StringArrayCustomEditorOperator customizer = new StringArrayCustomEditorOperator(propertyCustomizer); 111 112 if(propertyValue_L.startsWith(ADD)){ 113 customizer.add(getItem(propertyValue_L,ADD)); 114 } 115 116 if(propertyValue_L.startsWith(REMOVE)){ 117 customizer.remove(getItem(propertyValue_L,REMOVE)); 118 } 119 120 if(propertyValue_L.startsWith(EDIT)){ 121 customizer.edit(getItem(propertyValue_L,EDIT), getItem(propertyValue_L,EE)); 122 } 123 124 } 125 126 public void verifyPropertyValue(boolean expectation) { 127 verifyExpectationValue(propertyName_L,expectation, propertyValueExpectation_L, propertyValue_L, waitDialog); 128 } 129 130 private String getItem(String str, String delim) { 131 int first = str.indexOf(delim); 132 int end = str.indexOf(EE); 133 134 if(end > 0 && !delim.equals(EE)){ 135 return str.substring(delim.length(), end); 136 } else { 137 return str.substring(first + delim.length()); 138 } 139 } 140 141 public void verifyCustomizerLayout() { 142 StringArrayCustomEditorOperator customizer = new StringArrayCustomEditorOperator(propertyCustomizer); 143 customizer.btAdd(); 144 customizer.btRemove(); 145 customizer.btEdit(); 146 customizer.lstItemList(); 147 customizer.txtItemText(); 148 customizer.btOK(); 149 customizer.btCancel(); 150 } 151 152 155 public static void main(String [] args) { 156 junit.textui.TestRunner.run(suite()); 158 } 159 160 } 161 | Popular Tags |