Skip to content
This repository has been archived by the owner on Mar 14, 2018. It is now read-only.

Commit

Permalink
fixed: RobotFramework support on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
RaiMan committed May 20, 2016
1 parent fa81548 commit 17c8f94
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -14,6 +14,7 @@ opencvsrc/
.project
.classpath
*$py.class
*.pyc
.exe
original/
*.sikuli.robot/
3 changes: 3 additions & 0 deletions API/src/main/java/org/sikuli/script/RunTime.java
Expand Up @@ -2547,6 +2547,9 @@ public Rectangle getMonitor(int n) {
if (isHeadless()) {
return new Rectangle(0, 0, 1, 1);
}
if (null == monitorBounds) {
return null;
}
n = (n < 0 || n >= nMonitors) ? mainMonitor : n;
return monitorBounds[n];
}
Expand Down
17 changes: 11 additions & 6 deletions API/src/main/java/org/sikuli/script/Runner.java
Expand Up @@ -519,13 +519,18 @@ public static int runrobot(String code) {
pyRunner.exec("import robot.run;");
String robotCmd = String.format(
"ret = robot.run(\"%s\", "
+ "outputdir=\"%s\"", fRobot, fRobotWork);
if (RunTime.get().runningWindows) robotCmd = robotCmd.replaceAll("\\\\", "\\\\\\\\");
robotCmd += String.format("); print \"robot.run returned:\", ret; " +
"print \"robot.run output is here:\\n%s\";", fRobotWork);
pyRunner.exec(robotCmd);
+ "outputdir=\"%s\")", fRobot, fRobotWork);
File fReport = new File(fRobotWork, "report.html");
String urlReport = fReport.getAbsolutePath();
if (RunTime.get().runningWindows) {
robotCmd = robotCmd.replaceAll("\\\\", "\\\\\\\\");
urlReport = "/" + urlReport.replaceAll("\\\\", "/");
}
pyRunner.exec(robotCmd + "; print \"robot.run returned:\", ret; " +
String.format("print \"robot.run output is here:\\n%s\";",
fRobotWork.getAbsolutePath().replaceAll("\\\\", "\\\\\\\\")));
if (new File(fRobotWork, "report.html").exists()) {
App.openLink("file://" + new File(fRobotWork, "report.html").getAbsolutePath());
App.openLink("file:" + urlReport);
}
return 0;
}
Expand Down
37 changes: 26 additions & 11 deletions API/src/main/java/org/sikuli/script/Sikulix.java
Expand Up @@ -6,11 +6,12 @@
*/
package org.sikuli.script;

import java.awt.Color;
import java.awt.*;

import org.sikuli.basics.HotkeyManager;
import org.sikuli.util.Tests;
import org.sikuli.util.ScreenHighlighter;
import java.awt.Dimension;

import java.io.File;
import java.net.URL;
import java.security.CodeSource;
Expand Down Expand Up @@ -60,7 +61,7 @@ private static void terminate(int retVal, String msg, Object... args) {
private static RunTime rt = null;
public static int testNumber = -1;
private static boolean shouldRunServer = false;
private static Location locPopAt = new Screen().getCenter();
private static Point locPopAt = null;

static {
String jarName = "";
Expand Down Expand Up @@ -677,26 +678,40 @@ public static void popup(String message, String title) {
}

public static Location popat(Location at) {
locPopAt = at;
return locPopAt;
locPopAt = new Point(at.x, at.y);
return new Location(locPopAt);
}

public static Location popat(Region at) {
locPopAt = at.getCenter();
return locPopAt;
locPopAt = new Point(at.getCenter().x, at.getCenter().y);
return new Location(locPopAt);
}

public static Location popat(int atx, int aty) {
locPopAt = new Location(atx, aty);
return locPopAt;
locPopAt = new Point(atx, aty);
return new Location(locPopAt);
}

public static Location popat() {
locPopAt = new Screen().getCenter();
return locPopAt;
locPopAt = getLocPopAt();
return new Location(locPopAt);
}

private static Point getLocPopAt() {
Rectangle screen0 = rt.getMonitor(0);
if (null == screen0) {
return null;
}
return new Point((int) screen0.getCenterX(), (int) screen0.getCenterY());
}

private static JFrame popLocation() {
if (null == locPopAt) {
locPopAt = getLocPopAt();
if (null == locPopAt) {
return null;
}
}
return popLocation(locPopAt.x, locPopAt.y);
}

Expand Down

0 comments on commit 17c8f94

Please sign in to comment.