1 19 20 package gui.propertyeditors; 21 22 import java.util.StringTokenizer ; 23 24 import org.netbeans.jellytools.properties.editors.RectangleCustomEditorOperator; 25 26 import org.netbeans.jemmy.JemmyException; 27 28 import org.netbeans.junit.NbTestSuite; 29 30 35 public class PropertyType_Rectangle extends PropertyEditorsTest { 36 37 public String propertyName_L; 38 public String propertyValue_L; 39 public String propertyValueExpectation_L; 40 41 public boolean waitDialog = false; 42 43 44 public PropertyType_Rectangle(String testName) { 45 super(testName); 46 } 47 48 49 public void setUp(){ 50 propertyName_L = "Rectangle"; 51 super.setUp(); 52 } 53 54 public static NbTestSuite suite() { 55 NbTestSuite suite = new NbTestSuite(); 56 suite.addTest(new PropertyType_Rectangle("verifyCustomizer")); 57 suite.addTest(new PropertyType_Rectangle("testCustomizerCancel")); 58 suite.addTest(new PropertyType_Rectangle("testCustomizerOk")); 59 suite.addTest(new PropertyType_Rectangle("testByInPlace")); 60 suite.addTest(new PropertyType_Rectangle("testByInPlaceOneValue")); 61 suite.addTest(new PropertyType_Rectangle("testByInPlaceInvalid")); 62 suite.addTest(new PropertyType_Rectangle("testCustomizerInvalid")); 63 return suite; 64 } 65 66 public void testCustomizerOk() { 67 propertyValue_L = "10, 20, 30, 40"; 68 propertyValueExpectation_L = "["+propertyValue_L+"]"; 69 waitDialog = false; 70 setByCustomizerOk(propertyName_L, true); 71 } 72 73 public void testCustomizerCancel(){ 74 propertyValue_L = "100, 100, 200, 200"; 75 propertyValueExpectation_L = "["+propertyValue_L+"]"; 76 waitDialog = false; 77 setByCustomizerCancel(propertyName_L, false); 78 } 79 80 public void testCustomizerInvalid(){ 81 propertyValue_L = "xx, 20, 30, 50"; 82 propertyValueExpectation_L = "["+propertyValue_L+"]"; 83 waitDialog = true; 84 setByCustomizerOk(propertyName_L, false); 85 } 86 87 public void testByInPlace(){ 88 propertyValue_L = "30, 40, 50, 60"; 89 propertyValueExpectation_L = "["+propertyValue_L+"]"; 90 waitDialog = false; 91 setByInPlace(propertyName_L, propertyValue_L, true); 92 } 93 94 public void testByInPlaceOneValue(){ 95 propertyValue_L = "70"; 96 propertyValueExpectation_L = "["+propertyValue_L+", "+propertyValue_L+", "+propertyValue_L+", "+propertyValue_L+"]"; 97 waitDialog = false; 98 setByInPlace(propertyName_L, propertyValue_L, true); 99 } 100 101 public void testByInPlaceInvalid(){ 102 propertyValue_L = "xx"; 103 propertyValueExpectation_L = propertyValue_L; 104 waitDialog = true; 105 setByInPlace(propertyName_L, propertyValue_L, false); 106 } 107 108 public void verifyCustomizer() { 109 verifyCustomizer(propertyName_L); 110 } 111 112 public void setCustomizerValue() { 113 RectangleCustomEditorOperator customizer = new RectangleCustomEditorOperator(propertyCustomizer); 114 StringTokenizer st = new StringTokenizer (propertyValue_L, ", "); 115 int x = st.countTokens(); 116 117 if(x>4) 118 throw new JemmyException("ERROR: InsetsCustomizer.setValue(\""+propertyValue_L+"\") - {number values="+x+"}."); 119 120 customizer.setRectangleValue(st.nextToken(), st.nextToken(), st.nextToken(), st.nextToken()); 121 } 122 123 public void verifyPropertyValue(boolean expectation) { 124 verifyExpectationValue(propertyName_L,expectation, propertyValueExpectation_L, propertyValue_L, waitDialog); 125 } 126 127 public void verifyCustomizerLayout() { 128 RectangleCustomEditorOperator customizer = new RectangleCustomEditorOperator(propertyCustomizer); 129 customizer.verify(); 130 customizer.btOK(); 131 customizer.btCancel(); 132 } 133 134 137 public static void main(String [] args) { 138 junit.textui.TestRunner.run(suite()); 140 } 141 142 } 143 | Popular Tags |