mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-17 03:13:11 +00:00
8242174: [macos] The NestedModelessDialogTest test make the macOS unstable
Reviewed-by: prr
This commit is contained in:
parent
8b002d881d
commit
73e52d0690
@ -67,6 +67,7 @@ static NSTimeInterval gsLastClickTime;
|
||||
// happen with z-order.
|
||||
static int gsEventNumber;
|
||||
static int* gsButtonEventNumber;
|
||||
static NSTimeInterval gNextKeyEventTime;
|
||||
|
||||
static inline CGKeyCode GetCGKeyCode(jint javaKeyCode);
|
||||
|
||||
@ -84,6 +85,28 @@ CreateJavaException(JNIEnv* env, CGError err)
|
||||
[s UTF8String]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the "safe moment" when the NEXT event can be posted by the robot safely
|
||||
* and sleeps for some time if the "safe moment" for the CURRENT event is not
|
||||
* reached.
|
||||
*
|
||||
* We need to sleep to give time for the macOS to update the state.
|
||||
*
|
||||
* The "mouse move" events are skipped, because it is not a big issue if we lost
|
||||
* some of them, the latest coordinates are saved in the peer and will be used
|
||||
* for clicks.
|
||||
*/
|
||||
static inline void autoDelay(BOOL isMove) {
|
||||
if (!isMove){
|
||||
NSTimeInterval now = [[NSDate date] timeIntervalSinceReferenceDate];
|
||||
NSTimeInterval delay = gNextKeyEventTime - now;
|
||||
if (delay > 0) {
|
||||
[NSThread sleepForTimeInterval:delay];
|
||||
}
|
||||
}
|
||||
gNextKeyEventTime = [[NSDate date] timeIntervalSinceReferenceDate] + 0.050;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_CRobot
|
||||
* Method: initRobot
|
||||
@ -119,6 +142,7 @@ Java_sun_lwawt_macosx_CRobot_initRobot
|
||||
|
||||
gsClickCount = 0;
|
||||
gsLastClickTime = 0;
|
||||
gNextKeyEventTime = 0;
|
||||
gsEventNumber = ROBOT_EVENT_NUMBER_START;
|
||||
|
||||
gsButtonEventNumber = (int*)SAFE_SIZE_ARRAY_ALLOC(malloc, sizeof(int), gNumberOfButtons);
|
||||
@ -145,6 +169,7 @@ Java_sun_lwawt_macosx_CRobot_mouseEvent
|
||||
jboolean isButtonsDownState, jboolean isMouseMove)
|
||||
{
|
||||
JNF_COCOA_ENTER(env);
|
||||
autoDelay(isMouseMove);
|
||||
|
||||
// This is the native method called when Robot mouse events occur.
|
||||
// The CRobot tracks the mouse position, and which button was
|
||||
@ -241,14 +266,19 @@ JNIEXPORT void JNICALL
|
||||
Java_sun_lwawt_macosx_CRobot_mouseWheel
|
||||
(JNIEnv *env, jobject peer, jint wheelAmt)
|
||||
{
|
||||
autoDelay(NO);
|
||||
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
|
||||
CGEventRef event = CGEventCreateScrollWheelEvent(NULL,
|
||||
CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
|
||||
CGEventRef event = CGEventCreateScrollWheelEvent(source,
|
||||
kCGScrollEventUnitLine,
|
||||
k_JAVA_ROBOT_WHEEL_COUNT, wheelAmt);
|
||||
if (event != NULL) {
|
||||
CGEventPost(kCGSessionEventTap, event);
|
||||
CGEventPost(kCGHIDEventTap, event);
|
||||
CFRelease(event);
|
||||
}
|
||||
if (source != NULL) {
|
||||
CFRelease(source);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@ -261,13 +291,18 @@ JNIEXPORT void JNICALL
|
||||
Java_sun_lwawt_macosx_CRobot_keyEvent
|
||||
(JNIEnv *env, jobject peer, jint javaKeyCode, jboolean keyPressed)
|
||||
{
|
||||
autoDelay(NO);
|
||||
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
|
||||
CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
|
||||
CGKeyCode keyCode = GetCGKeyCode(javaKeyCode);
|
||||
CGEventRef event = CGEventCreateKeyboardEvent(NULL, keyCode, keyPressed);
|
||||
CGEventRef event = CGEventCreateKeyboardEvent(source, keyCode, keyPressed);
|
||||
if (event != NULL) {
|
||||
CGEventPost(kCGSessionEventTap, event);
|
||||
CGEventPost(kCGHIDEventTap, event);
|
||||
CFRelease(event);
|
||||
}
|
||||
if (source != NULL) {
|
||||
CFRelease(source);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@ -338,13 +373,17 @@ static void PostMouseEvent(const CGPoint point, CGMouseButton button,
|
||||
CGEventType type, int clickCount, int eventNumber)
|
||||
{
|
||||
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
|
||||
CGEventRef mouseEvent = CGEventCreateMouseEvent(NULL, type, point, button);
|
||||
CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
|
||||
CGEventRef mouseEvent = CGEventCreateMouseEvent(source, type, point, button);
|
||||
if (mouseEvent != NULL) {
|
||||
CGEventSetIntegerValueField(mouseEvent, kCGMouseEventClickState, clickCount);
|
||||
CGEventSetIntegerValueField(mouseEvent, kCGMouseEventNumber, eventNumber);
|
||||
CGEventPost(kCGSessionEventTap, mouseEvent);
|
||||
CGEventPost(kCGHIDEventTap, mouseEvent);
|
||||
CFRelease(mouseEvent);
|
||||
}
|
||||
if (source != NULL) {
|
||||
CFRelease(source);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
@ -196,7 +196,7 @@ java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowRetaining.java 6829264
|
||||
java/awt/datatransfer/DragImage/MultiResolutionDragImageTest.java 8080982 generic-all
|
||||
java/awt/datatransfer/SystemFlavorMap/AddFlavorTest.java 8079268 linux-all
|
||||
java/awt/Toolkit/ScreenInsetsTest/ScreenInsetsTest.java 6829250 windows-all
|
||||
java/awt/Toolkit/RealSync/Test.java 6849383 macosx-all,linux-all
|
||||
java/awt/Toolkit/RealSync/Test.java 6849383 linux-all
|
||||
java/awt/LightweightComponent/LightweightEventTest/LightweightEventTest.java 8159252 windows-all
|
||||
java/awt/EventDispatchThread/HandleExceptionOnEDT/HandleExceptionOnEDT.java 8203047 macosx-all
|
||||
java/awt/EventDispatchThread/LoopRobustness/LoopRobustness.java 8073636 macosx-all
|
||||
@ -223,7 +223,7 @@ java/awt/Mouse/GetMousePositionTest/GetMousePositionWithPopup.java 8196017 windo
|
||||
java/awt/Scrollbar/ScrollbarMouseWheelTest/ScrollbarMouseWheelTest.java 8196018 windows-all,linux-all
|
||||
java/awt/TrayIcon/ActionCommand/ActionCommand.java 8150540 windows-all
|
||||
java/awt/TrayIcon/ActionEventMask/ActionEventMask.java 8150540 windows-all
|
||||
java/awt/TrayIcon/ActionEventTest/ActionEventTest.java 8150540 windows-all
|
||||
java/awt/TrayIcon/ActionEventTest/ActionEventTest.java 8150540,8242801 windows-all,macosx-all
|
||||
java/awt/TrayIcon/ModalityTest/ModalityTest.java 8150540 windows-all,macosx-all
|
||||
java/awt/TrayIcon/MouseEventMask/MouseEventMaskTest.java 8150540 windows-all
|
||||
java/awt/TrayIcon/MouseMovedTest/MouseMovedTest.java 8150540 windows-all
|
||||
@ -541,6 +541,7 @@ java/awt/Window/WindowResizing/DoubleClickTitleBarTest.java 8233557 macosx-all
|
||||
java/awt/Window/WindowOwnedByEmbeddedFrameTest/WindowOwnedByEmbeddedFrameTest.java 8233558 macosx-all
|
||||
java/awt/Mouse/MouseComboBoxTest/MouseComboBoxTest.java 8233564 macosx-all
|
||||
java/awt/Modal/NullModalityDialogTest/NullModalityDialogTest.java 8233565 macosx-all
|
||||
java/awt/keyboard/AllKeyCode/AllKeyCode.java 8242930 macosx-all
|
||||
java/awt/KeyboardFocusmanager/TypeAhead/SubMenuShowTest/SubMenuShowTest.java 8233566 macosx-all
|
||||
java/awt/KeyboardFocusmanager/TypeAhead/EnqueueWithDialogTest/EnqueueWithDialogTest.java 8233566,6447537 macosx-all,windows-all
|
||||
java/awt/FullScreen/8013581/bug8013581.java 8169471 macosx-all
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
@test
|
||||
@bug 6252005
|
||||
@bug 6252005 8242174
|
||||
@key headful
|
||||
@summary Tests that realSync feature works
|
||||
@author denis.mikhalkin: area=awt.toolkit
|
||||
@ -31,16 +31,17 @@
|
||||
@run main/timeout=6000 Test
|
||||
*/
|
||||
|
||||
import java.awt.Frame;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Collections;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.image.*;
|
||||
import javax.imageio.*;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* Tests various problematic areas and how they are fixed using real-sync API:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user