1 19 20 package gui.updatecenterwizard; 21 22 import gui.updatecenterwizard.settings.CatalogDataValues; 23 import gui.updatecenterwizard.settings.CatalogXMLFileParser; 24 import java.awt.Container ; 25 import java.io.File ; 26 import java.io.FileInputStream ; 27 import javax.swing.JDialog ; 28 import org.netbeans.jellytools.Bundle; 29 import org.netbeans.jellytools.JellyTestCase; 30 import org.netbeans.jellytools.WizardOperator; 31 import org.netbeans.jellytools.actions.Action; 32 import org.netbeans.jemmy.ComponentSearcher; 33 import org.netbeans.jemmy.JemmyException; 34 import org.netbeans.jemmy.operators.ContainerOperator; 35 import org.netbeans.jemmy.operators.JButtonOperator; 36 import org.netbeans.jemmy.operators.JDialogOperator; 37 import org.netbeans.jemmy.operators.JTableOperator; 38 39 43 44 public class UpdateCenterWizardTests extends JellyTestCase { 45 46 public String WORKDIR_PROPERTY="work.dir"; 47 public String WORKDIR_DEFAULT="C:\\TEMP"; 48 49 50 public UpdateCenterWizardTests(String name) { 51 super(name); 52 53 } 54 55 57 public WizardOperator openUpdateCenterWizard() throws JemmyException { 58 String toolsItem = Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Menu/Tools"); WizardOperator updateCenterWizardOper = null; 61 String updateCenterItem = Bundle.getStringTrimmed("org.netbeans.modules.autoupdate.Bundle", "CTL_Update"); 62 new Action(toolsItem+"|"+updateCenterItem, null).perform(); 63 String updateCenterTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Wizard"); 65 updateCenterWizardOper = new WizardOperator(updateCenterTitle); 66 67 return updateCenterWizardOper; 68 } 69 70 71 public CatalogDataValues readDataValues(String file){ 72 CatalogDataValues values = null; 73 try{ 74 CatalogXMLFileParser xfp = new CatalogXMLFileParser(); 75 javax.xml.parsers.SAXParserFactory saxParserFactory = javax.xml.parsers.SAXParserFactory.newInstance(); 76 javax.xml.parsers.SAXParser saxParser = saxParserFactory.newSAXParser(); 77 org.xml.sax.XMLReader parser = saxParser.getXMLReader(); 78 parser.setContentHandler(xfp); 79 parser.parse( new org.xml.sax.InputSource ( new FileInputStream (getDataDir() + File.separator + "settings" + File.separator + file) )); 82 xfp.getData().printValues(); 83 values = xfp.getData(); 84 }catch(Exception e){ 85 e.printStackTrace(); 86 } 87 return values; 88 } 89 90 public void setAUtypeSelected(String name, boolean selected){ 91 WizardOperator ucWizard = openUpdateCenterWizard(); 92 JTableOperator serversTable=new JTableOperator(ucWizard); 93 for(int row = 0; row<serversTable.getRowCount(); row++){ 94 if(((String )(serversTable.getValueAt(row, 1))).equals(name)){ 95 serversTable.setValueAt(new Boolean (selected), row, 1); 96 } 97 } 98 } 99 public void setAllAUtypesSelected(boolean selected){ 100 WizardOperator ucWizard = openUpdateCenterWizard(); 101 JTableOperator serversTable=new JTableOperator(ucWizard); 102 for(int row = 0; row<serversTable.getRowCount(); row++){ 103 serversTable.setValueAt(new Boolean (selected), row, 1); 104 } 105 } 106 public void setAUtypeSelected(int row, boolean selected){ 107 WizardOperator ucWizard = openUpdateCenterWizard(); 108 JTableOperator serversTable=new JTableOperator(ucWizard); 109 serversTable.setValueAt(new Boolean (selected), row, 1); 110 } 111 public String getAUtypeName(int row){ 112 WizardOperator ucWizard = openUpdateCenterWizard(); 113 JTableOperator serversTable=new JTableOperator(ucWizard); 114 String name = (String )(serversTable.getValueAt(row, 1)); 115 return name; 116 } 117 120 public boolean isAUtypeSelected(int row){ 121 WizardOperator ucWizard = openUpdateCenterWizard(); 122 JTableOperator serversTable=new JTableOperator(ucWizard); 123 Boolean b = (Boolean )(serversTable.getValueAt(row, 0)); 124 return b.booleanValue(); 125 } 126 127 public void selectAllAsSigned(){ 128 129 JTableOperator resultsTable = new JTableOperator(openUpdateCenterWizard()); 130 for(int row=0; row < resultsTable.getRowCount(); row++){ 131 133 resultsTable.setValueAt(new Boolean (true), row, 0); 134 135 142 } 143 } 144 public int indexOfButton(String name, JDialogOperator dialog){ 145 int current_index=0; 146 String button_string; 147 JButtonOperator button_operator=new JButtonOperator(dialog); 148 while(button_operator.findJButton(dialog.getContainer(ComponentSearcher.getTrueChooser("")),ComponentSearcher.getTrueChooser(""),current_index)!=null) { 149 button_string = new JButtonOperator(dialog, current_index).toString(); 150 if(button_string.indexOf(name)!=-1){ 151 return current_index; 152 } 153 current_index++; 154 } 155 return -1; 156 } 157 public void scloseAllModal() { 158 JDialogOperator oper = null; 159 JDialog jDialog = JDialogOperator.findJDialog(ComponentSearcher.getTrueChooser("")); 161 int nonModal = 0; 163 while(jDialog!=null) { 165 oper = new JDialogOperator(jDialog); 166 if(oper.isModal()) { 167 oper.close(); 169 } else { 170 nonModal++; 172 } 173 jDialog = JDialogOperator.findJDialog(ComponentSearcher.getTrueChooser(""), nonModal); 175 } 176 } 177 178 public void confirmAllModal() { 179 JDialogOperator oper = null; 180 JDialog jDialog = JDialogOperator.findJDialog(ComponentSearcher.getTrueChooser("")); 182 int nonModal = 0; 184 while(jDialog!=null) { 186 oper = new JDialogOperator(jDialog); 187 if(oper.isModal()) { 188 String unsignedModuleString = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_NotSignedConfirmation"); 189 String moduleCertificateString = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Certificate_Title"); 190 191 if(oper.getTitle().indexOf(unsignedModuleString) != -1){ 193 new JButtonOperator(oper, "Yes").push(); 194 }else{ 195 if (oper.getTitle().indexOf(moduleCertificateString) != -1){ 197 new JButtonOperator(oper, "Accept").push(); 198 }else{ 199 oper.close(); 201 } 202 } 203 204 205 } else { 206 nonModal++; 208 } 209 jDialog = JDialogOperator.findJDialog(ComponentSearcher.getTrueChooser(""), nonModal); 211 } 212 } 213 214 public void sleep(int millis){ 215 try{ 216 new Thread ().sleep(millis); 217 }catch(Exception e){ 218 e.printStackTrace(); 219 } 220 } 221 } 222 | Popular Tags |