53 setModal = modal; 54 owner = o; 55 56 robot = new ExtendedRobot(); 57 EventQueue.invokeLater(this::createGUI); 58 } 59 60 public ToBackFDFTest(Dialog.ModalityType modalityType, 61 DialogOwner o) throws Exception { 62 this(modalityType, false, o); 63 } 64 65 public ToBackFDFTest(boolean modal, DialogOwner o) throws Exception { 66 this(null, modal, o); 67 } 68 69 private void createGUI() { 70 71 leftFrame = new TestFrame(); 72 leftFrame.setLocation(50, 50); 73 leftFrame.setBackground(Color.BLUE); 74 leftFrame.setVisible(true); 75 76 switch (owner) { 77 case HIDDEN_DIALOG: 78 hiddenDialog = new Dialog((Frame) null); 79 dialog = new CustomDialog(hiddenDialog); 80 break; 81 case NULL_DIALOG: 82 dialog = new CustomDialog((Dialog) null); 83 break; 84 case HIDDEN_FRAME: 85 hiddenFrame = new Frame(); 86 dialog = new CustomDialog(hiddenFrame); 87 break; 88 case NULL_FRAME: 89 dialog = new CustomDialog((Frame) null); 90 break; 91 case FRAME: 92 dialog = new CustomDialog(leftFrame); 93 break; 94 } 95 96 if (modalityType == null) { 97 dialog.setModal(setModal); 98 modalityType = dialog.getModalityType(); 99 } else if (modalityType != null) { 100 dialog.setModalityType(modalityType); 101 } 102 103 dialog.setBackground(Color.WHITE); 104 dialog.setLocation(150, 50); 105 106 rightFrame = new TestFrame(); 107 rightFrame.setLocation(250, 50); 108 rightFrame.setBackground(Color.RED); 109 110 if (modalityType == Dialog.ModalityType.APPLICATION_MODAL) { 111 rightFrame.setModalExclusionType( 112 Dialog.ModalExclusionType.APPLICATION_EXCLUDE); 113 } else if (modalityType == Dialog.ModalityType.TOOLKIT_MODAL) { 114 rightFrame.setModalExclusionType( 115 Dialog.ModalExclusionType.TOOLKIT_EXCLUDE); 116 } 117 118 dialog.setVisible(true); 119 } 120 121 private void checkIfLeftOnTop(boolean refState, String msg) { 122 123 Point p = leftFrame.getLocationOnScreen(); 124 int x = p.x + (int)(leftFrame.getWidth() * 0.9); 125 int y = p.y + (int)(leftFrame.getHeight() * 0.9); 126 boolean f = robot.getPixelColor(x, y).equals(leftFrame.getBackground()); 127 assertEQ(refState, f, msg); | 53 setModal = modal; 54 owner = o; 55 56 robot = new ExtendedRobot(); 57 EventQueue.invokeLater(this::createGUI); 58 } 59 60 public ToBackFDFTest(Dialog.ModalityType modalityType, 61 DialogOwner o) throws Exception { 62 this(modalityType, false, o); 63 } 64 65 public ToBackFDFTest(boolean modal, DialogOwner o) throws Exception { 66 this(null, modal, o); 67 } 68 69 private void createGUI() { 70 71 leftFrame = new TestFrame(); 72 leftFrame.setLocation(50, 50); 73 leftFrame.setResizable(false); 74 leftFrame.setBackground(Color.BLUE); 75 leftFrame.setVisible(true); 76 77 switch (owner) { 78 case HIDDEN_DIALOG: 79 hiddenDialog = new Dialog((Frame) null); 80 dialog = new CustomDialog(hiddenDialog); 81 break; 82 case NULL_DIALOG: 83 dialog = new CustomDialog((Dialog) null); 84 break; 85 case HIDDEN_FRAME: 86 hiddenFrame = new Frame(); 87 dialog = new CustomDialog(hiddenFrame); 88 break; 89 case NULL_FRAME: 90 dialog = new CustomDialog((Frame) null); 91 break; 92 case FRAME: 93 dialog = new CustomDialog(leftFrame); 94 break; 95 } 96 97 if (modalityType == null) { 98 dialog.setModal(setModal); 99 modalityType = dialog.getModalityType(); 100 } else if (modalityType != null) { 101 dialog.setModalityType(modalityType); 102 } 103 104 dialog.setBackground(Color.WHITE); 105 dialog.setLocation(150, 50); 106 dialog.setResizable(false); 107 108 rightFrame = new TestFrame(); 109 rightFrame.setLocation(250, 50); 110 rightFrame.setResizable(false); 111 rightFrame.setBackground(Color.RED); 112 113 if (modalityType == Dialog.ModalityType.APPLICATION_MODAL) { 114 rightFrame.setModalExclusionType( 115 Dialog.ModalExclusionType.APPLICATION_EXCLUDE); 116 } else if (modalityType == Dialog.ModalityType.TOOLKIT_MODAL) { 117 rightFrame.setModalExclusionType( 118 Dialog.ModalExclusionType.TOOLKIT_EXCLUDE); 119 } 120 121 dialog.setVisible(true); 122 } 123 124 private void checkIfLeftOnTop(boolean refState, String msg) { 125 126 Point p = leftFrame.getLocationOnScreen(); 127 int x = p.x + (int)(leftFrame.getWidth() * 0.9); 128 int y = p.y + (int)(leftFrame.getHeight() * 0.9); 129 boolean f = robot.getPixelColor(x, y).equals(leftFrame.getBackground()); 130 assertEQ(refState, f, msg); |