diff options
author | Markus Keller | 2012-08-27 16:44:12 +0000 |
---|---|---|
committer | Markus Keller | 2012-08-27 16:44:12 +0000 |
commit | 30ddc1675a17f0abf9c32fc1b490d55fe2bd232b (patch) | |
tree | fa808c4ed278c4847a3f92babb65d6ab1656f1e1 | |
parent | 386f2895bf7503ce73c7e436582087c4b68ce898 (diff) | |
download | eclipse.platform.text-30ddc1675a17f0abf9c32fc1b490d55fe2bd232b.tar.gz eclipse.platform.text-30ddc1675a17f0abf9c32fc1b490d55fe2bd232b.tar.xz eclipse.platform.text-30ddc1675a17f0abf9c32fc1b490d55fe2bd232b.zip |
Bug 379026: Test failures on GTK because workbench window doesn't have focusv20120827-164412I20120828-0800
Try to take screenshots on all platforms (into -junitReportOutput argument)
-rw-r--r-- | org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/FindReplaceDialogTest.java | 32 |
1 files changed, 27 insertions, 5 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 9cbc64b8c11..b63293134e1 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 @@ -28,7 +28,7 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Shell; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; import org.eclipse.text.tests.Accessor; @@ -194,6 +194,9 @@ public class FindReplaceDialogTest extends TestCase { event.doit= true; findField.traverse(SWT.TRAVERSE_RETURN, event); runEventQueue(); + + takeScreenshot(); //XXX: shoot unconditionally + 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()); @@ -216,8 +219,16 @@ public class FindReplaceDialogTest extends TestCase { } private String takeScreenshot() { - File eclipseDir= new File("").getAbsoluteFile(); // eclipse-testing/test-eclipse/eclipse - File resultsHtmlDir= new File(eclipseDir, "../../results/html/").getAbsoluteFile(); + return takeScreenshot(FindReplaceDialogTest.class, getName()); + } + + private static String takeScreenshot(Class testClass, String testName) { + File resultsHtmlDir= getJunitReportOutput(); + + if (resultsHtmlDir == null) { // fallback, NOT platform-dependent: + File eclipseDir= new File("").getAbsoluteFile(); // eclipse-testing/test-eclipse/eclipse + resultsHtmlDir= new File(eclipseDir, "../../results/html/").getAbsoluteFile(); + } // Take a screenshot: Display display= Display.getDefault(); @@ -227,8 +238,9 @@ public class FindReplaceDialogTest extends TestCase { gc.dispose(); resultsHtmlDir.mkdirs(); - String filename = new Path(resultsHtmlDir.getAbsolutePath()).append( - "FindReplaceDialogTest." + getName() + ".png").toOSString(); + String filename = new File( + resultsHtmlDir.getAbsolutePath(), + testClass.getName() + "." + testName + ".png").getAbsolutePath(); ImageLoader loader = new ImageLoader(); loader.data = new ImageData[] { image.getImageData() }; loader.save(filename, SWT.IMAGE_PNG); @@ -237,6 +249,16 @@ public class FindReplaceDialogTest extends TestCase { return filename; } + private static File getJunitReportOutput() { + String[] args= Platform.getCommandLineArgs(); + for (int i= 0; i < args.length - 1; i++) { + if ("-junitReportOutput".equals(args[i])) { // see library.xml and org.eclipse.test.EclipseTestRunner + return new File(args[i + 1]).getAbsoluteFile(); + } + } + return null; + } + public void testFocusNotChangedWhenButtonMnemonicPressed() { openTextViewerAndFindReplaceDialog(); |