diff --git a/plugins/NewTest.form b/plugins/NewTest.form
index 8ecd9da..5aaf9c2 100644
--- a/plugins/NewTest.form
+++ b/plugins/NewTest.form
@@ -44,34 +44,32 @@
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
+
-
+
+
+
+
+
-
+
-
+
+
+
+
-
+
+
@@ -82,33 +80,41 @@
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
@@ -116,19 +122,20 @@
-
+
+
-
+
-
+
@@ -138,6 +145,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -188,46 +226,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/NewTest.java b/plugins/NewTest.java
index 2dea7bc..5503686 100644
--- a/plugins/NewTest.java
+++ b/plugins/NewTest.java
@@ -45,13 +45,15 @@ public class NewTest extends javax.swing.JPanel {
/**
* Creates new form TestingListDetails
*/
+ private String sType;
public NewTest() {
initComponents();
}
public NewTest(String hDetails) {
initComponents();
- fillComponents();
+ sType = hDetails;
+ fillComponents(sType);
}
/**
@@ -66,16 +68,16 @@ public class NewTest extends javax.swing.JPanel {
jPopupMenuTable = new javax.swing.JPopupMenu();
jMenuItemAddRow = new javax.swing.JMenuItem();
jMenuItemReleteRow = new javax.swing.JMenuItem();
- jLabel4 = new javax.swing.JLabel();
- txtTestSuite = new javax.swing.JTextField();
- jLabel5 = new javax.swing.JLabel();
+ lblName = new javax.swing.JLabel();
+ lblSuite = new javax.swing.JLabel();
+ lblParams = new javax.swing.JLabel();
+ lblDescr = new javax.swing.JLabel();
txtTestName = new javax.swing.JTextField();
- jScrollPane1 = new javax.swing.JScrollPane();
- jTableParams = new javax.swing.JTable();
- jLabel7 = new javax.swing.JLabel();
- jLabel8 = new javax.swing.JLabel();
+ jComboBoxTestSuites = new javax.swing.JComboBox();
jScrollPane3 = new javax.swing.JScrollPane();
txtTestDescription = new javax.swing.JTextArea();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ jTableParams = new javax.swing.JTable();
jButtonGenerate = new javax.swing.JButton();
jMenuItemAddRow.setText("Add Row");
@@ -94,16 +96,28 @@ public class NewTest extends javax.swing.JPanel {
});
jPopupMenuTable.add(jMenuItemReleteRow);
- jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- jLabel4.setText("Test Case/Suite *");
+ lblName.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
+ lblName.setText("Name *");
- txtTestSuite.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
+ lblSuite.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
+ lblSuite.setText("Test Case/Suite *");
- jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- jLabel5.setText("Test Name *");
+ lblParams.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
+ lblParams.setText("Test Parameters");
+
+ lblDescr.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
+ lblDescr.setText("Description *");
txtTestName.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
+ jScrollPane3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
+
+ txtTestDescription.setColumns(20);
+ txtTestDescription.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
+ txtTestDescription.setLineWrap(true);
+ txtTestDescription.setRows(5);
+ jScrollPane3.setViewportView(txtTestDescription);
+
jTableParams.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jTableParams.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
@@ -129,20 +143,6 @@ public class NewTest extends javax.swing.JPanel {
jTableParams.getColumnModel().getColumn(1).setMaxWidth(100);
}
- jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- jLabel7.setText("Test Parameters");
-
- jLabel8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- jLabel8.setText("Test Description *");
-
- jScrollPane3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
-
- txtTestDescription.setColumns(20);
- txtTestDescription.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- txtTestDescription.setLineWrap(true);
- txtTestDescription.setRows(5);
- jScrollPane3.setViewportView(txtTestDescription);
-
jButtonGenerate.setText("Generate");
jButtonGenerate.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@@ -156,27 +156,25 @@ public class NewTest extends javax.swing.JPanel {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jLabel4)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(txtTestSuite, javax.swing.GroupLayout.PREFERRED_SIZE, 513, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createSequentialGroup()
- .addComponent(jLabel5)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(txtTestName, javax.swing.GroupLayout.PREFERRED_SIZE, 513, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel7)
- .addComponent(jLabel8))
+ .addComponent(lblParams)
+ .addComponent(lblDescr))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(19, 19, 19)
- .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 513, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+ .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 513, Short.MAX_VALUE)
+ .addComponent(txtTestName, javax.swing.GroupLayout.DEFAULT_SIZE, 513, Short.MAX_VALUE)
+ .addComponent(jComboBoxTestSuites, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 513, javax.swing.GroupLayout.PREFERRED_SIZE))))
- .addComponent(jButtonGenerate, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(jButtonGenerate, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 513, javax.swing.GroupLayout.PREFERRED_SIZE)))))
+ .addComponent(lblName)
+ .addComponent(lblSuite))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
@@ -184,30 +182,29 @@ public class NewTest extends javax.swing.JPanel {
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel5)
+ .addComponent(lblName)
.addComponent(txtTestName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel4)
- .addComponent(txtTestSuite, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addComponent(lblSuite)
+ .addComponent(jComboBoxTestSuites, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel8))
+ .addComponent(lblDescr))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel7)
+ .addComponent(lblParams)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButtonGenerate, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap())
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
}// //GEN-END:initComponents
private void jButtonGenerateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGenerateActionPerformed
// TODO add your handling code here:
- if(checkDataFields())
- {
+ if(checkDataFields()){
generateTestFiles();
}
}//GEN-LAST:event_jButtonGenerateActionPerformed
@@ -234,7 +231,6 @@ public class NewTest extends javax.swing.JPanel {
model.removeRow(row);
}
}//GEN-LAST:event_jMenuItemReleteRowActionPerformed
-
public static Path TESTS_DEVICES_DEFAULT_DIR = Paths.get(".", "home", "script", "tests", "devices");
public static Path TESTS_TESTS_DEFAULT_DIR = Paths.get(".", "home", "script", "tests", "tests");
@@ -243,17 +239,40 @@ public class NewTest extends javax.swing.JPanel {
public static String TESTS_HELP_FILENAME = "help.html";
public static Path TEMPLATES_HELP_FILEPATH = Paths.get(".", "home", "script", "tests","templates","helpTemplate.html");
public static Path TEMPLATES_TESTSCRIPT_FILEPATH = Paths.get(".", "home", "script", "tests","templates","testTemplate.py");
- public static Path TEMPLATES_CONFIG_FILEPATH = Paths.get(".", "home", "script", "tests","templates","template.config");
+ public static Path TEMPLATES_TESTCONFIG_FILEPATH = Paths.get(".", "home", "script", "tests","templates","testTemplate.config");
+ public static Path TEMPLATES_DEVICECONFIG_FILEPATH = Paths.get(".", "home", "script", "tests","templates","deviceTemplate.config");
public static String ALLOWED_CHARS = "[a-zA-Z0-9._\\-\\]\\[(){} ]*";
/**
* fill table with example parameters
+ * @param newType the new can be Device or Test.
*/
- private void fillComponents() {
+ private void fillComponents(String newType) {
+ if(newType == "Device"){
+ this.lblDescr.setText(newType + " "+ this.lblDescr.getText());
+ this.lblName.setText(newType + " "+ this.lblName.getText());
+ lblParams.setVisible(false);
+ jTableParams.setVisible(false);
+ jScrollPane1.setVisible(false);
+ }
+
+ //fill test suites combo box
+ File testsFolder = Paths.get(TESTS_TESTS_DEFAULT_DIR.toString()).toFile();
+ if (testsFolder.exists() && testsFolder.isDirectory()) {
+ File[] listOfTests = testsFolder.listFiles();
+ for (File listOfTest : listOfTests) {
+ if (listOfTest.isDirectory()) {
+ this.jComboBoxTestSuites.addItem(listOfTest.getName().toString());
+ }
+ }
+ }
+ this.jComboBoxTestSuites.setEditable(true);
+ this.jComboBoxTestSuites.setSelectedItem(null);
+ //fill parameters table
InputStream ist = null;
try {
Properties propTest = new Properties();
- File configFile = TEMPLATES_CONFIG_FILEPATH.toFile();
+ File configFile = TEMPLATES_TESTCONFIG_FILEPATH.toFile();
ist = new FileInputStream(configFile);
propTest.load(ist);
String testParams = propTest.getProperty("parameters");
@@ -276,16 +295,16 @@ public class NewTest extends javax.swing.JPanel {
jTableParams.setModel(model);
}
} catch (FileNotFoundException ex) {
- SwingUtils.showMessage(this, "fillComponents()", "Cannot find file " + TEMPLATES_CONFIG_FILEPATH.toString());
+ SwingUtils.showMessage(this, "fillComponents()", "Cannot find file " + TEMPLATES_TESTCONFIG_FILEPATH.toString());
Logger.getLogger(NewTest.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
- SwingUtils.showMessage(this, "fillComponents()", "Cannot read file " + TEMPLATES_CONFIG_FILEPATH.toString());
+ SwingUtils.showMessage(this, "fillComponents()", "Cannot read file " + TEMPLATES_TESTCONFIG_FILEPATH.toString());
Logger.getLogger(NewTest.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
ist.close();
} catch (IOException ex) {
- SwingUtils.showMessage(this, "fillComponents()", "Cannot close file " + TEMPLATES_CONFIG_FILEPATH.toString());
+ SwingUtils.showMessage(this, "fillComponents()", "Cannot close file " + TEMPLATES_TESTCONFIG_FILEPATH.toString());
Logger.getLogger(NewTest.class.getName()).log(Level.SEVERE, null, ex);
}
}
@@ -339,14 +358,14 @@ public class NewTest extends javax.swing.JPanel {
//check compulsory data fields
if(this.txtTestName.getText().isEmpty() ||
this.txtTestDescription.getText().isEmpty() ||
- this.txtTestSuite.getText().isEmpty()){
+ this.jComboBoxTestSuites.getSelectedItem().toString().isEmpty()){
SwingUtils.showMessage(this, "checkDataFields()",
"Please fill-in all compulsory fields (marked with *)");
return false;
}
if(!(txtTestName.getText().matches(ALLOWED_CHARS) &&
txtTestDescription.getText().matches(ALLOWED_CHARS) &&
- txtTestSuite.getText().matches(ALLOWED_CHARS)
+ jComboBoxTestSuites.getSelectedItem().toString().matches(ALLOWED_CHARS)
)){
SwingUtils.showMessage(this, "checkDataFields()",
"Please remove forbidden chars: only letters, numbers, parenthesis are allowed");
@@ -376,10 +395,17 @@ public class NewTest extends javax.swing.JPanel {
public void generateTestFiles(){
HashMap hmTestParams = (HashMap) getParametersFromTable();
- generateTestFiles(this.txtTestName.getText(),
- this.txtTestDescription.getText(),
- this.txtTestSuite.getText(),
- hmTestParams);
+ if(sType.equals("Device")){
+ generateDeviceFiles(this.txtTestName.getText(),
+ this.txtTestDescription.getText(),
+ this.jComboBoxTestSuites.getSelectedItem().toString(),
+ hmTestParams);
+ }else{
+ generateTestFiles(this.txtTestName.getText(),
+ this.txtTestDescription.getText(),
+ this.jComboBoxTestSuites.getSelectedItem().toString(),
+ hmTestParams);
+ }
}
public void generateTestFiles(String sTestName,
@@ -415,7 +441,8 @@ public class NewTest extends javax.swing.JPanel {
}
//generate test files inside test dir
- if (!generateTestConfig(testDir,
+ if (!generateTestConfig(TEMPLATES_TESTCONFIG_FILEPATH,
+ testDir,
sTestName,
sTestDescription,
sTestSuite,
@@ -436,6 +463,43 @@ public class NewTest extends javax.swing.JPanel {
SwingUtils.showMessage(this, "generateTestFiles()", "Cannot find tests default directory " + TESTS_TESTS_DEFAULT_DIR.toString());
}
}
+
+ public void generateDeviceFiles(String sTestName,
+ String sTestDescription,
+ String sTestSuite,
+ HashMap hmTestParams){
+ if (TESTS_DEVICES_DEFAULT_DIR.toFile().isDirectory()) {
+ //new device directory inside tests suite dir
+ Path testDir = Paths.get(TESTS_DEVICES_DEFAULT_DIR.toString(),sTestName);
+ if( testDir.toFile().isDirectory()){
+ //device already exists: ask to overwrite
+ OptionResult res = SwingUtils.showOption(this, "Overwrite Device?", "Device already exists. Overwrite with this new one?", OptionType.YesNo);
+ if (res == OptionResult.No){
+ return;
+ }
+ }else{
+ boolean success = testDir.toFile().mkdirs();
+ if (!success) {
+ // Directory creation failed
+ SwingUtils.showMessage(this, "generateTestFiles()", "Cannot create directory " + testDir.toString());
+ return;
+ }
+ }
+ //generate device files inside device dir
+ if (!generateTestConfig(TEMPLATES_DEVICECONFIG_FILEPATH,
+ testDir,
+ sTestName,
+ sTestDescription,
+ sTestSuite,
+ hmTestParams)) return;
+ SwingUtils.showMessage(this, "Test generated", "Test "+sTestName+" successfully generated in \n"+testDir.toString());
+
+ }else{
+ SwingUtils.showMessage(this, "generateTestFiles()", "Cannot find tests default directory " + TESTS_TESTS_DEFAULT_DIR.toString());
+ }
+ }
+
+
public boolean generateTestScript(Path testDir,
String sTestName,
@@ -465,8 +529,8 @@ public class NewTest extends javax.swing.JPanel {
}
}
replaceParameters(path,
- new String[]{"$testName","$testDescription","#$testParameters"},
- new String[]{sTestName,sTestDescription,sSyntaxGetTestParameters});
+ new String[]{"$testName", "$testDescription","$testSuite","#$testParameters"},
+ new String[]{sTestName, sTestDescription,sTestSuite,sSyntaxGetTestParameters});
success = true;
} catch (IOException ex) {
SwingUtils.showMessage(this, "generateTestScript()", "Cannot copy file " + ex.toString());
@@ -475,7 +539,8 @@ public class NewTest extends javax.swing.JPanel {
return success;
}
- public boolean generateTestConfig(Path testDir,
+ public boolean generateTestConfig(Path templateDir,
+ Path testDir,
String sTestName,
String sTestDescription,
String sTestSuite,
@@ -487,7 +552,7 @@ public class NewTest extends javax.swing.JPanel {
if(Files.exists(path)){
Files.delete(path);
}
- Files.copy(TEMPLATES_CONFIG_FILEPATH, path);
+ Files.copy(templateDir, path);
File configFile = path.toFile();
//Loop among the test parameters and generate variable assignement syntax for python
String sTestParameters = "";
@@ -502,16 +567,23 @@ public class NewTest extends javax.swing.JPanel {
//build the python code for getting the test parameter
sTestParameters = sTestParameters + name + ":" + value + ":" + description + ";" ;
}
- }
- String content = "#Test configuration\n";
- content +=("\nname=" + sTestName);
- content +=("\ndescription=" + sTestDescription);
- content +=("\nparameters=" + sTestParameters);
- OutputStream is = new FileOutputStream(configFile);
- Charset charset = StandardCharsets.UTF_8;
- Files.write(path, content.getBytes(charset));
- is.write(content.getBytes());
- is.close();
+ }
+ FileInputStream in = new FileInputStream(configFile);
+ Properties props = new Properties();
+ props.load(in);
+ in.close();
+ FileOutputStream out = new FileOutputStream(configFile);
+ if(sType.equals("Devices")){
+ props.setProperty("name", sTestName);
+ props.setProperty("description", sTestDescription);
+ props.setProperty("parameters", sTestParameters);
+ }else{
+ props.setProperty("name", sTestName);
+ props.setProperty("description", sTestDescription);
+ props.setProperty("tests", sTestSuite);
+ }
+ props.store(out, null);
+ out.close();
success = true;
} catch (FileNotFoundException ex) {
SwingUtils.showMessage(this, "generateTestConfig()", "Cannot find file: " + ex.toString());
@@ -590,18 +662,18 @@ public class NewTest extends javax.swing.JPanel {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButtonGenerate;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JLabel jLabel5;
- private javax.swing.JLabel jLabel7;
- private javax.swing.JLabel jLabel8;
+ private javax.swing.JComboBox jComboBoxTestSuites;
private javax.swing.JMenuItem jMenuItemAddRow;
private javax.swing.JMenuItem jMenuItemReleteRow;
private javax.swing.JPopupMenu jPopupMenuTable;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JTable jTableParams;
+ private javax.swing.JLabel lblDescr;
+ private javax.swing.JLabel lblName;
+ private javax.swing.JLabel lblParams;
+ private javax.swing.JLabel lblSuite;
private javax.swing.JTextArea txtTestDescription;
private javax.swing.JTextField txtTestName;
- private javax.swing.JTextField txtTestSuite;
// End of variables declaration//GEN-END:variables
}
diff --git a/plugins/TestingList.form b/plugins/TestingList.form
index ab19f83..5aa1a48 100644
--- a/plugins/TestingList.form
+++ b/plugins/TestingList.form
@@ -39,6 +39,16 @@
+
+
-
+
@@ -87,18 +87,16 @@
-
+
-
-
-
-
-
+
+
+
@@ -313,47 +311,14 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/plugins/TestingListDetails.java b/plugins/TestingListDetails.java
index 6b58c29..849327f 100644
--- a/plugins/TestingListDetails.java
+++ b/plugins/TestingListDetails.java
@@ -82,8 +82,6 @@ public class TestingListDetails extends javax.swing.JPanel {
txtTestDescription = new javax.swing.JTextArea();
jScrollPane4 = new javax.swing.JScrollPane();
jEditorPaneHelp = new javax.swing.JEditorPane();
- jPanel1 = new javax.swing.JPanel();
- jButtonCancel = new javax.swing.JButton();
jButtonOk = new javax.swing.JButton();
jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
@@ -174,35 +172,14 @@ public class TestingListDetails extends javax.swing.JPanel {
jEditorPaneHelp.setDropMode(javax.swing.DropMode.INSERT);
jScrollPane4.setViewportView(jEditorPaneHelp);
- jButtonCancel.setText("Cancel");
-
- jButtonOk.setText("Ok");
+ jButtonOk.setText("Save");
+ jButtonOk.setToolTipText("Save parameters values");
jButtonOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonOkActionPerformed(evt);
}
});
- javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
- jPanel1.setLayout(jPanel1Layout);
- jPanel1Layout.setHorizontalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jButtonOk, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(18, 18, 18)
- .addComponent(jButtonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
- );
- jPanel1Layout.setVerticalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jButtonCancel)
- .addComponent(jButtonOk))
- .addContainerGap())
- );
-
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -228,7 +205,7 @@ public class TestingListDetails extends javax.swing.JPanel {
.addComponent(jScrollPane3)
.addComponent(jScrollPane2)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 513, Short.MAX_VALUE)))
- .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addComponent(jButtonOk, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)
.addContainerGap())
@@ -266,13 +243,12 @@ public class TestingListDetails extends javax.swing.JPanel {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel7)
- .addGap(0, 192, Short.MAX_VALUE))
+ .addGap(0, 216, Short.MAX_VALUE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
- .addGap(18, 18, 18)
- .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createSequentialGroup()
- .addComponent(jScrollPane4)
- .addContainerGap())))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jButtonOk))
+ .addComponent(jScrollPane4))
+ .addContainerGap())
);
}// //GEN-END:initComponents
@@ -411,20 +387,22 @@ public class TestingListDetails extends javax.swing.JPanel {
sTestParameters = sTestParameters + name + ":" + value + ":" + description + ";" ;
}
}
- FileOutputStream out = new FileOutputStream(path.toFile());
FileInputStream in = new FileInputStream(path.toFile());
Properties props = new Properties();
props.load(in);
in.close();
- props.setProperty("parameters", "sTestParameters");
+ FileOutputStream out = new FileOutputStream(path.toFile());
+ props.setProperty("parameters", sTestParameters);
props.store(out, null);
out.close();
success = true;
} catch (FileNotFoundException ex) {
SwingUtils.showMessage(this, "generateTestConfig()", "Cannot find file: " + ex.toString());
+ success = false;
} catch (IOException ex) {
SwingUtils.showMessage(this, "generateTestConfig()", "Problem with file aaccess: " + ex.toString());
+ success = false;
}
return success;
}
@@ -437,7 +415,6 @@ public class TestingListDetails extends javax.swing.JPanel {
// Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton jButtonCancel;
private javax.swing.JButton jButtonOk;
private javax.swing.JEditorPane jEditorPaneHelp;
private javax.swing.JLabel jLabel1;
@@ -447,7 +424,6 @@ public class TestingListDetails extends javax.swing.JPanel {
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
- private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
diff --git a/script/tests/tests/Collimator Tests pro/Monitor movement/.config b/script/tests/tests/Collimator Tests pro/Monitor movement/.config
deleted file mode 100644
index 37b7543..0000000
--- a/script/tests/tests/Collimator Tests pro/Monitor movement/.config
+++ /dev/null
@@ -1,7 +0,0 @@
-name=Monitor Movement
-description=Monitor the movements during the specified time interval. No commands are sent.
-
-
-#optional parameters. Description is compulsory. Syntax:
-#parameters=::[;::]
-parameters=monitorTime:40:Monitor time interval [s]
diff --git a/script/tests/tests/Collimator Tests pro/Monitor movement/Monitor Movement.py b/script/tests/tests/Collimator Tests pro/Monitor movement/Monitor Movement.py
deleted file mode 100644
index 9a4f2d3..0000000
--- a/script/tests/tests/Collimator Tests pro/Monitor movement/Monitor Movement.py
+++ /dev/null
@@ -1,91 +0,0 @@
-
-###### DO NOT MODIFY THE CODE BELOW ######
-def startTest(testName, DEVICE, params):
- #get the path of this script
- testPath = inspect.getfile(inspect.currentframe())
- #by default, failed
- ret = 'Test failed'
- status = False
- #plot name to be given to the scan. Use: scan.setPlotName(plotName)
- plotName = DEVICE + ' - ' + testName
-###### WRITE YOUR CODE HERE BELOW #######
- #get parameters from the calling interface
- print_log(testName, DEVICE, 'testpath: ' + testPath )
- print_log(testName, DEVICE, 'parameters:' + str( params) )
- print_log(testName, DEVICE, 'device: ' + DEVICE )
- scan = ManualScan(['time'], ['idMotorStep', 'idPotiPosition', 'idPotiRef1Position','idMotorStep-idPotiPosition'] , [0.0], [30.0], [20])
- scan.setPlotName(plotName)
- scan.start()
-
- #Creating channels: dimension 1
- try:
- idCom = Channel(DEVICE+':COM:2', type = 'd') #current position as from motor step counter [mm]
- idMotorStep = Channel(DEVICE+':IST3:2', type = 'd') #current position as from motor step counter [mm]
- idPotiPosFromBeam = Channel(DEVICE+':IST1:2', type = 'd') #current position from beam as from potentiometer [mm]
- idPotiPosition = Channel(DEVICE+':IST2:1', type = 'd') #current position as from potentiometer [mm]
- idPotiRef1Position = Channel(DEVICE+':REF1:1', type = 'd') #R1 position as from potentiometer [mm]
- idPotiRef2Position = Channel(DEVICE+':REF2:1', type = 'd') #R2 position as from potentiometer [mm]
-
- except:
- sendFeedback(testPath, testName, DEVICE, 'Unable to create channel - ' + traceback.format_exc(), False)
- #raise Exception('Unable to create channel - ' + traceback.format_exc())
- return
-
- monitorTime=40 #seconds
- print_log(testName, DEVICE, 'Monitoring movement for ' + str(monitorTime) + 's')
- #scan quickly the output during some seconds
- detector4 = idPotiPosition.get()
- detector6 = idPotiRef2Position.get()
- timeElapsed=0
- while timeElapsed<(monitorTime*10):
- #Detector time
- detector1 = float(java.lang.System.currentTimeMillis())
-
- detector2 = idMotorStep.get()
- detector3 = idPotiPosFromBeam.get()
- detector4 = idPotiPosition.get()
- detector5 = idPotiRef1Position.get()
- detector6 = idPotiRef2Position.get()
- diff1 = detector2-detector4
- scan.append ([detector1], [detector1], [detector2, detector4, detector5, diff1])
- sleep( 0.1 ) # Settling time
- timeElapsed=timeElapsed+1
-
- #Closing channels
- idCom.close()
- idMotorStep.close()
- idPotiPosFromBeam.close()
- idPotiPosition.close()
- idPotiRef1Position.close()
- idPotiRef2Position.close()
- print_log(testName, DEVICE, 'End of Monitoring')
- ret = 'End of Monitoring'
- status = True
-########## END OF YOUR CODE ###########
-
-###### DO NOT MODIFY THE CODE BELOW ######
- sendFeedback(testPath, testName, DEVICE, ret, status)
-
-#prepare and send feedback to calling tool
-def sendFeedback(testPath, testName, DEVICE, returnString, testPassed):
- print_log(testName, DEVICE, 'End of test. Result:')
- print_log(testName, DEVICE, 'Test path: ' + testPath)
- print_log(testName, DEVICE, 'Test name: ' + testName )
- print_log(testName, DEVICE, 'Device: ' + DEVICE)
- print_log(testName, DEVICE, 'Test passed: ' + str(testPassed))
- print_log(testName, DEVICE, 'Return string: ' + returnString)
- ret = [testPath, DEVICE, returnString, testPassed]
- set_return(ret)
-
-def print_log(testName, DEVICE, text):
- time.ctime()
- now = time.strftime('%Y.%m.%d %H:%M:%S')
- print now + ' ' + DEVICE + ' - ' + testName + ': ' + text
-
-import sys, inspect, os, traceback
-#get test arguments
-DEVICE = device
-testName = test
-params = parameters
-#launch the test
-startTest(testName, DEVICE, params)