Merge branch 'master' of https://github.com/google/webdriver.dart
diff --git a/lib/src/common.dart b/lib/src/common.dart
index 6f12503..648a18d 100644
--- a/lib/src/common.dart
+++ b/lib/src/common.dart
@@ -35,27 +35,6 @@
String toString() => 'Size<${height}h X ${width}w>';
}
-class Point {
- final num x;
- final num y;
-
- const Point(this.x, this.y);
-
- Point.fromJson(Map json) : this(json['x'], json['y']);
-
- Map<String, num> toJson() => {'x': x, 'y': y};
-
- @override
- int get hashCode => x.hashCode * 3 + x.hashCode;
-
- @override
- bool operator ==(other) =>
- other is Point && other.x == this.x && other.x == this.x;
-
- @override
- String toString() => 'Point($x, $y)';
-}
-
abstract class SearchContext {
WebDriver get driver;
diff --git a/lib/src/web_element.dart b/lib/src/web_element.dart
index 45a3c05..6846744 100644
--- a/lib/src/web_element.dart
+++ b/lib/src/web_element.dart
@@ -48,7 +48,8 @@
/// The location within the document of this element.
Future<Point> get location async {
var point = await _get('location');
- return new Point.fromJson(point);
+ return new Point<int>(point['x'].toInt(), point['y'].toInt());
+ ;
}
/// The size of this element.
diff --git a/lib/src/window.dart b/lib/src/window.dart
index c8f750c..49235de 100644
--- a/lib/src/window.dart
+++ b/lib/src/window.dart
@@ -18,9 +18,9 @@
}
/// The location of this window.
- Future<Point> get location async {
+ Future<Point<int>> get location async {
var point = await _get('position');
- return new Point.fromJson(point);
+ return new Point<int>(point['x'].toInt(), point['y'].toInt());
}
/// Maximize this window.
@@ -34,8 +34,8 @@
}
/// Set this window location.
- Future setLocation(Point point) async {
- await _post('position', point);
+ Future setLocation(Point<int> point) async {
+ await _post('position', {'x': point.x, 'y': point.y});
}
@override
diff --git a/lib/webdriver.dart b/lib/webdriver.dart
index ccfaada..7f87d40 100644
--- a/lib/webdriver.dart
+++ b/lib/webdriver.dart
@@ -8,6 +8,8 @@
import 'dart:collection';
import 'dart:convert';
import 'dart:io';
+import 'dart:math' show Point;
+export 'dart:math' show Point;
import 'package:crypto/crypto.dart';
import 'package:matcher/matcher.dart';
diff --git a/test/src/window_test.dart b/test/src/window_test.dart
index 550413a..80a34b5 100644
--- a/test/src/window_test.dart
+++ b/test/src/window_test.dart
@@ -28,7 +28,7 @@
test('location', () async {
var window = await driver.window;
- var position = const Point(100, 200);
+ var position = const Point<int>(100, 200);
await window.setLocation(position);
expect(await window.location, position);
});
@@ -37,7 +37,7 @@
skip_test('maximize', () async {
var window = await driver.window;
await window.setSize(const Size(200, 300));
- await window.setLocation(const Point(100, 200));
+ await window.setLocation(const Point<int>(100, 200));
await window.maximize();
// maximizing can take some time
diff --git a/test/test_util.dart b/test/test_util.dart
index bcbe7bb..7219135 100644
--- a/test/test_util.dart
+++ b/test/test_util.dart
@@ -14,7 +14,7 @@
final Matcher isWebElement = new isInstanceOf<WebElement>();
final Matcher isSize = new isInstanceOf<Size>();
-final Matcher isPoint = new isInstanceOf<Point>();
+final Matcher isPoint = new isInstanceOf<Point<int>>();
bool isRunningOnTravis() => io.Platform.environment['TRAVIS'] == 'true';