diff options
author | Jiri Vanek <[email protected]> | 2012-06-19 14:36:25 +0200 |
---|---|---|
committer | Jiri Vanek <[email protected]> | 2012-06-19 14:36:25 +0200 |
commit | 7b0adacff066b704b05d2d9de27b1bd2e10c568d (patch) | |
tree | 9f6ac563a2db429563ebf7a383b13ae675c0a6fa /tests/netx | |
parent | 7a1099690059f820a37419c1c6e7308689655f35 (diff) |
testInBrowser annotation
Diffstat (limited to 'tests/netx')
15 files changed, 736 insertions, 15 deletions
diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java index db95a0a..e5490fd 100644 --- a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java +++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/ServerAccess.java @@ -44,7 +44,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; -import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -54,6 +53,7 @@ import java.io.PrintWriter; import java.io.Reader; import java.io.StringWriter; import java.io.Writer; +import java.lang.reflect.Method; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.ServerSocket; @@ -71,6 +71,11 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.StringTokenizer; +import net.sourceforge.jnlp.annotations.TestInBrowsers; +import net.sourceforge.jnlp.browsertesting.Browser; +import net.sourceforge.jnlp.browsertesting.BrowserFactory; +import net.sourceforge.jnlp.browsertesting.BrowserTest; +import net.sourceforge.jnlp.browsertesting.Browsers; import org.junit.Assert; import org.junit.Test; @@ -102,7 +107,7 @@ public class ServerAccess { public static final String JAVAWS_BUILD_BIN = "javaws.build.bin"; /** property to set the different then default browser */ - public static final String USED_BROWSER_COMMAND = "used.browser.command"; + public static final String USED_BROWSERS = "used.browsers"; public static final String DEFAULT_LOCALHOST_NAME = "localhost"; /** * server instance singleton @@ -132,6 +137,13 @@ public class ServerAccess { public static boolean PROCESS_LOG = true; public static boolean LOGS_REPRINT = false; + private Browser currentBrowser; + /** + * This is static copy of name of id of currentBrowser for logging purposes + */ + private static String loggedBrowser=Browsers.none.toString(); + public static final String UNSET_BROWSER="unset_browser"; + /** * map of classes, each have map of methods, each have errorlist, outLIst, and allList (allist contains also not std or err messages) * class.testMethod.logs @@ -200,14 +212,39 @@ public class ServerAccess { classLog = new HashMap<String, TestsLogs>(50); processLogs.put(ste.getClassName(), classLog); } - TestsLogs methodLog = classLog.get(ste.getMethodName()); + String methodBrowseredName = ste.getMethodName(); + methodBrowseredName = modifyMethodWithForBrowser(methodBrowseredName,ste.getClassName()); + TestsLogs methodLog = classLog.get(methodBrowseredName); if (methodLog == null) { methodLog = new TestsLogs(); - classLog.put(ste.getMethodName(), methodLog); + classLog.put(methodBrowseredName, methodLog); } methodLog.add(printToErr, printToOut, message); } + private static String modifyMethodWithForBrowser(String methodBrowseredName, String className) { + try { + Class clazz = Class.forName(className); + /* + * By using this isAssignable to ensure corect class before invocation, + * then we lost possibility to track manualy set browsers, but it is correct, + * as method description is set only when annotation is used + */ + if (clazz != null && BrowserTest.class.isAssignableFrom(clazz)){ + Method testMethod = clazz.getMethod(methodBrowseredName); + if (testMethod != null) { + TestInBrowsers tib = testMethod.getAnnotation(TestInBrowsers.class); + if (tib != null) { + methodBrowseredName = methodBrowseredName + " - " + loggedBrowser; + } + } + } + } catch (Throwable ex) { + ex.printStackTrace(); + } + return methodBrowseredName; + } + private static class TestsLogs { public final List<LogItem> outs = new LinkedList<LogItem>(); @@ -419,14 +456,52 @@ public class ServerAccess { /** * - * @return - value passed inside as javaws binary location. See JAVAWS_BUILD_BIN + * @return - bianry from where to lunch current browser */ public String getBrowserLocation() { - String s=System.getProperty(USED_BROWSER_COMMAND); - if (s==null) s="firefox"; - return s; + if (this.currentBrowser==null) return UNSET_BROWSER; + return this.currentBrowser.getBin(); + } + + public List<String> getBrowserParams() { + if (this.currentBrowser==null) return null; + List<String> l1=this.currentBrowser.getComaptibilitySwitches(); + List<String> l2=this.currentBrowser.getDefaultSwitches(); + List<String> l= new ArrayList(); + if (l1!=null)l.addAll(l1); + if (l2!=null)l.addAll(l2); + return l; + + } + + public Browsers getCurrentBrowsers() { + if (currentBrowser==null) return null; + return currentBrowser.getID(); + } + public Browser getCurrentBrowser() { + return currentBrowser; + } + + public void setCurrentBrowser(Browsers currentBrowser) { + this.currentBrowser = BrowserFactory.getFactory().getBrowser(currentBrowser); + if (this.currentBrowser == null) { + loggedBrowser = UNSET_BROWSER; + } else { + loggedBrowser = this.currentBrowser.getID().toString(); + } } + public void setCurrentBrowser(Browser currentBrowser) { + this.currentBrowser = currentBrowser; + if (this.currentBrowser == null) { + loggedBrowser = UNSET_BROWSER; + } else { + loggedBrowser = this.currentBrowser.getID().toString(); + } + } + + + /** * * @return - value passed inside as javaws binary location as file. See JAVAWS_BUILD_BIN @@ -790,10 +865,10 @@ public class ServerAccess { return executeJavaws(null, resource,stdoutl,stderrl); } public ProcessResult executeBrowser(String resource) throws Exception { - return executeBrowser(null, resource); + return executeBrowser(getBrowserParams(), resource); } public ProcessResult executeBrowser(String resource,ContentReaderListener stdoutl,ContentReaderListener stderrl) throws Exception { - return executeBrowser(null, resource,stderrl,stdoutl); + return executeBrowser(getBrowserParams(), resource,stderrl,stdoutl); } /** @@ -818,6 +893,13 @@ public class ServerAccess { return executeProcessUponURL(getBrowserLocation(), otherargs, getUrlUponThisInstance(resource),stdoutl,stderrl); } + public ProcessResult executeBrowser(Browser b,List<String> otherargs, String resource) throws Exception { + return executeProcessUponURL(b.getBin(), otherargs, getUrlUponThisInstance(resource)); + } + public ProcessResult executeBrowser(Browser b,List<String> otherargs, String resource,ContentReaderListener stdoutl,ContentReaderListener stderrl) throws Exception { + return executeProcessUponURL(b.getBin(), otherargs, getUrlUponThisInstance(resource),stdoutl,stderrl); + } + /** * Ctreate resource on http, on 'localhost' on port on which this instance is running * @param resource @@ -927,6 +1009,7 @@ public class ServerAccess { String idded; StackTraceElement ste = getTestMethod(); String fullId = ste.getClassName() + "." + ste.getMethodName(); + fullId = modifyMethodWithForBrowser(ste.getMethodName(), ste.getClassName()); if (message.contains("\n")) { idded = fullId + ": \n" + message + "\n" + fullId + " ---"; } else { @@ -1050,7 +1133,7 @@ public class ServerAccess { Thread.sleep(100); } pa.setCanRun(false); - // System.out.println(t.getP().exitValue()); when process is killed, this throws exception + // ServerAccess.logOutputReprint(t.getP().exitValue()); when process is killed, this throws exception ProcessResult pr=new ProcessResult(crs.getContent(), cre.getContent(), t.getP(), pa.wasTerminated(), t.getExitCode(), null); if (PROCESS_LOG) { @@ -1144,11 +1227,13 @@ public class ServerAccess { if (ex instanceof InterruptedException) { //add to the set of terminated threaded processes deadlyException = ex; + logException(deadlyException, false); terminated.add(this); } else { //happens when non-existing process is launched, is causing p null! terminated.add(this); deadlyException = ex; + logException(deadlyException, false); throw new RuntimeException(ex); } } finally { @@ -1492,8 +1577,8 @@ public class ServerAccess { try { long time = System.nanoTime() / NANO_TIME_DELIMITER; - //System.out.println(time - startTime); - //System.out.println((time - startTime) > timeout); + //ServerAccess.logOutputReprint(time - startTime); + //ServerAccess.logOutputReprint((time - startTime) > timeout); if ((time - startTime) > timeout) { try { if (p != null) { @@ -1660,8 +1745,7 @@ public class ServerAccess { //do not want to bother output with terminations //mostly compaling when assassin kill the process about StreamClosed } catch (Exception ex) { - // ex.printStackTrace(); - // System.err.flush(); + // logException(ex); } finally { try { is.close(); diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/annotations/TestInBrowsers.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/annotations/TestInBrowsers.java new file mode 100644 index 0000000..b4ea2a3 --- /dev/null +++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/annotations/TestInBrowsers.java @@ -0,0 +1,18 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package net.sourceforge.jnlp.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import net.sourceforge.jnlp.browsertesting.Browsers; + +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface TestInBrowsers { + public Browsers[] testIn(); +} diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/Browser.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/Browser.java new file mode 100644 index 0000000..81db960 --- /dev/null +++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/Browser.java @@ -0,0 +1,19 @@ +package net.sourceforge.jnlp.browsertesting; + +import java.util.List; + +/** + * interface which represents individual browsers + */ +public interface Browser { + public String getDefaultBin(); + public String getDefaultPluginExpectedLocation(); + public String getBin(); + //public void setBin(String bin); + public String getUserDefaultPluginExpectedLocation(); + public Browsers getID(); + public List<String> getComaptibilitySwitches(); + public List<String> getDefaultSwitches(); + + +} diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/BrowserFactory.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/BrowserFactory.java new file mode 100644 index 0000000..c0fa1d1 --- /dev/null +++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/BrowserFactory.java @@ -0,0 +1,184 @@ +package net.sourceforge.jnlp.browsertesting; + +import net.sourceforge.jnlp.annotations.TestInBrowsers; +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Random; +import net.sourceforge.jnlp.ServerAccess; +import net.sourceforge.jnlp.browsertesting.browsers.Chrome; +import net.sourceforge.jnlp.browsertesting.browsers.Chromium; +import net.sourceforge.jnlp.browsertesting.browsers.Firefox; +import net.sourceforge.jnlp.browsertesting.browsers.Opera; + +public class BrowserFactory { + + private static final BrowserFactory factory = new BrowserFactory(System.getProperty(ServerAccess.USED_BROWSERS)); + private List<Browser> configuredBrowsers; + Random oneGenerator = new Random(); + + public static BrowserFactory getFactory() { + return factory; + } + + /** + * This is public just for testing purposes! + */ + public BrowserFactory(String browsers) { + if (browsers == null) { + configuredBrowsers = new ArrayList<Browser>(0); + } else { + String[] s = browsers.split(File.pathSeparator); + configuredBrowsers = new ArrayList<Browser>(s.length); + for (int i = 0; i < s.length; i++) { + String string = s[i]; + String[] p = string.split("/"); + if (p.length > 1) { + string = p[p.length - 1]; + } + if (string.equals(Browsers.chromiumBrowser.toString())) { + configuredBrowsers.add(new Chromium(s[i])); + } + if (string.equals(Browsers.googleChrome.toString())) { + configuredBrowsers.add(new Chrome(s[i])); + } + if (string.equals(Browsers.opera.toString())) { + configuredBrowsers.add(new Opera(s[i])); + } + if (string.equals(Browsers.firefox.toString())) { + configuredBrowsers.add(new Firefox(s[i])); + } + + + + } + } + + } + + public Browser getBrowser(Browsers id) { + for (int i = 0; i < configuredBrowsers.size(); i++) { + Browser browser = configuredBrowsers.get(i); + if (browser.getID() == id) { + return browser; + } + + } + return null; + + } + + public Browser getFirst() { + for (int i = 0; i < configuredBrowsers.size(); i++) { + Browser browser = configuredBrowsers.get(i); + return browser; + + } + return null; + + } + + public Browser getRandom() { + if (configuredBrowsers.isEmpty()){ + return null; + } + return configuredBrowsers.get(oneGenerator.nextInt(configuredBrowsers.size())); + } + + public List<Browser> getAllBrowsers() { + return Collections.unmodifiableList(configuredBrowsers); + } + + public List<Browsers> getBrowsers(TestInBrowsers tib) { + return getBrowsers(tib.testIn()); + } + public List<Browsers> getBrowsers(Browsers[] testIn) { + List<Browser> q = translateAnnotationSilently(testIn); + if (q==null || q.isEmpty()){ + List<Browsers> qq = new ArrayList<Browsers>(0); + qq.add(Browsers.none); + return qq; + } + List<Browsers> qq = new ArrayList<Browsers>(q.size()); + for (Browser browser : q) { + qq.add(browser.getID()); + } + return qq; + + } + /** + * + * @param testIn Bbrowsers which should be transformed to list of Browser + * @return all matching browser, if browser do not exists, this is ignored and run is silently continued + */ + public List<Browser> translateAnnotationSilently(Browsers[] testIn) { + if (testIn==null) { + return null; + } + List<Browser> r = new ArrayList<Browser>(configuredBrowsers.size()); + for (Browsers b : testIn) { + if (b == Browsers.all) { + if (getAllBrowsers().isEmpty()) { + ServerAccess.logErrorReprint("You try to add all browsers, but there is none"); + } else { + r.addAll(getAllBrowsers()); + } + } else if (b == Browsers.one) { + Browser bb = getRandom(); + if (bb == null) { + ServerAccess.logErrorReprint("You try to add random browser, but there is none"); + } else { + r.add(bb); + } + } else { + Browser bb = getBrowser(b); + if (bb == null) { + ServerAccess.logErrorReprint("You try to add " + b.toString() + " browser, but it do not exists"); + } else { + r.add(bb); + } + + } + } + + return r; + + } + + /** + * + * @param tib + * @return all matching browser, if browser do not exists, exception is thrown + */ + public List<Browser> translateAnnotationLaudly(TestInBrowsers tib) { + return translateAnnotationLaudly(tib.testIn()); + } + public List<Browser> translateAnnotationLaudly(Browsers[] testIn) { + List<Browser> r = new ArrayList<Browser>(configuredBrowsers.size()); + for (Browsers b :testIn) { + if (b == Browsers.all) { + if (getAllBrowsers().isEmpty()) { + throw new IllegalStateException("You try to add all browsers, but there is none"); + } + r.addAll(getAllBrowsers()); + } else if (b == Browsers.one) { + Browser bb = getRandom(); + if (bb == null) { + throw new IllegalStateException("You try to add random browser, but there is none"); + } + r.add(bb); + } else { + Browser bb = getBrowser(b); + if (bb == null) { + throw new IllegalStateException("You try to add " + b.toString() + " browser, but it do not exists"); + } + r.add(bb); + + } + } + + return r; + + } +} diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/BrowserTest.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/BrowserTest.java new file mode 100644 index 0000000..232b63a --- /dev/null +++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/BrowserTest.java @@ -0,0 +1,23 @@ +package net.sourceforge.jnlp.browsertesting; + +import net.sourceforge.jnlp.ServerAccess; +import org.junit.runner.RunWith; + + +@RunWith(value = BrowserTestRunner.class) +public abstract class BrowserTest { + + public static Browsers browser=null; + public static final ServerAccess server = new ServerAccess(); + + public static void setBrowser(Browsers b) { + browser = b; + server.setCurrentBrowser(browser); + } + + public static Browsers getBrowser() { + return browser; + } + + +} diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/BrowserTestRunner.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/BrowserTestRunner.java new file mode 100644 index 0000000..ae2934f --- /dev/null +++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/BrowserTestRunner.java @@ -0,0 +1,137 @@ +package net.sourceforge.jnlp.browsertesting; + +import java.lang.annotation.Annotation; +import java.lang.reflect.InvocationTargetException; +import net.sourceforge.jnlp.annotations.TestInBrowsers; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.List; +import java.util.Random; +import net.sourceforge.jnlp.ServerAccess; +import org.junit.Ignore; +import org.junit.internal.AssumptionViolatedException; +import org.junit.internal.runners.model.EachTestNotifier; +import org.junit.runner.Description; +import org.junit.runner.notification.RunNotifier; +import org.junit.runners.BlockJUnit4ClassRunner; +import org.junit.runners.model.FrameworkMethod; +import org.junit.runners.model.InitializationError; +import org.junit.runners.model.Statement; + +public class BrowserTestRunner extends BlockJUnit4ClassRunner { + + public BrowserTestRunner(java.lang.Class<?> testClass) throws InitializationError { + super(testClass); + } + + @Override + protected void runChild(FrameworkMethod method, RunNotifier notifier) { + Method mm = method.getMethod(); + TestInBrowsers tib = mm.getAnnotation(TestInBrowsers.class); + injectBrowserCatched(method, Browsers.none); + boolean browserIgnoration = false; + if (tib != null) { + try { + List<Browsers> testableBrowsers = BrowserFactory.getFactory().getBrowsers(tib); + String mbr = System.getProperty("modified.browsers.run"); + if (mbr != null) { + if (mbr.equalsIgnoreCase("all")) { + testableBrowsers = BrowserFactory.getFactory().getBrowsers(new Browsers[]{Browsers.all}); + } else if (mbr.equalsIgnoreCase("one")) { + //this complication here is for case like + // namely enumerated concrete browsers, so we want to pick up + // random one from those already enumerated + testableBrowsers = Arrays.asList(new Browsers[]{testableBrowsers.get(new Random().nextInt(testableBrowsers.size()))}); + } else if (mbr.equalsIgnoreCase("ignore")) { + testableBrowsers = BrowserFactory.getFactory().getBrowsers(new Browsers[]{Browsers.none}); + browserIgnoration = true; + } else { + ServerAccess.logErrorReprint("unrecognized value of modified.browsers.run - " + mbr); + } + } + for (Browsers browser : testableBrowsers) { + try { + injcetBrowser(method, browser); + runChildX(method, notifier, browser, browserIgnoration); + } catch (Exception ex) { + //throw new RuntimeException("unabled to inject browser", ex); + ServerAccess.logException(ex, true); + } + } + } finally { + injectBrowserCatched(method, Browsers.none); + } + } else { + runChildX(method, notifier, null, false); + } + } + + private void injectBrowserCatched(FrameworkMethod method, Browsers browser) { + try { + injcetBrowser(method, browser); + } catch (Exception ex) { + //throw new RuntimeException("unabled to inject browser", ex); + ServerAccess.logException(ex, true); + } + } + + private void injcetBrowser(FrameworkMethod method, Browsers browser) throws IllegalAccessException, SecurityException, NoSuchMethodException, IllegalArgumentException, InvocationTargetException { + Method ff = method.getMethod().getDeclaringClass().getMethod("setBrowser", Browsers.class); + ff.invoke(null, browser); + } + + protected void runChildX(final FrameworkMethod method, RunNotifier notifier, Browsers browser, boolean browserIgnoration) { + Description description = describeChild(method, browser); + if (method.getAnnotation(Ignore.class) != null) { + notifier.fireTestIgnored(description); + } else { + try { + runLeaf(methodBlock(method), description, notifier, browserIgnoration); +// ServerAccess.logOutputReprint("trying leaf"); +// Method m = this.getClass().getMethod("runLeaf", Statement.class, Description.class, RunNotifier.class); +// m.setAccessible(true); +// m.invoke(this, methodBlock(method), description, notifier); +// ServerAccess.logOutputReprint("leaf invoked"); + } catch (Exception ex) { + //throw new RuntimeException("unabled to lunch test on leaf", ex); + ServerAccess.logException(ex, true); + } + } + } + + /** + * Runs a {@link Statement} that represents a leaf (aka atomic) test. + */ + protected final void runLeaf(Statement statement, Description description, + RunNotifier notifier, boolean ignore) { + EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description); + eachNotifier.fireTestStarted(); + if (ignore) { + eachNotifier.fireTestIgnored(); + return; + } + try { + statement.evaluate(); + } catch (AssumptionViolatedException e) { + eachNotifier.addFailedAssumption(e); + } catch (Throwable e) { + eachNotifier.addFailure(e); + } finally { + eachNotifier.fireTestFinished(); + } + } + + protected Description describeChild(FrameworkMethod method, Browsers browser) { + if (browser == null) { + return super.describeChild(method); + } else { + try { + return Description.createTestDescription(getTestClass().getJavaClass(), + testName(method) + " - " + browser.toString(), method.getAnnotations()); + } catch (Exception ex) { + ServerAccess.logException(ex, true); + return super.describeChild(method); + } + } + } +} diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/Browsers.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/Browsers.java new file mode 100644 index 0000000..8d85241 --- /dev/null +++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/Browsers.java @@ -0,0 +1,46 @@ +package net.sourceforge.jnlp.browsertesting; + +/** + * When all represent all configured browser, one represens one random + * (the first found) configured browser. Each other represents inidivdual browsers + * + */ +public enum Browsers { + + none, all, one, opera, googleChrome, chromiumBrowser, firefox, midori,epiphany; + + public String toExec() { + switch (this) { + case opera: + return "opera"; + case googleChrome: + return "google-chrome"; + case chromiumBrowser: + return "chromium-browser"; + case firefox: + return "firefox"; + case midori: + return "midori"; + case epiphany: + return "epiphany"; + default: + return null; + + } + } + + @Override + public String toString() { + if (toExec()!=null) return toExec(); + switch (this) { + case all: + return "all"; + case one: + return "one"; + case none: + return "unset_browser"; + default: return "unknown"; + + } + } +} diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/Chrome.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/Chrome.java new file mode 100644 index 0000000..2668d65 --- /dev/null +++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/Chrome.java @@ -0,0 +1,15 @@ +package net.sourceforge.jnlp.browsertesting.browsers; + +import net.sourceforge.jnlp.browsertesting.Browsers; + +public class Chrome extends MozillaFamilyLinuxBrowser { + + public Chrome(String bin) { + super(bin); + } + + @Override + public Browsers getID() { + return Browsers.googleChrome; + } +} diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/Chromium.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/Chromium.java new file mode 100644 index 0000000..616d38a --- /dev/null +++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/Chromium.java @@ -0,0 +1,15 @@ +package net.sourceforge.jnlp.browsertesting.browsers; + +import net.sourceforge.jnlp.browsertesting.Browsers; + +public class Chromium extends MozillaFamilyLinuxBrowser { + + public Chromium(String bin) { + super(bin); + } + + @Override + public Browsers getID() { + return Browsers.chromiumBrowser; + } +} diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/Epiphany.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/Epiphany.java new file mode 100644 index 0000000..3adc3d8 --- /dev/null +++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/Epiphany.java @@ -0,0 +1,18 @@ +package net.sourceforge.jnlp.browsertesting.browsers; + +import net.sourceforge.jnlp.browsertesting.Browsers; + +public class Epiphany extends MozillaFamilyLinuxBrowser { + + public Epiphany(String bin) { + super(bin); + } + + @Override + public Browsers getID() { + return Browsers.epiphany; + } + + + +} diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/Firefox.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/Firefox.java new file mode 100644 index 0000000..af20aaa --- /dev/null +++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/Firefox.java @@ -0,0 +1,18 @@ +package net.sourceforge.jnlp.browsertesting.browsers; + +import net.sourceforge.jnlp.browsertesting.Browsers; + +public class Firefox extends MozillaFamilyLinuxBrowser { + + public Firefox(String bin) { + super(bin); + } + + @Override + public Browsers getID() { + return Browsers.firefox; + } + + + +} diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/LinuxBrowser.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/LinuxBrowser.java new file mode 100644 index 0000000..edc95e0 --- /dev/null +++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/LinuxBrowser.java @@ -0,0 +1,60 @@ +package net.sourceforge.jnlp.browsertesting.browsers; + +import net.sourceforge.jnlp.browsertesting.Browser; + + +public abstract class LinuxBrowser implements Browser{ + public static final String DEFAULT_PLUGIN_NAME="libjavaplugin.so"; + public static final String DEFAULT_BIN_PATH="/usr/bin/"; + + protected final String bin; + protected String fsdir="unknown"; + + public LinuxBrowser(String bin) { + this.bin = bin; + } + + + + @Override + public String getBin() { + return bin; + } + +// @Override +// public void setBin(String bin) { +// this.bin=bin; +// } + + @Override + public String getDefaultBin() { + return DEFAULT_BIN_PATH+getID().toExec(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Browser)) return false; + Browser b=(Browser) obj; + return b.getBin().equals(getBin()); + } + + @Override + public int hashCode() { + int hash = 5; + hash = 59 * hash + (this.bin != null ? this.bin.hashCode() : 0); + return hash; + } + + @Override + public String getDefaultPluginExpectedLocation() { + if (System.getProperty("os.arch").contains("64")) { + return "/usr/lib64/"+fsdir+"/plugins"; + } else { + return "/usr/lib/"+fsdir+"/plugins"; + + } + } + + + +} diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/Midory.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/Midory.java new file mode 100644 index 0000000..fc563fb --- /dev/null +++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/Midory.java @@ -0,0 +1,18 @@ +package net.sourceforge.jnlp.browsertesting.browsers; + +import net.sourceforge.jnlp.browsertesting.Browsers; + +public class Midory extends MozillaFamilyLinuxBrowser { + + public Midory(String bin) { + super(bin); + } + + @Override + public Browsers getID() { + return Browsers.midori; + } + + + +} diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/MozillaFamilyLinuxBrowser.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/MozillaFamilyLinuxBrowser.java new file mode 100644 index 0000000..c8d1e85 --- /dev/null +++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/MozillaFamilyLinuxBrowser.java @@ -0,0 +1,29 @@ +package net.sourceforge.jnlp.browsertesting.browsers; + +import java.util.List; + +public abstract class MozillaFamilyLinuxBrowser extends LinuxBrowser{ + + public MozillaFamilyLinuxBrowser(String bin) { + super(bin); + fsdir="mozilla"; + } + + + @Override + public List<String> getComaptibilitySwitches() { + return null; + } + + @Override + public List<String> getDefaultSwitches() { + return null; + } + + @Override + public String getUserDefaultPluginExpectedLocation() { + return System.getProperty("user.home")+"/.mozilla/plugins"; + } + + +} diff --git a/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/Opera.java b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/Opera.java new file mode 100644 index 0000000..edbf57f --- /dev/null +++ b/tests/netx/jnlp_testsengine/net/sourceforge/jnlp/browsertesting/browsers/Opera.java @@ -0,0 +1,37 @@ +package net.sourceforge.jnlp.browsertesting.browsers; + +import java.util.Arrays; +import java.util.List; +import net.sourceforge.jnlp.browsertesting.Browsers; + +public class Opera extends LinuxBrowser { + + public Opera(String bin) { + super(bin); + fsdir="opera"; + } + + @Override + public Browsers getID() { + return Browsers.opera; + } + + @Override + public String getUserDefaultPluginExpectedLocation() { + return null; + } + + + String[] cs={"-nosession", "-nomail", "-nolirc", "-newtab"}; + + @Override + public List<String> getComaptibilitySwitches() { + return Arrays.asList(cs); + } + + @Override + public List<String> getDefaultSwitches() { + return null; + } + +}
\ No newline at end of file |