Skip to content

Commit

Permalink
Added Set Window Size and Get Window Size keywords (#121)
Browse files Browse the repository at this point in the history
Closes #75
  • Loading branch information
mihaiparvu authored Mar 27, 2019
1 parent e08884e commit da1cc58
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,31 @@ public void selectWindow(String identifier) {
setContext(operator);
}

@RobotKeyword("Sets a window size.\n\n"
+ "Examples:\n"
+ "| `Set Window Size` | Help | 800 | 600 | # Re-sizes the Help window to 800 px width and 600 px height. |\n")
@ArgumentNames({ "identifier", "width", "height" })
public void setWindowSize(String identifier, String width, String height) {
FrameOperator operator = operatorFactory.createOperator(identifier);
setContext(operator);
operator.resize(Integer.parseInt(width), Integer.parseInt(height));
}

@RobotKeyword("Returns a list containing the width and the height of the window.\n\n"
+ "Examples:\n"
+ "| ${size} | `Get Window Size` | Help | # Gets the size of the Help window. |\n"
+ "| `Should Be Equal As Integers` | ${size[0]} | 800 |\n"
+ "| `Should Be Equal As Integers` | ${size[1]} | 600 |\n")
@ArgumentNames({ "identifier" })
public List<String> getWindowSize(String identifier) {
FrameOperator operator = operatorFactory.createOperator(identifier);
setContext(operator);
List<String> result = new ArrayList<String>();
result.add(String.valueOf(operator.getWidth()));
result.add(String.valueOf(operator.getHeight()));
return result;
}

@RobotKeyword("Closes a window.\n\n"
+ "*N.B.* Regular expression can be used to close the window by prefixing the identifier with ``regexp=``.\n"
+ "See more details in `Regular expressions` section.\n\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,29 @@ public void selectWindowSetsDesignatedWindowAsContext() {
specify(Context.getContext(), must.equal(frameOperator));
}

public void setSize() {
checking(new Expectations() {
{
one(frameOperator).getFocus();
one(frameOperator).resize(800,600);
}
});
context.setWindowSize(windowIdentifier, "800", "600");
}

public void getSize() {
checking(new Expectations() {
{
one(frameOperator).getFocus();
one(frameOperator).getWidth();will(returnValue(800));
one(frameOperator).getHeight();will(returnValue(600));
}
});
java.util.List<String> size = context.getWindowSize(windowIdentifier);
specify(size.get(0), "800");
specify(size.get(1), "600");
}

public void closesWindow() {
checking(new Expectations() {
{
Expand Down
8 changes: 8 additions & 0 deletions src/test/resources/robot-tests/window.robot
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ List Windows
Should be equal @{windows}[0] Test App
[teardown] closeWindow Test Window

Resize Window
${initial_size} Get Window Size Test App
Set Window Size Test App 1280 720
${resized_size} Get Window Size Test App
Should Be Equal As Integers ${resized_size[0]} 1280
Should Be Equal As Integers ${resized_size[1]} 720
[Teardown] Set Window Size Test App ${initial_size[0]} ${initial_size[1]}

Close Window
selectFromMainMenu Test Menu|Show Test Window
Select Window Test Window
Expand Down

0 comments on commit da1cc58

Please sign in to comment.