From 3c0d6224aad18eb868d7103979c488ca59948967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Wed, 30 Oct 2024 07:43:40 +0200 Subject: [PATCH] Fix DialogCheck ArithmeticException Caused by https://github.com/eclipse-platform/eclipse.platform.ui/pull/2457 doing division by zero when button has no text but just image. --- .../src/org/eclipse/ui/tests/harness/util/DialogCheck.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/DialogCheck.java b/tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/DialogCheck.java index 1166a64b47a..7be2ae1dccd 100644 --- a/tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/DialogCheck.java +++ b/tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/DialogCheck.java @@ -156,7 +156,8 @@ private static void verifyButtonText(Button button) { //if (size.y/preferred.y) == X, then label spans X lines, so divide //the calculated value of preferred.x by X if (preferred.y * size.y > 0) { - preferred.y /= button.getText().lines().count(); // check for '\n\' + String buttonText = button.getText(); + preferred.y /= buttonText.isEmpty() ? 1 : buttonText.lines().count(); // check for '\n\' if (size.y / preferred.y > 1) { preferred.x /= (size.y / preferred.y); }