Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2015-03-22 16:10:51 +0000
committerDani Megert2015-03-22 16:10:51 +0000
commit813034ea2c3c4db4f283b37f2e8cbfe65cb47fea (patch)
treedc4ad563341f0c6397abd16ba7ab02ed559136aa
parent0cfdcf63faaf40dab307eb2b272008ecab536947 (diff)
downloadeclipse.platform.text-813034ea2c3c4db4f283b37f2e8cbfe65cb47fea.tar.gz
eclipse.platform.text-813034ea2c3c4db4f283b37f2e8cbfe65cb47fea.tar.xz
eclipse.platform.text-813034ea2c3c4db4f283b37f2e8cbfe65cb47fea.zip
Make screenshot available in Gerrit Hudson jobs
-rw-r--r--org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/FindReplaceDialogTest.java34
-rw-r--r--org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/ScreenshotTest.java15
2 files changed, 35 insertions, 14 deletions
diff --git a/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/FindReplaceDialogTest.java b/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/FindReplaceDialogTest.java
index d2c0c02ff8b..9c971d226a1 100644
--- a/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/FindReplaceDialogTest.java
+++ b/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/FindReplaceDialogTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation 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
@@ -12,9 +12,6 @@ package org.eclipse.ui.workbench.texteditor.tests;
import java.util.ResourceBundle;
-import junit.framework.Test;
-import junit.framework.TestCase;
-
import org.eclipse.test.OrderedTestSuite;
import org.eclipse.swt.SWT;
@@ -34,6 +31,9 @@ import org.eclipse.jface.text.TextViewer;
import org.eclipse.ui.PlatformUI;
+import junit.framework.Test;
+import junit.framework.TestCase;
+
/**
* Tests the FindReplaceDialog.
*
@@ -181,8 +181,13 @@ public class FindReplaceDialogTest extends TestCase {
runEventQueue();
Shell shell= ((Shell)fFindReplaceDialog.get("fActiveShell"));
- if (shell == null && Util.isGtk())
- fail("this test does not work on GTK unless the runtime workbench has focus. Screenshot: " + takeScreenshot());
+ if (shell == null && Util.isGtk()) {
+ if (ScreenshotTest.isRunByGerritHudsonJob()) {
+ takeScreenshot();
+ return;
+ } else
+ fail("this test does not work on GTK unless the runtime workbench has focus. Screenshot: " + takeScreenshot());
+ }
assertTrue(findField.isFocusControl());
@@ -223,7 +228,11 @@ public class FindReplaceDialogTest extends TestCase {
runEventQueue();
Shell shell= ((Shell)fFindReplaceDialog.get("fActiveShell"));
if (shell == null && Util.isGtk())
- fail("this test does not work on GTK unless the runtime workbench has focus. Screenshot: " + takeScreenshot());
+ if (ScreenshotTest.isRunByGerritHudsonJob()) {
+ takeScreenshot();
+ return;
+ } else
+ fail("this test does not work on GTK unless the runtime workbench has focus. Screenshot: " + takeScreenshot());
Button wrapSearchBox= (Button)fFindReplaceDialog.get("fWrapCheckBox");
wrapSearchBox.setFocus();
@@ -259,9 +268,13 @@ public class FindReplaceDialogTest extends TestCase {
IFindReplaceTarget target= (IFindReplaceTarget)fFindReplaceDialog.get("fTarget");
runEventQueue();
Shell shell= ((Shell)fFindReplaceDialog.get("fActiveShell"));
- if (shell == null && Util.isGtk())
- fail("this test does not work on GTK unless the runtime workbench has focus. Screenshot: " + takeScreenshot());
-
+ if (shell == null && Util.isGtk()) {
+ if (ScreenshotTest.isRunByGerritHudsonJob()) {
+ takeScreenshot();
+ return;
+ } else
+ fail("this test does not work on GTK unless the runtime workbench has focus. Screenshot: " + takeScreenshot());
+ }
final Event event= new Event();
event.detail= SWT.TRAVERSE_RETURN;
@@ -289,4 +302,5 @@ public class FindReplaceDialogTest extends TestCase {
forwardRadioButton.traverse(SWT.TRAVERSE_RETURN, event);
assertEquals(5, (target.getSelection()).x);
}
+
}
diff --git a/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/ScreenshotTest.java b/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/ScreenshotTest.java
index 58ce2862663..b0adab96d9c 100644
--- a/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/ScreenshotTest.java
+++ b/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/ScreenshotTest.java
@@ -13,9 +13,6 @@ package org.eclipse.ui.workbench.texteditor.tests;
import java.io.File;
import java.io.PrintStream;
-import junit.framework.Test;
-import junit.framework.TestCase;
-
import org.eclipse.test.OrderedTestSuite;
import org.eclipse.swt.SWT;
@@ -35,6 +32,9 @@ import org.eclipse.jface.util.Util;
import org.eclipse.ui.PlatformUI;
+import junit.framework.Test;
+import junit.framework.TestCase;
+
public class ScreenshotTest extends TestCase {
public ScreenshotTest(String name) {
@@ -101,7 +101,10 @@ public class ScreenshotTest extends TestCase {
if (resultsHtmlDir == null) { // Fallback. Warning: uses same file location on all test platforms:
File eclipseDir= new File("").getAbsoluteFile(); // eclipse-testing/test-eclipse/eclipse
- resultsHtmlDir= new File(eclipseDir, "../../results/html/").getAbsoluteFile(); // ends up in testresults/html/<class>.<test>.png
+ if (isRunByGerritHudsonJob())
+ resultsHtmlDir= new File(eclipseDir, "/../").getAbsoluteFile(); // ends up in the workspace root
+ else
+ resultsHtmlDir= new File(eclipseDir, "../../results/html/").getAbsoluteFile(); // ends up in testresults/html/<class>.<test>.png
}
Display display= PlatformUI.getWorkbench().getDisplay();
@@ -171,6 +174,10 @@ public class ScreenshotTest extends TestCase {
return null;
}
+ public static boolean isRunByGerritHudsonJob() {
+ return System.getProperty("user.dir").indexOf("eclipse.platform.text-Gerrit") != -1;
+ }
+
private static void runEventQueue() {
Display display= PlatformUI.getWorkbench().getDisplay();
for (int i= 0; i < 10; i++) { // workaround for https://bugs.eclipse.org/323272

Back to the top