8172701: Jemmy: FrameOperator: maximize() and demaximize() is not properly implemented

Reviewed-by: serb, shurailine, mrkam
This commit is contained in:
Muneer Kolarkunnu 2017-02-15 18:22:39 -08:00 committed by Alexander Kouznetsov
parent 7f74b3f6bc
commit b107e7fa38
2 changed files with 45 additions and 7 deletions

View File

@ -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 @@ public class DefaultFrameDriver extends LightSupportiveDriver implements FrameDr
((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);
}
}

View File

@ -274,7 +274,7 @@ public class FrameOperator extends WindowOperator implements Outputable {
output.printGolden("Maximizing frame");
driver.maximize(this);
if (getVerification()) {
waitState(Frame.NORMAL);
waitState(Frame.MAXIMIZED_BOTH);
}
}
@ -306,7 +306,7 @@ public class FrameOperator extends WindowOperator implements Outputable {
waitState(new ComponentChooser() {
@Override
public boolean checkComponent(Component comp) {
return ((Frame) comp).getState() == state;
return ((Frame) comp).getExtendedState() == state;
}
@Override
@ -375,6 +375,19 @@ public class FrameOperator extends WindowOperator implements Outputable {
}));
}
/**
* 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
*/
@ -447,6 +460,21 @@ public class FrameOperator extends WindowOperator implements Outputable {
});
}
/**
* 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
*/