1 19 20 package gui.propertyeditors; 21 22 import org.netbeans.jellytools.properties.Property; 23 import org.netbeans.jellytools.properties.PropertySheetOperator; 24 25 import org.netbeans.jellytools.properties.editors.IconCustomEditorOperator; 26 27 import org.netbeans.jemmy.EventTool; 28 import org.netbeans.jemmy.JemmyException; 29 30 import org.netbeans.junit.NbTestSuite; 31 32 33 34 39 public class PropertyType_Icon extends PropertyEditorsTest { 40 41 public String propertyName_L; 42 public String propertyValue_L; 43 public String propertyValueExpectation_L; 44 45 private final String FILE = "File: "; 46 private final String CLASSPATH = "Classpath: "; 47 private final String URL = "URL: "; 48 private final String NO_PICTURE = "No Picture"; 49 50 public boolean waitDialog = false; 51 52 53 public PropertyType_Icon(String testName) { 54 super(testName); 55 } 56 57 58 public void setUp(){ 59 propertyName_L = "Icon"; 60 super.setUp(); 61 } 62 63 public static NbTestSuite suite() { 64 NbTestSuite suite = new NbTestSuite(); 65 suite.addTest(new PropertyType_Icon("verifyCustomizer")); 66 suite.addTest(new PropertyType_Icon("testCustomizerCancel")); 67 suite.addTest(new PropertyType_Icon("testCustomizerOkURL")); 68 suite.addTest(new PropertyType_Icon("testCustomizerOkFile")); 69 suite.addTest(new PropertyType_Icon("testCustomizerOkClasspath")); 70 suite.addTest(new PropertyType_Icon("testCustomizerOkNoPicture")); 71 suite.addTest(new PropertyType_Icon("testByInPlace")); 72 suite.addTest(new PropertyType_Icon("testByInPlaceInvalid")); 73 return suite; 75 } 76 77 78 public void testCustomizerOkURL() { 79 propertyValue_L = URL + "http://www.netbeans.org/1.gif"; 80 propertyValueExpectation_L = propertyValue_L; 81 waitDialog = false; 82 setByCustomizerOk(propertyName_L, true); 83 } 84 85 public void testCustomizerOkFile() { 86 propertyValue_L = FILE + "/home/mm119185/samplxxxxeDir.gif"; 87 propertyValueExpectation_L = propertyValue_L; 88 waitDialog = false; 89 setByCustomizerOk(propertyName_L, true); 90 } 91 92 public void testCustomizerOkClasspath() { 93 propertyValue_L = CLASSPATH + "/gui/propertyeditors/data/ColorPreview.gif"; 94 propertyValueExpectation_L = propertyValue_L; 95 waitDialog = false; 96 setByCustomizerOk(propertyName_L, true); 97 } 98 99 public void testCustomizerOkNoPicture() { 100 propertyValue_L = NO_PICTURE; 101 propertyValueExpectation_L = "null"; 102 waitDialog = false; 103 setByCustomizerOk(propertyName_L, true); 104 } 105 106 public void testCustomizerCancel(){ 107 propertyValue_L = URL + "http://www.netbeans.org/2.gif"; 108 propertyValueExpectation_L = propertyValue_L; 109 waitDialog = false; 110 setByCustomizerCancel(propertyName_L, false); 111 } 112 113 120 public void testByInPlace(){ 121 propertyValue_L = CLASSPATH +"/trash/PropertyEditorsTest.java";; 122 propertyValueExpectation_L = "Invalid value " + propertyValue_L; 123 waitDialog = false; 124 setByInPlace(propertyName_L, propertyValue_L, true); 125 } 126 127 public void testByInPlaceInvalid(){ 128 propertyValue_L = "xx"; 129 propertyValueExpectation_L = "File: " +propertyValue_L; 130 waitDialog = false; 131 setByInPlace(propertyName_L, propertyValue_L, true); 132 } 133 134 public void verifyCustomizer() { 135 verifyCustomizer(propertyName_L); 136 } 137 138 public void setCustomizerValue() { 139 IconCustomEditorOperator customizer = new IconCustomEditorOperator(propertyCustomizer); 140 141 String type; 142 String path; 143 int delim_index = propertyValue_L.indexOf(": "); 144 145 if(delim_index>0){ 146 type = propertyValue_L.substring(0,delim_index+2); 147 path = propertyValue_L.substring(delim_index+1).trim(); 148 149 if(type.equalsIgnoreCase(NO_PICTURE)){ 150 customizer.noPicture(); 151 }else if(type.equalsIgnoreCase(URL)){ 152 customizer.uRL(); 153 customizer.setName(path); 154 }else if(type.equalsIgnoreCase(FILE)){ 155 customizer.file(); 156 customizer.setName(path); 157 }else if(type.equalsIgnoreCase(CLASSPATH)){ 158 customizer.classpath(); 159 customizer.txtName().enterText(path); 161 new EventTool().waitNoEvent(6000); 162 }else { 163 throw new JemmyException("ERROR: value is (\""+propertyValue_L+"\") - wrong format or unknown source type!!! type=["+type+"]/path=["+path+"]"); 164 } 165 166 }else{ 167 customizer.noPicture(); 168 } 169 170 } 171 172 public void verifyPropertyValue(boolean expectation) { 173 verifyExpectationValue(propertyName_L,expectation, propertyValueExpectation_L, propertyValue_L, waitDialog); 174 } 175 176 177 public String getValue(String property) { 178 String returnValue; 179 PropertySheetOperator propertiesTab = new PropertySheetOperator(propertiesWindow); 180 181 returnValue = new Property(propertiesTab, property).getValue(); 182 err.println("X GET VALUE = [" + returnValue + "]."); 183 184 returnValue = new Property(propertiesTab, property).getValue(); 186 returnValue = returnValue.substring(returnValue.indexOf(property)+property.length()+2); 187 err.println("X GET VALUE ACCESSIBLE NAME = [" + returnValue + "]."); 188 189 return returnValue; 190 } 191 192 public void verifyCustomizerLayout() { 193 IconCustomEditorOperator customizer = new IconCustomEditorOperator(propertyCustomizer); 194 customizer.verify(); 195 customizer.btOK(); 196 customizer.btCancel(); 197 } 198 199 202 public static void main(String [] args) { 203 junit.textui.TestRunner.run(suite()); 205 } 206 207 } 208 | Popular Tags |