From ff7f4daea86d4b245c59265285e242330925b3c7 Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Tue, 31 Oct 2023 14:02:55 +0100 Subject: [PATCH] Fix UI tests that fail with Eclipse 4.18 - 4.20 --- .../eclipse/eclemma/ui/CoverageViewTest.java | 6 +++- .../eclipse/eclemma/ui/ExportImportTest.java | 12 +++++-- .../org/eclipse/eclemma/ui/UiTestUtils.java | 36 +++++++++++++++++++ 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 org.eclipse.eclemma.ui.test/src/org/eclipse/eclemma/ui/UiTestUtils.java diff --git a/org.eclipse.eclemma.ui.test/src/org/eclipse/eclemma/ui/CoverageViewTest.java b/org.eclipse.eclemma.ui.test/src/org/eclipse/eclemma/ui/CoverageViewTest.java index b7561a6f..72a17adf 100644 --- a/org.eclipse.eclemma.ui.test/src/org/eclipse/eclemma/ui/CoverageViewTest.java +++ b/org.eclipse.eclemma.ui.test/src/org/eclipse/eclemma/ui/CoverageViewTest.java @@ -50,7 +50,11 @@ public void run() { // then bot.shell("Import").activate(); - bot.text(" Please select an existing execution data file."); + if (UiTestUtils.TITLE_AREA_DIALOG_USES_LABEL) { + bot.label(" Please select an existing execution data file."); + } else { + bot.text(" Please select an existing execution data file."); + } } } diff --git a/org.eclipse.eclemma.ui.test/src/org/eclipse/eclemma/ui/ExportImportTest.java b/org.eclipse.eclemma.ui.test/src/org/eclipse/eclemma/ui/ExportImportTest.java index e47b17b5..490966b8 100644 --- a/org.eclipse.eclemma.ui.test/src/org/eclipse/eclemma/ui/ExportImportTest.java +++ b/org.eclipse.eclemma.ui.test/src/org/eclipse/eclemma/ui/ExportImportTest.java @@ -35,7 +35,11 @@ public void testImport() { treeItem.getNode("Coverage Session").select(); bot.button("Next >").click(); - bot.text(" Please select an existing execution data file."); + if (UiTestUtils.TITLE_AREA_DIALOG_USES_LABEL) { + bot.label(" Please select an existing execution data file."); + } else { + bot.text(" Please select an existing execution data file."); + } } @Test @@ -47,7 +51,11 @@ public void testExport() { treeItem.getNode("Coverage Session").select(); bot.button("Next >").click(); - bot.text(" No coverage session available for export."); + if (UiTestUtils.TITLE_AREA_DIALOG_USES_LABEL) { + bot.label(" No coverage session available for export."); + } else { + bot.text(" No coverage session available for export."); + } } } diff --git a/org.eclipse.eclemma.ui.test/src/org/eclipse/eclemma/ui/UiTestUtils.java b/org.eclipse.eclemma.ui.test/src/org/eclipse/eclemma/ui/UiTestUtils.java new file mode 100644 index 00000000..b8fa7994 --- /dev/null +++ b/org.eclipse.eclemma.ui.test/src/org/eclipse/eclemma/ui/UiTestUtils.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2006, 2020 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + ******************************************************************************/ +package org.eclipse.eclemma.ui; + +import org.eclipse.core.runtime.Platform; +import org.osgi.framework.Version; + +final class UiTestUtils { + + /** + * https://github.com/eclipse-platform/eclipse.platform.ui/commit/40b5475e2790b36228537d6446e470b36386b17c + * https://github.com/eclipse-platform/eclipse.platform.ui/commit/a43240d58eebb2015c48a4957859bb944a432a6e + */ + public static final boolean TITLE_AREA_DIALOG_USES_LABEL; + + static { + final Version jfaceVersion = Platform.getBundle("org.eclipse.jface") + .getVersion(); + TITLE_AREA_DIALOG_USES_LABEL = jfaceVersion.getMajor() == 3 + && jfaceVersion.getMinor() == 22; + } + + private UiTestUtils() { + } + +}