8144125: [macOS] java/awt/event/ComponentEvent/MovedResizedTwiceTest/MovedResizedTwiceTest.java failed automatically

Reviewed-by: dmarkov
This commit is contained in:
Sergey Bylokhov 2019-05-08 16:19:22 -07:00
parent a9f9b8ff41
commit 1d922fee0e
2 changed files with 53 additions and 31 deletions

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,48 +23,64 @@
* questions. * questions.
*/ */
package sun.lwawt; 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.DropTarget;
import java.awt.dnd.peer.DropTargetPeer; 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.ColorModel;
import java.awt.image.ImageObserver; import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer; import java.awt.image.ImageProducer;
import java.awt.image.VolatileImage; import java.awt.image.VolatileImage;
import java.awt.peer.ComponentPeer; import java.awt.peer.ComponentPeer;
import java.awt.peer.ContainerPeer; import java.awt.peer.ContainerPeer;
import java.awt.peer.KeyboardFocusManagerPeer; import java.awt.peer.KeyboardFocusManagerPeer;
import java.util.concurrent.atomic.AtomicBoolean;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction; 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.event.IgnorePaintEvent;
import sun.awt.image.SunVolatileImage; import sun.awt.image.SunVolatileImage;
import sun.awt.image.ToolkitImage; import sun.awt.image.ToolkitImage;
import sun.java2d.SunGraphics2D; import sun.java2d.SunGraphics2D;
import sun.java2d.opengl.OGLRenderQueue; import sun.java2d.opengl.OGLRenderQueue;
import sun.java2d.pipe.Region; import sun.java2d.pipe.Region;
import sun.util.logging.PlatformLogger; 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> public abstract class LWComponentPeer<T extends Component, D extends JComponent>
implements ComponentPeer, DropTargetPeer implements ComponentPeer, DropTargetPeer
{ {
@ -1105,9 +1121,9 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
final boolean updateTarget) { final boolean updateTarget) {
if (updateTarget) { if (updateTarget) {
AWTAccessor.getComponentAccessor().setLocation(getTarget(), x, y); AWTAccessor.getComponentAccessor().setLocation(getTarget(), x, y);
postEvent(new ComponentEvent(getTarget(),
ComponentEvent.COMPONENT_MOVED));
} }
postEvent(new ComponentEvent(getTarget(),
ComponentEvent.COMPONENT_MOVED));
} }
/** /**
@ -1129,9 +1145,9 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
if (updateTarget) { if (updateTarget) {
AWTAccessor.getComponentAccessor().setSize(getTarget(), w, h); 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) { protected final void repaintOldNewBounds(final Rectangle oldB) {

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,18 +25,24 @@
/* /*
@test @test
@bug 5025858 @key headful
@bug 5025858 8144125
@summary Tests that after programmatically moving or resizing a component, @summary Tests that after programmatically moving or resizing a component,
corresponding ComponentEvents are generated only once corresponding ComponentEvents are generated only once
@author artem.ananiev: area=awt.event
@run main/manual MovedResizedTwiceTest
*/ */
import java.awt.*; import java.awt.Button;
import java.awt.event.*; 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 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 popular platforms (windows, linux w/ KDE or GNOME, solaris w/ CDE or
GNOME) it usually passes successfully. GNOME) it usually passes successfully.