Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMariot Chauvin2010-08-31 14:35:46 +0000
committerMariot Chauvin2010-08-31 14:35:46 +0000
commit838beb19666abc9b08e771295578c070ee411c63 (patch)
tree9a875685fcd11d9ccc7aea7b9efc181895a3fe94
parent11a70c9f8de6d9aec47283cc850b95451d7ffab2 (diff)
downloadorg.eclipse.swtbot-838beb19666abc9b08e771295578c070ee411c63.tar.gz
org.eclipse.swtbot-838beb19666abc9b08e771295578c070ee411c63.tar.xz
org.eclipse.swtbot-838beb19666abc9b08e771295578c070ee411c63.zip
Externalize in a class the SWT 3.5 dependency
-rw-r--r--org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/BrowserAuthenticationListener.java56
-rw-r--r--org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotBrowser.java31
2 files changed, 57 insertions, 30 deletions
diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/BrowserAuthenticationListener.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/BrowserAuthenticationListener.java
new file mode 100644
index 00000000..ece1db63
--- /dev/null
+++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/BrowserAuthenticationListener.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Obeo and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mariot Chauvin, Obeo - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.swtbot.swt.finder.widgets;
+
+import org.eclipse.swt.browser.AuthenticationEvent;
+import org.eclipse.swt.browser.AuthenticationListener;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.eclipse.swtbot.swt.finder.utils.Credentials;
+
+/**
+ * A browser authentication listener.
+ * This implementation requires SWT 3.5 or later version.
+ * @author mchauvin
+ */
+final class BrowserAuthenticationListener implements AuthenticationListener {
+
+ private Credentials credentials;
+
+ public void init(final Browser widget) {
+ UIThreadRunnable.syncExec(new VoidResult() {
+ public void run() {
+ widget.addAuthenticationListener(this);
+ }
+ });
+ }
+
+ public void setCredentials(Credentials credentials) {
+ this.credentials = credentials;
+ }
+
+ public Credentials getCredentials() {
+ return this.credentials;
+ }
+
+ public void authenticate(AuthenticationEvent event) {
+ if (credentials == null) {
+ event.doit = false;
+ return;
+ }
+ event.doit = true;
+ event.user = credentials.username();
+ event.password = credentials.password();
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotBrowser.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotBrowser.java
index 1633ead2..18308eab 100644
--- a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotBrowser.java
+++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotBrowser.java
@@ -11,8 +11,6 @@
*******************************************************************************/
package org.eclipse.swtbot.swt.finder.widgets;
-import org.eclipse.swt.browser.AuthenticationEvent;
-import org.eclipse.swt.browser.AuthenticationListener;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.ProgressEvent;
import org.eclipse.swt.browser.ProgressListener;
@@ -61,11 +59,7 @@ public class SWTBotBrowser extends AbstractSWTBotControl<Browser> {
public SWTBotBrowser(Browser browser, SelfDescribing description) {
super(browser, description);
progressListener = new InternalProgressListener(this);
- UIThreadRunnable.syncExec(new VoidResult() {
- public void run() {
- widget.addAuthenticationListener(authListener);
- }
- });
+ authListener.init(widget);
}
/**
@@ -274,29 +268,6 @@ public class SWTBotBrowser extends AbstractSWTBotControl<Browser> {
}
- private static final class BrowserAuthenticationListener implements AuthenticationListener {
- private Credentials credentials;
-
- public void setCredentials(Credentials credentials) {
- this.credentials = credentials;
- }
-
- public Credentials getCredentials() {
- return this.credentials;
- }
-
- public void authenticate(AuthenticationEvent event) {
- if (credentials == null) {
- event.doit = false;
- return;
- }
- event.doit = true;
- event.user = credentials.username();
- event.password = credentials.password();
- }
-
- }
-
private static final class WaitForBrowserLoadsPage extends DefaultCondition {
private final SWTBotBrowser browser;

Back to the top