Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2019-03-05 04:49:49 -0500
committerMickael Istria2019-03-05 05:52:25 -0500
commita469aff0f60d49271f26c2bbf95af678d2172a68 (patch)
treea577a32beb5c229ac18e6092e69d6109445ab789
parent6c60b84d03bb78c253650de64a61b6a8219315c3 (diff)
downloadeclipse.platform.text-a469aff0f60d49271f26c2bbf95af678d2172a68.tar.gz
eclipse.platform.text-a469aff0f60d49271f26c2bbf95af678d2172a68.tar.xz
eclipse.platform.text-a469aff0f60d49271f26c2bbf95af678d2172a68.zip
Bug 545006 - Reuse existing API for screenshots during testsI20190306-0600I20190305-1800I20190305-0600
This should allow screenshots to be found more easily in official tests and allow to more easily spot tests disabled on Mac. Change-Id: I7d57891ef83976401d5fdf165f7655b6f783f6fe Signed-off-by: Mickael Istria <mistria@redhat.com>
-rw-r--r--org.eclipse.jface.text.tests/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/CodeMiningTest.java11
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/ScreenshotOnFailureRule.java25
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextViewerTest.java11
4 files changed, 10 insertions, 40 deletions
diff --git a/org.eclipse.jface.text.tests/META-INF/MANIFEST.MF b/org.eclipse.jface.text.tests/META-INF/MANIFEST.MF
index cdd9a2077..d39b0daf6 100644
--- a/org.eclipse.jface.text.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.jface.text.tests/META-INF/MANIFEST.MF
@@ -19,7 +19,8 @@ Require-Bundle:
org.junit;bundle-version="4.12.0",
org.eclipse.text.tests;bundle-version="[3.5.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
- org.eclipse.ui.workbench.texteditor
+ org.eclipse.ui.workbench.texteditor,
+ org.eclipse.test.performance;bundle-version="3.13.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Eclipse-BundleShape: dir
Automatic-Module-Name: org.eclipse.jface.text.tests
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/CodeMiningTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/CodeMiningTest.java
index b8ef5947b..a02f64b5b 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/CodeMiningTest.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/CodeMiningTest.java
@@ -17,6 +17,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.junit.After;
import org.junit.Assert;
+import org.junit.Assume;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -110,10 +111,7 @@ public class CodeMiningTest {
@Test
public void testCodeMiningCtrlHome() throws BadLocationException {
- if(Util.isMac()) {
- // See bug 541415. For whatever reason, this shortcut doesn't work on Mac
- return;
- }
+ Assume.assumeFalse("See bug 541415. For whatever reason, this shortcut doesn't work on Mac", Util.isMac());
DelayedEchoCodeMiningProvider.DELAY = 500;
fViewer.getDocument().set(TextViewerTest.generate5000Lines());
Assert.assertTrue(new DisplayHelper() {
@@ -154,10 +152,7 @@ public class CodeMiningTest {
@Test
public void testCodeMiningCtrlEnd() throws BadLocationException {
- if(Util.isMac()) {
- // See bug 541415. For whatever reason, this shortcut doesn't work on Mac
- return;
- }
+ Assume.assumeFalse("See bug 541415. For whatever reason, this shortcut doesn't work on Mac", Util.isMac());
fViewer.getDocument().set(TextViewerTest.generate5000Lines());
Assert.assertTrue(new DisplayHelper() {
@Override
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/ScreenshotOnFailureRule.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/ScreenshotOnFailureRule.java
index 69a10a6d8..3deb57992 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/ScreenshotOnFailureRule.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/ScreenshotOnFailureRule.java
@@ -13,34 +13,13 @@
*******************************************************************************/
package org.eclipse.jface.text.tests;
-import java.awt.Rectangle;
-import java.awt.Robot;
-import java.awt.Toolkit;
-import java.awt.image.BufferedImage;
-import java.io.File;
-
-import javax.imageio.ImageIO;
-
import org.junit.rules.TestWatcher;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
+import org.eclipse.test.Screenshots;
final class ScreenshotOnFailureRule extends TestWatcher {
@Override
protected void failed(Throwable e, org.junit.runner.Description description) {
- Robot robot;
- try {
- robot= new Robot();
- String format = "jpg";
- String fileName = Platform.getLogFileLocation().removeLastSegments(2).toString() + '/' + description.getClassName() + '.' + description.getMethodName() + ".failure." + format;
- Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
- BufferedImage screenFullImage = robot.createScreenCapture(screenRect);
- ImageIO.write(screenFullImage, format, new File(fileName));
- super.failed(e, description);
- } catch (Exception ex) {
- Platform.getLog(Platform.getBundle("org.eclipse.jface.text.tests")).log(new Status(IStatus.ERROR, "org.eclipse.jface.text.tests", ex.getMessage(), ex));
- }
+ Screenshots.takeScreenshot(description.getTestClass(), description.getMethodName());
}
} \ No newline at end of file
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextViewerTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextViewerTest.java
index 67fbc6479..2374ead8d 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextViewerTest.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextViewerTest.java
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertTrue;
import java.util.concurrent.atomic.AtomicBoolean;
+import org.junit.Assume;
import org.junit.Rule;
import org.junit.Test;
@@ -72,10 +73,7 @@ public class TextViewerTest {
@Test
public void testCtrlHomeViewportListener() {
- if(Util.isMac()) {
- // See bug 541415. For whatever reason, this shortcut doesn't work on Mac
- return;
- }
+ Assume.assumeFalse("See bug 541415. For whatever reason, this shortcut doesn't work on Mac", Util.isMac());
Shell shell= new Shell();
try {
shell.setLayout(new FillLayout());
@@ -102,10 +100,7 @@ public class TextViewerTest {
@Test
public void testCtrlEndViewportListener() {
- if(Util.isMac()) {
- // See bug 541415. For whatever reason, this shortcut doesn't work on Mac
- return;
- }
+ Assume.assumeFalse("See bug 541415. For whatever reason, this shortcut doesn't work on Mac", Util.isMac());
Shell shell= new Shell();
try {
shell.setLayout(new FillLayout());

Back to the top