8172701: Jemmy: FrameOperator: maximize() and demaximize() is not properly implemented
Reviewed-by: serb, shurailine, mrkam
Contributed-by: Muneer Kolarkunnu <abdul.kolarkunnu@oracle.com>
--- a/jdk/test/sanity/client/lib/jemmy/src/org/netbeans/jemmy/drivers/windows/DefaultFrameDriver.java Wed Feb 15 16:16:21 2017 -0800
+++ b/jdk/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/jdk/test/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/FrameOperator.java Wed Feb 15 16:16:21 2017 -0800
+++ b/jdk/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) {