|
|
|
@ -16,15 +16,23 @@ class CursorTest {
@@ -16,15 +16,23 @@ class CursorTest {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void testMoveCursorToCoordinatesHelper() throws InterruptedException, AWTException { |
|
|
|
|
void testMoveCursorToCoordinatesHelper() throws Exception { |
|
|
|
|
initialize(); |
|
|
|
|
cursor.displayCursorPaths(); |
|
|
|
|
//cursor.displayCursorPaths();
|
|
|
|
|
|
|
|
|
|
testThetaBetweenPoints(); |
|
|
|
|
testFindNearestPathLengthThatExists(); |
|
|
|
|
testMoveCursorToCoordinates(); |
|
|
|
|
//testRightClickCursor();
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void testFindNearestPathLengthThatExists() throws Exception { |
|
|
|
|
for (int i = 0; i < 2203; i++) { |
|
|
|
|
int closestLength = cursor.findNearestPathLengthThatExists(i); |
|
|
|
|
System.out.println("Closest path to length " + i + " is " + closestLength); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void testThetaBetweenPoints() { |
|
|
|
|
Point a = new Point(0, 0); |
|
|
|
|
Point b = new Point(10, 0); |
|
|
|
@ -36,7 +44,7 @@ class CursorTest {
@@ -36,7 +44,7 @@ class CursorTest {
|
|
|
|
|
assertEquals(degreesToRadians(45), cursor.getThetaBetweenPoints(b, d)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void testMoveCursorToCoordinates() throws InterruptedException { |
|
|
|
|
void testMoveCursorToCoordinates() throws Exception { |
|
|
|
|
Point a = new Point(0, 0); |
|
|
|
|
Point b = new Point(150, 250); |
|
|
|
|
Point c = new Point(375, 190); |
|
|
|
@ -44,6 +52,18 @@ class CursorTest {
@@ -44,6 +52,18 @@ class CursorTest {
|
|
|
|
|
Point e = new Point(952, 603); |
|
|
|
|
Point f = new Point(1025, 133); |
|
|
|
|
Point g = new Point(543, 582); |
|
|
|
|
Point h = new Point(1643, 582); |
|
|
|
|
Point i = new Point(0, 582); |
|
|
|
|
Point j = new Point(954, 123); |
|
|
|
|
Point k = new Point(954, 960); |
|
|
|
|
Point l = new Point(384, 654); |
|
|
|
|
Point m = new Point(84, 43); |
|
|
|
|
Point n = new Point(84, 43); |
|
|
|
|
Point o = new Point(12, 842); |
|
|
|
|
Point p = new Point(1600, 514); |
|
|
|
|
Point q = new Point(1599, 513); |
|
|
|
|
Point r = new Point(1600, 515); |
|
|
|
|
Point s = new Point(1602, 513); |
|
|
|
|
testMoveCursorToCoordinates(a, b); |
|
|
|
|
testMoveCursorToCoordinates(b, c); |
|
|
|
|
testMoveCursorToCoordinates(c, d); |
|
|
|
@ -55,6 +75,19 @@ class CursorTest {
@@ -55,6 +75,19 @@ class CursorTest {
|
|
|
|
|
testMoveCursorToCoordinates(f, b); |
|
|
|
|
testMoveCursorToCoordinates(b, a); |
|
|
|
|
testMoveCursorToCoordinates(a, g); |
|
|
|
|
testMoveCursorToCoordinates(g, h); |
|
|
|
|
testMoveCursorToCoordinates(h, i); |
|
|
|
|
testMoveCursorToCoordinates(i, j); |
|
|
|
|
testMoveCursorToCoordinates(j, k); |
|
|
|
|
testMoveCursorToCoordinates(k, l); |
|
|
|
|
testMoveCursorToCoordinates(l, m); |
|
|
|
|
testMoveCursorToCoordinates(m, n); |
|
|
|
|
testMoveCursorToCoordinates(n, o); |
|
|
|
|
testMoveCursorToCoordinates(o, p); |
|
|
|
|
testMoveCursorToCoordinates(p, q); |
|
|
|
|
testMoveCursorToCoordinates(q, r); |
|
|
|
|
testMoveCursorToCoordinates(r, s); |
|
|
|
|
testMoveCursorToCoordinates(s, a); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*void testRightClickCursor() throws InterruptedException { |
|
|
|
@ -77,27 +110,20 @@ class CursorTest {
@@ -77,27 +110,20 @@ class CursorTest {
|
|
|
|
|
// Way to verify that context menu is open?
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
void testMoveCursorToCoordinates(Point a, Point b) throws InterruptedException { |
|
|
|
|
void testMoveCursorToCoordinates(Point a, Point b) throws Exception { |
|
|
|
|
cursor.robotMouseMove(a); |
|
|
|
|
cursor.moveCursorToCoordinates(b); |
|
|
|
|
Point point = cursor.getCurrentCursorPoint(); |
|
|
|
|
System.out.println("Cursor ended up on " + point.x + "," + point.y); |
|
|
|
|
//System.out.println("Cursor ended up on " + point.x + "," + point.y);
|
|
|
|
|
verifyCursorIsInCorrectPlace(point, b); |
|
|
|
|
Thread.sleep(500); |
|
|
|
|
Thread.sleep(250); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void verifyCursorIsInCorrectPlace(Point actualPoint, Point expectedPoint) { |
|
|
|
|
assertInRangeByAbsoluteValue(actualPoint.x, expectedPoint.x, cursorTolerance); |
|
|
|
|
assertInRangeByAbsoluteValue(actualPoint.y, expectedPoint.y, cursorTolerance); |
|
|
|
|
assertEquals(actualPoint.x, expectedPoint.x, cursorTolerance); |
|
|
|
|
assertEquals(actualPoint.y, expectedPoint.y, cursorTolerance); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void assertInRangeByPercentage(double valueToTest, double expectation, double tolerancePercentage) { |
|
|
|
|
assertTrue((valueToTest <= (expectation * (1 + tolerancePercentage))) && (valueToTest >= (expectation * (1 - tolerancePercentage)))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void assertInRangeByAbsoluteValue(double valueToTest, double expectation, double toleranceAbsolute) { |
|
|
|
|
assertTrue((valueToTest <= (expectation + toleranceAbsolute)) && (valueToTest >= (expectation * (1 - toleranceAbsolute)))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private double degreesToRadians(double degrees) { |
|
|
|
|
return degrees * Math.PI / 180.0; |
|
|
|
|