Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/interfaces/AbstractConnectedService.java Mon Apr 06 09:13:52 2009 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/interfaces/AbstractConnectedService.java Mon Apr 06 09:17:53 2009 -0500
@@ -32,7 +32,7 @@
public abstract class AbstractConnectedService implements IConnectedService {
- protected final static int TIMEOUT = 2000;
+ public final static int TIMEOUT = 2000;
public static class ConnectionFailException extends Exception {
public ConnectionFailException(String string) {
@@ -122,6 +122,7 @@
protected IRunnableContext runnableContext;
protected Status currentStatus;
protected Tester tester;
+ protected boolean manualTesting;
public AbstractConnectedService(IService service, AbstractSynchronizedConnection connection) {
this.service = service;
@@ -173,7 +174,7 @@
}
public void testStatus() {
- if (!isEnabled())
+ if (!(isEnabled() || manualTesting))
return;
final TestResult result[] = { null };
@@ -196,12 +197,16 @@
result[0] = runTestStatus(new NullProgressMonitor());
}
- if (!isEnabled()) // could be waiting for response past when service testing was disabled
+ if (!(isEnabled() || manualTesting)) // could be waiting for response past when service testing was disabled
return;
if (result[0].shortDescription != null && result[0].longDescription != null) {
currentStatus.setEStatus(result[0].estatus, result[0].shortDescription, result[0].longDescription);
}
}
+
+ public void setManualTesting() {
+ manualTesting = true;
+ }
public boolean isEnabled() {
return tester != null;
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionSettingsPage.java Mon Apr 06 09:13:52 2009 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionSettingsPage.java Mon Apr 06 09:17:53 2009 -0500
@@ -23,6 +23,7 @@
import com.nokia.carbide.remoteconnections.interfaces.*;
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus;
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatusChangedListener;
+import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus.EStatus;
import com.nokia.carbide.remoteconnections.interfaces.IConnectionFactory.IValidationErrorReporter;
import com.nokia.carbide.remoteconnections.interfaces.IRemoteAgentInstallerProvider.IRemoteAgentInstaller;
import com.nokia.carbide.remoteconnections.interfaces.IRemoteAgentInstallerProvider.IRemoteAgentInstaller.IPackageContents;
@@ -55,6 +56,23 @@
import java.util.List;
public class ConnectionSettingsPage extends WizardPage {
+
+ public final class Tester extends Thread {
+ @Override
+ public void run() {
+ ((AbstractConnectedService) connectedService).setManualTesting();
+ for (int i = 0; i < 3 && connectedService != null; i++) {
+ connectedService.testStatus();
+ try {
+ if (i < 2)
+ sleep(AbstractConnectedService.TIMEOUT);
+ } catch (InterruptedException e) {
+ break;
+ }
+ }
+ resetServiceTesting(false);
+ }
+ }
private final static TreeNode LOADING_CONTENT_TREENODE =
new TreeNode(Messages.getString("ConnectionSettingsPage.GettingDataMessage")); //$NON-NLS-1$
@@ -78,8 +96,9 @@
private IConnectionFactory connectionFactory;
private IConnection connection;
private IService service;
- private IConnectedService connectedService;
+ private volatile IConnectedService connectedService;
private IStatusChangedListener statusListener;
+ private Tester tester;
private SashForm installerSashForm;
private TreeViewer installerTreeViewer;
private Text installerInfoText;
@@ -201,7 +220,7 @@
IService curService = (IService) selection.getFirstElement();
if (!curService.equals(service)) {
service = curService;
- resetServiceTesting();
+ resetServiceTesting(true);
}
}
});
@@ -230,7 +249,7 @@
public void widgetSelected(SelectionEvent e) {
if (isTesting) {
serviceTestButton.setText(Messages.getString("ConnectionSettingsPage.StartServiceTestButtonLabel")); //$NON-NLS-1$
- resetServiceTesting();
+ resetServiceTesting(true);
}
else {
serviceTestButton.setText(Messages.getString("ConnectionSettingsPage.StopServiceTestButtonLabel")); //$NON-NLS-1$
@@ -443,7 +462,7 @@
}
servicesListViewer.getList().addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent e) {
- resetServiceTesting();
+ resetServiceTesting(true);
}
});
@@ -505,7 +524,7 @@
}
deviceOSComboViewer.getCombo().addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent e) {
- resetServiceTesting();
+ resetServiceTesting(true);
}
});
}
@@ -568,13 +587,16 @@
public void run() {
if (!statusText.isDisposed())
statusText.setText(status.getLongDescription());
+ if (status.getEStatus().equals(EStatus.UP))
+ resetServiceTesting(false);
}
});
}
});
if (connectedService instanceof AbstractConnectedService)
((AbstractConnectedService) connectedService).setRunnableContext(getContainer());
- connectedService.setEnabled(true);
+ tester = new Tester();
+ tester.start();
isTesting = true;
}
}
@@ -764,16 +786,23 @@
}
}
- private void resetServiceTesting() {
+ private void resetServiceTesting(final boolean resetAll) {
isTesting = false;
if (service == null)
return;
- serviceTestInfo.setText(service.getAdditionalServiceInfo());
- agentTestTabComposite.layout(true, true);
- statusText.setText(STATUS_NOT_TESTED);
- disposeConnectedService();
- String buttonLabel = Messages.getString("ConnectionSettingsPage.StartServiceTestButtonLabel"); //$NON-NLS-1$
- serviceTestButton.setText(buttonLabel);
+ // may be called from a test thread
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ if (resetAll) {
+ statusText.setText(STATUS_NOT_TESTED);
+ serviceTestInfo.setText(service.getAdditionalServiceInfo());
+ agentTestTabComposite.layout(true, true);
+ }
+ disposeConnectedService();
+ String buttonLabel = Messages.getString("ConnectionSettingsPage.StartServiceTestButtonLabel"); //$NON-NLS-1$
+ serviceTestButton.setText(buttonLabel);
+ }
+ });
}
}