Compare commits

..

2 Commits

Author SHA1 Message Date
Vitaly Provodin
06951b9da5 update exclude list on results of 21.0.1_b306.2 test runs 2023-12-06 05:49:53 +07:00
Vitaly Provodin
1728549185 Revert "JBR-6246 add default CDS archives into jbrsdk distributions and remove the step normalizing timestamp"
This reverts commit be6842220b.
2023-12-02 05:15:36 +07:00
43 changed files with 391 additions and 603 deletions

View File

@@ -21,13 +21,11 @@ can be found on the [releases page](https://github.com/JetBrains/JetBrainsRuntim
## Releases based on JDK 17
| IDE Version | Latest JBR | Date Released |
|-------------|---------------------------------------------------------------------------------------------------------|---------------|
| 2023.3 | [17.0.9b1087.7](https://github.com/JetBrains/JetBrainsRuntime/releases/tag/jbr-release-17.0.9b1087.7) | 20-Nov-2023 |
| 2023.2 | [17.0.9b1000.46](https://github.com/JetBrains/JetBrainsRuntime/releases/tag/jbr-release-17.0.9b1000.46) | 01-Nov-2023 |
| 2023.1 | [17.0.6-b829.5](https://github.com/JetBrains/JetBrainsRuntime/releases/tag/jbr-release-17.0.6b829.5) | 01-Mar-2023 |
| 2022.3 | [17.0.6-b653.34](https://github.com/JetBrains/JetBrainsRuntime/releases/tag/jbr-release-17.0.6b653.34) | 28-Feb-2023 |
| 2022.2 | [17.0.6-b469.82](https://github.com/JetBrains/JetBrainsRuntime/releases/tag/jbr-release-17.0.6b469.82) | 06-Mar-2023 |
| IDE Version | Latest JBR | Date Released |
|-------------|--------------------------------------------------------------------------------------------------------|---------------|
| 2023.1 | [17.0.6-b829.5](https://github.com/JetBrains/JetBrainsRuntime/releases/tag/jbr-release-17.0.6b829.5) | 01-Mar-2023 |
| 2022.3 | [17.0.6-b653.34](https://github.com/JetBrains/JetBrainsRuntime/releases/tag/jbr-release-17.0.6b653.34) | 28-Feb-2023 |
| 2022.2 | [17.0.6-b469.82](https://github.com/JetBrains/JetBrainsRuntime/releases/tag/jbr-release-17.0.6b469.82) | 06-Mar-2023 |
## Releases based on JDK 11
@@ -126,8 +124,8 @@ $ docker run -v `pwd`../../../../:/JetBrainsRuntime -it 942ea9900054
### Ubuntu Linux
Install the necessary tools, libraries, and headers with:
```
$ sudo apt-get install autoconf make build-essential libwayland-dev libx11-dev libxext-dev libxrender-dev \
libxtst-dev libxt-dev libxrandr-dev libcups2-dev libfontconfig1-dev libasound2-dev
$ sudo apt-get install autoconf make build-essential libx11-dev libxext-dev libxrender-dev libxtst-dev \
libxt-dev libxrandr-dev libcups2-dev libfontconfig1-dev libasound2-dev
```
Get Java 19 (for instance, [Azul Zulu Builds of OpenJDK 19](https://www.azul.com/downloads/?version=java-19-sts&os=linux&package=jdk)).

View File

@@ -410,25 +410,23 @@ bool SharedClassPathEntry::validate(bool is_class_path) const {
log_warning(cds)("directory is not empty: %s", name);
ok = false;
}
} else {
bool size_differs = _filesize != st.st_size;
bool time_differs = has_timestamp() && _timestamp != st.st_mtime;
if (time_differs || size_differs) {
ok = false;
if (PrintSharedArchiveAndExit) {
log_warning(cds)(time_differs ? "Timestamp mismatch" : "File size mismatch");
} else if ((has_timestamp() && _timestamp != st.st_mtime) ||
_filesize != st.st_size) {
ok = false;
if (PrintSharedArchiveAndExit) {
log_warning(cds)(_timestamp != st.st_mtime ?
"Timestamp mismatch" :
"File size mismatch");
} else {
const char* bad_jar_msg = "A jar file is not the one used while building the shared archive file:";
log_warning(cds)("%s %s", bad_jar_msg, name);
if (!log_is_enabled(Info, cds)) {
log_warning(cds)("%s %s", bad_jar_msg, name);
}
if (_timestamp != st.st_mtime) {
log_warning(cds)("%s timestamp has changed.", name);
} else {
const char* bad_file_msg = "This file is not the one used while building the shared archive file:";
log_warning(cds)("%s %s", bad_file_msg, name);
if (!log_is_enabled(Info, cds)) {
log_warning(cds)("%s %s", bad_file_msg, name);
}
if (time_differs) {
log_warning(cds)("%s timestamp has changed.", name);
}
if (size_differs) {
log_warning(cds)("%s size has changed.", name);
}
log_warning(cds)("%s size has changed.", name);
}
}
}

View File

@@ -355,14 +355,6 @@ public final class ToolTipManager extends MouseAdapter implements MouseMotionLis
location.y);
popupFactory.setPopupType(PopupFactory.LIGHT_WEIGHT_POPUP);
if (isTooltipPositionedRelatively() && tipWindow.getComponent() != null) {
// When only relative positioning is available, we cannot know if
// the mouse is still over the "hot spot" area where tooltip needs
// to be shown. Instead, we allow the tooltip to remain visible
// as long as the mouse is over the tooltip window. To implement that,
// we want to know when the mouse enters that window.
tipWindow.getComponent().addMouseListener(this);
}
tipWindow.show();
Window componentWindow = SwingUtilities.windowForComponent(
@@ -386,9 +378,6 @@ public final class ToolTipManager extends MouseAdapter implements MouseMotionLis
window.removeMouseListener(this);
window = null;
}
if (isTooltipPositionedRelatively() && tipWindow.getComponent() != null) {
tipWindow.getComponent().removeMouseListener(this);
}
tipWindow.hide();
tipWindow = null;
tipShowing = false;
@@ -463,11 +452,6 @@ public final class ToolTipManager extends MouseAdapter implements MouseMotionLis
* @param event the event in question
*/
public void mouseEntered(MouseEvent event) {
if (isTooltipPositionedRelatively()) {
var source = event.getSource();
var tooltipComp = tipWindow != null ? tipWindow.getComponent() : null;
tooltipWindowEntered = source == tooltipComp;
}
initiateToolTip(event);
}
@@ -532,8 +516,6 @@ public final class ToolTipManager extends MouseAdapter implements MouseMotionLis
*/
public void mouseExited(MouseEvent event) {
boolean shouldHide = true;
boolean shouldHideImmediately = false;
if (insideComponent == null) {
// Drag exit
}
@@ -581,21 +563,9 @@ public final class ToolTipManager extends MouseAdapter implements MouseMotionLis
shouldHide = true;
}
}
} else if (isTooltipPositionedRelatively()) {
boolean hasExitedTooltipWindow = tipWindow != null && tipWindow.getComponent() == event.getSource();
if (hasExitedTooltipWindow) {
tooltipWindowEntered = false;
shouldHideImmediately = true;
}
}
if (shouldHide && !shouldHideImmediately && isTooltipPositionedRelatively()) {
// Let's wait for the tooltip window to get a chance to generate
// the "mouse enter" event. It usually doesn't take long;
// in fact, that event is probably in the queue already.
hideAttemptsCounter = 3;
SwingUtilities.invokeLater(this::maybeHideTipWindow);
} else if (shouldHide) {
if (shouldHide) {
enterTimer.stop();
if (insideComponent != null) {
insideComponent.removeMouseMotionListener(this);
@@ -608,19 +578,6 @@ public final class ToolTipManager extends MouseAdapter implements MouseMotionLis
}
}
private int hideAttemptsCounter = 0;
private boolean tooltipWindowEntered = false;
private void maybeHideTipWindow() {
if (tooltipWindowEntered) {
// Don't hide as the mouse is within the tooltip bounds
hideAttemptsCounter = 0;
} else if (hideAttemptsCounter-- > 0) {
SwingUtilities.invokeLater(this::maybeHideTipWindow);
} else {
hideTipWindow();
}
}
// implements java.awt.event.MouseListener
/**
* Called when the mouse is pressed.

View File

@@ -245,6 +245,8 @@ public class WLComponentPeer implements ComponentPeer {
if (isWlPopup) {
Window popup = (Window) target;
final Component popupParent = AWTAccessor.getWindowAccessor().getPopupParent(popup);
final int parentWidth = popupParent.getWidth();
final int parentHeight = popupParent.getHeight();
final Window toplevel = getToplevelFor(popupParent);
// We need to provide popup "parent" location relative to
// the surface it is painted upon:
@@ -267,9 +269,10 @@ public class WLComponentPeer implements ComponentPeer {
popupLog.fine("\toffset from anchor: " + offsetFromParent);
}
nativeCreateWLPopup(nativePtr, getParentNativePtr(target),
nativeCreateWLPopup(nativePtr,
getParentNativePtr(target), parentX, parentY, parentWidth, parentHeight,
thisWidth, thisHeight,
parentX + offsetX, parentY + offsetY);
offsetX, offsetY);
} else {
nativeCreateWLSurface(nativePtr,
getParentNativePtr(target),
@@ -453,6 +456,8 @@ public class WLComponentPeer implements ComponentPeer {
performLocked(() -> {
Window popup = (Window) target;
final Component popupParent = AWTAccessor.getWindowAccessor().getPopupParent(popup);
final int parentWidth = popupParent.getWidth();
final int parentHeight = popupParent.getHeight();
final Window toplevel = getToplevelFor(popupParent);
// We need to provide popup "parent" location relative to
// the surface it is painted upon:
@@ -468,7 +473,9 @@ public class WLComponentPeer implements ComponentPeer {
popupLog.fine("\toffset of anchor from toplevel: " + toplevelLocation);
popupLog.fine("\toffset from anchor: " + newX + ", " + newY);
}
nativeRepositionWLPopup(nativePtr, thisWidth, thisHeight, parentX + newX, parentY + newY);
nativeRepositionWLPopup(nativePtr, parentX, parentY, parentWidth, parentHeight,
thisWidth, thisHeight,
newX, newY);
} );
}
@@ -933,10 +940,14 @@ public class WLComponentPeer implements ComponentPeer {
String title, String appID);
protected native void nativeCreateWLPopup(long ptr, long parentPtr,
int parentX, int parentY,
int parentWidth, int parentHeight,
int width, int height,
int offsetX, int offsetY);
protected native void nativeRepositionWLPopup(long ptr,
int parentX, int parentY,
int parentWidth, int parentHeight,
int width, int height,
int offsetX, int offsetY);
protected native void nativeHideFrame(long ptr);

View File

@@ -482,7 +482,8 @@ Java_sun_awt_wl_WLComponentPeer_nativeCreateWLSurface
static struct xdg_positioner *
newPositioner
(jint width, jint height, jint offsetX, jint offsetY)
(jint parentX, jint parentY, jint parentWidth, jint parentHeight,
jint width, jint height, jint offsetX, jint offsetY)
{
struct xdg_positioner *xdg_positioner = xdg_wm_base_create_positioner(xdg_wm_base);
CHECK_NULL_RETURN(xdg_positioner, NULL);
@@ -491,20 +492,20 @@ newPositioner
// a non-zero size set by set_size, and a non-zero anchor rectangle
// set by set_anchor_rect."
xdg_positioner_set_size(xdg_positioner, width, height);
xdg_positioner_set_anchor_rect(xdg_positioner, offsetX, offsetY, 1, 1);
xdg_positioner_set_offset(xdg_positioner, 0, 0);
xdg_positioner_set_anchor(xdg_positioner, XDG_POSITIONER_ANCHOR_BOTTOM_LEFT);
xdg_positioner_set_anchor_rect(xdg_positioner, parentX, parentY, parentWidth, parentHeight);
xdg_positioner_set_offset(xdg_positioner, offsetX, offsetY);
xdg_positioner_set_anchor(xdg_positioner, XDG_POSITIONER_ANCHOR_TOP_LEFT);
xdg_positioner_set_gravity(xdg_positioner, XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT);
xdg_positioner_set_constraint_adjustment(xdg_positioner,
XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y
| XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X
| XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y);
xdg_positioner_set_constraint_adjustment(xdg_positioner, XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X |
XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y);
return xdg_positioner;
}
JNIEXPORT void JNICALL
Java_sun_awt_wl_WLComponentPeer_nativeCreateWLPopup
(JNIEnv *env, jobject obj, jlong ptr, jlong parentPtr,
jint parentX, jint parentY,
jint parentWidth, jint parentHeight,
jint width, jint height,
jint offsetX, jint offsetY)
{
@@ -521,7 +522,8 @@ Java_sun_awt_wl_WLComponentPeer_nativeCreateWLPopup
frame->toplevel = JNI_FALSE;
assert(parentFrame);
struct xdg_positioner *xdg_positioner = newPositioner(width, height, offsetX, offsetY);
struct xdg_positioner *xdg_positioner = newPositioner(parentX, parentY, parentWidth, parentHeight,
width, height, offsetX, offsetY);
CHECK_NULL(xdg_positioner);
frame->xdg_popup = xdg_surface_get_popup(frame->xdg_surface, parentFrame->xdg_surface, xdg_positioner);
CHECK_NULL(frame->xdg_popup);
@@ -538,6 +540,8 @@ Java_sun_awt_wl_WLComponentPeer_nativeCreateWLPopup
JNIEXPORT void JNICALL
Java_sun_awt_wl_WLComponentPeer_nativeRepositionWLPopup
(JNIEnv *env, jobject obj, jlong ptr,
jint parentX, jint parentY,
jint parentWidth, jint parentHeight,
jint width, jint height,
jint offsetX, jint offsetY)
{
@@ -545,7 +549,8 @@ Java_sun_awt_wl_WLComponentPeer_nativeRepositionWLPopup
assert (!frame->toplevel);
if (wl_proxy_get_version((struct wl_proxy *)xdg_wm_base) >= 3) {
struct xdg_positioner *xdg_positioner = newPositioner(width, height, offsetX, offsetY);
struct xdg_positioner *xdg_positioner = newPositioner(parentX, parentY, parentWidth, parentHeight,
width, height, offsetX, offsetY);
CHECK_NULL(xdg_positioner);
static int token = 42; // This will be received by xdg_popup_repositioned(); unused for now.
xdg_popup_reposition(frame->xdg_popup, xdg_positioner, token++);

View File

@@ -2312,8 +2312,7 @@ static Bool jbNewXimClient_initializeXICs(
return False;
}
if (xInputMethodConnection == NULL) {
// printf has been disabled because it pollutes stderr in environments without input methods
//jio_fprintf(stderr, "%s: xInputMethodConnection == NULL.\n", __func__);
jio_fprintf(stderr, "%s: xInputMethodConnection == NULL.\n", __func__);
return False;
}
if (pX11IMData == NULL) {

View File

@@ -108,7 +108,7 @@ public class WrongClasspath {
// message should be there.
output = TestCommon.execAuto(
"-cp", jars, "Hello");
output.shouldMatch("This file is not the one used while building the shared archive file:.*jar2.jar")
output.shouldMatch("A jar file is not the one used while building the shared archive file:.*jar2.jar")
.shouldMatch(".warning..cds.*jar2.jar timestamp has changed.");
}
}

View File

@@ -204,7 +204,7 @@ public class MainModuleOnly extends DynamicArchiveTestBase {
"--module-path", moduleDir.toString(),
"-m", TEST_MODULE1)
.assertAbnormalExit(
"This file is not the one used while building the shared archive file:");
"A jar file is not the one used while building the shared archive file:");
// create an archive with a non-empty directory in the --module-path.
// The dumping process will exit with an error due to non-empty directory
// in the --module-path.

View File

@@ -111,7 +111,7 @@ public class WrongTopClasspath extends DynamicArchiveTestBase {
"assertNotShared:GenericTestApp") // but top archive is not useable
.assertNormalExit(output -> {
output.shouldContain(topArchiveMsg);
output.shouldMatch("This file is not the one used while building the shared archive file:.*GenericTestApp.jar");
output.shouldMatch("A jar file is not the one used while building the shared archive file:.*GenericTestApp.jar");
output.shouldMatch(".warning..cds.*GenericTestApp.jar timestamp has changed.");});
}
}

View File

@@ -65,7 +65,7 @@ public class MainModuleOnly {
private static Path moduleDir2 = null;
private static Path destJar = null;
private static final String jarFileError = "This file is not the one used while building the shared archive file:";
private static final String jarFileError = "A jar file is not the one used while building the shared archive file:";
public static void buildTestModule() throws Exception {

View File

@@ -22,11 +22,7 @@
*/
import com.jetbrains.JBR;
import test.jb.testhelpers.TitleBar.TaskResult;
import test.jb.testhelpers.TitleBar.TestUtils;
import test.jb.testhelpers.TitleBar.Task;
import test.jb.testhelpers.TitleBar.CommonAPISuite;
import test.jb.testhelpers.utils.MouseUtils;
import util.*;
import javax.swing.*;
import java.awt.*;
@@ -38,8 +34,6 @@ import java.util.List;
* @test
* @summary Verify mouse events in custom title bar's area added by ActionListener
* @requires (os.family == "windows" | os.family == "mac")
* @library ../../../testhelpers/screenshot ../../../testhelpers/TitleBar ../../../testhelpers/utils
* @build TestUtils TaskResult Task CommonAPISuite MouseUtils ScreenShotHelpers Rect RectCoordinates MouseUtils
* @run main/othervm ActionListenerTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.0 ActionListenerTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.25 ActionListenerTest

View File

@@ -22,10 +22,10 @@
*/
import com.jetbrains.JBR;
import test.jb.testhelpers.TitleBar.CommonAPISuite;
import test.jb.testhelpers.TitleBar.TaskResult;
import test.jb.testhelpers.TitleBar.TestUtils;
import test.jb.testhelpers.TitleBar.Task;
import util.CommonAPISuite;
import util.Task;
import util.TaskResult;
import util.TestUtils;
import java.lang.invoke.MethodHandles;
@@ -33,8 +33,6 @@ import java.lang.invoke.MethodHandles;
* @test
* @summary Verify modifying of title bar height
* @requires (os.family == "windows" | os.family == "mac")
* @library ../../../testhelpers/screenshot ../../../testhelpers/TitleBar ../../../testhelpers/utils
* @build TestUtils TaskResult Task CommonAPISuite MouseUtils ScreenShotHelpers Rect RectCoordinates MouseUtils
* @run main/othervm ChangeTitleBarHeightTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.0 ChangeTitleBarHeightTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.25 ChangeTitleBarHeightTest

View File

@@ -1,29 +1,6 @@
/*
* Copyright 2000-2023 JetBrains s.r.o.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import com.jetbrains.JBR;
import com.jetbrains.WindowDecorations;
import test.jb.testhelpers.screenshot.ScreenShotHelpers;
import util.ScreenShotHelpers;
import java.awt.AWTException;
import java.awt.Color;
@@ -39,8 +16,6 @@ import java.io.IOException;
* @test
* @summary Verify modifying of title bar height
* @requires (os.family == "windows" | os.family == "mac")
* @library ../../../testhelpers/screenshot ../../../testhelpers/TitleBar ../../../testhelpers/utils
* @build TestUtils TaskResult Task CommonAPISuite MouseUtils ScreenShotHelpers Rect RectCoordinates MouseUtils
* @run main/othervm CheckFullScreen
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.0 CheckFullScreen
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.25 CheckFullScreen

View File

@@ -22,10 +22,10 @@
*/
import com.jetbrains.JBR;
import test.jb.testhelpers.TitleBar.CommonAPISuite;
import test.jb.testhelpers.TitleBar.TaskResult;
import test.jb.testhelpers.TitleBar.TestUtils;
import test.jb.testhelpers.TitleBar.Task;
import util.CommonAPISuite;
import util.Task;
import util.TaskResult;
import util.TestUtils;
import java.lang.invoke.MethodHandles;
@@ -33,8 +33,6 @@ import java.lang.invoke.MethodHandles;
* @test
* @summary Verify creating to a custom title bar
* @requires (os.family == "windows" | os.family == "mac")
* @library ../../../testhelpers/screenshot ../../../testhelpers/TitleBar ../../../testhelpers/utils
* @build TestUtils TaskResult Task CommonAPISuite MouseUtils ScreenShotHelpers Rect RectCoordinates MouseUtils
* @run main/othervm CreateTitleBarTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.0 CreateTitleBarTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.25 CreateTitleBarTest

View File

@@ -21,11 +21,7 @@
* questions.
*/
import com.jetbrains.JBR;
import test.jb.testhelpers.screenshot.ScreenShotHelpers;
import test.jb.testhelpers.screenshot.Rect;
import test.jb.testhelpers.TitleBar.TaskResult;
import test.jb.testhelpers.TitleBar.TestUtils;
import test.jb.testhelpers.TitleBar.Task;
import util.*;
import java.awt.event.InputEvent;
import java.awt.event.WindowAdapter;
@@ -40,8 +36,6 @@ import java.util.List;
* @test
* @summary Detect and check behavior of clicking to native controls
* @requires (os.family == "windows" | os.family == "mac")
* @library ../../../testhelpers/screenshot ../../../testhelpers/TitleBar ../../../testhelpers/utils
* @build TestUtils TaskResult Task CommonAPISuite MouseUtils ScreenShotHelpers Rect RectCoordinates MouseUtils
* @run main/othervm DialogNativeControlsTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.0 DialogNativeControlsTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.25 DialogNativeControlsTest

View File

@@ -0,0 +1,211 @@
/*
* Copyright 2000-2023 JetBrains s.r.o.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import com.jetbrains.JBR;
import com.jetbrains.WindowDecorations;
import util.*;
import javax.swing.JFrame;
import java.awt.Frame;
import java.awt.Window;
import java.awt.event.InputEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.awt.event.WindowStateListener;
import java.awt.image.BufferedImage;
import java.lang.invoke.MethodHandles;
import java.util.List;
import java.util.function.Function;
/*
* @test
* @summary Detect and check behavior of clicking to native controls
* @requires (os.family == "mac")
* @modules java.desktop/com.apple.eawt
* java.desktop/com.apple.eawt.event
* @run main/othervm FrameNativeControlsMacOSTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.0 FrameNativeControlsMacOSTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.25 FrameNativeControlsMacOSTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.5 FrameNativeControlsMacOSTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=2.0 FrameNativeControlsMacOSTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=2.5 FrameNativeControlsMacOSTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=3.0 FrameNativeControlsMacOSTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=3.5 FrameNativeControlsMacOSTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=4.0 FrameNativeControlsMacOSTest
*/
public class FrameNativeControlsMacOSTest {
public static void main(String... args) {
List<Function<WindowDecorations.CustomTitleBar, Window>> functions =
List.of(TestUtils::createFrameWithCustomTitleBar, TestUtils::createJFrameWithCustomTitleBar);
TaskResult result = CommonAPISuite.runTestSuite(functions, frameNativeControlsClicks);
if (!result.isPassed()) {
final String message = String.format("%s FAILED. %s", MethodHandles.lookup().lookupClass().getName(), result.getError());
throw new RuntimeException(message);
}
}
private static final Task frameNativeControlsClicks = new Task("Frame native controls clicks") {
private boolean closingActionCalled;
private boolean iconifyingActionCalled;
private boolean maximizingActionDetected;
private boolean deiconifyindActionDetected;
private final WindowListener windowListener = new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
closingActionCalled = true;
}
@Override
public void windowIconified(WindowEvent e) {
iconifyingActionCalled = true;
if (window.getName().equals("Frame")) {
((Frame) window).setState(Frame.NORMAL);
} else if (window.getName().equals("JFrame")) {
((JFrame) window).setState(JFrame.NORMAL);
}
window.setVisible(true);
window.requestFocus();
}
};
private final WindowStateListener windowStateListener = new WindowAdapter() {
@Override
public void windowStateChanged(WindowEvent e) {
System.out.println("change " + e.getOldState() + " -> " + e.getNewState());
if (e.getNewState() == 6) {
maximizingActionDetected = true;
}
if (e.getOldState() == 1 && e.getNewState() == 0) {
deiconifyindActionDetected = true;
}
}
};
@Override
public void prepareTitleBar() {
titleBar = JBR.getWindowDecorations().createCustomTitleBar();
titleBar.setHeight(TestUtils.TITLE_BAR_HEIGHT);
}
@Override
protected void init() {
closingActionCalled = false;
iconifyingActionCalled = false;
maximizingActionDetected = false;
deiconifyindActionDetected = false;
}
@Override
protected void cleanup() {
window.removeWindowListener(windowListener);
window.removeWindowStateListener(windowStateListener);
}
@Override
protected void customizeWindow() {
window.addWindowListener(windowListener);
window.addWindowStateListener(windowStateListener);
if (window.getName().equals("JFrame")) {
com.apple.eawt.FullScreenUtilities.addFullScreenListenerTo(window, new com.apple.eawt.FullScreenListener() {
@Override
public void windowEnteringFullScreen(com.apple.eawt.event.FullScreenEvent fse) {
maximizingActionDetected = true;
}
@Override
public void windowEnteredFullScreen(com.apple.eawt.event.FullScreenEvent fse) {
}
@Override
public void windowExitingFullScreen(com.apple.eawt.event.FullScreenEvent fse) {
}
@Override
public void windowExitedFullScreen(com.apple.eawt.event.FullScreenEvent fse) {
}
});
}
}
@Override
public void test() throws Exception {
robot.delay(500);
robot.mouseMove(window.getLocationOnScreen().x + window.getWidth() / 2,
window.getLocationOnScreen().y + window.getHeight() / 2);
robot.delay(500);
BufferedImage image = ScreenShotHelpers.takeScreenshot(window);
List<Rect> foundControls = ScreenShotHelpers.findControls(image, window, titleBar);
if (foundControls.size() == 0) {
passed = false;
System.out.println("Error: no controls found");
}
foundControls.forEach(control -> {
System.out.println("Using control: " + control);
int x = window.getLocationOnScreen().x + control.getX1() + (control.getX2() - control.getX1()) / 2;
int y = window.getLocationOnScreen().y + control.getY1() + (control.getY2() - control.getY1()) / 2;
System.out.println("Click to (" + x + ", " + y + ")");
int screenX = window.getBounds().x;
int screenY = window.getBounds().y;
int h = window.getBounds().height;
int w = window.getBounds().width;
robot.waitForIdle();
robot.mouseMove(x, y);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robot.waitForIdle();
window.setBounds(screenX, screenY, w, h);
window.setVisible(true);
robot.waitForIdle();
});
if (!maximizingActionDetected) {
err("maximizing action was not detected");
}
if (!closingActionCalled) {
err("closing action was not detected");
}
if (!iconifyingActionCalled) {
err("iconifying action was not detected");
}
if (!deiconifyindActionDetected) {
err("deiconifying action was not detected");
}
}
};
}

View File

@@ -22,12 +22,13 @@
*/
import com.jetbrains.JBR;
import com.jetbrains.WindowDecorations;
import test.jb.testhelpers.screenshot.ScreenShotHelpers;
import test.jb.testhelpers.screenshot.Rect;
import test.jb.testhelpers.TitleBar.TaskResult;
import test.jb.testhelpers.TitleBar.TestUtils;
import test.jb.testhelpers.TitleBar.Task;
import test.jb.testhelpers.TitleBar.CommonAPISuite;
import util.CommonAPISuite;
import util.Rect;
import util.ScreenShotHelpers;
import util.Task;
import util.TestUtils;
import util.TaskResult;
import javax.swing.JFrame;
import java.awt.Frame;
import java.awt.Window;
@@ -44,9 +45,7 @@ import java.util.function.Function;
/*
* @test
* @summary Detect and check behavior of clicking to native controls
* @requires (os.family == "windows") | (os.family == "mac")
* @library ../../../testhelpers/screenshot ../../../testhelpers/TitleBar ../../../testhelpers/utils
* @build TestUtils TaskResult Task CommonAPISuite MouseUtils ScreenShotHelpers Rect RectCoordinates MouseUtils
* @requires (os.family == "windows")
* @run main/othervm FrameNativeControlsTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.0 FrameNativeControlsTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.25 FrameNativeControlsTest
@@ -60,7 +59,8 @@ import java.util.function.Function;
public class FrameNativeControlsTest {
public static void main(String... args) {
List<Function<WindowDecorations.CustomTitleBar, Window>> functions = List.of(TestUtils::createFrameWithCustomTitleBar);
List<Function<WindowDecorations.CustomTitleBar, Window>> functions =
List.of(TestUtils::createFrameWithCustomTitleBar, TestUtils::createJFrameWithCustomTitleBar);
TaskResult result = CommonAPISuite.runTestSuite(functions, frameNativeControlsClicks);
if (!result.isPassed()) {
@@ -145,7 +145,7 @@ public class FrameNativeControlsTest {
BufferedImage image = ScreenShotHelpers.takeScreenshot(window);
List<Rect> foundControls = ScreenShotHelpers.findControls(image, window, titleBar);
if (foundControls.isEmpty()) {
if (foundControls.size() == 0) {
passed = false;
System.out.println("Error: no controls found");
}

View File

@@ -21,13 +21,7 @@
* questions.
*/
import com.jetbrains.JBR;
import test.jb.testhelpers.screenshot.ScreenShotHelpers;
import test.jb.testhelpers.screenshot.Rect;
import test.jb.testhelpers.TitleBar.CommonAPISuite;
import test.jb.testhelpers.TitleBar.TaskResult;
import test.jb.testhelpers.TitleBar.TestUtils;
import test.jb.testhelpers.TitleBar.Task;
import util.*;
import java.awt.Robot;
import java.awt.image.BufferedImage;
@@ -38,8 +32,6 @@ import java.util.List;
* @test
* @summary Verify a property to change visibility of native controls
* @requires (os.family == "windows" | os.family == "mac")
* @library ../../../testhelpers/screenshot ../../../testhelpers/TitleBar ../../../testhelpers/utils
* @build TestUtils TaskResult Task CommonAPISuite MouseUtils ScreenShotHelpers Rect RectCoordinates MouseUtils
* @run main/othervm HiddenNativeControlsTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.0 HiddenNativeControlsTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.25 HiddenNativeControlsTest
@@ -97,7 +89,7 @@ public class HiddenNativeControlsTest {
System.out.println("Found controls at the title bar:");
foundControls.forEach(System.out::println);
if (!foundControls.isEmpty()) {
if (foundControls.size() != 0) {
err("controls are disabled, but found in the screenshot");
}

View File

@@ -22,15 +22,10 @@
*/
import com.jetbrains.JBR;
import util.*;
import test.jb.testhelpers.TitleBar.TaskResult;
import test.jb.testhelpers.TitleBar.TestUtils;
import test.jb.testhelpers.TitleBar.Task;
import test.jb.testhelpers.TitleBar.CommonAPISuite;
import test.jb.testhelpers.utils.MouseUtils;
import util.AWTTask;
import util.SwingTask;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.*;
import java.awt.event.InputEvent;
@@ -44,8 +39,6 @@ import java.util.List;
* @test
* @summary Verify control under native actions in custom title bar
* @requires (os.family == "windows" | os.family == "mac")
* @library ../../../testhelpers/screenshot ../../../testhelpers/TitleBar ../../../testhelpers/utils
* @build TestUtils TaskResult Task CommonAPISuite MouseUtils ScreenShotHelpers Rect RectCoordinates MouseUtils
* @run main/othervm HitTestClientArea
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.0 HitTestClientArea
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.25 HitTestClientArea

View File

@@ -23,11 +23,7 @@
import com.jetbrains.JBR;
import util.*;
import test.jb.testhelpers.TitleBar.CommonAPISuite;
import test.jb.testhelpers.TitleBar.TaskResult;
import test.jb.testhelpers.TitleBar.TestUtils;
import test.jb.testhelpers.TitleBar.Task;
import test.jb.testhelpers.utils.MouseUtils;
import javax.swing.*;
import java.awt.AWTException;
import java.awt.Button;
@@ -46,8 +42,6 @@ import java.util.List;
* @test
* @summary Verify control under native actions in custom title bar
* @requires (os.family == "windows" | os.family == "mac")
* @library ../../../testhelpers/screenshot ../../../testhelpers/TitleBar ../../../testhelpers/utils
* @build TestUtils TaskResult Task CommonAPISuite MouseUtils ScreenShotHelpers Rect RectCoordinates MouseUtils
* @run main/othervm HitTestNonClientArea
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.0 HitTestNonClientArea
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.25 HitTestNonClientArea

View File

@@ -22,12 +22,7 @@
*/
import com.jetbrains.JBR;
import util.*;
import test.jb.testhelpers.screenshot.ScreenShotHelpers;
import test.jb.testhelpers.screenshot.Rect;
import test.jb.testhelpers.TitleBar.CommonAPISuite;
import test.jb.testhelpers.TitleBar.TaskResult;
import test.jb.testhelpers.TitleBar.TestUtils;
import test.jb.testhelpers.TitleBar.Task;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.awt.event.WindowAdapter;
@@ -42,8 +37,6 @@ import java.util.List;
* @test
* @summary Detect and check behavior of clicking to native controls
* @requires (os.family == "windows" | os.family == "mac")
* @library ../../../testhelpers/screenshot ../../../testhelpers/TitleBar ../../../testhelpers/utils
* @build TestUtils TaskResult Task CommonAPISuite MouseUtils ScreenShotHelpers Rect RectCoordinates MouseUtils
* @run main/othervm JDialogNativeControlsTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.0 JDialogNativeControlsTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.25 JDialogNativeControlsTest

View File

@@ -23,10 +23,10 @@
import com.jetbrains.JBR;
import com.jetbrains.WindowDecorations;
import test.jb.testhelpers.TitleBar.CommonAPISuite;
import test.jb.testhelpers.TitleBar.TaskResult;
import test.jb.testhelpers.TitleBar.TestUtils;
import test.jb.testhelpers.TitleBar.Task;
import util.CommonAPISuite;
import util.Task;
import util.TaskResult;
import util.TestUtils;
import java.awt.AWTException;
import java.awt.Dialog;
@@ -42,8 +42,6 @@ import java.util.function.Function;
* @test
* @summary Verify ability to maximize window by clicking to custom title bar area
* @requires (os.family == "windows" | os.family == "mac")
* @library ../../../testhelpers/screenshot ../../../testhelpers/TitleBar ../../../testhelpers/utils
* @build TestUtils TaskResult Task CommonAPISuite MouseUtils ScreenShotHelpers Rect RectCoordinates MouseUtils
* @run main/othervm MaximizeWindowTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.0 MaximizeWindowTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.25 MaximizeWindowTest

View File

@@ -40,8 +40,6 @@ import java.util.concurrent.TimeUnit;
* @test
* @summary Regression test for JBR-3157 Maximized window with custom decorations isn't focused on showing
* @requires (os.family == "windows" | os.family == "mac")
* @library ../../../testhelpers/screenshot ../../../testhelpers/TitleBar ../../../testhelpers/utils
* @build TestUtils TaskResult Task CommonAPISuite MouseUtils ScreenShotHelpers Rect RectCoordinates MouseUtils
* @run main/othervm MaximizedWindowFocusTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.0 MaximizedWindowFocusTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=2.0 MaximizedWindowFocusTest

View File

@@ -23,12 +23,7 @@
import com.jetbrains.JBR;
import util.*;
import test.jb.testhelpers.screenshot.ScreenShotHelpers;
import test.jb.testhelpers.screenshot.Rect;
import test.jb.testhelpers.TitleBar.CommonAPISuite;
import test.jb.testhelpers.TitleBar.TaskResult;
import test.jb.testhelpers.TitleBar.TestUtils;
import test.jb.testhelpers.TitleBar.Task;
import java.awt.Frame;
import java.awt.event.InputEvent;
import java.awt.event.WindowAdapter;
@@ -43,8 +38,6 @@ import java.util.List;
* @test
* @summary Detect and check behavior of clicking to native controls
* @requires (os.family == "windows" | os.family == "mac")
* @library ../../../testhelpers/screenshot ../../../testhelpers/TitleBar ../../../testhelpers/utils
* @build TestUtils TaskResult Task CommonAPISuite MouseUtils ScreenShotHelpers Rect RectCoordinates MouseUtils
* @run main/othervm MinimizingWindowTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.0 MinimizingWindowTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.25 MinimizingWindowTest

View File

@@ -23,10 +23,7 @@
import com.jetbrains.JBR;
import com.jetbrains.WindowDecorations;
import util.*;
import test.jb.testhelpers.TitleBar.CommonAPISuite;
import test.jb.testhelpers.TitleBar.TaskResult;
import test.jb.testhelpers.TitleBar.TestUtils;
import test.jb.testhelpers.TitleBar.Task;
import javax.swing.*;
import java.awt.*;
import java.awt.event.InputEvent;
@@ -42,8 +39,6 @@ import java.util.concurrent.TimeUnit;
* @test
* @summary Verify mouse events on custom title bar area
* @requires (os.family == "windows" | os.family == "mac")
* @library ../../../testhelpers/screenshot ../../../testhelpers/TitleBar ../../../testhelpers/utils
* @build TestUtils TaskResult Task CommonAPISuite MouseUtils ScreenShotHelpers Rect RectCoordinates MouseUtils
* @run main/othervm MouseEventsOnClientArea
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.0 MouseEventsOnClientArea
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.25 MouseEventsOnClientArea

View File

@@ -22,23 +22,17 @@
*/
import com.jetbrains.JBR;
import test.jb.testhelpers.screenshot.ScreenShotHelpers;
import test.jb.testhelpers.screenshot.Rect;
import test.jb.testhelpers.TitleBar.CommonAPISuite;
import test.jb.testhelpers.TitleBar.TaskResult;
import test.jb.testhelpers.TitleBar.TestUtils;
import test.jb.testhelpers.TitleBar.Task;
import util.*;
import java.awt.Robot;
import java.util.List;
import java.awt.image.BufferedImage;
import java.lang.invoke.MethodHandles;
import java.util.List;
/*
* @test
* @summary Verify a property to change visibility of native controls
* @requires (os.family == "windows" | os.family == "mac")
* @library ../../../testhelpers/screenshot ../../../testhelpers/TitleBar ../../../testhelpers/utils
* @build TestUtils TaskResult Task CommonAPISuite MouseUtils ScreenShotHelpers Rect RectCoordinates MouseUtils
* @run main/othervm NativeControlsVisibilityTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.0 NativeControlsVisibilityTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.25 NativeControlsVisibilityTest

View File

@@ -21,13 +21,7 @@
* questions.
*/
import com.jetbrains.JBR;
import test.jb.testhelpers.screenshot.ScreenShotHelpers;
import test.jb.testhelpers.screenshot.Rect;
import test.jb.testhelpers.screenshot.RectCoordinates;
import test.jb.testhelpers.TitleBar.CommonAPISuite;
import test.jb.testhelpers.TitleBar.TaskResult;
import test.jb.testhelpers.TitleBar.TestUtils;
import test.jb.testhelpers.TitleBar.Task;
import util.*;
import java.awt.Dimension;
import java.awt.Robot;
@@ -39,8 +33,6 @@ import java.lang.invoke.MethodHandles;
* @test
* @summary Verify custom title bar in case of window resizing
* @requires (os.family == "windows" | os.family == "mac")
* @library ../../../testhelpers/screenshot ../../../testhelpers/TitleBar ../../../testhelpers/utils
* @build TestUtils TaskResult Task CommonAPISuite MouseUtils ScreenShotHelpers Rect RectCoordinates MouseUtils
* @run main/othervm WindowResizeTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.0 WindowResizeTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.25 WindowResizeTest

View File

@@ -21,10 +21,10 @@
* questions.
*/
import com.jetbrains.JBR;
import test.jb.testhelpers.TitleBar.CommonAPISuite;
import test.jb.testhelpers.TitleBar.TaskResult;
import test.jb.testhelpers.TitleBar.TestUtils;
import test.jb.testhelpers.TitleBar.Task;
import util.CommonAPISuite;
import util.Task;
import util.TaskResult;
import util.TestUtils;
import java.awt.Robot;
import java.lang.invoke.MethodHandles;
@@ -33,8 +33,6 @@ import java.lang.invoke.MethodHandles;
* @test
* @summary Verify custom title bar in case of changing visibility of a window
* @requires (os.family == "windows" | os.family == "mac")
* @library ../../../testhelpers/screenshot ../../../testhelpers/TitleBar ../../../testhelpers/utils
* @build TestUtils TaskResult Task CommonAPISuite MouseUtils ScreenShotHelpers Rect RectCoordinates MouseUtils
* @run main/othervm WindowVisibilityTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.0 WindowVisibilityTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.25 WindowVisibilityTest

View File

@@ -22,12 +22,7 @@
*/
import com.jetbrains.JBR;
import test.jb.testhelpers.screenshot.ScreenShotHelpers;
import test.jb.testhelpers.screenshot.Rect;
import test.jb.testhelpers.TitleBar.CommonAPISuite;
import test.jb.testhelpers.TitleBar.TaskResult;
import test.jb.testhelpers.TitleBar.TestUtils;
import test.jb.testhelpers.TitleBar.Task;
import util.*;
import java.awt.Color;
import java.awt.Robot;
@@ -39,8 +34,6 @@ import java.util.List;
* @test
* @summary Verify a property to change visibility of native controls
* @requires os.family == "windows"
* @library ../../../testhelpers/screenshot ../../../testhelpers/TitleBar ../../../testhelpers/utils
* @build TestUtils TaskResult Task CommonAPISuite MouseUtils ScreenShotHelpers Rect RectCoordinates MouseUtils
* @run main/othervm WindowsControlWidthTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.0 WindowsControlWidthTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.25 WindowsControlWidthTest

View File

@@ -2,9 +2,6 @@ package util;
import com.jetbrains.WindowDecorations;
import test.jb.testhelpers.TitleBar.Task;
import test.jb.testhelpers.TitleBar.TaskResult;
import test.jb.testhelpers.TitleBar.TestUtils;
import java.awt.*;
import java.util.function.Function;

View File

@@ -20,12 +20,11 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.jb.testhelpers.TitleBar;
package util;
import com.jetbrains.WindowDecorations;
import test.jb.testhelpers.TitleBar.TaskResult;
import test.jb.testhelpers.TitleBar.Task;
import java.awt.Window;
import java.util.ArrayList;
import java.util.List;

View File

@@ -1,29 +1,6 @@
/*
* Copyright 2000-2023 JetBrains s.r.o.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.jb.testhelpers.utils;
package util;
import java.awt.Robot;
import java.awt.Window;
import java.awt.*;
public class MouseUtils {

View File

@@ -20,9 +20,9 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.jb.testhelpers.screenshot;
package util;
import java.awt.*;
import java.awt.Color;
import java.util.Objects;
public class Rect {

View File

@@ -20,7 +20,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.jb.testhelpers.screenshot;
package util;
public record RectCoordinates(int x1, int y1, int x2, int y2) {

View File

@@ -20,15 +20,11 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.jb.testhelpers.screenshot;
package util;
import com.jetbrains.WindowDecorations;
import test.jb.testhelpers.screenshot.Rect;
import test.jb.testhelpers.screenshot.RectCoordinates;
import test.jb.testhelpers.TitleBar.TestUtils;
import javax.imageio.ImageIO;
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Rectangle;
@@ -50,9 +46,10 @@ public class ScreenShotHelpers {
Robot robot = new Robot();
robot.delay(1000);
return robot.createScreenCapture(
final BufferedImage screenShot = robot.createScreenCapture(
new Rectangle(window.getLocationOnScreen().x, window.getLocationOnScreen().y,
window.getWidth(), window.getHeight()));
return screenShot;
}
public static String storeScreenshot(String namePrefix, BufferedImage image) throws IOException {
@@ -280,7 +277,7 @@ public class ScreenShotHelpers {
}
public static List<Rect> detectControls(BufferedImage image, int titleBarHeight, int leftInset, int rightInset) {
RectCoordinates coords = findRectangleTitleBar(image, titleBarHeight);
RectCoordinates coords = ScreenShotHelpers.findRectangleTitleBar(image, titleBarHeight);
System.out.println("Detect controls");
System.out.println(coords);
@@ -403,4 +400,4 @@ public class ScreenShotHelpers {
}
}
}

View File

@@ -2,9 +2,6 @@ package util;
import com.jetbrains.WindowDecorations;
import test.jb.testhelpers.TitleBar.Task;
import test.jb.testhelpers.TitleBar.TaskResult;
import test.jb.testhelpers.TitleBar.TestUtils;
import javax.swing.*;
import java.awt.*;
import java.util.function.Function;

View File

@@ -20,15 +20,13 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.jb.testhelpers.TitleBar;
package util;
import com.jetbrains.WindowDecorations;
import test.jb.testhelpers.TitleBar.TaskResult;
import test.jb.testhelpers.TitleBar.TestUtils;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.Window;
import java.awt.*;
import java.lang.reflect.InvocationTargetException;
import java.util.function.Function;
abstract public class Task {

View File

@@ -0,0 +1,35 @@
package util;
public class TaskResult {
private final boolean passed;
private final boolean metConditions;
private final String error;
public TaskResult(boolean passed, String error) {
this.passed = passed;
this.metConditions = true;
this.error = error;
}
public TaskResult(boolean metConditions, boolean passed, String error) {
this.metConditions = metConditions;
this.passed = passed;
this.error = error;
}
public boolean isPassed() {
return passed;
}
public String getError() {
return error;
}
public TaskResult merge(TaskResult another) {
final String error = this.error + "\n" + another.error;
final boolean status = this.passed && another.passed;
return new TaskResult(status, error);
}
}

View File

@@ -20,13 +20,24 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.jb.testhelpers.TitleBar;
package util;
import com.jetbrains.JBR;
import com.jetbrains.WindowDecorations;
import javax.swing.*;
import java.awt.*;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.Window;
import java.util.List;
import java.util.function.Function;

View File

@@ -1,232 +0,0 @@
/*
* Copyright 2000-2023 JetBrains s.r.o.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import com.apple.eawt.FullScreenListener;
import com.apple.eawt.FullScreenUtilities;
import com.apple.eawt.event.FullScreenEvent;
import com.jetbrains.JBR;
import com.jetbrains.WindowDecorations;
import test.jb.testhelpers.TitleBar.TestUtils;
import test.jb.testhelpers.screenshot.ScreenShotHelpers;
import test.jb.testhelpers.screenshot.Rect;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import java.awt.Robot;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.util.List;
/*
* @test
* @summary Detect and check behavior of clicking to native controls
* @requires (os.family == "mac")
* @library ../../../testhelpers/screenshot ../../../testhelpers/TitleBar
* @build TestUtils ScreenShotHelpers Rect RectCoordinates
* @modules java.desktop/com.apple.eawt
* java.desktop/com.apple.eawt.event
* @run main/othervm JFrameNativeControlsMacOSTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.0 JFrameNativeControlsMacOSTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.25 JFrameNativeControlsMacOSTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1.5 JFrameNativeControlsMacOSTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=2.0 JFrameNativeControlsMacOSTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=2.5 JFrameNativeControlsMacOSTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=3.0 JFrameNativeControlsMacOSTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=3.5 JFrameNativeControlsMacOSTest
* @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=4.0 JFrameNativeControlsMacOSTest
*/
public class JFrameNativeControlsMacOSTest {
private static WindowDecorations.CustomTitleBar titleBar;
private static JFrame jFrame;
private static WindowListener windowListener;
private static WindowStateListener windowStateListener;
private static FullScreenListener fullScreenListener;
private static boolean closingActionCalled = false;
private static boolean iconifyingActionCalled = false;
private static volatile boolean maximizingActionDetected = false;
private static boolean deiconifyindActionDetected = false;
private static boolean passed = true;
private static String error = "";
private static Robot robot;
public static void main(String... args) throws Exception {
robot = new Robot();
robot.setAutoDelay(50);
try {
SwingUtilities.invokeAndWait(JFrameNativeControlsMacOSTest::prepareUI);
robot.delay(500);
robot.mouseMove(jFrame.getLocationOnScreen().x + jFrame.getWidth() / 2,
jFrame.getLocationOnScreen().y + jFrame.getHeight() / 2);
robot.delay(500);
BufferedImage image = ScreenShotHelpers.takeScreenshot(jFrame);
List<Rect> foundControls = ScreenShotHelpers.findControls(image, jFrame, titleBar);
if (foundControls.isEmpty()) {
System.out.println("Error: no controls found");
}
foundControls.forEach(control -> {
System.out.println("Using control: " + control);
int x = jFrame.getLocationOnScreen().x + control.getX1() + (control.getX2() - control.getX1()) / 2;
int y = jFrame.getLocationOnScreen().y + control.getY1() + (control.getY2() - control.getY1()) / 2;
System.out.println("Click to (" + x + ", " + y + ")");
int screenX = jFrame.getBounds().x;
int screenY = jFrame.getBounds().y;
int h = jFrame.getBounds().height;
int w = jFrame.getBounds().width;
robot.waitForIdle();
robot.mouseMove(x, y);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robot.waitForIdle();
if (maximizingActionDetected) {
robot.keyPress(KeyEvent.VK_META);
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_F);
robot.keyRelease(KeyEvent.VK_META);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_F);
robot.delay(500);
}
jFrame.setBounds(screenX, screenY, w, h);
jFrame.setVisible(true);
robot.waitForIdle();
});
} finally {
SwingUtilities.invokeAndWait(JFrameNativeControlsMacOSTest::disposeUI);
}
if (!maximizingActionDetected) {
err("maximizing action was not detected");
}
if (!closingActionCalled) {
err("closing action was not detected");
}
if (!iconifyingActionCalled) {
err("iconifying action was not detected");
}
if (!deiconifyindActionDetected) {
err("deiconifying action was not detected");
}
if (!passed) {
System.out.println("TEST FAILED");
} else {
System.out.println("TEST PASSED");
}
}
private static void prepareUI() {
titleBar = JBR.getWindowDecorations().createCustomTitleBar();
titleBar.setHeight(TestUtils.TITLE_BAR_HEIGHT);
jFrame = TestUtils.createJFrameWithCustomTitleBar(titleBar);
addWindowListener();
addWindowStateListener();
addMacOsFullScreenListener();
jFrame.setVisible(true);
jFrame.setAlwaysOnTop(true);
jFrame.requestFocus();
}
private static void disposeUI() {
jFrame.removeWindowListener(windowListener);
jFrame.removeWindowStateListener(windowStateListener);
FullScreenUtilities.removeFullScreenListenerFrom(jFrame, fullScreenListener);
if (jFrame != null) {
jFrame.dispose();
}
}
private static void addWindowListener() {
windowListener = new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
closingActionCalled = true;
}
@Override
public void windowIconified(WindowEvent e) {
iconifyingActionCalled = true;
jFrame.setState(JFrame.NORMAL);
jFrame.setVisible(true);
jFrame.requestFocus();
}
};
jFrame.addWindowListener(windowListener);
}
private static void addWindowStateListener() {
windowStateListener = new WindowAdapter() {
@Override
public void windowStateChanged(WindowEvent e) {
System.out.println("change " + e.getOldState() + " -> " + e.getNewState());
if (e.getNewState() == 6) {
maximizingActionDetected = true;
}
if (e.getOldState() == 1 && e.getNewState() == 0) {
deiconifyindActionDetected = true;
}
}
};
jFrame.addWindowStateListener(windowStateListener);
}
private static void addMacOsFullScreenListener() {
fullScreenListener = new FullScreenListener() {
@Override
public void windowEnteringFullScreen(FullScreenEvent fse) {
maximizingActionDetected = true;
}
@Override
public void windowEnteredFullScreen(FullScreenEvent fse) {
}
@Override
public void windowExitingFullScreen(FullScreenEvent fse) {
System.out.println("Exiting fullscreen");
}
@Override
public void windowExitedFullScreen(FullScreenEvent fse) {
System.out.println("Exited fullscreen");
}
};
FullScreenUtilities.addFullScreenListenerTo(jFrame, fullScreenListener);
}
private static void err(String message) {
error = error + message + "\n";
passed = false;
System.out.println(message);
}
}

View File

@@ -25,13 +25,11 @@ import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.plaf.FontUIResource;
/* @test
@@ -56,7 +54,8 @@ public class JLabel269 {
}
}
public static void main(String[] args) throws InterruptedException, InvocationTargetException {
public static void main(String[] args) {
String labelText = "<html><body><code>A</code></body></html>";
verbose = Arrays.asList(args).contains("-verbose");
@@ -64,27 +63,23 @@ public class JLabel269 {
JFrame mainFrame = new JFrame();
JPanel container = new JPanel();
container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS));
JPanel p1 = new JPanel();
JLabel l1 = new JLabelTest(labelText);
l1.setFont(new FontUIResource("Tahoma", Font.PLAIN, 36));
p1.add(l1);
container.add(p1);
JPanel p2 = new JPanel();
JLabel l2 = new JLabelTest(labelText);
l2.setFont(new FontUIResource("Tahoma", Font.PLAIN, 72));
p2.add(l2);
container.add(p2);
SwingUtilities.invokeAndWait(() -> {
container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS));
l1.setFont(new FontUIResource("Tahoma", Font.PLAIN, 36));
p1.add(l1);
container.add(p1);
l2.setFont(new FontUIResource("Tahoma", Font.PLAIN, 72));
p2.add(l2);
container.add(p2);
mainFrame.add(container);
mainFrame.pack();
mainFrame.setVisible(true);
});
mainFrame.add(container);
mainFrame.pack();
mainFrame.setVisible(true);
BufferedImage bi = new BufferedImage(
l1.getWidth(), l1.getHeight(), BufferedImage.TYPE_INT_ARGB);

View File

@@ -1,56 +0,0 @@
/*
* Copyright 2000-2023 JetBrains s.r.o.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.jb.testhelpers.TitleBar;
public class TaskResult {
private final boolean passed;
private final boolean metConditions;
private final String error;
public TaskResult(boolean passed, String error) {
this.passed = passed;
this.metConditions = true;
this.error = error;
}
public TaskResult(boolean metConditions, boolean passed, String error) {
this.metConditions = metConditions;
this.passed = passed;
this.error = error;
}
public boolean isPassed() {
return passed;
}
public String getError() {
return error;
}
public TaskResult merge(TaskResult another) {
final String error = this.error + "\n" + another.error;
final boolean status = this.passed && another.passed;
return new TaskResult(status, error);
}
}

View File

@@ -927,7 +927,6 @@ javax/swing/JOptionPane/7138665/bug7138665.java JBR-5799 windows-all
javax/swing/JOptionPane/8081019/bug8081019.java JBR-5767 windows-all
javax/swing/JPopupMenu/6415145/bug6415145.java 8197552 windows-all
javax/swing/JPopupMenu/6515446/bug6515446.java 8197552 windows-all
javax/swing/JPopupMenu/SetInvokerJPopupMenuTest.java JBR-6021 linux-all
javax/swing/JRadioButton/8033699/bug8033699.java 8197552 windows-all
javax/swing/JRadioButton/8075609/bug8075609.java 8197552,8266085,JBR-5510 windows-all,linux-5.18.2-arch1-1
javax/swing/JRadioButton/ButtonGroupFocus/ButtonGroupFocusTest.java 8197552,8266085 windows-all