diff --git a/packages/flutter_driver/lib/src/common/geometry.dart b/packages/flutter_driver/lib/src/common/geometry.dart index 90318bd4a3..6cab238f24 100644 --- a/packages/flutter_driver/lib/src/common/geometry.dart +++ b/packages/flutter_driver/lib/src/common/geometry.dart @@ -27,8 +27,11 @@ enum OffsetType { EnumIndex _offsetTypeIndex = EnumIndex(OffsetType.values); -/// A Flutter Driver command that return the [offsetType] from the RenderObject +/// A Flutter Driver command that returns the [offsetType] from the RenderObject /// identified by [finder]. +/// +/// The requested offset is returned in logical pixels, which can be translated +/// to device pixels via [Window.devicePixelRatio]. class GetOffset extends CommandWithTarget { /// The `finder` looks for an element to get its rect. GetOffset(SerializableFinder finder, this.offsetType, { Duration timeout }) : super(finder, timeout: timeout); @@ -51,14 +54,23 @@ class GetOffset extends CommandWithTarget { } /// The result of the [GetRect] command. +/// +/// The offset is provided in logical pixels, which can be translated +/// to device pixels via [Window.devicePixelRatio]. class GetOffsetResult extends Result { /// Creates a result with the offset defined by [dx] and [dy]. const GetOffsetResult({ this.dx = 0.0, this.dy = 0.0}); - /// The x component of the offset. + /// The x component of the offset in logical pixels. + /// + /// The value can be translated to device pixels via + /// [Window.devicePixelRatio]. final double dx; - /// The y component of the offset. + /// The y component of the offset in logical pixels. + /// + /// The value can be translated to device pixels via + /// [Window.devicePixelRatio]. final double dy; /// Deserializes the result from JSON. diff --git a/packages/flutter_driver/lib/src/driver/driver.dart b/packages/flutter_driver/lib/src/driver/driver.dart index c119399135..ea499d30ed 100644 --- a/packages/flutter_driver/lib/src/driver/driver.dart +++ b/packages/flutter_driver/lib/src/driver/driver.dart @@ -483,26 +483,41 @@ class FlutterDriver { } /// Returns the point at the top left of the widget identified by `finder`. + /// + /// The offset is expressed in logical pixels and can be translated to + /// device pixels via [Window.devicePixelRatio]. Future getTopLeft(SerializableFinder finder, { Duration timeout }) async { return _getOffset(finder, OffsetType.topLeft, timeout: timeout); } /// Returns the point at the top right of the widget identified by `finder`. + /// + /// The offset is expressed in logical pixels and can be translated to + /// device pixels via [Window.devicePixelRatio]. Future getTopRight(SerializableFinder finder, { Duration timeout }) async { return _getOffset(finder, OffsetType.topRight, timeout: timeout); } /// Returns the point at the bottom left of the widget identified by `finder`. + /// + /// The offset is expressed in logical pixels and can be translated to + /// device pixels via [Window.devicePixelRatio]. Future getBottomLeft(SerializableFinder finder, { Duration timeout }) async { return _getOffset(finder, OffsetType.bottomLeft, timeout: timeout); } /// Returns the point at the bottom right of the widget identified by `finder`. + /// + /// The offset is expressed in logical pixels and can be translated to + /// device pixels via [Window.devicePixelRatio]. Future getBottomRight(SerializableFinder finder, { Duration timeout }) async { return _getOffset(finder, OffsetType.bottomRight, timeout: timeout); } /// Returns the point at the center of the widget identified by `finder`. + /// + /// The offset is expressed in logical pixels and can be translated to + /// device pixels via [Window.devicePixelRatio]. Future getCenter(SerializableFinder finder, { Duration timeout }) async { return _getOffset(finder, OffsetType.center, timeout: timeout); }