Unverified Commit 8cf65526 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

everything const (#32380)

parent 87d9c553
...@@ -59,14 +59,17 @@ class WaitFor extends CommandWithTarget { ...@@ -59,14 +59,17 @@ class WaitFor extends CommandWithTarget {
WaitFor.deserialize(Map<String, String> json) : super.deserialize(json); WaitFor.deserialize(Map<String, String> json) : super.deserialize(json);
@override @override
final String kind = 'waitFor'; String get kind => 'waitFor';
} }
/// The result of a [WaitFor] command. /// The result of a [WaitFor] command.
class WaitForResult extends Result { class WaitForResult extends Result {
/// Creates a [WaitForResult].
const WaitForResult();
/// Deserializes the result from JSON. /// Deserializes the result from JSON.
static WaitForResult fromJson(Map<String, dynamic> json) { static WaitForResult fromJson(Map<String, dynamic> json) {
return WaitForResult(); return const WaitForResult();
} }
@override @override
...@@ -86,14 +89,17 @@ class WaitForAbsent extends CommandWithTarget { ...@@ -86,14 +89,17 @@ class WaitForAbsent extends CommandWithTarget {
WaitForAbsent.deserialize(Map<String, String> json) : super.deserialize(json); WaitForAbsent.deserialize(Map<String, String> json) : super.deserialize(json);
@override @override
final String kind = 'waitForAbsent'; String get kind => 'waitForAbsent';
} }
/// The result of a [WaitForAbsent] command. /// The result of a [WaitForAbsent] command.
class WaitForAbsentResult extends Result { class WaitForAbsentResult extends Result {
/// Creates a [WaitForAbsentResult].
const WaitForAbsentResult();
/// Deserializes the result from JSON. /// Deserializes the result from JSON.
static WaitForAbsentResult fromJson(Map<String, dynamic> json) { static WaitForAbsentResult fromJson(Map<String, dynamic> json) {
return WaitForAbsentResult(); return const WaitForAbsentResult();
} }
@override @override
...@@ -103,19 +109,23 @@ class WaitForAbsentResult extends Result { ...@@ -103,19 +109,23 @@ class WaitForAbsentResult extends Result {
/// A Flutter Driver command that waits until there are no more transient callbacks in the queue. /// A Flutter Driver command that waits until there are no more transient callbacks in the queue.
class WaitUntilNoTransientCallbacks extends Command { class WaitUntilNoTransientCallbacks extends Command {
/// Creates a command that waits for there to be no transient callbacks. /// Creates a command that waits for there to be no transient callbacks.
WaitUntilNoTransientCallbacks({ Duration timeout }) : super(timeout: timeout); const WaitUntilNoTransientCallbacks({ Duration timeout }) : super(timeout: timeout);
/// Deserializes this command from the value generated by [serialize]. /// Deserializes this command from the value generated by [serialize].
WaitUntilNoTransientCallbacks.deserialize(Map<String, String> json) WaitUntilNoTransientCallbacks.deserialize(Map<String, String> json)
: super.deserialize(json); : super.deserialize(json);
@override @override
final String kind = 'waitUntilNoTransientCallbacks'; String get kind => 'waitUntilNoTransientCallbacks';
} }
/// Base class for Flutter Driver finders, objects that describe how the driver /// Base class for Flutter Driver finders, objects that describe how the driver
/// should search for elements. /// should search for elements.
abstract class SerializableFinder { abstract class SerializableFinder {
/// A const constructor to allow subclasses to be const.
const SerializableFinder();
/// Identifies the type of finder to be used by the driver extension. /// Identifies the type of finder to be used by the driver extension.
String get finderType; String get finderType;
...@@ -137,7 +147,7 @@ abstract class SerializableFinder { ...@@ -137,7 +147,7 @@ abstract class SerializableFinder {
case 'ByTooltipMessage': return ByTooltipMessage.deserialize(json); case 'ByTooltipMessage': return ByTooltipMessage.deserialize(json);
case 'BySemanticsLabel': return BySemanticsLabel.deserialize(json); case 'BySemanticsLabel': return BySemanticsLabel.deserialize(json);
case 'ByText': return ByText.deserialize(json); case 'ByText': return ByText.deserialize(json);
case 'PageBack': return PageBack(); case 'PageBack': return const PageBack();
} }
throw DriverError('Unsupported search specification type $finderType'); throw DriverError('Unsupported search specification type $finderType');
} }
...@@ -146,13 +156,13 @@ abstract class SerializableFinder { ...@@ -146,13 +156,13 @@ abstract class SerializableFinder {
/// A Flutter Driver finder that finds widgets by tooltip text. /// A Flutter Driver finder that finds widgets by tooltip text.
class ByTooltipMessage extends SerializableFinder { class ByTooltipMessage extends SerializableFinder {
/// Creates a tooltip finder given the tooltip's message [text]. /// Creates a tooltip finder given the tooltip's message [text].
ByTooltipMessage(this.text); const ByTooltipMessage(this.text);
/// Tooltip message text. /// Tooltip message text.
final String text; final String text;
@override @override
final String finderType = 'ByTooltipMessage'; String get finderType => 'ByTooltipMessage';
@override @override
Map<String, String> serialize() => super.serialize()..addAll(<String, String>{ Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
...@@ -171,7 +181,7 @@ class ByTooltipMessage extends SerializableFinder { ...@@ -171,7 +181,7 @@ class ByTooltipMessage extends SerializableFinder {
/// match. If it is a [RegExp], it will return true for [RegExp.hasMatch]. /// match. If it is a [RegExp], it will return true for [RegExp.hasMatch].
class BySemanticsLabel extends SerializableFinder { class BySemanticsLabel extends SerializableFinder {
/// Creates a semantic label finder given the [label]. /// Creates a semantic label finder given the [label].
BySemanticsLabel(this.label); const BySemanticsLabel(this.label);
/// A [Pattern] matching the [Semantics.properties.label]. /// A [Pattern] matching the [Semantics.properties.label].
/// ///
...@@ -179,7 +189,7 @@ class BySemanticsLabel extends SerializableFinder { ...@@ -179,7 +189,7 @@ class BySemanticsLabel extends SerializableFinder {
final Pattern label; final Pattern label;
@override @override
final String finderType = 'BySemanticsLabel'; String get finderType => 'BySemanticsLabel';
@override @override
Map<String, String> serialize() { Map<String, String> serialize() {
...@@ -207,13 +217,13 @@ class BySemanticsLabel extends SerializableFinder { ...@@ -207,13 +217,13 @@ class BySemanticsLabel extends SerializableFinder {
/// [EditableText] widget. /// [EditableText] widget.
class ByText extends SerializableFinder { class ByText extends SerializableFinder {
/// Creates a text finder given the text. /// Creates a text finder given the text.
ByText(this.text); const ByText(this.text);
/// The text that appears inside the [Text] or [EditableText] widget. /// The text that appears inside the [Text] or [EditableText] widget.
final String text; final String text;
@override @override
final String finderType = 'ByText'; String get finderType => 'ByText';
@override @override
Map<String, String> serialize() => super.serialize()..addAll(<String, String>{ Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
...@@ -248,7 +258,7 @@ class ByValueKey extends SerializableFinder { ...@@ -248,7 +258,7 @@ class ByValueKey extends SerializableFinder {
final String keyValueType; final String keyValueType;
@override @override
final String finderType = 'ByValueKey'; String get finderType => 'ByValueKey';
@override @override
Map<String, String> serialize() => super.serialize()..addAll(<String, String>{ Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
...@@ -274,13 +284,13 @@ class ByValueKey extends SerializableFinder { ...@@ -274,13 +284,13 @@ class ByValueKey extends SerializableFinder {
/// A Flutter Driver finder that finds widgets by their [runtimeType]. /// A Flutter Driver finder that finds widgets by their [runtimeType].
class ByType extends SerializableFinder { class ByType extends SerializableFinder {
/// Creates a finder that given the runtime type in string form. /// Creates a finder that given the runtime type in string form.
ByType(this.type); const ByType(this.type);
/// The widget's [runtimeType], in string form. /// The widget's [runtimeType], in string form.
final String type; final String type;
@override @override
final String finderType = 'ByType'; String get finderType => 'ByType';
@override @override
Map<String, String> serialize() => super.serialize()..addAll(<String, String>{ Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
...@@ -300,6 +310,9 @@ class ByType extends SerializableFinder { ...@@ -300,6 +310,9 @@ class ByType extends SerializableFinder {
/// ///
/// * [WidgetTester.pageBack], for a similar functionality in widget tests. /// * [WidgetTester.pageBack], for a similar functionality in widget tests.
class PageBack extends SerializableFinder { class PageBack extends SerializableFinder {
/// Creates a [PageBack].
const PageBack();
@override @override
String get finderType => 'PageBack'; String get finderType => 'PageBack';
} }
...@@ -333,7 +346,7 @@ class GetSemanticsId extends CommandWithTarget { ...@@ -333,7 +346,7 @@ class GetSemanticsId extends CommandWithTarget {
class GetSemanticsIdResult extends Result { class GetSemanticsIdResult extends Result {
/// Creates a new [GetSemanticsId] result. /// Creates a new [GetSemanticsId] result.
GetSemanticsIdResult(this.id); const GetSemanticsIdResult(this.id);
/// The semantics id of the node; /// The semantics id of the node;
final int id; final int id;
......
...@@ -7,7 +7,7 @@ import 'message.dart'; ...@@ -7,7 +7,7 @@ import 'message.dart';
/// A Flutter Driver command that enables or disables the FrameSync mechanism. /// A Flutter Driver command that enables or disables the FrameSync mechanism.
class SetFrameSync extends Command { class SetFrameSync extends Command {
/// Creates a command to toggle the FrameSync mechanism. /// Creates a command to toggle the FrameSync mechanism.
SetFrameSync(this.enabled, { Duration timeout }) : super(timeout: timeout); const SetFrameSync(this.enabled, { Duration timeout }) : super(timeout: timeout);
/// Deserializes this command from the value generated by [serialize]. /// Deserializes this command from the value generated by [serialize].
SetFrameSync.deserialize(Map<String, String> params) SetFrameSync.deserialize(Map<String, String> params)
...@@ -18,7 +18,7 @@ class SetFrameSync extends Command { ...@@ -18,7 +18,7 @@ class SetFrameSync extends Command {
final bool enabled; final bool enabled;
@override @override
final String kind = 'set_frame_sync'; String get kind => 'set_frame_sync';
@override @override
Map<String, String> serialize() => super.serialize()..addAll(<String, String>{ Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
...@@ -28,9 +28,12 @@ class SetFrameSync extends Command { ...@@ -28,9 +28,12 @@ class SetFrameSync extends Command {
/// The result of a [SetFrameSync] command. /// The result of a [SetFrameSync] command.
class SetFrameSyncResult extends Result { class SetFrameSyncResult extends Result {
/// Creates a [SetFrameSyncResult].
const SetFrameSyncResult();
/// Deserializes this result from JSON. /// Deserializes this result from JSON.
static SetFrameSyncResult fromJson(Map<String, dynamic> json) { static SetFrameSyncResult fromJson(Map<String, dynamic> json) {
return SetFrameSyncResult(); return const SetFrameSyncResult();
} }
@override @override
......
...@@ -47,13 +47,13 @@ class GetOffset extends CommandWithTarget { ...@@ -47,13 +47,13 @@ class GetOffset extends CommandWithTarget {
final OffsetType offsetType; final OffsetType offsetType;
@override @override
final String kind = 'get_offset'; String get kind => 'get_offset';
} }
/// The result of the [GetRect] command. /// The result of the [GetRect] command.
class GetOffsetResult extends Result { class GetOffsetResult extends Result {
/// Creates a result with the offset defined by [dx] and [dy]. /// Creates a result with the offset defined by [dx] and [dy].
GetOffsetResult({ this.dx = 0.0, this.dy = 0.0}); const GetOffsetResult({ this.dx = 0.0, this.dy = 0.0});
/// The x component of the offset. /// The x component of the offset.
final double dx; final double dx;
......
...@@ -14,14 +14,17 @@ class Tap extends CommandWithTarget { ...@@ -14,14 +14,17 @@ class Tap extends CommandWithTarget {
Tap.deserialize(Map<String, String> json) : super.deserialize(json); Tap.deserialize(Map<String, String> json) : super.deserialize(json);
@override @override
final String kind = 'tap'; String get kind => 'tap';
} }
/// The result of a [Tap] command. /// The result of a [Tap] command.
class TapResult extends Result { class TapResult extends Result {
/// Creates a [TapResult].
const TapResult();
/// Deserializes this result from JSON. /// Deserializes this result from JSON.
static TapResult fromJson(Map<String, dynamic> json) { static TapResult fromJson(Map<String, dynamic> json) {
return TapResult(); return const TapResult();
} }
@override @override
...@@ -63,7 +66,7 @@ class Scroll extends CommandWithTarget { ...@@ -63,7 +66,7 @@ class Scroll extends CommandWithTarget {
final int frequency; final int frequency;
@override @override
final String kind = 'scroll'; String get kind => 'scroll';
@override @override
Map<String, String> serialize() => super.serialize()..addAll(<String, String>{ Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
...@@ -76,9 +79,12 @@ class Scroll extends CommandWithTarget { ...@@ -76,9 +79,12 @@ class Scroll extends CommandWithTarget {
/// The result of a [Scroll] command. /// The result of a [Scroll] command.
class ScrollResult extends Result { class ScrollResult extends Result {
/// Creates a [ScrollResult].
const ScrollResult();
/// Deserializes this result from JSON. /// Deserializes this result from JSON.
static ScrollResult fromJson(Map<String, dynamic> json) { static ScrollResult fromJson(Map<String, dynamic> json) {
return ScrollResult(); return const ScrollResult();
} }
@override @override
...@@ -106,7 +112,7 @@ class ScrollIntoView extends CommandWithTarget { ...@@ -106,7 +112,7 @@ class ScrollIntoView extends CommandWithTarget {
final double alignment; final double alignment;
@override @override
final String kind = 'scrollIntoView'; String get kind => 'scrollIntoView';
@override @override
Map<String, String> serialize() => super.serialize()..addAll(<String, String>{ Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
......
...@@ -8,13 +8,13 @@ import 'message.dart'; ...@@ -8,13 +8,13 @@ import 'message.dart';
/// A Flutter Driver command that requests an application health check. /// A Flutter Driver command that requests an application health check.
class GetHealth extends Command { class GetHealth extends Command {
/// Create a health check command. /// Create a health check command.
GetHealth({ Duration timeout }) : super(timeout: timeout); const GetHealth({ Duration timeout }) : super(timeout: timeout);
/// Deserializes this command from the value generated by [serialize]. /// Deserializes this command from the value generated by [serialize].
GetHealth.deserialize(Map<String, String> json) : super.deserialize(json); GetHealth.deserialize(Map<String, String> json) : super.deserialize(json);
@override @override
final String kind = 'get_health'; String get kind => 'get_health';
} }
/// A description of application state. /// A description of application state.
...@@ -33,7 +33,7 @@ final EnumIndex<HealthStatus> _healthStatusIndex = ...@@ -33,7 +33,7 @@ final EnumIndex<HealthStatus> _healthStatusIndex =
/// [FlutterDriver.checkHealth] test. /// [FlutterDriver.checkHealth] test.
class Health extends Result { class Health extends Result {
/// Creates a [Health] object with the given [status]. /// Creates a [Health] object with the given [status].
Health(this.status) const Health(this.status)
: assert(status != null); : assert(status != null);
/// The status represented by this object. /// The status represented by this object.
......
...@@ -47,6 +47,9 @@ abstract class Command { ...@@ -47,6 +47,9 @@ abstract class Command {
/// An object sent from a Flutter application back to the Flutter Driver in /// An object sent from a Flutter application back to the Flutter Driver in
/// response to a command. /// response to a command.
abstract class Result { abstract class Result {
/// A const constructor to allow subclasses to be const.
const Result();
/// Serializes this message to a JSON map. /// Serializes this message to a JSON map.
Map<String, dynamic> toJson(); Map<String, dynamic> toJson();
} }
...@@ -7,20 +7,20 @@ import 'message.dart'; ...@@ -7,20 +7,20 @@ import 'message.dart';
/// A Flutter Driver command that requests a string representation of the render tree. /// A Flutter Driver command that requests a string representation of the render tree.
class GetRenderTree extends Command { class GetRenderTree extends Command {
/// Create a command to request a string representation of the render tree. /// Create a command to request a string representation of the render tree.
GetRenderTree({ Duration timeout }) : super(timeout: timeout); const GetRenderTree({ Duration timeout }) : super(timeout: timeout);
/// Deserializes this command from the value generated by [serialize]. /// Deserializes this command from the value generated by [serialize].
GetRenderTree.deserialize(Map<String, String> json) : super.deserialize(json); GetRenderTree.deserialize(Map<String, String> json) : super.deserialize(json);
@override @override
final String kind = 'get_render_tree'; String get kind => 'get_render_tree';
} }
/// A string representation of the render tree, the result of a /// A string representation of the render tree, the result of a
/// [FlutterDriver.getRenderTree] method. /// [FlutterDriver.getRenderTree] method.
class RenderTree extends Result { class RenderTree extends Result {
/// Creates a [RenderTree] object with the given string representation. /// Creates a [RenderTree] object with the given string representation.
RenderTree(this.tree); const RenderTree(this.tree);
/// String representation of the render tree. /// String representation of the render tree.
final String tree; final String tree;
......
...@@ -8,7 +8,7 @@ import 'message.dart'; ...@@ -8,7 +8,7 @@ import 'message.dart';
/// string response. /// string response.
class RequestData extends Command { class RequestData extends Command {
/// Create a command that sends a message. /// Create a command that sends a message.
RequestData(this.message, { Duration timeout }) : super(timeout: timeout); const RequestData(this.message, { Duration timeout }) : super(timeout: timeout);
/// Deserializes this command from the value generated by [serialize]. /// Deserializes this command from the value generated by [serialize].
RequestData.deserialize(Map<String, String> params) RequestData.deserialize(Map<String, String> params)
...@@ -19,7 +19,7 @@ class RequestData extends Command { ...@@ -19,7 +19,7 @@ class RequestData extends Command {
final String message; final String message;
@override @override
final String kind = 'request_data'; String get kind => 'request_data';
@override @override
Map<String, String> serialize() => super.serialize()..addAll(<String, String>{ Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
...@@ -30,7 +30,7 @@ class RequestData extends Command { ...@@ -30,7 +30,7 @@ class RequestData extends Command {
/// The result of the [RequestData] command. /// The result of the [RequestData] command.
class RequestDataResult extends Result { class RequestDataResult extends Result {
/// Creates a result with the given [message]. /// Creates a result with the given [message].
RequestDataResult(this.message); const RequestDataResult(this.message);
/// The text extracted by the [RequestData] command. /// The text extracted by the [RequestData] command.
final String message; final String message;
......
...@@ -7,7 +7,7 @@ import 'message.dart'; ...@@ -7,7 +7,7 @@ import 'message.dart';
/// A Flutter Driver command that enables or disables semantics. /// A Flutter Driver command that enables or disables semantics.
class SetSemantics extends Command { class SetSemantics extends Command {
/// Creates a command that enables or disables semantics. /// Creates a command that enables or disables semantics.
SetSemantics(this.enabled, { Duration timeout }) : super(timeout: timeout); const SetSemantics(this.enabled, { Duration timeout }) : super(timeout: timeout);
/// Deserializes this command from the value generated by [serialize]. /// Deserializes this command from the value generated by [serialize].
SetSemantics.deserialize(Map<String, String> params) SetSemantics.deserialize(Map<String, String> params)
...@@ -18,7 +18,7 @@ class SetSemantics extends Command { ...@@ -18,7 +18,7 @@ class SetSemantics extends Command {
final bool enabled; final bool enabled;
@override @override
final String kind = 'set_semantics'; String get kind => 'set_semantics';
@override @override
Map<String, String> serialize() => super.serialize()..addAll(<String, String>{ Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
...@@ -29,7 +29,7 @@ class SetSemantics extends Command { ...@@ -29,7 +29,7 @@ class SetSemantics extends Command {
/// The result of a [SetSemantics] command. /// The result of a [SetSemantics] command.
class SetSemanticsResult extends Result { class SetSemanticsResult extends Result {
/// Create a result with the given [changedState]. /// Create a result with the given [changedState].
SetSemanticsResult(this.changedState); const SetSemanticsResult(this.changedState);
/// Whether the [SetSemantics] command actually changed the state that the /// Whether the [SetSemantics] command actually changed the state that the
/// application was in. /// application was in.
......
...@@ -14,13 +14,13 @@ class GetText extends CommandWithTarget { ...@@ -14,13 +14,13 @@ class GetText extends CommandWithTarget {
GetText.deserialize(Map<String, dynamic> json) : super.deserialize(json); GetText.deserialize(Map<String, dynamic> json) : super.deserialize(json);
@override @override
final String kind = 'get_text'; String get kind => 'get_text';
} }
/// The result of the [GetText] command. /// The result of the [GetText] command.
class GetTextResult extends Result { class GetTextResult extends Result {
/// Creates a result with the given [text]. /// Creates a result with the given [text].
GetTextResult(this.text); const GetTextResult(this.text);
/// The text extracted by the [GetText] command. /// The text extracted by the [GetText] command.
final String text; final String text;
...@@ -39,7 +39,7 @@ class GetTextResult extends Result { ...@@ -39,7 +39,7 @@ class GetTextResult extends Result {
/// A Flutter Driver command that enters text into the currently focused widget. /// A Flutter Driver command that enters text into the currently focused widget.
class EnterText extends Command { class EnterText extends Command {
/// Creates a command that enters text into the currently focused widget. /// Creates a command that enters text into the currently focused widget.
EnterText(this.text, { Duration timeout }) : super(timeout: timeout); const EnterText(this.text, { Duration timeout }) : super(timeout: timeout);
/// Deserializes this command from the value generated by [serialize]. /// Deserializes this command from the value generated by [serialize].
EnterText.deserialize(Map<String, dynamic> json) EnterText.deserialize(Map<String, dynamic> json)
...@@ -50,7 +50,7 @@ class EnterText extends Command { ...@@ -50,7 +50,7 @@ class EnterText extends Command {
final String text; final String text;
@override @override
final String kind = 'enter_text'; String get kind => 'enter_text';
@override @override
Map<String, String> serialize() => super.serialize()..addAll(<String, String>{ Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
...@@ -61,11 +61,11 @@ class EnterText extends Command { ...@@ -61,11 +61,11 @@ class EnterText extends Command {
/// The result of the [EnterText] command. /// The result of the [EnterText] command.
class EnterTextResult extends Result { class EnterTextResult extends Result {
/// Creates a successful result of entering the text. /// Creates a successful result of entering the text.
EnterTextResult(); const EnterTextResult();
/// Deserializes the result from JSON. /// Deserializes the result from JSON.
static EnterTextResult fromJson(Map<String, dynamic> json) { static EnterTextResult fromJson(Map<String, dynamic> json) {
return EnterTextResult(); return const EnterTextResult();
} }
@override @override
...@@ -75,7 +75,7 @@ class EnterTextResult extends Result { ...@@ -75,7 +75,7 @@ class EnterTextResult extends Result {
/// A Flutter Driver command that enables and disables text entry emulation. /// A Flutter Driver command that enables and disables text entry emulation.
class SetTextEntryEmulation extends Command { class SetTextEntryEmulation extends Command {
/// Creates a command that enables and disables text entry emulation. /// Creates a command that enables and disables text entry emulation.
SetTextEntryEmulation(this.enabled, { Duration timeout }) : super(timeout: timeout); const SetTextEntryEmulation(this.enabled, { Duration timeout }) : super(timeout: timeout);
/// Deserializes this command from the value generated by [serialize]. /// Deserializes this command from the value generated by [serialize].
SetTextEntryEmulation.deserialize(Map<String, dynamic> json) SetTextEntryEmulation.deserialize(Map<String, dynamic> json)
...@@ -86,7 +86,7 @@ class SetTextEntryEmulation extends Command { ...@@ -86,7 +86,7 @@ class SetTextEntryEmulation extends Command {
final bool enabled; final bool enabled;
@override @override
final String kind = 'set_text_entry_emulation'; String get kind => 'set_text_entry_emulation';
@override @override
Map<String, String> serialize() => super.serialize()..addAll(<String, String>{ Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
...@@ -97,11 +97,11 @@ class SetTextEntryEmulation extends Command { ...@@ -97,11 +97,11 @@ class SetTextEntryEmulation extends Command {
/// The result of the [SetTextEntryEmulation] command. /// The result of the [SetTextEntryEmulation] command.
class SetTextEntryEmulationResult extends Result { class SetTextEntryEmulationResult extends Result {
/// Creates a successful result. /// Creates a successful result.
SetTextEntryEmulationResult(); const SetTextEntryEmulationResult();
/// Deserializes the result from JSON. /// Deserializes the result from JSON.
static SetTextEntryEmulationResult fromJson(Map<String, dynamic> json) { static SetTextEntryEmulationResult fromJson(Map<String, dynamic> json) {
return SetTextEntryEmulationResult(); return const SetTextEntryEmulationResult();
} }
@override @override
......
...@@ -1016,7 +1016,7 @@ class CommonFinders { ...@@ -1016,7 +1016,7 @@ class CommonFinders {
SerializableFinder byType(String type) => ByType(type); SerializableFinder byType(String type) => ByType(type);
/// Finds the back button on a Material or Cupertino page's scaffold. /// Finds the back button on a Material or Cupertino page's scaffold.
SerializableFinder pageBack() => PageBack(); SerializableFinder pageBack() => const PageBack();
} }
/// An immutable 2D floating-point offset used by Flutter Driver. /// An immutable 2D floating-point offset used by Flutter Driver.
......
...@@ -205,7 +205,7 @@ class FlutterDriverExtension { ...@@ -205,7 +205,7 @@ class FlutterDriverExtension {
}; };
} }
Future<Health> _getHealth(Command command) async => Health(HealthStatus.ok); Future<Health> _getHealth(Command command) async => const Health(HealthStatus.ok);
Future<RenderTree> _getRenderTree(Command command) async { Future<RenderTree> _getRenderTree(Command command) async {
return RenderTree(RendererBinding.instance?.renderView?.toStringDeep()); return RenderTree(RendererBinding.instance?.renderView?.toStringDeep());
...@@ -325,19 +325,19 @@ class FlutterDriverExtension { ...@@ -325,19 +325,19 @@ class FlutterDriverExtension {
_createFinder(tapCommand.finder).hitTestable() _createFinder(tapCommand.finder).hitTestable()
); );
await _prober.tap(computedFinder); await _prober.tap(computedFinder);
return TapResult(); return const TapResult();
} }
Future<WaitForResult> _waitFor(Command command) async { Future<WaitForResult> _waitFor(Command command) async {
final WaitFor waitForCommand = command; final WaitFor waitForCommand = command;
await _waitForElement(_createFinder(waitForCommand.finder)); await _waitForElement(_createFinder(waitForCommand.finder));
return WaitForResult(); return const WaitForResult();
} }
Future<WaitForAbsentResult> _waitForAbsent(Command command) async { Future<WaitForAbsentResult> _waitForAbsent(Command command) async {
final WaitForAbsent waitForAbsentCommand = command; final WaitForAbsent waitForAbsentCommand = command;
await _waitForAbsentElement(_createFinder(waitForAbsentCommand.finder)); await _waitForAbsentElement(_createFinder(waitForAbsentCommand.finder));
return WaitForAbsentResult(); return const WaitForAbsentResult();
} }
Future<Result> _waitUntilNoTransientCallbacks(Command command) async { Future<Result> _waitUntilNoTransientCallbacks(Command command) async {
...@@ -409,14 +409,14 @@ class FlutterDriverExtension { ...@@ -409,14 +409,14 @@ class FlutterDriverExtension {
} }
_prober.binding.dispatchEvent(pointer.up(), hitTest); _prober.binding.dispatchEvent(pointer.up(), hitTest);
return ScrollResult(); return const ScrollResult();
} }
Future<ScrollResult> _scrollIntoView(Command command) async { Future<ScrollResult> _scrollIntoView(Command command) async {
final ScrollIntoView scrollIntoViewCommand = command; final ScrollIntoView scrollIntoViewCommand = command;
final Finder target = await _waitForElement(_createFinder(scrollIntoViewCommand.finder)); final Finder target = await _waitForElement(_createFinder(scrollIntoViewCommand.finder));
await Scrollable.ensureVisible(target.evaluate().single, duration: const Duration(milliseconds: 100), alignment: scrollIntoViewCommand.alignment ?? 0.0); await Scrollable.ensureVisible(target.evaluate().single, duration: const Duration(milliseconds: 100), alignment: scrollIntoViewCommand.alignment ?? 0.0);
return ScrollResult(); return const ScrollResult();
} }
Future<GetTextResult> _getText(Command command) async { Future<GetTextResult> _getText(Command command) async {
...@@ -434,7 +434,7 @@ class FlutterDriverExtension { ...@@ -434,7 +434,7 @@ class FlutterDriverExtension {
} else { } else {
_testTextInput.unregister(); _testTextInput.unregister();
} }
return SetTextEntryEmulationResult(); return const SetTextEntryEmulationResult();
} }
Future<EnterTextResult> _enterText(Command command) async { Future<EnterTextResult> _enterText(Command command) async {
...@@ -444,7 +444,7 @@ class FlutterDriverExtension { ...@@ -444,7 +444,7 @@ class FlutterDriverExtension {
} }
final EnterText enterTextCommand = command; final EnterText enterTextCommand = command;
_testTextInput.enterText(enterTextCommand.text); _testTextInput.enterText(enterTextCommand.text);
return EnterTextResult(); return const EnterTextResult();
} }
Future<RequestDataResult> _requestData(Command command) async { Future<RequestDataResult> _requestData(Command command) async {
...@@ -455,7 +455,7 @@ class FlutterDriverExtension { ...@@ -455,7 +455,7 @@ class FlutterDriverExtension {
Future<SetFrameSyncResult> _setFrameSync(Command command) async { Future<SetFrameSyncResult> _setFrameSync(Command command) async {
final SetFrameSync setFrameSyncCommand = command; final SetFrameSync setFrameSyncCommand = command;
_frameSync = setFrameSyncCommand.enabled; _frameSync = setFrameSyncCommand.enabled;
return SetFrameSyncResult(); return const SetFrameSyncResult();
} }
SemanticsHandle _semantics; SemanticsHandle _semantics;
......
...@@ -24,7 +24,7 @@ void main() { ...@@ -24,7 +24,7 @@ void main() {
}); });
testWidgets('returns immediately when transient callback queue is empty', (WidgetTester tester) async { testWidgets('returns immediately when transient callback queue is empty', (WidgetTester tester) async {
extension.call(WaitUntilNoTransientCallbacks().serialize()) extension.call(const WaitUntilNoTransientCallbacks().serialize())
.then<void>(expectAsync1((Map<String, dynamic> r) { .then<void>(expectAsync1((Map<String, dynamic> r) {
result = r; result = r;
})); }));
...@@ -44,7 +44,7 @@ void main() { ...@@ -44,7 +44,7 @@ void main() {
// Intentionally blank. We only care about existence of a callback. // Intentionally blank. We only care about existence of a callback.
}); });
extension.call(WaitUntilNoTransientCallbacks().serialize()) extension.call(const WaitUntilNoTransientCallbacks().serialize())
.then<void>(expectAsync1((Map<String, dynamic> r) { .then<void>(expectAsync1((Map<String, dynamic> r) {
result = r; result = r;
})); }));
...@@ -66,7 +66,7 @@ void main() { ...@@ -66,7 +66,7 @@ void main() {
testWidgets('handler', (WidgetTester tester) async { testWidgets('handler', (WidgetTester tester) async {
expect(log, isEmpty); expect(log, isEmpty);
final dynamic result = RequestDataResult.fromJson((await extension.call(RequestData('hello').serialize()))['response']); final dynamic result = RequestDataResult.fromJson((await extension.call(const RequestData('hello').serialize()))['response']);
expect(log, <String>['hello']); expect(log, <String>['hello']);
expect(result.message, '1'); expect(result.message, '1');
}); });
...@@ -83,7 +83,7 @@ void main() { ...@@ -83,7 +83,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
const Text('hello', textDirection: TextDirection.ltr)); const Text('hello', textDirection: TextDirection.ltr));
final Map<String, Object> arguments = GetSemanticsId(ByText('hello')).serialize(); final Map<String, Object> arguments = GetSemanticsId(const ByText('hello')).serialize();
final GetSemanticsIdResult result = GetSemanticsIdResult.fromJson((await extension.call(arguments))['response']); final GetSemanticsIdResult result = GetSemanticsIdResult.fromJson((await extension.call(arguments))['response']);
expect(result.id, 1); expect(result.id, 1);
...@@ -94,7 +94,7 @@ void main() { ...@@ -94,7 +94,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
const Text('hello', textDirection: TextDirection.ltr)); const Text('hello', textDirection: TextDirection.ltr));
final Map<String, Object> arguments = GetSemanticsId(ByText('hello')).serialize(); final Map<String, Object> arguments = GetSemanticsId(const ByText('hello')).serialize();
final Map<String, Object> response = await extension.call(arguments); final Map<String, Object> response = await extension.call(arguments);
expect(response['isError'], true); expect(response['isError'], true);
...@@ -113,7 +113,7 @@ void main() { ...@@ -113,7 +113,7 @@ void main() {
), ),
); );
final Map<String, Object> arguments = GetSemanticsId(ByText('hello')).serialize(); final Map<String, Object> arguments = GetSemanticsId(const ByText('hello')).serialize();
final Map<String, Object> response = await extension.call(arguments); final Map<String, Object> response = await extension.call(arguments);
expect(response['isError'], true); expect(response['isError'], true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment