1 19 20 package gui.propertyeditors; 21 22 import java.util.StringTokenizer ; 23 24 import org.netbeans.jellytools.properties.editors.DimensionCustomEditorOperator; 25 26 import org.netbeans.jemmy.JemmyException; 27 28 import org.netbeans.junit.NbTestSuite; 29 30 31 32 37 public class PropertyType_Dimension 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_Dimension(String testName) { 47 super(testName); 48 } 49 50 51 public void setUp(){ 52 propertyName_L = "Dimension"; 53 super.setUp(); 54 } 55 56 public static NbTestSuite suite() { 57 NbTestSuite suite = new NbTestSuite(); 58 suite.addTest(new PropertyType_Dimension("verifyCustomizer")); 59 suite.addTest(new PropertyType_Dimension("testCustomizerCancel")); 60 suite.addTest(new PropertyType_Dimension("testCustomizerOk")); 61 suite.addTest(new PropertyType_Dimension("testByInPlace")); 62 suite.addTest(new PropertyType_Dimension("testByInPlaceOneValue")); 63 suite.addTest(new PropertyType_Dimension("testByInPlaceInvalid")); 64 suite.addTest(new PropertyType_Dimension("testCustomizerInvalid")); 65 return suite; 66 } 67 68 public void testCustomizerOk() { 69 propertyValue_L = "10, 20"; 70 propertyValueExpectation_L = "["+propertyValue_L+"]"; 71 waitDialog = false; 72 setByCustomizerOk(propertyName_L, true); 73 } 74 75 public void testCustomizerCancel(){ 76 propertyValue_L = "100, 200"; 77 propertyValueExpectation_L = "["+propertyValue_L+"]"; 78 waitDialog = false; 79 setByCustomizerCancel(propertyName_L, false); 80 } 81 82 public void testCustomizerInvalid(){ 83 propertyValue_L = "xx, ww"; 84 propertyValueExpectation_L = "["+propertyValue_L+"]"; 85 waitDialog = true; 86 setByCustomizerOk(propertyName_L, false); 87 } 88 89 public void testByInPlace(){ 90 propertyValue_L = "30, 50"; 91 propertyValueExpectation_L = "["+propertyValue_L+"]"; 92 waitDialog = false; 93 setByInPlace(propertyName_L, propertyValue_L, true); 94 } 95 96 public void testByInPlaceOneValue(){ 97 propertyValue_L = "20"; 98 propertyValueExpectation_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 Dimension"; 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 DimensionCustomEditorOperator customizer = new DimensionCustomEditorOperator(propertyCustomizer); 116 117 StringTokenizer st = new StringTokenizer (propertyValue_L, ", "); 118 int x = st.countTokens(); 119 120 if(x>2) 121 throw new JemmyException("ERROR: DimensionPointCustomizer.setValue(\""+propertyValue_L+"\") - {number values="+x+"}."); 122 123 customizer.setDimensionValue(st.nextToken(), st.nextToken()); 124 } 125 126 public void verifyPropertyValue(boolean expectation) { 127 verifyExpectationValue(propertyName_L,expectation, propertyValueExpectation_L, propertyValue_L, waitDialog); 128 } 129 130 public void verifyCustomizerLayout() { 131 DimensionCustomEditorOperator customizer = new DimensionCustomEditorOperator(propertyCustomizer); 132 customizer.verify(); 133 customizer.btOK(); 134 customizer.btCancel(); 135 } 136 137 140 public static void main(String [] args) { 141 junit.textui.TestRunner.run(suite()); 143 } 144 145 } 146 | Popular Tags |