8144125: [macOS] java/awt/event/ComponentEvent/MovedResizedTwiceTest/MovedResizedTwiceTest.java failed automatically
Reviewed-by: dmarkov
--- a/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java Wed May 08 14:34:21 2019 -0700
+++ b/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java Wed May 08 16:19:22 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,48 +23,64 @@
* questions.
*/
-
package sun.lwawt;
-import java.awt.*;
-
+import java.awt.AWTEvent;
+import java.awt.AWTException;
+import java.awt.BufferCapabilities;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.GraphicsConfiguration;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Toolkit;
+import java.awt.Window;
import java.awt.dnd.DropTarget;
import java.awt.dnd.peer.DropTargetPeer;
-import java.awt.event.*;
-
+import java.awt.event.AWTEventListener;
+import java.awt.event.ComponentEvent;
+import java.awt.event.FocusEvent;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.PaintEvent;
import java.awt.image.ColorModel;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.image.VolatileImage;
-
import java.awt.peer.ComponentPeer;
import java.awt.peer.ContainerPeer;
-
import java.awt.peer.KeyboardFocusManagerPeer;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.lang.reflect.Field;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.util.concurrent.atomic.AtomicBoolean;
-import sun.awt.*;
+import javax.swing.JComponent;
+import javax.swing.RepaintManager;
+import javax.swing.SwingUtilities;
+import com.sun.java.swing.SwingUtilities3;
+import sun.awt.AWTAccessor;
+import sun.awt.PaintEventDispatcher;
+import sun.awt.RepaintArea;
+import sun.awt.SunToolkit;
import sun.awt.event.IgnorePaintEvent;
-
import sun.awt.image.SunVolatileImage;
import sun.awt.image.ToolkitImage;
-
import sun.java2d.SunGraphics2D;
import sun.java2d.opengl.OGLRenderQueue;
import sun.java2d.pipe.Region;
-
import sun.util.logging.PlatformLogger;
-import javax.swing.JComponent;
-import javax.swing.SwingUtilities;
-import javax.swing.RepaintManager;
-
-import com.sun.java.swing.SwingUtilities3;
-
public abstract class LWComponentPeer<T extends Component, D extends JComponent>
implements ComponentPeer, DropTargetPeer
{
@@ -1105,9 +1121,9 @@
final boolean updateTarget) {
if (updateTarget) {
AWTAccessor.getComponentAccessor().setLocation(getTarget(), x, y);
+ postEvent(new ComponentEvent(getTarget(),
+ ComponentEvent.COMPONENT_MOVED));
}
- postEvent(new ComponentEvent(getTarget(),
- ComponentEvent.COMPONENT_MOVED));
}
/**
@@ -1129,9 +1145,9 @@
if (updateTarget) {
AWTAccessor.getComponentAccessor().setSize(getTarget(), w, h);
+ postEvent(new ComponentEvent(getTarget(),
+ ComponentEvent.COMPONENT_RESIZED));
}
- postEvent(new ComponentEvent(getTarget(),
- ComponentEvent.COMPONENT_RESIZED));
}
protected final void repaintOldNewBounds(final Rectangle oldB) {
--- a/test/jdk/java/awt/event/ComponentEvent/MovedResizedTwiceTest/MovedResizedTwiceTest.java Wed May 08 14:34:21 2019 -0700
+++ b/test/jdk/java/awt/event/ComponentEvent/MovedResizedTwiceTest/MovedResizedTwiceTest.java Wed May 08 16:19:22 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,18 +25,24 @@
/*
@test
- @bug 5025858
+ @key headful
+ @bug 5025858 8144125
@summary Tests that after programmatically moving or resizing a component,
-corresponding ComponentEvents are generated only once
- @author artem.ananiev: area=awt.event
- @run main/manual MovedResizedTwiceTest
+ corresponding ComponentEvents are generated only once
*/
-import java.awt.*;
-import java.awt.event.*;
+import java.awt.Button;
+import java.awt.Component;
+import java.awt.Frame;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.Window;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
/*
- IMPORTANT: this test is made manual as some window managers may generate
+ IMPORTANT: this test can fail because some window managers may generate
strange events and that would lead to the test to fail. However, on most
popular platforms (windows, linux w/ KDE or GNOME, solaris w/ CDE or
GNOME) it usually passes successfully.