changeset 16821:656ccef366ac

8172701: Jemmy: FrameOperator: maximize() and demaximize() is not properly implemented Reviewed-by: serb, shurailine, mrkam Contributed-by: Muneer Kolarkunnu <abdul.kolarkunnu@oracle.com>
author mrkam
date Wed, 15 Feb 2017 18:22:39 -0800
parents 7bea1b574070
children c0cfc1420a14 e67a9a0f1561
files test/sanity/client/lib/jemmy/src/org/netbeans/jemmy/drivers/windows/DefaultFrameDriver.java test/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/FrameOperator.java
diffstat 2 files changed, 45 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/test/sanity/client/lib/jemmy/src/org/netbeans/jemmy/drivers/windows/DefaultFrameDriver.java	Wed Feb 15 16:16:21 2017 -0800
+++ b/test/sanity/client/lib/jemmy/src/org/netbeans/jemmy/drivers/windows/DefaultFrameDriver.java	Wed Feb 15 18:22:39 2017 -0800
@@ -22,9 +22,7 @@
  */
 package org.netbeans.jemmy.drivers.windows;
 
-import java.awt.Dimension;
 import java.awt.Frame;
-import java.awt.Toolkit;
 import java.awt.Window;
 import java.awt.event.WindowEvent;
 
@@ -61,16 +59,28 @@
         ((FrameOperator) oper).setState(Frame.NORMAL);
     }
 
+    /** Maximizes the frame.
+     *
+     * @param oper Frame operator.
+     * @throws UnsupportedOperatorException if operator class name is not in
+     *         the list of supported classes names
+     */
     @Override
     public void maximize(ComponentOperator oper) {
         checkSupported(oper);
-        oper.setLocation(0, 0);
-        Dimension ssize = Toolkit.getDefaultToolkit().getScreenSize();
-        oper.setSize(ssize.width, ssize.height);
+        ((FrameOperator) oper).setExtendedState(Frame.MAXIMIZED_BOTH);
     }
 
+    /** Demaximizes the frame.
+     *
+     * @param oper Frame operator.
+     * @throws UnsupportedOperatorException if operator class name is not in
+     *         the list of supported classes names
+     */
     @Override
     public void demaximize(ComponentOperator oper) {
         checkSupported(oper);
+        ((FrameOperator) oper).setExtendedState(Frame.NORMAL);
     }
+
 }
--- a/test/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/FrameOperator.java	Wed Feb 15 16:16:21 2017 -0800
+++ b/test/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/FrameOperator.java	Wed Feb 15 18:22:39 2017 -0800
@@ -274,7 +274,7 @@
         output.printGolden("Maximizing frame");
         driver.maximize(this);
         if (getVerification()) {
-            waitState(Frame.NORMAL);
+            waitState(Frame.MAXIMIZED_BOTH);
         }
     }
 
@@ -306,7 +306,7 @@
         waitState(new ComponentChooser() {
             @Override
             public boolean checkComponent(Component comp) {
-                return ((Frame) comp).getState() == state;
+                return ((Frame) comp).getExtendedState() == state;
             }
 
             @Override
@@ -376,6 +376,19 @@
     }
 
     /**
+     * Maps {@code Frame.getExtendedState()} through queue
+     * @return the state of the frame
+     */
+    public int getExtendedState() {
+        return (runMapping(new MapAction<Integer>("getExtendedState") {
+            @Override
+            public Integer map() {
+                return ((Frame) getSource()).getExtendedState();
+            }
+        }));
+    }
+
+    /**
      * Maps {@code Frame.getTitle()} through queue
      */
     public String getTitle() {
@@ -448,6 +461,21 @@
     }
 
     /**
+     * Maps {@code Frame.setExtendedState(int)} through queue
+     * @param state of the frame
+     */
+    public void setExtendedState(final int state) {
+        runMapping(new MapAction<Void>("setExtendedState") {
+            @Override
+            public Void map() {
+                ((Frame) getSource()).setExtendedState(state);
+                return null;
+            }
+        });
+
+    }
+
+    /**
      * Maps {@code Frame.setTitle(String)} through queue
      */
     public void setTitle(final String string) {