< prev index next >

src/org/netbeans/jemmy/operators/JInternalFrameOperator.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * 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
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -22,10 +22,12 @@
  */
 package org.netbeans.jemmy.operators;
 
 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;
 
 import javax.swing.Icon;

@@ -503,10 +505,13 @@
                 + Integer.toString(x) + ","
                 + Integer.toString(y) + ")"
                 + " position");
         checkIconified(false);
         wDriver.move(this, x, y);
+        if (getVerification()) {
+            waitComponentLocation(new Point(x, y));
+        }
     }
 
     /**
      * Resizes frame. Note: frame should not be iconified.
      *

@@ -524,28 +529,37 @@
                 + Integer.toString(width) + ","
                 + Integer.toString(height) + ")"
                 + " size");
         checkIconified(false);
         wDriver.resize(this, width, height);
+        if (getVerification()) {
+            waitComponentSize(new Dimension(width, height));
+        }
     }
 
     /**
      * Activates frame. Note: frame should not be iconified.
      *
      * @throws WrongInternalFrameStateException
      */
     public void activate() {
         checkIconified(false);
         wDriver.activate(this);
+        if (getVerification()) {
+            waitActivate(true);
+        }
     }
 
     /**
      * Closes the frame.
      */
     public void close() {
         checkIconified(false);
         wDriver.requestClose(this);
+        if (getVerification()) {
+            waitClosed();
+        }
     }
 
     /**
      * Scrolls to internal frame's rectangle.
      *

@@ -652,46 +666,92 @@
     }
 
     /**
      * 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
             public String toString() {
                 return "JInternalFrameOperator.waitIcon.ComponentChooser{description = " + getDescription() + '}';
             }
         });
     }
 
     /**
+     * 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
             public String toString() {
                 return "JInternalFrameOperator.waitMaximum.ComponentChooser{description = " + getDescription() + '}';
< prev index next >