diff options
author | Johannes Dahlström <johannes.dahlstrom@vaadin.com> | 2012-01-16 07:01:28 +0000 |
---|---|---|
committer | Johannes Dahlström <johannes.dahlstrom@vaadin.com> | 2012-01-16 07:01:28 +0000 |
commit | 326ccadd49971a36bcf4c356f114eba70a4e337f (patch) | |
tree | 7756dead0ad908b23911030464fe308f5929be3d /tests | |
parent | c661750fbc7149becd34548ac3a0a844df39b3b7 (diff) | |
download | vaadin-framework-326ccadd49971a36bcf4c356f114eba70a4e337f.tar.gz vaadin-framework-326ccadd49971a36bcf4c356f114eba70a4e337f.zip |
Merged #8105 Compile core files and test files to separate folders
svn changeset:22636/svn branch:6.8
Diffstat (limited to 'tests')
-rw-r--r-- | tests/server-side/com/vaadin/tests/VaadinClasses.java (renamed from tests/testbench/com/vaadin/tests/VaadinClasses.java) | 9 | ||||
-rw-r--r-- | tests/testbench/com/vaadin/launcher/util/BrowserLauncher.java | 127 | ||||
-rw-r--r-- | tests/testbench/com/vaadin/tests/Components.java | 17 |
3 files changed, 140 insertions, 13 deletions
diff --git a/tests/testbench/com/vaadin/tests/VaadinClasses.java b/tests/server-side/com/vaadin/tests/VaadinClasses.java index 0f4e2ff4da..e02c4f0b6e 100644 --- a/tests/testbench/com/vaadin/tests/VaadinClasses.java +++ b/tests/server-side/com/vaadin/tests/VaadinClasses.java @@ -18,7 +18,6 @@ import java.util.jar.JarEntry; import org.junit.Test; import com.vaadin.Application; -import com.vaadin.tests.components.AbstractComponentTest; import com.vaadin.ui.Component; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.CustomComponent; @@ -103,11 +102,13 @@ public class VaadinClasses { } @SuppressWarnings({ "unchecked", "rawtypes" }) - public static List<Class<? extends AbstractComponentTest<?>>> getBasicComponentTests() { + public static List<Class<?>> getBasicComponentTests() { try { - return (List) findClasses(AbstractComponentTest.class, + // Given as name to avoid dependencies on testbench source folder + return (List) findClasses( + Class.forName("com.vaadin.tests.components.AbstractComponentTest"), "com.vaadin.tests.components"); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); return null; } diff --git a/tests/testbench/com/vaadin/launcher/util/BrowserLauncher.java b/tests/testbench/com/vaadin/launcher/util/BrowserLauncher.java new file mode 100644 index 0000000000..55692cb251 --- /dev/null +++ b/tests/testbench/com/vaadin/launcher/util/BrowserLauncher.java @@ -0,0 +1,127 @@ +/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.launcher.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+/**
+ * This class opens default browser for DemoLauncher class. Default browser is
+ * detected by the operating system.
+ *
+ */
+public class BrowserLauncher {
+
+ /**
+ * Open browser on specified URL.
+ *
+ * @param url
+ */
+ public static void openBrowser(String url) {
+
+ final Runtime runtime = Runtime.getRuntime();
+ boolean started = false;
+
+ final String os = System.getProperty("os.name", "windows")
+ .toLowerCase();
+
+ // Linux
+ if (os.indexOf("linux") >= 0) {
+ // See if the default browser is Konqueror by resolving the symlink.
+ boolean isDefaultKonqueror = false;
+ try {
+ // Find out the location of the x-www-browser link from path.
+ Process process = runtime.exec("which x-www-browser");
+ BufferedInputStream ins = new BufferedInputStream(
+ process.getInputStream());
+ BufferedReader bufreader = new BufferedReader(
+ new InputStreamReader(ins));
+ String defaultLinkPath = bufreader.readLine();
+ ins.close();
+
+ // The path is null if the link did not exist.
+ if (defaultLinkPath != null) {
+ // See if the default browser is Konqueror.
+ File file = new File(defaultLinkPath);
+ String canonical = file.getCanonicalPath();
+ if (canonical.indexOf("konqueror") != -1) {
+ isDefaultKonqueror = true;
+ }
+ }
+ } catch (IOException e1) {
+ // The symlink was probably not found, so this is ok.
+ }
+
+ // Try x-www-browser, which is symlink to the default browser,
+ // except if we found that it is Konqueror.
+ if (!started && !isDefaultKonqueror) {
+ try {
+ runtime.exec("x-www-browser " + url);
+ started = true;
+ } catch (final IOException e) {
+ }
+ }
+
+ // Try firefox
+ if (!started) {
+ try {
+ runtime.exec("firefox " + url);
+ started = true;
+ } catch (final IOException e) {
+ }
+ }
+
+ // Try mozilla
+ if (!started) {
+ try {
+ runtime.exec("mozilla " + url);
+ started = true;
+ } catch (final IOException e) {
+ }
+ }
+
+ // Try konqueror
+ if (!started) {
+ try {
+ runtime.exec("konqueror " + url);
+ started = true;
+ } catch (final IOException e) {
+ }
+ }
+ }
+
+ // OS X
+ if (os.indexOf("mac os x") >= 0) {
+
+ // Try open
+ if (!started) {
+ try {
+ runtime.exec("open " + url);
+ started = true;
+ } catch (final IOException e) {
+ }
+ }
+ }
+
+ // Try cmd /start command on windows
+ if (os.indexOf("win") >= 0) {
+ if (!started) {
+ try {
+ runtime.exec("cmd /c start " + url);
+ started = true;
+ } catch (final IOException e) {
+ }
+ }
+ }
+
+ if (!started) {
+ System.out.println("Failed to open browser. Please go to " + url);
+ }
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/Components.java b/tests/testbench/com/vaadin/tests/Components.java index 6987c04a54..d7bc18e2f6 100644 --- a/tests/testbench/com/vaadin/tests/Components.java +++ b/tests/testbench/com/vaadin/tests/Components.java @@ -32,7 +32,7 @@ import com.vaadin.ui.Window; public class Components extends Application {
private static final Object CAPTION = "c";
- private Map<Class<? extends AbstractComponentTest<?>>, String> tests = new HashMap<Class<? extends AbstractComponentTest<?>>, String>();
+ private Map<Class<? extends AbstractComponentTest>, String> tests = new HashMap<Class<? extends AbstractComponentTest>, String>();
private Tree naviTree;
private HorizontalSplitPanel sp;
private Window mainWindow;
@@ -41,10 +41,9 @@ public class Components extends Application { private List<Class<? extends Component>> componentsWithoutTests = new ArrayList<Class<? extends Component>>();
{
- for (Class<? extends AbstractComponentTest<?>> c : VaadinClasses
- .getBasicComponentTests()) {
+ for (Class<?> c : VaadinClasses.getBasicComponentTests()) {
String testClass = c.getSimpleName();
- tests.put(c, testClass);
+ tests.put((Class<? extends AbstractComponentTest>) c, testClass);
}
List<Class<? extends Component>> componentsWithoutTest = VaadinClasses
@@ -171,7 +170,7 @@ public class Components extends Application { hc.setItemSorter(sorter);
naviTree.addContainerProperty(CAPTION, String.class, "");
naviTree.setItemCaptionPropertyId(CAPTION);
- for (Class<? extends AbstractComponentTest<?>> cls : tests.keySet()) {
+ for (Class<? extends AbstractComponentTest> cls : tests.keySet()) {
addTreeItem(cls);
}
hc.sort(new Object[] { CAPTION }, new boolean[] { true });
@@ -226,13 +225,13 @@ public class Components extends Application { }
@SuppressWarnings("unchecked")
- private void addTreeItem(Class<? extends AbstractComponentTest<?>> cls) {
+ private void addTreeItem(Class<? extends AbstractComponentTest> cls) {
String name = tests.get(cls);
if (name == null) {
name = cls.getSimpleName();
}
- Class<? extends AbstractComponentTest<?>> superClass = (Class<? extends AbstractComponentTest<?>>) cls
+ Class<? extends AbstractComponentTest> superClass = (Class<? extends AbstractComponentTest>) cls
.getSuperclass();
// This cast is needed only to make compilation through Ant work ..
@@ -249,9 +248,9 @@ public class Components extends Application { }
protected Component createTestComponent(
- Class<? extends AbstractComponentTest<?>> cls) {
+ Class<? extends AbstractComponentTest> cls) {
try {
- AbstractComponentTest<?> t = cls.newInstance();
+ AbstractComponentTest t = cls.newInstance();
t.init();
ComponentContainer c = t.getMainWindow().getContent();
t.getMainWindow().setContent(null);
|