--- old/src/org/netbeans/jemmy/operators/JInternalFrameOperator.java 2018-04-18 05:12:32.943314129 -0700 +++ new/src/org/netbeans/jemmy/operators/JInternalFrameOperator.java 2018-04-18 05:12:32.866313018 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2018, 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 @@ -24,6 +24,8 @@ import java.awt.Component; import java.awt.Container; +import java.awt.Dimension; +import java.awt.Point; import java.awt.Rectangle; import java.beans.PropertyVetoException; import java.util.Hashtable; @@ -505,6 +507,9 @@ + " position"); checkIconified(false); wDriver.move(this, x, y); + if (getVerification()) { + waitComponentLocation(new Point(x, y)); + } } /** @@ -526,6 +531,9 @@ + " size"); checkIconified(false); wDriver.resize(this, width, height); + if (getVerification()) { + waitComponentSize(new Dimension(width, height)); + } } /** @@ -536,6 +544,9 @@ public void activate() { checkIconified(false); wDriver.activate(this); + if (getVerification()) { + waitActivate(true); + } } /** @@ -544,6 +555,9 @@ public void close() { checkIconified(false); wDriver.requestClose(this); + if (getVerification()) { + waitClosed(); + } } /** @@ -654,18 +668,18 @@ /** * Waits for the frame to be iconified or deiconified. * - * @param icon whether the frame needs to be iconified. + * @param isIconified whether the frame needs to be iconified or deiconified. */ - public void waitIcon(final boolean icon) { - waitState(new ComponentChooser() { + public void waitIcon(final boolean isIconified) { + waitStateOnQueue(new ComponentChooser() { @Override public boolean checkComponent(Component comp) { - return ((JInternalFrame) comp).isIcon() == icon; + return isIcon() == isIconified; } @Override public String getDescription() { - return "Iconified JInternalFrame"; + return "Internal Frame is " + (isIconified ? "iconified" : "deiconified"); } @Override @@ -676,20 +690,66 @@ } /** + * Waits for the frame to be activated or deactivated. + * + * @param isActivate whether the frame needs to be activated or deactivated. + */ + public void waitActivate(final boolean isActivate) { + waitStateOnQueue(new ComponentChooser() { + @Override + public boolean checkComponent(Component comp) { + return isSelected() == isActivate; + } + + @Override + public String getDescription() { + return "Internal Frame is " + (isActivate ? "activated" : "deactivated"); + } + + @Override + public String toString() { + return "JInternalFrameOperator.waitActivate.ComponentChooser{description = " + getDescription() + '}'; + } + }); + } + + /** + * Waits for the frame to be closed. + */ + public void waitClosed() { + waitStateOnQueue(new ComponentChooser() { + @Override + public boolean checkComponent(Component comp) { + return isClosed(); + } + + @Override + public String getDescription() { + return "Internal Frame is closed"; + } + + @Override + public String toString() { + return "JInternalFrameOperator.waitClosed.ComponentChooser{description = " + getDescription() + '}'; + } + }); + } + + /** * Waits for the frame to be maximized or demaximized. * - * @param maximum whether the frame needs to be maximized. + * @param isMaximum whether the frame needs to be maximized or demaximized. */ - public void waitMaximum(final boolean maximum) { - waitState(new ComponentChooser() { + public void waitMaximum(final boolean isMaximum) { + waitStateOnQueue(new ComponentChooser() { @Override public boolean checkComponent(Component comp) { - return ((JInternalFrame) comp).isMaximum() == maximum; + return isMaximum() == isMaximum; } @Override public String getDescription() { - return "Maximizied JInternalFrame"; + return "Internal Frame is " + (isMaximum ? "maximizied" : "demaximizied"); } @Override --- old/src/org/netbeans/jemmy/version_info 2018-04-18 05:12:33.303319321 -0700 +++ new/src/org/netbeans/jemmy/version_info 2018-04-18 05:12:33.227318225 -0700 @@ -1,6 +1,6 @@ Manifest-version: 1.0 Main-Class: org.netbeans.jemmy.JemmyProperties Jemmy-MajorVersion: 3.0 -Jemmy-MinorVersion: 0.0 +Jemmy-MinorVersion: 1.0 Jemmy-Build: @BUILD_NUMBER@ --- /dev/null 2018-02-03 01:34:01.991000000 -0800 +++ new/test/org/netbeans/jemmy/operators/JInternalFrameOperatorCloseTest.java 2018-04-18 05:12:33.534322652 -0700 @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2018, 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 + * 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 org.netbeans.jemmy.operators; + +import static org.testng.Assert.fail; + +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.event.InternalFrameEvent; +import javax.swing.event.InternalFrameListener; + +import org.netbeans.jemmy.TimeoutExpiredException; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class JInternalFrameOperatorCloseTest { + + private JFrameOperator frameOper; + + private JInternalFrameOperator internalFrameOper; + + @BeforeClass + protected void setUp() throws Exception { + JFrame frame = new JFrame(); + JDesktopPane desktop = new JDesktopPane(); + frame.setContentPane(desktop); + JInternalFrame internalFrame = new JInternalFrame("JInternalFrameOperatorTest", true, true, true, true); + internalFrame.setName("JInternalFrameOperatorTest"); + internalFrame.setSize(200, 200); + internalFrame.setVisible(true); + desktop.add(internalFrame); + frame.setSize(400,400); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + frameOper = new JFrameOperator(); + internalFrameOper = new JInternalFrameOperator(frameOper); + internalFrameOper.setVerification(true); + } + + @AfterClass + protected void tearDown() throws Exception { + frameOper.setVisible(false); + frameOper.dispose(); + } + + @Test + public void testClose() { + + InternalFrameListener listener = new InternalFrameListener() { + + @Override + public void internalFrameOpened(InternalFrameEvent e) { + } + + @Override + public void internalFrameIconified(InternalFrameEvent e) { + } + + @Override + public void internalFrameDeiconified(InternalFrameEvent e) { + } + + @Override + public void internalFrameDeactivated(InternalFrameEvent e) { + } + + @Override + public void internalFrameClosing(InternalFrameEvent e) { + try { + this.wait(80000); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + } + + @Override + public void internalFrameClosed(InternalFrameEvent e) { + } + + @Override + public void internalFrameActivated(InternalFrameEvent e) { + } + }; + + // Making not to close the fame for 1 minute and expecting TimeoutExpiredException + // from waitClosed() + try { + internalFrameOper.addInternalFrameListener(listener); + internalFrameOper.close(); + fail(); + } catch (TimeoutExpiredException e) { + } finally { + internalFrameOper.removeInternalFrameListener(listener); + } + + // Really closing the frame + internalFrameOper.close(); + } + +} --- /dev/null 2018-02-03 01:34:01.991000000 -0800 +++ new/test/org/netbeans/jemmy/operators/JInternalFrameOperatorTest.java 2018-04-18 05:12:33.834326979 -0700 @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2018, 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 + * 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 org.netbeans.jemmy.operators; + +import java.awt.Dimension; +import java.awt.Point; + +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; + +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class JInternalFrameOperatorTest { + + private JFrameOperator frameOper; + + private JInternalFrameOperator internalFrameOper; + + @BeforeClass + protected void setUp() throws Exception { + JFrame frame = new JFrame(); + JDesktopPane desktop = new JDesktopPane(); + frame.setContentPane(desktop); + JInternalFrame internalFrame = new JInternalFrame( + "JInternalFrameOperatorTest", true, true, true, true); + internalFrame.setName("JInternalFrameOperatorTest"); + internalFrame.setSize(200, 200); + internalFrame.setVisible(true); + desktop.add(internalFrame); + frame.setSize(400,400); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + frameOper = new JFrameOperator(); + internalFrameOper = new JInternalFrameOperator(frameOper); + internalFrameOper.setVerification(true); + } + + @AfterClass + protected void tearDown() throws Exception { + frameOper.setVisible(false); + frameOper.dispose(); + } + + @Test + public void testIconify() { + internalFrameOper.iconify(); + internalFrameOper.deiconify(); + } + + @Test + public void testMaximize() { + internalFrameOper.maximize(); + internalFrameOper.demaximize(); + } + + @Test + public void testMove() { + Point originalLocation = internalFrameOper.getLocation(); + internalFrameOper.move(150, 150); + internalFrameOper.move(originalLocation.x, originalLocation.y); + } + + @Test + public void testResize() { + Dimension originaSize = internalFrameOper.getSize(); + internalFrameOper.resize(250, 250); + internalFrameOper.resize(originaSize.width, originaSize.height); + } + + @Test + public void testActivate() { + internalFrameOper.activate(); + } + +}