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