8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3)
authordermashov
Wed, 30 Jul 2014 14:29:36 +0400
changeset 26017 4d9ac57cd697
parent 26016 d2c378099a3d
child 26018 2a797c982509
8052408: Move AWT_BAT functional tests to OpenJDK (3 of 3) Reviewed-by: alexsch
jdk/test/javax/swing/reliability/GUIUndFrame.java
jdk/test/javax/swing/reliability/GUIZoomFrame.java
jdk/test/javax/swing/reliability/Task.java
jdk/test/javax/swing/reliability/TaskUndJFrameProperties.java
jdk/test/javax/swing/reliability/TaskZoomJFrameChangeState.java
jdk/test/javax/swing/reliability/TaskZoomJFrameRepaint.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/reliability/GUIUndFrame.java	Wed Jul 30 14:29:36 2014 +0400
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2004, 2014, 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.
+ */
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+/*
+ * @author Aruna Samji
+ */
+
+public class GUIUndFrame extends Frame {
+
+    JFrame jframe1, jframe2, jframe3;
+    Component comp;
+    JButton jbutton1, jbutton2, jbutton3, jbutton4;
+    JTextArea jtextarea;
+
+    volatile boolean win_act, win_deact, win_ico, win_deico, win_close;
+
+    public GUIUndFrame() {
+        //GUI for UndJFrameProperties
+        jframe1 = new JFrame();
+        jframe1.getContentPane().setLayout(new FlowLayout());
+        jframe1.setSize(500,255);
+        jframe1.setUndecorated(true);
+        jframe1.getContentPane().setBackground(Color.red);
+
+        jframe1.addWindowListener( new WindowAdapter() {
+            public void windowActivated(WindowEvent e){
+                comp = null;
+                comp = e.getComponent();
+                if (e.getComponent() == jframe1)
+                    win_act = true;
+            }
+
+            public void windowDeactivated(WindowEvent e){
+                win_deact = true;
+            }
+        });
+
+
+        jbutton1 = new JButton("Hide me");
+        jbutton1.addActionListener(e -> jframe1.setVisible(false));
+
+
+        //Create a normal decorated frame to test all the relevant assertions
+        jframe2 = new JFrame();
+        jframe2.getContentPane().setLayout(new FlowLayout());
+        jframe2.setLocation(0,270);
+        jframe2.setSize(500,255);
+        jframe2.getContentPane().setBackground(Color.blue);
+        jbutton2 = new JButton("Show hiddenJFrame");
+        jbutton2.addActionListener(e -> jframe1.setVisible(true));
+
+
+        //GUI for UndFrameIconifyRepaint
+        jframe3 = new JFrame();
+        jframe3.getContentPane().setLayout(new FlowLayout());
+        jframe3.setSize(500,255);
+        jframe3.getContentPane().setBackground(Color.green);
+        jframe3.setUndecorated(true);
+        jframe3.addWindowListener( new WindowAdapter() {
+            public void windowActivated(WindowEvent e) {
+                comp = null;
+                comp = e.getComponent();
+                if(e.getComponent() == jframe3){
+                    win_act=true;
+
+                }
+            }
+            public void windowIconified(WindowEvent e){ win_ico = true; }
+            public void windowDeiconified(WindowEvent e){ win_deico = true; }
+            public void windowDeactivated(WindowEvent e){ win_deact = true; }
+            public void windowClosed(WindowEvent e){ win_close = true; }
+        });
+
+        jbutton3 = new JButton("Minimize me");
+        jbutton3.addActionListener(e -> jframe3.setState(Frame.ICONIFIED));
+        jbutton4 = new JButton("Maximize me");
+        jbutton4.addActionListener(e -> {
+            if (Toolkit.getDefaultToolkit().isFrameStateSupported
+                    (Frame.MAXIMIZED_BOTH)) {
+                jframe3.setExtendedState(Frame.MAXIMIZED_BOTH);
+            }
+        });
+
+        jtextarea = new JTextArea("Textarea");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/reliability/GUIZoomFrame.java	Wed Jul 30 14:29:36 2014 +0400
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2004, 2014, 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.
+ */
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+/*
+ * @author Aruna Samji
+ */
+
+public class GUIZoomFrame extends Frame {
+
+    JFrame jframe1, jframe2;
+    JButton jbutton;
+    JTextArea jtextarea;
+    volatile boolean maxHor, maxVer, maxBoth, normal, iconify;
+
+    public GUIZoomFrame() {
+        //GUI for ZoomJFrameChangeState
+        jframe1 = new JFrame("ZoomJFrameChangeState");
+        jframe1.getContentPane().setBackground(Color.red);
+        jframe1.getContentPane().setLayout(null);
+        jframe1.setSize(500,270);
+
+        //GUI for ZoomJFrameRepaint
+        jframe2 = new JFrame("ZoomJFrameRepaint");
+        jframe2.getContentPane().setBackground(Color.red);
+        jframe2.setSize(500, 270);
+        jframe2.getContentPane().setLayout(null);
+        jbutton = new JButton("TestButton");
+        jtextarea = new JTextArea("TextArea");
+        jbutton.setBounds(20, 100, 80, 60);
+        jtextarea.setBounds(120, 100, 80, 60);
+
+        //Listeners for ZoomJFrameChangeState
+        jframe1.addWindowStateListener(new WindowAdapter() {
+            public void windowStateChanged(WindowEvent e) {
+                if (e.getNewState() == Frame.MAXIMIZED_BOTH)
+                    maxBoth = true;
+
+                if (e.getNewState() == Frame.NORMAL)
+                    normal = true;
+
+                if (e.getNewState() == Frame.ICONIFIED)
+                    iconify = true;
+
+                if (e.getNewState() == Frame.MAXIMIZED_HORIZ)
+                    maxHor = true;
+
+                if (e.getNewState() == Frame.MAXIMIZED_VERT)
+                    maxVer = true;
+            }
+        });
+
+        //Listeners for ZoomJFrameRepaint
+        jframe2.addWindowStateListener( new WindowAdapter() {
+            public void windowStateChanged(WindowEvent e) {
+                if (e.getNewState() == Frame.MAXIMIZED_BOTH)
+                    maxBoth = true;
+
+                if (e.getNewState() == Frame.NORMAL)
+                    normal = true;
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/reliability/Task.java	Wed Jul 30 14:29:36 2014 +0400
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2004, 2014, 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.
+ */
+
+import javax.swing.*;
+import java.awt.*;
+
+/*
+ * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
+ */
+
+public abstract class Task <T extends Frame> {
+
+    protected T gui;
+    protected ExtendedRobot robot;
+
+    public Task(Class guiClass, ExtendedRobot robot) throws Exception {
+        this.robot = robot;
+        SwingUtilities.invokeAndWait( () -> {
+            try {
+                this.gui = (T) guiClass.getConstructor().newInstance();
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        });
+
+        robot.waitForIdle(1000);
+    }
+
+    public abstract void task() throws Exception;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/reliability/TaskUndJFrameProperties.java	Wed Jul 30 14:29:36 2014 +0400
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2004, 2014, 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.
+ */
+
+import javax.swing.*;
+import java.awt.*;
+
+/*
+ * @test
+ * @summary Construct a Undecorated JFrame, try to change the properties
+ *          using setVisible() method.
+ * @author Aruna Samji
+ * @library ../../../lib/testlibrary
+ * @build ExtendedRobot
+ * @run main TaskUndJFrameProperties
+ */
+
+public class TaskUndJFrameProperties extends Task<GUIUndFrame> {
+
+    public static void main (String[] args) throws Exception {
+        new TaskUndJFrameProperties(GUIUndFrame.class, new ExtendedRobot()).task();
+    }
+
+    TaskUndJFrameProperties(Class guiClass, ExtendedRobot robot) throws Exception {
+        super(guiClass, robot);
+    }
+
+    public void task() throws Exception {
+        SwingUtilities.invokeAndWait(() -> {
+            gui.jframe2.setVisible(true);
+            gui.jframe1.setVisible(true);
+
+            gui.jframe1.getContentPane().removeAll();
+            gui.jframe2.getContentPane().removeAll();
+            gui.jframe1.getContentPane().add(gui.jbutton1);
+            gui.jframe2.getContentPane().add(gui.jbutton2);
+            gui.jframe1.revalidate();
+            gui.jframe2.revalidate();
+        });
+        robot.waitForIdle(1000);
+
+        Point button1Origin = gui.jbutton1.getLocationOnScreen();
+        Point button1Center = gui.jbutton1.getLocationOnScreen();
+        button1Center.translate(gui.jbutton1.getWidth()/2, gui.jbutton1.getHeight()/2);
+        Point button2Origin = gui.jbutton2.getLocationOnScreen();
+        Point button2Center = gui.jbutton2.getLocationOnScreen();
+        button2Center.translate(gui.jbutton2.getWidth()/2, gui.jbutton2.getHeight()/2);
+
+        robot.glide(button1Origin, button1Center);
+        robot.waitForIdle(1000);
+        robot.click();
+        //After Hide
+        if (gui.win_deact == false)
+            throw new RuntimeException("Undecorated JFrame has not triggered " +
+                    "WINDOW_DEACTIVATED event when in Hide state\n");
+
+        if (gui.jframe1.hasFocus() == true)
+            throw new RuntimeException("Undecorated Frame Still has Focus even " +
+                    "when in Hide state\n");
+
+        //click on the jbutton2 in jframe2
+        SwingUtilities.invokeAndWait(gui.jframe2::toFront);
+        robot.waitForIdle(1000);
+        robot.glide(button2Origin, button2Center);
+        robot.waitForIdle(1000);
+        robot.click();
+        //After Show
+        if (gui.win_act == false)
+            throw new RuntimeException("Undecorated Frame can't trigger " +
+                    "WINDOW_ACTIVATED when visible\n");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/reliability/TaskZoomJFrameChangeState.java	Wed Jul 30 14:29:36 2014 +0400
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2004, 2014, 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.
+ */
+
+import javax.swing.*;
+import java.awt.*;
+
+/*
+ * @test
+ * @summary Construct a JFrame, zoom it from the normal state and back forth
+ *          using Frame.ZOOMED and Frame.NORMAL. Iconofy from the zoomed
+ *          state and back forth using Frame.ICONIFIED and Frame.NORMAL and
+ *          check the zoomed size is same as the screen size. Check the
+ *          location of the jframe after restoration from zoom or icon.
+ * @author Aruna Samji
+ * @library ../../../lib/testlibrary
+ * @build ExtendedRobot
+ * @run main TaskZoomJFrameChangeState
+ */
+
+public class TaskZoomJFrameChangeState extends Task<GUIZoomFrame> {
+
+    public static void main (String[] args) throws Exception {
+        new TaskZoomJFrameChangeState(GUIZoomFrame.class, new ExtendedRobot()).task();
+    }
+
+    TaskZoomJFrameChangeState(Class guiClass, ExtendedRobot robot) throws Exception {
+         super(guiClass, robot);
+    }
+
+    public void task() throws Exception {
+        SwingUtilities.invokeAndWait(() -> {
+            gui.jframe1.setVisible(true);
+            gui.jframe1.getContentPane().removeAll();
+            if (gui.jframe1.getExtendedState() != Frame.NORMAL)
+                gui.jframe1.setExtendedState(Frame.NORMAL);
+        });
+        robot.waitForIdle(1000);
+
+        Point frameOrigin = gui.jframe1.getLocationOnScreen();
+        SwingUtilities.invokeAndWait(() ->
+            gui.jframe1.setExtendedState(Frame.ICONIFIED)
+        );
+        robot.waitForIdle(1000);
+
+        //To check whether the bitwise mask for ICONIFIED state is set
+        if (gui.jframe1.getExtendedState() != Frame.ICONIFIED)
+            throw new RuntimeException("The bitwise mask Frame.ICONIFIED is " +
+                    "not set when the frame is in ICONIFIED state");
+
+        //To check whether the Frame is iconified programmatically
+        if (!gui.iconify)
+            throw new RuntimeException("Frame is not Iconified");
+
+        //Normalising the Frame.
+        SwingUtilities.invokeAndWait(() ->
+            gui.jframe1.setExtendedState(Frame.NORMAL)
+        );
+        robot.waitForIdle(1000);
+
+        //To check whether the bitwise mask for NORMAL state is set
+        if (gui.jframe1.getExtendedState() != Frame.NORMAL)
+            throw new RuntimeException("The bitwise mask Frame.NORMAL is " +
+                    "not set when the frame is in NORMAL state");
+
+        //To check whether the Frame is normalised programmatically
+        if (!gui.normal)
+            throw new RuntimeException("Frame is not restored to normal");
+
+        Point newposition = gui.jframe1.getLocationOnScreen();
+
+        if ((frameOrigin.x != newposition.x) & (frameOrigin.y != newposition.y))
+            throw new RuntimeException("The frame is not positioned back to " +
+                    "the original place  on the screen after iconified");
+
+        robot.waitForIdle(1000);
+
+        //To check whether the state is supported in the platform
+        if (Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_HORIZ)) {
+            //Maximising the Frame horizontally
+            SwingUtilities.invokeAndWait(() ->
+                gui.jframe1.setExtendedState(Frame.MAXIMIZED_HORIZ)
+            );
+            robot.waitForIdle(1000);
+
+            //To check whether the bitwise mask for MAXIMIZED_HORIZ state is set
+            if (gui.jframe1.getExtendedState() != Frame.MAXIMIZED_HORIZ)
+                throw new RuntimeException("The bitwise mask Frame.MAXIMIZED_HOR " +
+                        "is not set when the frame is in MAXIMIZED_HOR state");
+
+            //To check whether the Frame is maximized horizontally
+            if (!gui.maxHor)
+                throw new RuntimeException("Frame is not maximized horizontally");
+
+            SwingUtilities.invokeAndWait(() ->
+                gui.jframe1.setExtendedState(Frame.NORMAL)
+            );
+            robot.waitForIdle(1000);
+        }
+
+        //To check whether the state is supported in the platform
+        if (Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_VERT)) {
+            //Maximising the Frame vertically
+            SwingUtilities.invokeAndWait(() ->
+                gui.jframe1.setExtendedState(Frame.MAXIMIZED_VERT)
+            );
+            robot.waitForIdle(1000);
+
+            //To check whether the bitwise mask for MAXIMIZED_VERT state is set
+            if (gui.jframe1.getExtendedState() != Frame.MAXIMIZED_VERT)
+                throw new RuntimeException("The bitwise mask Frame.MAXIMIZED_VERT " +
+                        "is not set when the frame is in MAXIMIZED_VERT state");
+
+            //To check whether the Frame is maximized vertically
+            if (!gui.maxVer)
+                throw new RuntimeException("Frame is not maximized vertically");
+
+            SwingUtilities.invokeAndWait(() ->
+                gui.jframe1.setExtendedState(Frame.NORMAL)
+            );
+            robot.waitForIdle(1000);
+        }
+
+        if (Toolkit.getDefaultToolkit().isFrameStateSupported
+                (Frame.MAXIMIZED_BOTH)){
+            //Maximising the Frame fully
+            SwingUtilities.invokeAndWait(() ->
+                gui.jframe1.setExtendedState(Frame.MAXIMIZED_BOTH)
+            );
+        }
+        robot.waitForIdle(1000);
+
+        //To check whether the state is supported in the platform
+        if (Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) {
+            //To check whether the bitwise mask for MAXIMIZED_BOTH state is set
+            if (gui.jframe1.getExtendedState() != Frame.MAXIMIZED_BOTH)
+                throw new RuntimeException("The bitwise mask Frame.MAXIMIZED_BOTH " +
+                        "is not set when the frame is in MAXIMIZED_BOTH state");
+
+            //To check whether the Frame is maximized fully
+            if (!gui.maxBoth)
+                throw new RuntimeException("Frame is not maximized fully");
+        }
+
+        //Normalising the Frame
+        SwingUtilities.invokeAndWait(() ->
+            gui.jframe1.setExtendedState(Frame.NORMAL)
+        );
+        robot.waitForIdle(1000);
+
+        //To check whether the bitwise mask for NORMAL state is set
+        if (gui.jframe1.getExtendedState() != Frame.NORMAL)
+            throw new RuntimeException("The bitwise mask Frame.NORMAL is not " +
+                    "set when the frame is in NORMAL state after Zoomed");
+
+        //To check whether the Frame is normalised programmatically
+        if (!gui.normal)
+            throw new RuntimeException("Frame is not restored to normal after Zoomed");
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/reliability/TaskZoomJFrameRepaint.java	Wed Jul 30 14:29:36 2014 +0400
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2004, 2014, 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.
+ */
+
+import javax.swing.*;
+import java.awt.*;
+
+/*
+ * @test
+ * @summary Construct a jframe with some components and zoom the frame and bring it back to normal state.
+ * @author Aruna Samji
+ * @library ../../../lib/testlibrary
+ * @build ExtendedRobot
+ * @run main TaskZoomJFrameRepaint
+ */
+
+public class TaskZoomJFrameRepaint extends Task<GUIZoomFrame> {
+
+    public static void main (String[] args) throws Exception {
+        new TaskZoomJFrameRepaint(GUIZoomFrame.class, new ExtendedRobot()).task();
+    }
+
+    TaskZoomJFrameRepaint(Class guiClass, ExtendedRobot robot) throws Exception {
+         super(guiClass, robot);
+    }
+
+    public void task() throws Exception {
+        SwingUtilities.invokeAndWait(() -> {
+            gui.jframe2.setVisible(true);
+            gui.jframe2.getContentPane().removeAll();
+            gui.jframe2.getContentPane().add(gui.jbutton);
+            gui.jframe2.getContentPane().add(gui.jtextarea);
+            if (gui.jframe2.getExtendedState() != Frame.NORMAL)
+                gui.jframe2.setExtendedState(Frame.NORMAL);
+        });
+        robot.waitForIdle(1000);
+
+        Point buttonOrigin, newbuttonOrigin,  newbuttonCenter;
+        Point textareaOrigin, newtextareaOrigin,  newtextareaCenter ;
+
+        //to find the lenght and width of the component originally
+        buttonOrigin = gui.jbutton.getLocationOnScreen();
+        textareaOrigin = gui.jtextarea.getLocationOnScreen();
+
+        if (Toolkit.getDefaultToolkit().isFrameStateSupported(
+            Frame.MAXIMIZED_BOTH)){
+            //Maximising the Frame fully
+            SwingUtilities.invokeAndWait(() ->
+                gui.jframe2.setExtendedState(Frame.MAXIMIZED_BOTH)
+            );
+            robot.waitForIdle(1000);
+
+            //To check whether the bitwise mask for MAXIMIZED_BOTH state is set
+            if (gui.jframe2.getExtendedState() != Frame.MAXIMIZED_BOTH)
+                throw new RuntimeException("The bitwise mask Frame.MAXIMIZED_BOTH " +
+                        "is not set when the frame is in MAXIMIZED_BOTH state");
+
+            //To check whether the Frame is maximized fully
+            if (gui.maxBoth == false)
+                throw new RuntimeException("Frame is not maximized fully");
+        }
+
+        //Normalising the Frame....
+        SwingUtilities.invokeAndWait(() ->
+            gui.jframe2.setExtendedState(Frame.NORMAL)
+        );
+        robot.waitForIdle(1000);
+
+        //To check whether the bitwise mask for NORMAL state is set
+        if (gui.jframe2.getExtendedState() != Frame.NORMAL)
+            throw new RuntimeException("The bitwise mask Frame.NORMAL is not " +
+                    "set when the frame is in NORMAL state");
+
+        //To check whether the Frame is normalised programmatically
+        if (! gui.normal)
+            throw new RuntimeException("Frame is not restored to normal");
+
+        //to find the lenght and width of the component after zommed and back to normal
+        newbuttonOrigin = gui.jbutton.getLocationOnScreen();
+        newtextareaOrigin = gui.jtextarea.getLocationOnScreen();
+        newbuttonCenter = gui.jbutton.getLocationOnScreen();
+        newbuttonCenter.translate(gui.jbutton.getWidth()/2, gui.jbutton.getHeight()/2);
+        newtextareaCenter = gui.jtextarea.getLocationOnScreen();
+        newtextareaCenter.translate(gui.jtextarea.getWidth()/2, gui.jtextarea.getHeight()/2);
+
+        if((buttonOrigin.x != newbuttonOrigin.x) & (buttonOrigin.y != newbuttonOrigin.y))
+            throw new RuntimeException("The button is not positioned back " +
+                    "to the original place  on the screen after iconified");
+
+        if((textareaOrigin.x != newtextareaOrigin.x) & (textareaOrigin.y != newtextareaOrigin.y))
+            throw new RuntimeException("The TextArea is not positioned back " +
+                    "to the original place  on the screen after iconified");
+    }
+}