Startup
This commit is contained in:
@@ -40,8 +40,6 @@ import java.lang.reflect.Method;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -58,7 +56,6 @@ import javax.swing.JDialog;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.RowFilter;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.filechooser.FileSystemView;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.TableModel;
|
||||
@@ -66,7 +63,7 @@ import javax.swing.table.TableRowSorter;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.python.core.PyList;
|
||||
import static org.python.bouncycastle.util.Arrays.append;
|
||||
import java.util.Collections;
|
||||
|
||||
//</editor-fold>
|
||||
|
||||
/**
|
||||
@@ -295,17 +292,12 @@ public class TestingList extends Panel {
|
||||
public final Path TESTS_LOG_DEFAULT_DIR = Paths.get(".", "home", "script", "tests", "log", "TestsLog" + getnow() + ".txt");
|
||||
public static String TESTS_CONFIG_FILENAME = ".config";
|
||||
public static String TESTS_HELP_FILENAME = "help.html";
|
||||
public static String VALUE_SEPARATOR = "&";
|
||||
public static String PARAM_SEPARATOR = ";";
|
||||
|
||||
|
||||
/**
|
||||
* initialise panel
|
||||
*/
|
||||
private void initialise(){
|
||||
|
||||
/*
|
||||
// testing RPS packets
|
||||
System.out.println("msg:");
|
||||
int PORT1 = 0x8899; // this port
|
||||
String mode = "2,IQCOM,$BMA1,1,DIA";
|
||||
@@ -326,8 +318,6 @@ public class TestingList extends Panel {
|
||||
System.out.print(String.format("%02X ", msg[i]));
|
||||
}
|
||||
System.out.println("");
|
||||
// end of testing RPS packets
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -336,8 +326,9 @@ public class TestingList extends Panel {
|
||||
|
||||
|
||||
|
||||
initComponents();
|
||||
addIcons();
|
||||
|
||||
|
||||
initComponents();
|
||||
initLogger();
|
||||
buildTable();
|
||||
|
||||
@@ -349,8 +340,7 @@ public class TestingList extends Panel {
|
||||
} catch (Exception ex) {
|
||||
getLogger().severe(ex.getMessage());
|
||||
}
|
||||
loadProperties();
|
||||
|
||||
loadProperties();
|
||||
}
|
||||
|
||||
|
||||
@@ -680,7 +670,7 @@ public class TestingList extends Panel {
|
||||
logger.addHandler(fh);
|
||||
SimpleFormatter formatter = new SimpleFormatter();
|
||||
fh.setFormatter(formatter);
|
||||
log("INF - " + "New testing session");
|
||||
log("INFO - " + "New testing session");
|
||||
} catch (SecurityException e) {
|
||||
SwingUtils.showMessage(this, "initLogger()", e.toString());
|
||||
} catch (IOException e) {
|
||||
@@ -732,7 +722,6 @@ public class TestingList extends Panel {
|
||||
jPanelButtons = new javax.swing.JPanel();
|
||||
jButtonOptions = new javax.swing.JButton();
|
||||
jButtonSave = new javax.swing.JButton();
|
||||
jButtonLog = new javax.swing.JButton();
|
||||
jButtonOpen = new javax.swing.JButton();
|
||||
jButtonRun = new javax.swing.JButton();
|
||||
jPanelSelection = new javax.swing.JPanel();
|
||||
@@ -824,6 +813,7 @@ public class TestingList extends Panel {
|
||||
jPopupMenuTable.add(jMenuItemShowDetails);
|
||||
jPopupMenuTable.add(jSeparator5);
|
||||
|
||||
jMenuItemRunSingleTest.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/play-circled-16-000000.png"))); // NOI18N
|
||||
jMenuItemRunSingleTest.setText("Run this test now");
|
||||
jMenuItemRunSingleTest.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
@@ -914,9 +904,10 @@ public class TestingList extends Panel {
|
||||
|
||||
jPanelButtons.setMinimumSize(new java.awt.Dimension(0, 80));
|
||||
jPanelButtons.setPreferredSize(new java.awt.Dimension(100, 80));
|
||||
jPanelButtons.setLayout(new java.awt.GridLayout(2, 2));
|
||||
jPanelButtons.setLayout(new java.awt.BorderLayout());
|
||||
|
||||
jButtonOptions.setToolTipText("More actions");
|
||||
jButtonOptions.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/listing-option-32px.png"))); // NOI18N
|
||||
jButtonOptions.setToolTipText("Optional actions");
|
||||
jButtonOptions.setMaximumSize(new java.awt.Dimension(60, 40));
|
||||
jButtonOptions.setMinimumSize(new java.awt.Dimension(0, 40));
|
||||
jButtonOptions.setPreferredSize(new java.awt.Dimension(50, 40));
|
||||
@@ -925,9 +916,10 @@ public class TestingList extends Panel {
|
||||
jButtonOptionsActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanelButtons.add(jButtonOptions);
|
||||
jPanelButtons.add(jButtonOptions, java.awt.BorderLayout.LINE_START);
|
||||
|
||||
jButtonSave.setToolTipText("Save current list of tests");
|
||||
jButtonSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/android-save-24-000000.png"))); // NOI18N
|
||||
jButtonSave.setToolTipText("Save current configuration");
|
||||
jButtonSave.setMaximumSize(new java.awt.Dimension(60, 40));
|
||||
jButtonSave.setMinimumSize(new java.awt.Dimension(0, 40));
|
||||
jButtonSave.setPreferredSize(new java.awt.Dimension(50, 40));
|
||||
@@ -936,16 +928,10 @@ public class TestingList extends Panel {
|
||||
jButtonSaveActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanelButtons.add(jButtonSave);
|
||||
jPanelButtons.add(jButtonSave, java.awt.BorderLayout.LINE_END);
|
||||
|
||||
jButtonLog.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButtonLogActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanelButtons.add(jButtonLog);
|
||||
|
||||
jButtonOpen.setToolTipText("Open a list of tests");
|
||||
jButtonOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/folder-open-24-000000.png"))); // NOI18N
|
||||
jButtonOpen.setToolTipText("Open configuration");
|
||||
jButtonOpen.setMinimumSize(new java.awt.Dimension(0, 9));
|
||||
jButtonOpen.setPreferredSize(new java.awt.Dimension(33, 50));
|
||||
jButtonOpen.addActionListener(new java.awt.event.ActionListener() {
|
||||
@@ -953,10 +939,11 @@ public class TestingList extends Panel {
|
||||
jButtonOpenActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanelButtons.add(jButtonOpen);
|
||||
jPanelButtons.add(jButtonOpen, java.awt.BorderLayout.PAGE_END);
|
||||
|
||||
jPanelTopCommands.add(jPanelButtons, java.awt.BorderLayout.EAST);
|
||||
|
||||
jButtonRun.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/play-circled-64-000000.png"))); // NOI18N
|
||||
jButtonRun.setToolTipText("Run enabled tests");
|
||||
jButtonRun.setMaximumSize(new java.awt.Dimension(330000, 39));
|
||||
jButtonRun.setMinimumSize(new java.awt.Dimension(90, 90));
|
||||
@@ -980,6 +967,7 @@ public class TestingList extends Panel {
|
||||
});
|
||||
jPanelSelection.add(jCheckBoxEnableDisable, java.awt.BorderLayout.WEST);
|
||||
|
||||
jButtonMoveDown.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/chevron-down-16-000000.png"))); // NOI18N
|
||||
jButtonMoveDown.setToolTipText("Move the selected tests down");
|
||||
jButtonMoveDown.setMaximumSize(new java.awt.Dimension(25, 25));
|
||||
jButtonMoveDown.setMinimumSize(new java.awt.Dimension(25, 25));
|
||||
@@ -991,6 +979,7 @@ public class TestingList extends Panel {
|
||||
});
|
||||
jPanelSelection.add(jButtonMoveDown, java.awt.BorderLayout.SOUTH);
|
||||
|
||||
jButtonMoveUp.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/chevron-up-16-000000.png"))); // NOI18N
|
||||
jButtonMoveUp.setToolTipText("Move the selected tests up");
|
||||
jButtonMoveUp.setMaximumSize(new java.awt.Dimension(25, 25));
|
||||
jButtonMoveUp.setMinimumSize(new java.awt.Dimension(25, 25));
|
||||
@@ -1056,10 +1045,12 @@ public class TestingList extends Panel {
|
||||
jPanelCustomHeader.setLayout(new java.awt.BorderLayout());
|
||||
|
||||
jButtonX.setFont(new java.awt.Font("Tahoma", 0, 8)); // NOI18N
|
||||
jButtonX.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/x-darker-8px.png"))); // NOI18N
|
||||
jButtonX.setToolTipText("Close this custom panel");
|
||||
jButtonX.setMaximumSize(new java.awt.Dimension(12, 12));
|
||||
jButtonX.setMinimumSize(new java.awt.Dimension(12, 12));
|
||||
jButtonX.setPreferredSize(new java.awt.Dimension(12, 12));
|
||||
jButtonX.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/x-darker-8px.png"))); // NOI18N
|
||||
jButtonX.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButtonXActionPerformed(evt);
|
||||
@@ -1101,16 +1092,6 @@ public class TestingList extends Panel {
|
||||
add(jPanelCustom, java.awt.BorderLayout.SOUTH);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void addIcons() {
|
||||
jButtonRun.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/play-circled-64-000000.png")));
|
||||
jButtonLog.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/logbook-32px.png")));
|
||||
jButtonOptions.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/listing-option-32px.png")));
|
||||
jButtonSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/android-save-24-000000.png")));
|
||||
jButtonOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/folder-open-36-000000.png")));
|
||||
jButtonMoveUp.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/chevron-up-24-000000.png")));
|
||||
jButtonMoveDown.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/chevron-down-24-000000.png")));
|
||||
}
|
||||
|
||||
private void jButtonRunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRunActionPerformed
|
||||
if (this.jButtonRun.getToolTipText().equals("Run enabled tests")) {
|
||||
Object pshellStatus;
|
||||
@@ -1236,7 +1217,7 @@ public class TestingList extends Panel {
|
||||
openDetails();
|
||||
break;
|
||||
}
|
||||
//updateStatus();
|
||||
updateStatus();
|
||||
} catch (Exception ex) {
|
||||
SwingUtils.showException(this, ex);
|
||||
}
|
||||
@@ -1289,14 +1270,14 @@ public class TestingList extends Panel {
|
||||
}//GEN-LAST:event_jButtonOptionsActionPerformed
|
||||
|
||||
private void jCheckBoxMenuShowSelectedTestsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuShowSelectedTestsActionPerformed
|
||||
|
||||
// TODO add your handling code here:
|
||||
boolean bShow = jCheckBoxMenuShowSelectedTests.getState();
|
||||
showEnabledTestsOnly(bShow);
|
||||
jCheckBoxMenuShowSelectedTests1.setState(bShow);
|
||||
}//GEN-LAST:event_jCheckBoxMenuShowSelectedTestsActionPerformed
|
||||
|
||||
private void jMenuItemOpenLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemOpenLogActionPerformed
|
||||
|
||||
// TODO add your handling code here:
|
||||
String cmd;
|
||||
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
|
||||
cmd = "notepad.exe " + TESTS_LOG_DEFAULT_DIR;
|
||||
@@ -1313,7 +1294,7 @@ public class TestingList extends Panel {
|
||||
}//GEN-LAST:event_jMenuItemOpenLogActionPerformed
|
||||
|
||||
private void jMenuItemReloadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemReloadActionPerformed
|
||||
|
||||
// TODO add your handling code here:
|
||||
reloadTests();
|
||||
try {
|
||||
cleanTests();
|
||||
@@ -1324,24 +1305,24 @@ public class TestingList extends Panel {
|
||||
}//GEN-LAST:event_jMenuItemReloadActionPerformed
|
||||
|
||||
private void jMenuItemNewTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemNewTestActionPerformed
|
||||
|
||||
// TODO add your handling code here:
|
||||
openNewTestEditor("Test");
|
||||
}//GEN-LAST:event_jMenuItemNewTestActionPerformed
|
||||
|
||||
private void jMenuItemNewDeviceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemNewDeviceActionPerformed
|
||||
|
||||
// TODO add your handling code here:
|
||||
openNewTestEditor("Device");
|
||||
}//GEN-LAST:event_jMenuItemNewDeviceActionPerformed
|
||||
|
||||
private void jCheckBoxMenuShowSelectedTests1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuShowSelectedTests1ActionPerformed
|
||||
|
||||
// TODO add your handling code here:
|
||||
boolean bShow = jCheckBoxMenuShowSelectedTests1.getState();
|
||||
showEnabledTestsOnly(bShow);
|
||||
jCheckBoxMenuShowSelectedTests.setState(bShow);
|
||||
}//GEN-LAST:event_jCheckBoxMenuShowSelectedTests1ActionPerformed
|
||||
|
||||
private void jMenuItemReload1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemReload1ActionPerformed
|
||||
|
||||
// TODO add your handling code here:
|
||||
reloadTests();
|
||||
try {
|
||||
cleanTests();
|
||||
@@ -1353,7 +1334,7 @@ public class TestingList extends Panel {
|
||||
|
||||
private void jMenuItemShowDetailsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemShowDetailsActionPerformed
|
||||
try {
|
||||
|
||||
// TODO add your handling code here:
|
||||
openDetails();
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex);
|
||||
@@ -1361,32 +1342,32 @@ public class TestingList extends Panel {
|
||||
}//GEN-LAST:event_jMenuItemShowDetailsActionPerformed
|
||||
|
||||
private void jMenuItemSelectAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSelectAllActionPerformed
|
||||
|
||||
// TODO add your handling code here:
|
||||
enableAll(true);
|
||||
}//GEN-LAST:event_jMenuItemSelectAllActionPerformed
|
||||
|
||||
private void jMenuItemSelectNoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSelectNoneActionPerformed
|
||||
|
||||
// TODO add your handling code here:
|
||||
enableAll(false);
|
||||
}//GEN-LAST:event_jMenuItemSelectNoneActionPerformed
|
||||
|
||||
private void jMenuItemSelectSelectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSelectSelectionActionPerformed
|
||||
|
||||
// TODO add your handling code here:
|
||||
enableSelection(true);
|
||||
}//GEN-LAST:event_jMenuItemSelectSelectionActionPerformed
|
||||
|
||||
private void jMenuItemDeselectSelectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDeselectSelectionActionPerformed
|
||||
|
||||
// TODO add your handling code here:
|
||||
enableSelection(false);
|
||||
}//GEN-LAST:event_jMenuItemDeselectSelectionActionPerformed
|
||||
|
||||
private void jMenuItemEditScriptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemEditScriptActionPerformed
|
||||
|
||||
// TODO add your handling code here:
|
||||
int rows[] = jTable1.getSelectedRows();
|
||||
for(int row=0 ; row<rows.length ; row++){
|
||||
try {
|
||||
String sTestPath = String.valueOf(jTable1.getValueAt(rows[row], COL.TESTPATH.ordinal())).replace("\\", File.separator);
|
||||
System.out.println("Test Path: " + sTestPath);
|
||||
System.out.println(sTestPath);
|
||||
((View)App.getInstance().getMainFrame()).openScript(sTestPath);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex);
|
||||
@@ -1395,14 +1376,14 @@ public class TestingList extends Panel {
|
||||
}//GEN-LAST:event_jMenuItemEditScriptActionPerformed
|
||||
|
||||
private void jMenuItemRunSingleTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemRunSingleTestActionPerformed
|
||||
|
||||
// TODO add your handling code here:
|
||||
enableAll(false);
|
||||
enableSelection(true);
|
||||
jButtonRunActionPerformed( evt);
|
||||
}//GEN-LAST:event_jMenuItemRunSingleTestActionPerformed
|
||||
|
||||
private void jMenuLoadCustomPanelMenuSelected(javax.swing.event.MenuEvent evt) {//GEN-FIRST:event_jMenuLoadCustomPanelMenuSelected
|
||||
|
||||
// TODO add your handling code here:
|
||||
List<String> menuList = getCustomPanels();
|
||||
jMenuLoadCustomPanel.removeAll();
|
||||
for(int u = 0; u < menuList.size(); u++){
|
||||
@@ -1435,22 +1416,12 @@ public class TestingList extends Panel {
|
||||
}//GEN-LAST:event_jMenuItemCustomCloseActionPerformed
|
||||
|
||||
private void jMenuItemDeselectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDeselectActionPerformed
|
||||
|
||||
// TODO add your handling code here:
|
||||
this.jTable1.clearSelection();
|
||||
}//GEN-LAST:event_jMenuItemDeselectActionPerformed
|
||||
|
||||
private void jButtonLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLogActionPerformed
|
||||
try {
|
||||
String logViewerScript = Paths.get(".", "home", "script", "startlogviewer-rpstests.sh").toString();
|
||||
Process p = Runtime.getRuntime().exec(logViewerScript);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}//GEN-LAST:event_jButtonLogActionPerformed
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Witget Variables declaration">
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton jButtonLog;
|
||||
private javax.swing.JButton jButtonMoveDown;
|
||||
private javax.swing.JButton jButtonMoveUp;
|
||||
private javax.swing.JButton jButtonOpen;
|
||||
@@ -1593,7 +1564,7 @@ public class TestingList extends Panel {
|
||||
* @return status of run button. True = tests launching sequence is running
|
||||
*/
|
||||
public boolean isTestRunAllowed() {
|
||||
return (this.jButtonRun.getToolTipText().equals("Stop tests") && countPendingTests() > 0);
|
||||
return (this.jButtonRun.getToolTipText().equals("Stop tests") && pendingTestsCount() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1645,12 +1616,10 @@ public class TestingList extends Panel {
|
||||
int row = jTable1.getSelectedRow();
|
||||
String sDeviceName = jTable1.getValueAt(row, COL.DEVICENAME.ordinal()).toString();
|
||||
String sTestName = jTable1.getValueAt(row, COL.TESTNAME.ordinal()).toString();
|
||||
String sTestPath = jTable1.getValueAt(row, COL.TESTPATH.ordinal()).toString();
|
||||
String sTestPath = String.valueOf(jTable1.getValueAt(row, COL.TESTPATH.ordinal())).replace("\\", File.separator);
|
||||
String sTestCaseName = jTable1.getValueAt(row, COL.TESTSUITE.ordinal()).toString();
|
||||
String sTestDescription = getTestDescription(sTestPath);
|
||||
String sDevicePath = jTable1.getValueAt(row, COL.DEVICEPATH.ordinal()).toString();
|
||||
System.out.println("sDevicePath: "+sDevicePath);
|
||||
System.out.println("sTestPath: "+sTestPath);
|
||||
String sDeviceDescription = jTable1.getValueAt(row, COL.DEVICEDESCR.ordinal()).toString();
|
||||
String sLastResult = jTable1.getValueAt(row, COL.RESULT.ordinal()).toString();
|
||||
String sResultTime = jTable1.getValueAt(row, COL.TIME.ordinal()).toString();
|
||||
@@ -1660,7 +1629,6 @@ public class TestingList extends Panel {
|
||||
HashMap details = new HashMap();
|
||||
details.put("deviceName", sDeviceName);
|
||||
details.put("deviceDescription", sDeviceDescription);
|
||||
details.put("devicePath", sDevicePath);
|
||||
details.put("testDescription", sTestDescription);
|
||||
details.put("testSuite", sTestCaseName);
|
||||
details.put("testName", sTestName);
|
||||
@@ -1739,7 +1707,7 @@ public class TestingList extends Panel {
|
||||
case "Success":
|
||||
icon = TestStatus.SUCCESS.Icon();
|
||||
logger.log(Level.INFO, sStatus + " - Device: " + deviceName + "; Test: " + sTestName + "; Result: " + res);
|
||||
log("INF - " + sStatus + " - Device: " + deviceName + "; Test: " + sTestName + "; Result: " + res);
|
||||
log("INFO - " + sStatus + " - Device: " + deviceName + "; Test: " + sTestName + "; Result: " + res);
|
||||
break;
|
||||
case "Failure":
|
||||
icon = TestStatus.FAILURE.Icon();
|
||||
@@ -1759,36 +1727,18 @@ public class TestingList extends Panel {
|
||||
logger.log(Level.SEVERE, "Cant find Test: " + testPath + " in table.");
|
||||
}
|
||||
//check if there are still pending tests. If not, set the status of the tool to Stopped.
|
||||
if (countPendingTests() == 0 && countRunningTests() == 0) {
|
||||
if (pendingTestsCount() == 0 && runningTestsCount() == 0) {
|
||||
setToStopped();
|
||||
}
|
||||
updateResultSummary();
|
||||
return rowD;
|
||||
}
|
||||
|
||||
/**
|
||||
* show a summary icon indicating if all tests succeeded
|
||||
* or if at least one failed
|
||||
*/
|
||||
public void updateResultSummary() {
|
||||
ImageIcon summaryIcon = null;
|
||||
if(countRunningTests()>0){
|
||||
summaryIcon = TestStatus.RUNNING.Icon();
|
||||
} else if(countFailureTests()>0){
|
||||
summaryIcon = TestStatus.FAILURE.Icon();
|
||||
} else if(countSuccessTests()>0){
|
||||
summaryIcon = TestStatus.SUCCESS.Icon();
|
||||
}
|
||||
//System.out.println("successful: "+countSuccessTests() + " Failed: "+countSuccessTests() );
|
||||
setIcon(jTable1, COL.ICON.ordinal(), summaryIcon, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* return the amount of tests currently in Pending state
|
||||
*
|
||||
* @return int counter of pending tests
|
||||
*/
|
||||
public int countPendingTests() {
|
||||
public int pendingTestsCount() {
|
||||
return testsStatusCount(TestStatus.PENDING);
|
||||
}
|
||||
|
||||
@@ -1797,7 +1747,7 @@ public class TestingList extends Panel {
|
||||
*
|
||||
* @return int counter of running tests
|
||||
*/
|
||||
public int countRunningTests() {
|
||||
public int runningTestsCount() {
|
||||
return testsStatusCount(TestStatus.RUNNING);
|
||||
}
|
||||
|
||||
@@ -1806,19 +1756,10 @@ public class TestingList extends Panel {
|
||||
*
|
||||
* @return int counter of successful tests
|
||||
*/
|
||||
public int countSuccessTests() {
|
||||
public int successTestsCount() {
|
||||
return testsStatusCount(TestStatus.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* return the amount of tests currently in Failure state
|
||||
*
|
||||
* @return int counter of failed tests
|
||||
*/
|
||||
public int countFailureTests() {
|
||||
return testsStatusCount(TestStatus.FAILURE);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the amount of tests currently in "status" state
|
||||
*
|
||||
@@ -1828,16 +1769,15 @@ public class TestingList extends Panel {
|
||||
private int testsStatusCount(TestStatus status) {
|
||||
String sStatus;
|
||||
boolean bSelected;
|
||||
int iTestsCount = 0;
|
||||
int iPendingTestsCount = 0;
|
||||
for (int row = 0; row < jTable1.getRowCount(); row++) {
|
||||
bSelected = (boolean) jTable1.getValueAt(row, COL.CHECK.ordinal());
|
||||
sStatus = jTable1.getValueAt(row, COL.STATUS.ordinal()).toString();
|
||||
//System.out.println("sStatus: " +sStatus);
|
||||
if (bSelected && sStatus.equals(status.toString())) {
|
||||
iTestsCount++;
|
||||
if (bSelected && sStatus == status.toString()) {
|
||||
iPendingTestsCount++;
|
||||
}
|
||||
}
|
||||
return iTestsCount;
|
||||
return iPendingTestsCount;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1949,7 +1889,6 @@ public class TestingList extends Panel {
|
||||
jTable1.setValueAt(sStatus, row, COL.STATUS.ordinal());
|
||||
jTable1.setValueAt(sStart, row, COL.STARTSEQUENCE.ordinal());
|
||||
}
|
||||
updateResultSummary();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2042,12 +1981,13 @@ public class TestingList extends Panel {
|
||||
String sDeviceName = jTable1.getValueAt(row, COL.DEVICENAME.ordinal()).toString();
|
||||
String sDevicePath = jTable1.getValueAt(row, COL.DEVICEPATH.ordinal()).toString().replace("\\", File.separator);
|
||||
String sTestName = jTable1.getValueAt(row, COL.TESTNAME.ordinal()).toString();
|
||||
String sTestCaseName = jTable1.getValueAt(row, COL.TESTSUITE.ordinal()).toString();
|
||||
String sTestPath = jTable1.getValueAt(row, COL.TESTPATH.ordinal()).toString().replace("\\", File.separator);
|
||||
// HashMap mParameters = buildParametersMap(String.valueOf(jTable1.getValueAt(row, COL.TESTPARAMS.ordinal())));
|
||||
//get the parameters directly frm he config file
|
||||
// System.out.println("sTestPath: " + sTestPath);
|
||||
HashMap mParameters = getParameters(sTestPath, sDevicePath);
|
||||
HashMap testArgs = new HashMap();
|
||||
System.out.println("mParameters: " + mParameters.toString());
|
||||
//args.put("ret", "");
|
||||
testArgs.put(testArgNames.PARAMETERS.toString(), mParameters);
|
||||
testArgs.put(testArgNames.TEST.toString(), sTestName);
|
||||
@@ -2064,10 +2004,10 @@ public class TestingList extends Panel {
|
||||
*
|
||||
* @param sParameters string coming from HashMap conaining the list of
|
||||
* parameters to be passed to the test script. Example:
|
||||
* {repeatTimes={description="Repeat N times", value="1"},
|
||||
* midPoint={description="Middle point A", value="41.0"},
|
||||
* spanFromMidPoint={description="B steps around middle point A",
|
||||
* value="2.0"}}
|
||||
* {repeatTimes={description=Repeat N times, value=1},
|
||||
* midPoint={description=Middle point A, value=41.0},
|
||||
* spanFromMidPoint={description=B steps around middle point A,
|
||||
* value=2.0}}
|
||||
* @return string of dictionary in python syntax. This can be passed to
|
||||
* the python test script. Example of output:
|
||||
* {'repeatTimes':{'description':'Repeat N
|
||||
@@ -2080,15 +2020,15 @@ public class TestingList extends Panel {
|
||||
sPythonParams = sPythonParams.replace(", ", ",");
|
||||
sPythonParams = sPythonParams.replace(" ,", ",");
|
||||
sPythonParams = sPythonParams.replace("{{", "#@");
|
||||
sPythonParams = sPythonParams.replace("\"}}", "@#");
|
||||
sPythonParams = sPythonParams.replace("\"},", "@%#");
|
||||
sPythonParams = sPythonParams.replace("}}", "@#");
|
||||
sPythonParams = sPythonParams.replace("},", "@%#");
|
||||
sPythonParams = sPythonParams.replace(",{", "#%@");
|
||||
sPythonParams = sPythonParams.replace("={", "^%&");
|
||||
sPythonParams = sPythonParams.replace("=}", "&%^");
|
||||
sPythonParams = sPythonParams.replace("\",", "','");
|
||||
sPythonParams = sPythonParams.replace(",", "','");
|
||||
sPythonParams = sPythonParams.replace("{", "{'");
|
||||
sPythonParams = sPythonParams.replace("\"}", "'}");
|
||||
sPythonParams = sPythonParams.replace("=\"", "':'");
|
||||
sPythonParams = sPythonParams.replace("}", "'}");
|
||||
sPythonParams = sPythonParams.replace("=", "':'");
|
||||
sPythonParams = sPythonParams.replace("^%&", "':{'");
|
||||
sPythonParams = sPythonParams.replace("&%^", "'}:'");
|
||||
sPythonParams = sPythonParams.replace("#@", "{{'");
|
||||
@@ -2113,6 +2053,7 @@ public class TestingList extends Panel {
|
||||
int iRet = -1;
|
||||
HashMap args2 = new HashMap(); //this is the global map that will contain one map per test.
|
||||
HashMap testArgs; //this is the map for a test.
|
||||
RunTest runTest;
|
||||
String sTestName = "", sDeviceName = "", sTestPath = "", sTestID = ""; //sTestID is the compination of device name + test path
|
||||
for (int row : rowsToExecute) {
|
||||
//System.out.println(String.valueOf(row) + "\t" + sDeviceName + "\t" + sTestName + "\t" + sTestCaseName + "\t" + String.valueOf(rowsToExecute.length));
|
||||
@@ -2144,9 +2085,7 @@ public class TestingList extends Panel {
|
||||
logger.log(Level.INFO, msg);
|
||||
System.out.println(msg);
|
||||
}
|
||||
//System.out.println("sTestID: " + sTestID);
|
||||
Object retargs = args2.put(sTestID, testArgs);
|
||||
//System.out.println("retargs: " + retargs);
|
||||
args2.put(sTestID, testArgs);
|
||||
hTests = args2;
|
||||
iRet = 0;
|
||||
} catch (Exception ex) {
|
||||
@@ -2188,7 +2127,7 @@ public class TestingList extends Panel {
|
||||
}
|
||||
//animate the custom panel (if present)
|
||||
animateCustomPanel(sDeviceName);
|
||||
//System.out.println("sParallelizeCommand: " +sParallelizeCommand);
|
||||
//System.out.println(sParallelizeCommand);
|
||||
//run test(s)
|
||||
Object ret = eval(sParallelizeCommand);
|
||||
//System.out.println(ret);
|
||||
@@ -2275,20 +2214,11 @@ public class TestingList extends Panel {
|
||||
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
|
||||
renderer.setToolTipText("Click for options");
|
||||
jTable1.getColumnModel().getColumn(COL.STARTSEQUENCE.ordinal()).setCellRenderer(renderer);
|
||||
jTable1.getColumnModel().getColumn(COL.STARTSEQUENCE.ordinal()).setPreferredWidth(130);
|
||||
jTable1.getColumnModel().getColumn(COL.STARTSEQUENCE.ordinal()).setMaxWidth(130);
|
||||
jTable1.getColumnModel().getColumn(COL.STARTSEQUENCE.ordinal()).setPreferredWidth(30);
|
||||
jTable1.getColumnModel().getColumn(COL.ICON.ordinal()).setMaxWidth(27);
|
||||
jTable1.getColumnModel().getColumn(COL.CHECK.ordinal()).setMaxWidth(27);
|
||||
jTable1.getColumnModel().getColumn(COL.DEVICENAME.ordinal()).setPreferredWidth(200);
|
||||
jTable1.getColumnModel().getColumn(COL.DEVICENAME.ordinal()).setMaxWidth(200);
|
||||
jTable1.getColumnModel().getColumn(COL.TESTNAME.ordinal()).setPreferredWidth(200);
|
||||
jTable1.getColumnModel().getColumn(COL.TESTNAME.ordinal()).setMaxWidth(200);
|
||||
jTable1.getColumnModel().getColumn(COL.TESTSUITE.ordinal()).setPreferredWidth(200);
|
||||
jTable1.getColumnModel().getColumn(COL.TESTSUITE.ordinal()).setMaxWidth(200);
|
||||
jTable1.getColumnModel().getColumn(COL.STATUS.ordinal()).setPreferredWidth(90);
|
||||
jTable1.getColumnModel().getColumn(COL.STATUS.ordinal()).setMaxWidth(90);
|
||||
jTable1.getColumnModel().getColumn(COL.TIME.ordinal()).setPreferredWidth(200);
|
||||
jTable1.getColumnModel().getColumn(COL.TIME.ordinal()).setMaxWidth(200);
|
||||
jTable1.getColumnModel().getColumn(COL.DEVICENAME.ordinal()).setPreferredWidth(30);
|
||||
jTable1.getColumnModel().getColumn(COL.STATUS.ordinal()).setPreferredWidth(20);
|
||||
hideColumn(COL.DEVICEDESCR);
|
||||
hideColumn(COL.DEVICEPATH);
|
||||
hideColumn(COL.TESTPATH);
|
||||
@@ -2323,12 +2253,10 @@ public class TestingList extends Panel {
|
||||
*/
|
||||
private void addToTable(String deviceName,
|
||||
String deviceDescription,
|
||||
String devicePath,
|
||||
String testSuite,
|
||||
String testName,
|
||||
String testParams,
|
||||
String testDescription,
|
||||
String testPath,
|
||||
String testHelp) {
|
||||
String sDate = "";
|
||||
if (testName.equals("") || deviceName.equals("")) {
|
||||
@@ -2338,14 +2266,9 @@ public class TestingList extends Panel {
|
||||
ImageIcon icon = null;// new ImageIcon(getClass().getResource("/icons/button_pause-16px.png"));
|
||||
DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
|
||||
//String testPath = FilenameUtils.separatorsToSystem(TESTS_TESTS_DEFAULT_DIR + testSuite + "/" + testName + "/" + testName + ".py");
|
||||
String otestPath = Paths.get(TESTS_TESTS_DEFAULT_DIR.toString(), testSuite, testName, testName + ".py").toString();
|
||||
String odevicePath = Paths.get(TESTS_DEVICES_DEFAULT_DIR.toString(), deviceName, deviceName + ".config").toString();
|
||||
|
||||
System.out.println("Old Test Path = " + otestPath);
|
||||
System.out.println("Old Dev Path = " + odevicePath);
|
||||
|
||||
System.out.println("Test Path = " + testPath);
|
||||
System.out.println("Dev Path = " + devicePath);
|
||||
String testPath = Paths.get(TESTS_TESTS_DEFAULT_DIR.toString(), testSuite, testName, testName + ".py").toString();
|
||||
String devicePath = Paths.get(TESTS_DEVICES_DEFAULT_DIR.toString(), deviceName, deviceName + ".config").toString();
|
||||
System.out.println("Path = " + testPath);
|
||||
Object rowData[] = new Object[]{false, "", sDate, deviceName, devicePath, deviceDescription, testSuite, testName, testPath, testParams, testDescription, testHelp, "", "Pending", icon};
|
||||
//vedify that this test is not already in the table
|
||||
int totalRows = model.getRowCount();
|
||||
@@ -2356,15 +2279,11 @@ public class TestingList extends Panel {
|
||||
&& model.getValueAt(row, COL.TESTNAME.ordinal()).toString().equals(testName)
|
||||
&& model.getValueAt(row, COL.TESTPATH.ordinal()).toString().replace("\\", File.separator).equals(testPath));
|
||||
if (bTestAlreadyInTable) {
|
||||
System.out.println(" test already in table");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!bTestAlreadyInTable) {
|
||||
System.out.println(" test not in table: adding it...");
|
||||
System.out.println(" rowData: " + rowData);
|
||||
model.addRow(rowData);
|
||||
jTable1.updateUI();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@@ -2412,45 +2331,34 @@ public class TestingList extends Panel {
|
||||
int iCounter = 0;
|
||||
//search devices and their tests
|
||||
//Scan the list of devices
|
||||
//File[] listOfDevices = TESTS_DEVICES_DEFAULT_DIR.toFile().listFiles();
|
||||
List<File> listOfDevices = new ArrayList<File>();
|
||||
Collections.addAll(listOfDevices, listFilesAsArray(TESTS_DEVICES_DEFAULT_DIR.toFile(), true));
|
||||
|
||||
File[] listOfDevices = TESTS_DEVICES_DEFAULT_DIR.toFile().listFiles();
|
||||
for (File deviceInList : listOfDevices) {
|
||||
propDevice.clear();
|
||||
if (deviceInList.isFile()) {
|
||||
} else if (deviceInList.isDirectory()) {
|
||||
System.out.println("deviceInList:" + deviceInList.getPath()+ FilenameUtils.separatorsToSystem("/" + TESTS_CONFIG_FILENAME));
|
||||
File configFile = new File(deviceInList.getPath() + FilenameUtils.separatorsToSystem("/" + TESTS_CONFIG_FILENAME));
|
||||
if (configFile.exists() && !configFile.isDirectory()) {
|
||||
System.out.println("deviceInList found");
|
||||
InputStream is = new FileInputStream(configFile);
|
||||
propDevice.load(is);
|
||||
is.close();
|
||||
//config of device was loaded. now load the config of each test belonging to the device
|
||||
testsFolder = Paths.get(TESTS_TESTS_DEFAULT_DIR.toString(), propDevice.getProperty("tests")).toFile();
|
||||
System.out.println(" testsFolder:" + testsFolder);
|
||||
if (testsFolder.exists() && testsFolder.isDirectory()) {
|
||||
System.out.println(" testsFolder found");
|
||||
File[] listOfTests = testsFolder.listFiles();
|
||||
for (File testinList : listOfTests) {
|
||||
propTest.clear();
|
||||
if (testinList.isDirectory()) {
|
||||
configFile = new File(testinList.getPath() + FilenameUtils.separatorsToSystem("/" + TESTS_CONFIG_FILENAME));
|
||||
System.out.println(" configFile:" + testinList.getPath() + FilenameUtils.separatorsToSystem("/" + TESTS_CONFIG_FILENAME));
|
||||
if (configFile.exists() && !configFile.isDirectory()) {
|
||||
System.out.println(" configFile exists");
|
||||
InputStream ist = new FileInputStream(configFile);
|
||||
propTest.load(ist);
|
||||
ist.close();
|
||||
addToTable(propDevice.getProperty("name"),
|
||||
propDevice.getProperty("description"),
|
||||
deviceInList.getPath(),
|
||||
propDevice.getProperty("tests"),
|
||||
propTest.getProperty("name"),
|
||||
"", //test parameters
|
||||
"", //test description
|
||||
testinList.getPath(),
|
||||
propTest.getProperty("help"));
|
||||
iCounter++;
|
||||
}
|
||||
@@ -2463,33 +2371,6 @@ public class TestingList extends Panel {
|
||||
//showEnabledTestsOnly(jCheckBoxMenuShowSelectedTests1.getState());
|
||||
logger.log(Level.INFO, iCounter + " tests loaded.");
|
||||
}
|
||||
|
||||
|
||||
public static File[] listFilesAsArray(File directory, boolean recurse)
|
||||
{
|
||||
Collection files = listFiles(directory, recurse);
|
||||
File[] arr = new File[files.size()];
|
||||
return (File[]) files.toArray(arr);
|
||||
}
|
||||
|
||||
public static Collection listFiles(File directory, boolean recurse){
|
||||
// List of files / directories
|
||||
Vector files = new Vector ();
|
||||
// Get files / directories in the directory
|
||||
File[] entries = directory.listFiles();
|
||||
// Go over entries
|
||||
for (File entry : entries){
|
||||
|
||||
files.add(entry);
|
||||
// If the file is a directory and the recurse flag
|
||||
// is set, recurse into the directory
|
||||
if (recurse && entry.isDirectory()){
|
||||
files.addAll(listFiles(entry, recurse));
|
||||
}
|
||||
}
|
||||
// Return collection of files
|
||||
return files;
|
||||
}
|
||||
|
||||
/**
|
||||
* scan tests table and see if tests/devices in the table still exist in directory.
|
||||
@@ -2596,16 +2477,15 @@ public static Collection listFiles(File directory, boolean recurse){
|
||||
HashMap mParameters = new HashMap(); // contains name and attributes
|
||||
HashMap mParameterAttributes = new HashMap(); //contians value and description
|
||||
String[] dsParameterAttributes = null;
|
||||
String[] dsParameters = parametersString.split(PARAM_SEPARATOR);
|
||||
String[] dsParameters = parametersString.split(";");
|
||||
for (String sParameter : dsParameters) {
|
||||
dsParameterAttributes = sParameter.split(VALUE_SEPARATOR);
|
||||
dsParameterAttributes = sParameter.split(":");
|
||||
if (dsParameterAttributes.length > 2) {
|
||||
mParameterAttributes = new HashMap();
|
||||
mParameterAttributes.put("value", (Object) dsParameterAttributes[1]);
|
||||
mParameterAttributes.put("description", dsParameterAttributes[2]);
|
||||
//add parameter name and attributes (value + description)
|
||||
mParameters.put(dsParameterAttributes[0], mParameterAttributes);
|
||||
System.out.println(dsParameterAttributes[0] + dsParameterAttributes[1] + dsParameterAttributes[2]);
|
||||
}
|
||||
}
|
||||
return mParameters;
|
||||
@@ -2794,51 +2674,4 @@ public static Collection listFiles(File directory, boolean recurse){
|
||||
SwingUtils.showMessage(this, "loadListFilter()", ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* for putting an icon and text to a table header
|
||||
*/
|
||||
public class iconRenderer extends DefaultTableCellRenderer{
|
||||
public Component getTableCellRendererComponent(javax.swing.JTable table,
|
||||
Object obj,boolean isSelected, boolean hasFocus, int row,
|
||||
int column) {
|
||||
txtIcon i = (txtIcon)obj;
|
||||
if (obj == i) {
|
||||
setIcon(i.imageIcon);
|
||||
setText(i.txt);
|
||||
}
|
||||
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
|
||||
setHorizontalAlignment(javax.swing.JLabel.CENTER);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* for putting an icon and text to a table header
|
||||
*/
|
||||
public class txtIcon {
|
||||
String txt;
|
||||
ImageIcon imageIcon;
|
||||
txtIcon(String text, ImageIcon icon) {
|
||||
txt = text;
|
||||
imageIcon = icon;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* put an icon and text to a table header
|
||||
*
|
||||
* @param table the table where the header is
|
||||
* @param col_index column index of the table header where to put the icon
|
||||
* @param icon the icon to put to the header
|
||||
* @param name the text to put to the header
|
||||
*/
|
||||
public void setIcon(javax.swing.JTable table, int col_index, ImageIcon icon,String name){
|
||||
table.getTableHeader().getColumnModel().getColumn(col_index).setHeaderRenderer(new iconRenderer());
|
||||
table.getColumnModel().getColumn(col_index).setHeaderValue(new txtIcon(name, icon));
|
||||
table.updateUI();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user