This reverts commit 8edc3f76cc53375a18057b1cd51eb7c2a85a2769.
This commit is contained in:
parent
8edc3f76cc
commit
df2db4e50f
@ -106,6 +106,52 @@ class WaitForAbsentResult extends Result {
|
|||||||
Map<String, dynamic> toJson() => <String, dynamic>{};
|
Map<String, dynamic> toJson() => <String, dynamic>{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A Flutter Driver command that waits until there are no more transient callbacks in the queue.
|
||||||
|
class WaitUntilNoTransientCallbacks extends Command {
|
||||||
|
/// Creates a command that waits for there to be no transient callbacks.
|
||||||
|
const WaitUntilNoTransientCallbacks({ Duration timeout }) : super(timeout: timeout);
|
||||||
|
|
||||||
|
/// Deserializes this command from the value generated by [serialize].
|
||||||
|
WaitUntilNoTransientCallbacks.deserialize(Map<String, String> json)
|
||||||
|
: super.deserialize(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get kind => 'waitUntilNoTransientCallbacks';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A Flutter Driver command that waits until the frame is synced.
|
||||||
|
class WaitUntilNoPendingFrame extends Command {
|
||||||
|
/// Creates a command that waits until there's no pending frame scheduled.
|
||||||
|
const WaitUntilNoPendingFrame({ Duration timeout }) : super(timeout: timeout);
|
||||||
|
|
||||||
|
/// Deserializes this command from the value generated by [serialize].
|
||||||
|
WaitUntilNoPendingFrame.deserialize(Map<String, String> json)
|
||||||
|
: super.deserialize(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get kind => 'waitUntilNoPendingFrame';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A Flutter Driver command that waits until the Flutter engine rasterizes the
|
||||||
|
/// first frame.
|
||||||
|
///
|
||||||
|
/// {@template flutter.frame_rasterized_vs_presented}
|
||||||
|
/// Usually, the time that a frame is rasterized is very close to the time that
|
||||||
|
/// it gets presented on the display. Specifically, rasterization is the last
|
||||||
|
/// expensive phase of a frame that's still in Flutter's control.
|
||||||
|
/// {@endtemplate}
|
||||||
|
class WaitUntilFirstFrameRasterized extends Command {
|
||||||
|
/// Creates this command.
|
||||||
|
const WaitUntilFirstFrameRasterized({ Duration timeout }) : super(timeout: timeout);
|
||||||
|
|
||||||
|
/// Deserializes this command from the value generated by [serialize].
|
||||||
|
WaitUntilFirstFrameRasterized.deserialize(Map<String, String> json)
|
||||||
|
: super.deserialize(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get kind => 'waitUntilFirstFrameRasterized';
|
||||||
|
}
|
||||||
|
|
||||||
/// 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 {
|
||||||
|
@ -1,324 +0,0 @@
|
|||||||
// Copyright 2019 The Chromium Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
|
||||||
// found in the LICENSE file.
|
|
||||||
|
|
||||||
import 'dart:async';
|
|
||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:flutter/scheduler.dart';
|
|
||||||
import 'package:flutter/widgets.dart';
|
|
||||||
|
|
||||||
import 'message.dart';
|
|
||||||
|
|
||||||
/// A Flutter Driver command that waits until a given [condition] is satisfied.
|
|
||||||
class WaitForCondition extends Command {
|
|
||||||
/// Creates a command that waits for the given [condition] is met.
|
|
||||||
///
|
|
||||||
/// The [condition] argument must not be null.
|
|
||||||
const WaitForCondition(this.condition, {Duration timeout})
|
|
||||||
: assert(condition != null),
|
|
||||||
super(timeout: timeout);
|
|
||||||
|
|
||||||
/// Deserializes this command from the value generated by [serialize].
|
|
||||||
///
|
|
||||||
/// The [json] argument cannot be null.
|
|
||||||
WaitForCondition.deserialize(Map<String, String> json)
|
|
||||||
: assert(json != null),
|
|
||||||
condition = _deserialize(json),
|
|
||||||
super.deserialize(json);
|
|
||||||
|
|
||||||
/// The condition that this command shall wait for.
|
|
||||||
final WaitCondition condition;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Map<String, String> serialize() => super.serialize()..addAll(condition.serialize());
|
|
||||||
|
|
||||||
@override
|
|
||||||
String get kind => 'waitForCondition';
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A Flutter Driver command that waits until there are no more transient callbacks in the queue.
|
|
||||||
///
|
|
||||||
/// This command has been deprecated in favor of [WaitForCondition]. Construct
|
|
||||||
/// a command that waits until no transient callbacks as follows:
|
|
||||||
///
|
|
||||||
/// ```dart
|
|
||||||
/// WaitForCondition noTransientCallbacks = WaitForCondition(NoTransientCallbacksCondition());
|
|
||||||
/// ```
|
|
||||||
@Deprecated('This command has been deprecated in favor of WaitForCondition. '
|
|
||||||
'Use WaitForCondition command with NoTransientCallbacksCondition.')
|
|
||||||
class WaitUntilNoTransientCallbacks extends Command {
|
|
||||||
/// Creates a command that waits for there to be no transient callbacks.
|
|
||||||
const WaitUntilNoTransientCallbacks({ Duration timeout }) : super(timeout: timeout);
|
|
||||||
|
|
||||||
/// Deserializes this command from the value generated by [serialize].
|
|
||||||
WaitUntilNoTransientCallbacks.deserialize(Map<String, String> json)
|
|
||||||
: super.deserialize(json);
|
|
||||||
|
|
||||||
@override
|
|
||||||
String get kind => 'waitUntilNoTransientCallbacks';
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A Flutter Driver command that waits until the frame is synced.
|
|
||||||
///
|
|
||||||
/// This command has been deprecated in favor of [WaitForCondition]. Construct
|
|
||||||
/// a command that waits until no pending frame as follows:
|
|
||||||
///
|
|
||||||
/// ```dart
|
|
||||||
/// WaitForCondition noPendingFrame = WaitForCondition(NoPendingFrameCondition());
|
|
||||||
/// ```
|
|
||||||
@Deprecated('This command has been deprecated in favor of WaitForCondition. '
|
|
||||||
'Use WaitForCondition command with NoPendingFrameCondition.')
|
|
||||||
class WaitUntilNoPendingFrame extends Command {
|
|
||||||
/// Creates a command that waits until there's no pending frame scheduled.
|
|
||||||
const WaitUntilNoPendingFrame({ Duration timeout }) : super(timeout: timeout);
|
|
||||||
|
|
||||||
/// Deserializes this command from the value generated by [serialize].
|
|
||||||
WaitUntilNoPendingFrame.deserialize(Map<String, String> json)
|
|
||||||
: super.deserialize(json);
|
|
||||||
|
|
||||||
@override
|
|
||||||
String get kind => 'waitUntilNoPendingFrame';
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A Flutter Driver command that waits until the Flutter engine rasterizes the
|
|
||||||
/// first frame.
|
|
||||||
///
|
|
||||||
/// {@template flutter.frame_rasterized_vs_presented}
|
|
||||||
/// Usually, the time that a frame is rasterized is very close to the time that
|
|
||||||
/// it gets presented on the display. Specifically, rasterization is the last
|
|
||||||
/// expensive phase of a frame that's still in Flutter's control.
|
|
||||||
/// {@endtemplate}
|
|
||||||
///
|
|
||||||
/// This command has been deprecated in favor of [WaitForCondition]. Construct
|
|
||||||
/// a command that waits until no pending frame as follows:
|
|
||||||
///
|
|
||||||
/// ```dart
|
|
||||||
/// WaitForCondition firstFrameRasterized = WaitForCondition(FirstFrameRasterizedCondition());
|
|
||||||
/// ```
|
|
||||||
@Deprecated('This command has been deprecated in favor of WaitForCondition. '
|
|
||||||
'Use WaitForCondition command with FirstFrameRasterizedCondition.')
|
|
||||||
class WaitUntilFirstFrameRasterized extends Command {
|
|
||||||
/// Creates this command.
|
|
||||||
const WaitUntilFirstFrameRasterized({ Duration timeout }) : super(timeout: timeout);
|
|
||||||
|
|
||||||
/// Deserializes this command from the value generated by [serialize].
|
|
||||||
WaitUntilFirstFrameRasterized.deserialize(Map<String, String> json)
|
|
||||||
: super.deserialize(json);
|
|
||||||
|
|
||||||
@override
|
|
||||||
String get kind => 'waitUntilFirstFrameRasterized';
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Base class for a condition that can be waited upon.
|
|
||||||
abstract class WaitCondition {
|
|
||||||
/// Gets the current status of the [condition], executed in the context of the
|
|
||||||
/// Flutter app:
|
|
||||||
///
|
|
||||||
/// * True, if the condition is satisfied.
|
|
||||||
/// * False otherwise.
|
|
||||||
///
|
|
||||||
/// The future returned by [wait] will complete when this [condition] is
|
|
||||||
/// fulfilled.
|
|
||||||
bool get condition;
|
|
||||||
|
|
||||||
/// Returns a future that completes when [condition] turns true.
|
|
||||||
Future<void> wait();
|
|
||||||
|
|
||||||
/// Serializes the object to JSON.
|
|
||||||
Map<String, String> serialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Thrown to indicate a JSON serialization error.
|
|
||||||
class SerializationException implements Exception {
|
|
||||||
/// Creates a [SerializationException] with an optional error message.
|
|
||||||
const SerializationException([this.message]);
|
|
||||||
|
|
||||||
/// The error message, possibly null.
|
|
||||||
final String message;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() => 'SerializationException($message)';
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A condition that waits until no transient callbacks are scheduled.
|
|
||||||
class NoTransientCallbacksCondition implements WaitCondition {
|
|
||||||
/// Creates a [NoTransientCallbacksCondition] instance.
|
|
||||||
const NoTransientCallbacksCondition();
|
|
||||||
|
|
||||||
/// Factory constructor to parse a [NoTransientCallbacksCondition] instance
|
|
||||||
/// from the given JSON map.
|
|
||||||
///
|
|
||||||
/// The [json] argument must not be null.
|
|
||||||
factory NoTransientCallbacksCondition.deserialize(Map<String, dynamic> json) {
|
|
||||||
assert(json != null);
|
|
||||||
if (json['conditionName'] != 'NoTransientCallbacksCondition')
|
|
||||||
throw SerializationException('Error occurred during deserializing the NoTransientCallbacksCondition JSON string: $json');
|
|
||||||
return const NoTransientCallbacksCondition();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool get condition => SchedulerBinding.instance.transientCallbackCount == 0;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> wait() async {
|
|
||||||
while (!condition) {
|
|
||||||
await SchedulerBinding.instance.endOfFrame;
|
|
||||||
}
|
|
||||||
assert(condition);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Map<String, String> serialize() {
|
|
||||||
return <String, String>{
|
|
||||||
'conditionName': 'NoTransientCallbacksCondition',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A condition that waits until no pending frame is scheduled.
|
|
||||||
class NoPendingFrameCondition implements WaitCondition {
|
|
||||||
/// Creates a [NoPendingFrameCondition] instance.
|
|
||||||
const NoPendingFrameCondition();
|
|
||||||
|
|
||||||
/// Factory constructor to parse a [NoPendingFrameCondition] instance from the
|
|
||||||
/// given JSON map.
|
|
||||||
///
|
|
||||||
/// The [json] argument must not be null.
|
|
||||||
factory NoPendingFrameCondition.deserialize(Map<String, dynamic> json) {
|
|
||||||
assert(json != null);
|
|
||||||
if (json['conditionName'] != 'NoPendingFrameCondition')
|
|
||||||
throw SerializationException('Error occurred during deserializing the NoPendingFrameCondition JSON string: $json');
|
|
||||||
return const NoPendingFrameCondition();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool get condition => !SchedulerBinding.instance.hasScheduledFrame;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> wait() async {
|
|
||||||
while (!condition) {
|
|
||||||
await SchedulerBinding.instance.endOfFrame;
|
|
||||||
}
|
|
||||||
assert(condition);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Map<String, String> serialize() {
|
|
||||||
return <String, String>{
|
|
||||||
'conditionName': 'NoPendingFrameCondition',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A condition that waits until the Flutter engine has rasterized the first frame.
|
|
||||||
class FirstFrameRasterizedCondition implements WaitCondition {
|
|
||||||
/// Creates a [FirstFrameRasterizedCondition] instance.
|
|
||||||
const FirstFrameRasterizedCondition();
|
|
||||||
|
|
||||||
/// Factory constructor to parse a [NoPendingFrameCondition] instance from the
|
|
||||||
/// given JSON map.
|
|
||||||
///
|
|
||||||
/// The [json] argument must not be null.
|
|
||||||
factory FirstFrameRasterizedCondition.deserialize(Map<String, dynamic> json) {
|
|
||||||
assert(json != null);
|
|
||||||
if (json['conditionName'] != 'FirstFrameRasterizedCondition')
|
|
||||||
throw SerializationException('Error occurred during deserializing the FirstFrameRasterizedCondition JSON string: $json');
|
|
||||||
return const FirstFrameRasterizedCondition();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool get condition => WidgetsBinding.instance.firstFrameRasterized;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> wait() async {
|
|
||||||
await WidgetsBinding.instance.waitUntilFirstFrameRasterized;
|
|
||||||
assert(condition);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Map<String, String> serialize() {
|
|
||||||
return <String, String>{
|
|
||||||
'conditionName': 'FirstFrameRasterizedCondition',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A combined condition that waits until all the given [conditions] are met.
|
|
||||||
class CombinedCondition implements WaitCondition {
|
|
||||||
/// Creates a [CombinedCondition] instance with the given list of
|
|
||||||
/// [conditions].
|
|
||||||
///
|
|
||||||
/// The [conditions] argument must not be null.
|
|
||||||
const CombinedCondition(this.conditions)
|
|
||||||
: assert(conditions != null);
|
|
||||||
|
|
||||||
/// Factory constructor to parse a [CombinedCondition] instance from the given
|
|
||||||
/// JSON map.
|
|
||||||
///
|
|
||||||
/// The [jsonMap] argument must not be null.
|
|
||||||
factory CombinedCondition.deserialize(Map<String, dynamic> jsonMap) {
|
|
||||||
assert(jsonMap != null);
|
|
||||||
if (jsonMap['conditionName'] != 'CombinedCondition')
|
|
||||||
throw SerializationException('Error occurred during deserializing the CombinedCondition JSON string: $jsonMap');
|
|
||||||
if (jsonMap['conditions'] == null) {
|
|
||||||
return const CombinedCondition(<WaitCondition>[]);
|
|
||||||
}
|
|
||||||
|
|
||||||
final List<WaitCondition> conditions = <WaitCondition>[];
|
|
||||||
for (Map<String, dynamic> condition in json.decode(jsonMap['conditions'])) {
|
|
||||||
conditions.add(_deserialize(condition));
|
|
||||||
}
|
|
||||||
return CombinedCondition(conditions);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A list of conditions it waits for.
|
|
||||||
final List<WaitCondition> conditions;
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool get condition {
|
|
||||||
return conditions.every((WaitCondition condition) => condition.condition);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> wait() async {
|
|
||||||
while (!condition) {
|
|
||||||
for (WaitCondition condition in conditions) {
|
|
||||||
assert (condition != null);
|
|
||||||
await condition.wait();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert(condition);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Map<String, String> serialize() {
|
|
||||||
final Map<String, String> jsonMap = <String, String>{
|
|
||||||
'conditionName': 'CombinedCondition'
|
|
||||||
};
|
|
||||||
final List<Map<String, String>> jsonConditions = conditions.map(
|
|
||||||
(WaitCondition condition) {
|
|
||||||
assert(condition != null);
|
|
||||||
return condition.serialize();
|
|
||||||
}).toList();
|
|
||||||
jsonMap['conditions'] = json.encode(jsonConditions);
|
|
||||||
return jsonMap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Parses a [WaitCondition] or its subclass from the given [json] map.
|
|
||||||
///
|
|
||||||
/// The [json] argument cannot be null.
|
|
||||||
WaitCondition _deserialize(Map<String, dynamic> json) {
|
|
||||||
assert(json != null);
|
|
||||||
final String conditionName = json['conditionName'];
|
|
||||||
switch (conditionName) {
|
|
||||||
case 'NoTransientCallbacksCondition':
|
|
||||||
return NoTransientCallbacksCondition.deserialize(json);
|
|
||||||
case 'NoPendingFrameCondition':
|
|
||||||
return NoPendingFrameCondition.deserialize(json);
|
|
||||||
case 'CombinedCondition':
|
|
||||||
return CombinedCondition.deserialize(json);
|
|
||||||
}
|
|
||||||
throw SerializationException('Unsupported wait condition $conditionName in the JSON string $json');
|
|
||||||
}
|
|
@ -28,7 +28,6 @@ import '../common/render_tree.dart';
|
|||||||
import '../common/request_data.dart';
|
import '../common/request_data.dart';
|
||||||
import '../common/semantics.dart';
|
import '../common/semantics.dart';
|
||||||
import '../common/text.dart';
|
import '../common/text.dart';
|
||||||
import '../common/wait.dart';
|
|
||||||
import 'common.dart';
|
import 'common.dart';
|
||||||
import 'timeline.dart';
|
import 'timeline.dart';
|
||||||
|
|
||||||
@ -492,17 +491,12 @@ class FlutterDriver {
|
|||||||
await _sendCommand(WaitForAbsent(finder, timeout: timeout));
|
await _sendCommand(WaitForAbsent(finder, timeout: timeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Waits until the given [waitCondition] is satisfied.
|
|
||||||
Future<void> waitForCondition(WaitCondition waitCondition, {Duration timeout}) async {
|
|
||||||
await _sendCommand(WaitForCondition(waitCondition, timeout: timeout));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Waits until there are no more transient callbacks in the queue.
|
/// Waits until there are no more transient callbacks in the queue.
|
||||||
///
|
///
|
||||||
/// Use this method when you need to wait for the moment when the application
|
/// Use this method when you need to wait for the moment when the application
|
||||||
/// becomes "stable", for example, prior to taking a [screenshot].
|
/// becomes "stable", for example, prior to taking a [screenshot].
|
||||||
Future<void> waitUntilNoTransientCallbacks({ Duration timeout }) async {
|
Future<void> waitUntilNoTransientCallbacks({ Duration timeout }) async {
|
||||||
await _sendCommand(WaitForCondition(const NoTransientCallbacksCondition(), timeout: timeout));
|
await _sendCommand(WaitUntilNoTransientCallbacks(timeout: timeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Waits until the next [Window.onReportTimings] is called.
|
/// Waits until the next [Window.onReportTimings] is called.
|
||||||
@ -510,7 +504,7 @@ class FlutterDriver {
|
|||||||
/// Use this method to wait for the first frame to be rasterized during the
|
/// Use this method to wait for the first frame to be rasterized during the
|
||||||
/// app launch.
|
/// app launch.
|
||||||
Future<void> waitUntilFirstFrameRasterized() async {
|
Future<void> waitUntilFirstFrameRasterized() async {
|
||||||
await _sendCommand(const WaitForCondition(FirstFrameRasterizedCondition()));
|
await _sendCommand(const WaitUntilFirstFrameRasterized());
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<DriverOffset> _getOffset(SerializableFinder finder, OffsetType type, { Duration timeout }) async {
|
Future<DriverOffset> _getOffset(SerializableFinder finder, OffsetType type, { Duration timeout }) async {
|
||||||
|
@ -29,7 +29,6 @@ import '../common/render_tree.dart';
|
|||||||
import '../common/request_data.dart';
|
import '../common/request_data.dart';
|
||||||
import '../common/semantics.dart';
|
import '../common/semantics.dart';
|
||||||
import '../common/text.dart';
|
import '../common/text.dart';
|
||||||
import '../common/wait.dart';
|
|
||||||
|
|
||||||
const String _extensionMethodName = 'driver';
|
const String _extensionMethodName = 'driver';
|
||||||
const String _extensionMethod = 'ext.flutter.$_extensionMethodName';
|
const String _extensionMethod = 'ext.flutter.$_extensionMethodName';
|
||||||
@ -113,10 +112,9 @@ class FlutterDriverExtension {
|
|||||||
'tap': _tap,
|
'tap': _tap,
|
||||||
'waitFor': _waitFor,
|
'waitFor': _waitFor,
|
||||||
'waitForAbsent': _waitForAbsent,
|
'waitForAbsent': _waitForAbsent,
|
||||||
'waitForCondition': _waitForCondition,
|
'waitUntilNoTransientCallbacks': _waitUntilNoTransientCallbacks,
|
||||||
'waitUntilNoTransientCallbacks': _waitUntilNoTransientCallbacks, // ignore: deprecated_member_use_from_same_package
|
'waitUntilNoPendingFrame': _waitUntilNoPendingFrame,
|
||||||
'waitUntilNoPendingFrame': _waitUntilNoPendingFrame, // ignore: deprecated_member_use_from_same_package
|
'waitUntilFirstFrameRasterized': _waitUntilFirstFrameRasterized,
|
||||||
'waitUntilFirstFrameRasterized': _waitUntilFirstFrameRasterized, // ignore: deprecated_member_use_from_same_package
|
|
||||||
'get_semantics_id': _getSemanticsId,
|
'get_semantics_id': _getSemanticsId,
|
||||||
'get_offset': _getOffset,
|
'get_offset': _getOffset,
|
||||||
'get_diagnostics_tree': _getDiagnosticsTree,
|
'get_diagnostics_tree': _getDiagnosticsTree,
|
||||||
@ -136,10 +134,9 @@ class FlutterDriverExtension {
|
|||||||
'tap': (Map<String, String> params) => Tap.deserialize(params),
|
'tap': (Map<String, String> params) => Tap.deserialize(params),
|
||||||
'waitFor': (Map<String, String> params) => WaitFor.deserialize(params),
|
'waitFor': (Map<String, String> params) => WaitFor.deserialize(params),
|
||||||
'waitForAbsent': (Map<String, String> params) => WaitForAbsent.deserialize(params),
|
'waitForAbsent': (Map<String, String> params) => WaitForAbsent.deserialize(params),
|
||||||
'waitForCondition': (Map<String, String> params) => WaitForCondition.deserialize(params),
|
'waitUntilNoTransientCallbacks': (Map<String, String> params) => WaitUntilNoTransientCallbacks.deserialize(params),
|
||||||
'waitUntilNoTransientCallbacks': (Map<String, String> params) => WaitUntilNoTransientCallbacks.deserialize(params), // ignore: deprecated_member_use_from_same_package
|
'waitUntilNoPendingFrame': (Map<String, String> params) => WaitUntilNoPendingFrame.deserialize(params),
|
||||||
'waitUntilNoPendingFrame': (Map<String, String> params) => WaitUntilNoPendingFrame.deserialize(params), // ignore: deprecated_member_use_from_same_package
|
'waitUntilFirstFrameRasterized': (Map<String, String> params) => WaitUntilFirstFrameRasterized.deserialize(params),
|
||||||
'waitUntilFirstFrameRasterized': (Map<String, String> params) => WaitUntilFirstFrameRasterized.deserialize(params), // ignore: deprecated_member_use_from_same_package
|
|
||||||
'get_semantics_id': (Map<String, String> params) => GetSemanticsId.deserialize(params),
|
'get_semantics_id': (Map<String, String> params) => GetSemanticsId.deserialize(params),
|
||||||
'get_offset': (Map<String, String> params) => GetOffset.deserialize(params),
|
'get_offset': (Map<String, String> params) => GetOffset.deserialize(params),
|
||||||
'get_diagnostics_tree': (Map<String, String> params) => GetDiagnosticsTree.deserialize(params),
|
'get_diagnostics_tree': (Map<String, String> params) => GetDiagnosticsTree.deserialize(params),
|
||||||
@ -226,7 +223,6 @@ class FlutterDriverExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This can be used to wait for the first frame being rasterized during app launch.
|
// This can be used to wait for the first frame being rasterized during app launch.
|
||||||
@Deprecated('This method has been deprecated in favor of _waitForCondition.')
|
|
||||||
Future<Result> _waitUntilFirstFrameRasterized(Command command) async {
|
Future<Result> _waitUntilFirstFrameRasterized(Command command) async {
|
||||||
await WidgetsBinding.instance.waitUntilFirstFrameRasterized;
|
await WidgetsBinding.instance.waitUntilFirstFrameRasterized;
|
||||||
return null;
|
return null;
|
||||||
@ -374,14 +370,6 @@ class FlutterDriverExtension {
|
|||||||
return const WaitForAbsentResult();
|
return const WaitForAbsentResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Result> _waitForCondition(Command command) async {
|
|
||||||
assert(command != null);
|
|
||||||
final WaitForCondition waitForConditionCommand = command;
|
|
||||||
await waitForConditionCommand.condition.wait();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated('This method has been deprecated in favor of _waitForCondition.')
|
|
||||||
Future<Result> _waitUntilNoTransientCallbacks(Command command) async {
|
Future<Result> _waitUntilNoTransientCallbacks(Command command) async {
|
||||||
if (SchedulerBinding.instance.transientCallbackCount != 0)
|
if (SchedulerBinding.instance.transientCallbackCount != 0)
|
||||||
await _waitUntilFrame(() => SchedulerBinding.instance.transientCallbackCount == 0);
|
await _waitUntilFrame(() => SchedulerBinding.instance.transientCallbackCount == 0);
|
||||||
@ -405,9 +393,6 @@ class FlutterDriverExtension {
|
|||||||
/// `set_frame_sync` method. See [FlutterDriver.runUnsynchronized] for more
|
/// `set_frame_sync` method. See [FlutterDriver.runUnsynchronized] for more
|
||||||
/// details on how to do this. Note, disabling frame sync will require the
|
/// details on how to do this. Note, disabling frame sync will require the
|
||||||
/// test author to use some other method to avoid flakiness.
|
/// test author to use some other method to avoid flakiness.
|
||||||
///
|
|
||||||
/// This method has been deprecated in favor of [_waitForCondition].
|
|
||||||
@Deprecated('This method has been deprecated in favor of _waitForCondition.')
|
|
||||||
Future<Result> _waitUntilNoPendingFrame(Command command) async {
|
Future<Result> _waitUntilNoPendingFrame(Command command) async {
|
||||||
await _waitUntilFrame(() {
|
await _waitUntilFrame(() {
|
||||||
return SchedulerBinding.instance.transientCallbackCount == 0
|
return SchedulerBinding.instance.transientCallbackCount == 0
|
||||||
|
@ -6,7 +6,6 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:flutter_driver/src/common/error.dart';
|
import 'package:flutter_driver/src/common/error.dart';
|
||||||
import 'package:flutter_driver/src/common/health.dart';
|
import 'package:flutter_driver/src/common/health.dart';
|
||||||
import 'package:flutter_driver/src/common/wait.dart';
|
|
||||||
import 'package:flutter_driver/src/driver/driver.dart';
|
import 'package:flutter_driver/src/driver/driver.dart';
|
||||||
import 'package:flutter_driver/src/driver/timeline.dart';
|
import 'package:flutter_driver/src/driver/timeline.dart';
|
||||||
import 'package:json_rpc_2/json_rpc_2.dart' as rpc;
|
import 'package:json_rpc_2/json_rpc_2.dart' as rpc;
|
||||||
@ -249,41 +248,12 @@ void main() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group('waitForCondition', () {
|
|
||||||
test('sends the wait for NoPendingFrameCondition command', () async {
|
|
||||||
when(mockIsolate.invokeExtension(any, any)).thenAnswer((Invocation i) {
|
|
||||||
expect(i.positionalArguments[1], <String, dynamic>{
|
|
||||||
'command': 'waitForCondition',
|
|
||||||
'timeout': _kSerializedTestTimeout,
|
|
||||||
'conditionName': 'NoPendingFrameCondition',
|
|
||||||
});
|
|
||||||
return makeMockResponse(<String, dynamic>{});
|
|
||||||
});
|
|
||||||
await driver.waitForCondition(const NoPendingFrameCondition(), timeout: _kTestTimeout);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('sends the waitForCondition of combined conditions command', () async {
|
|
||||||
when(mockIsolate.invokeExtension(any, any)).thenAnswer((Invocation i) {
|
|
||||||
expect(i.positionalArguments[1], <String, dynamic>{
|
|
||||||
'command': 'waitForCondition',
|
|
||||||
'timeout': _kSerializedTestTimeout,
|
|
||||||
'conditionName': 'CombinedCondition',
|
|
||||||
'conditions': '[{"conditionName":"NoPendingFrameCondition"},{"conditionName":"NoTransientCallbacksCondition"}]',
|
|
||||||
});
|
|
||||||
return makeMockResponse(<String, dynamic>{});
|
|
||||||
});
|
|
||||||
const WaitCondition combinedCondition = CombinedCondition(<WaitCondition>[NoPendingFrameCondition(), NoTransientCallbacksCondition()]);
|
|
||||||
await driver.waitForCondition(combinedCondition, timeout: _kTestTimeout);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
group('waitUntilNoTransientCallbacks', () {
|
group('waitUntilNoTransientCallbacks', () {
|
||||||
test('sends the waitUntilNoTransientCallbacks command', () async {
|
test('sends the waitUntilNoTransientCallbacks command', () async {
|
||||||
when(mockIsolate.invokeExtension(any, any)).thenAnswer((Invocation i) {
|
when(mockIsolate.invokeExtension(any, any)).thenAnswer((Invocation i) {
|
||||||
expect(i.positionalArguments[1], <String, dynamic>{
|
expect(i.positionalArguments[1], <String, dynamic>{
|
||||||
'command': 'waitForCondition',
|
'command': 'waitUntilNoTransientCallbacks',
|
||||||
'timeout': _kSerializedTestTimeout,
|
'timeout': _kSerializedTestTimeout,
|
||||||
'conditionName': 'NoTransientCallbacksCondition',
|
|
||||||
});
|
});
|
||||||
return makeMockResponse(<String, dynamic>{});
|
return makeMockResponse(<String, dynamic>{});
|
||||||
});
|
});
|
||||||
|
@ -12,7 +12,6 @@ import 'package:flutter_driver/src/common/find.dart';
|
|||||||
import 'package:flutter_driver/src/common/geometry.dart';
|
import 'package:flutter_driver/src/common/geometry.dart';
|
||||||
import 'package:flutter_driver/src/common/request_data.dart';
|
import 'package:flutter_driver/src/common/request_data.dart';
|
||||||
import 'package:flutter_driver/src/common/text.dart';
|
import 'package:flutter_driver/src/common/text.dart';
|
||||||
import 'package:flutter_driver/src/common/wait.dart';
|
|
||||||
import 'package:flutter_driver/src/extension/extension.dart';
|
import 'package:flutter_driver/src/extension/extension.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
@ -29,18 +28,18 @@ 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(const WaitUntilNoTransientCallbacks().serialize()) // ignore: deprecated_member_use_from_same_package
|
extension.call(const WaitUntilNoTransientCallbacks().serialize())
|
||||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||||
result = r;
|
result = r;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
await tester.idle();
|
await tester.idle();
|
||||||
expect(
|
expect(
|
||||||
result,
|
result,
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'isError': false,
|
'isError': false,
|
||||||
'response': null,
|
'response': null,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -49,10 +48,10 @@ void main() {
|
|||||||
// Intentionally blank. We only care about existence of a callback.
|
// Intentionally blank. We only care about existence of a callback.
|
||||||
});
|
});
|
||||||
|
|
||||||
extension.call(const WaitUntilNoTransientCallbacks().serialize()) // ignore: deprecated_member_use_from_same_package
|
extension.call(const WaitUntilNoTransientCallbacks().serialize())
|
||||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||||
result = r;
|
result = r;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Nothing should happen until the next frame.
|
// Nothing should happen until the next frame.
|
||||||
await tester.idle();
|
await tester.idle();
|
||||||
@ -61,11 +60,11 @@ void main() {
|
|||||||
// NOW we should receive the result.
|
// NOW we should receive the result.
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(
|
expect(
|
||||||
result,
|
result,
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'isError': false,
|
'isError': false,
|
||||||
'response': null,
|
'response': null,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -77,173 +76,6 @@ void main() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group('waitForCondition', () {
|
|
||||||
FlutterDriverExtension extension;
|
|
||||||
Map<String, dynamic> result;
|
|
||||||
int messageId = 0;
|
|
||||||
final List<String> log = <String>[];
|
|
||||||
|
|
||||||
setUp(() {
|
|
||||||
result = null;
|
|
||||||
extension = FlutterDriverExtension((String message) async { log.add(message); return (messageId += 1).toString(); }, false);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('waiting for NoTransientCallbacksCondition returns immediately when transient callback queue is empty', (WidgetTester tester) async {
|
|
||||||
extension.call(const WaitForCondition(NoTransientCallbacksCondition()).serialize())
|
|
||||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
|
||||||
result = r;
|
|
||||||
}));
|
|
||||||
|
|
||||||
await tester.idle();
|
|
||||||
expect(
|
|
||||||
result,
|
|
||||||
<String, dynamic>{
|
|
||||||
'isError': false,
|
|
||||||
'response': null,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('waiting for NoTransientCallbacksCondition returns until no transient callbacks', (WidgetTester tester) async {
|
|
||||||
SchedulerBinding.instance.scheduleFrameCallback((_) {
|
|
||||||
// Intentionally blank. We only care about existence of a callback.
|
|
||||||
});
|
|
||||||
|
|
||||||
extension.call(const WaitForCondition(NoTransientCallbacksCondition()).serialize())
|
|
||||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
|
||||||
result = r;
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Nothing should happen until the next frame.
|
|
||||||
await tester.idle();
|
|
||||||
expect(result, isNull);
|
|
||||||
|
|
||||||
// NOW we should receive the result.
|
|
||||||
await tester.pump();
|
|
||||||
expect(
|
|
||||||
result,
|
|
||||||
<String, dynamic>{
|
|
||||||
'isError': false,
|
|
||||||
'response': null,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('waiting for NoPendingFrameCondition returns immediately when frame is synced', (
|
|
||||||
WidgetTester tester) async {
|
|
||||||
extension.call(const WaitForCondition(NoPendingFrameCondition()).serialize())
|
|
||||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
|
||||||
result = r;
|
|
||||||
}));
|
|
||||||
|
|
||||||
await tester.idle();
|
|
||||||
expect(
|
|
||||||
result,
|
|
||||||
<String, dynamic>{
|
|
||||||
'isError': false,
|
|
||||||
'response': null,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('waiting for NoPendingFrameCondition returns until no pending scheduled frame', (WidgetTester tester) async {
|
|
||||||
SchedulerBinding.instance.scheduleFrame();
|
|
||||||
|
|
||||||
extension.call(const WaitForCondition(NoPendingFrameCondition()).serialize())
|
|
||||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
|
||||||
result = r;
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Nothing should happen until the next frame.
|
|
||||||
await tester.idle();
|
|
||||||
expect(result, isNull);
|
|
||||||
|
|
||||||
// NOW we should receive the result.
|
|
||||||
await tester.pump();
|
|
||||||
expect(
|
|
||||||
result,
|
|
||||||
<String, dynamic>{
|
|
||||||
'isError': false,
|
|
||||||
'response': null,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets(
|
|
||||||
'waiting for combined conditions returns immediately', (WidgetTester tester) async {
|
|
||||||
const WaitCondition combinedCondition = CombinedCondition(<WaitCondition>[NoTransientCallbacksCondition(), NoPendingFrameCondition()]);
|
|
||||||
extension.call(const WaitForCondition(combinedCondition).serialize())
|
|
||||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
|
||||||
result = r;
|
|
||||||
}));
|
|
||||||
|
|
||||||
await tester.idle();
|
|
||||||
expect(
|
|
||||||
result,
|
|
||||||
<String, dynamic>{
|
|
||||||
'isError': false,
|
|
||||||
'response': null,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets(
|
|
||||||
'waiting for combined conditions returns until no transient callbacks', (WidgetTester tester) async {
|
|
||||||
SchedulerBinding.instance.scheduleFrame();
|
|
||||||
SchedulerBinding.instance.scheduleFrameCallback((_) {
|
|
||||||
// Intentionally blank. We only care about existence of a callback.
|
|
||||||
});
|
|
||||||
|
|
||||||
const WaitCondition combinedCondition = CombinedCondition(<WaitCondition>[NoTransientCallbacksCondition(), NoPendingFrameCondition()]);
|
|
||||||
extension.call(const WaitForCondition(combinedCondition).serialize())
|
|
||||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
|
||||||
result = r;
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Nothing should happen until the next frame.
|
|
||||||
await tester.idle();
|
|
||||||
expect(result, isNull);
|
|
||||||
|
|
||||||
// NOW we should receive the result.
|
|
||||||
await tester.pump();
|
|
||||||
expect(
|
|
||||||
result,
|
|
||||||
<String, dynamic>{
|
|
||||||
'isError': false,
|
|
||||||
'response': null,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets(
|
|
||||||
'waiting for combined conditions returns until no pending scheduled frame', (WidgetTester tester) async {
|
|
||||||
SchedulerBinding.instance.scheduleFrame();
|
|
||||||
SchedulerBinding.instance.scheduleFrameCallback((_) {
|
|
||||||
// Intentionally blank. We only care about existence of a callback.
|
|
||||||
});
|
|
||||||
|
|
||||||
const WaitCondition combinedCondition = CombinedCondition(<WaitCondition>[NoPendingFrameCondition(), NoTransientCallbacksCondition()]);
|
|
||||||
extension.call(const WaitForCondition(combinedCondition).serialize())
|
|
||||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
|
||||||
result = r;
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Nothing should happen until the next frame.
|
|
||||||
await tester.idle();
|
|
||||||
expect(result, isNull);
|
|
||||||
|
|
||||||
// NOW we should receive the result.
|
|
||||||
await tester.pump();
|
|
||||||
expect(
|
|
||||||
result,
|
|
||||||
<String, dynamic>{
|
|
||||||
'isError': false,
|
|
||||||
'response': null,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
group('getSemanticsId', () {
|
group('getSemanticsId', () {
|
||||||
FlutterDriverExtension extension;
|
FlutterDriverExtension extension;
|
||||||
setUp(() {
|
setUp(() {
|
||||||
@ -513,7 +345,7 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('returns immediately when frame is synced', (
|
testWidgets('returns immediately when frame is synced', (
|
||||||
WidgetTester tester) async {
|
WidgetTester tester) async {
|
||||||
extension.call(const WaitUntilNoPendingFrame().serialize()) // ignore: deprecated_member_use_from_same_package
|
extension.call(const WaitUntilNoPendingFrame().serialize())
|
||||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||||
result = r;
|
result = r;
|
||||||
}));
|
}));
|
||||||
@ -534,7 +366,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(const WaitUntilNoPendingFrame().serialize()) // ignore: deprecated_member_use_from_same_package
|
extension.call(const WaitUntilNoPendingFrame().serialize())
|
||||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||||
result = r;
|
result = r;
|
||||||
}));
|
}));
|
||||||
@ -558,7 +390,7 @@ void main() {
|
|||||||
'waits until no pending scheduled frame', (WidgetTester tester) async {
|
'waits until no pending scheduled frame', (WidgetTester tester) async {
|
||||||
SchedulerBinding.instance.scheduleFrame();
|
SchedulerBinding.instance.scheduleFrame();
|
||||||
|
|
||||||
extension.call(const WaitUntilNoPendingFrame().serialize()) // ignore: deprecated_member_use_from_same_package
|
extension.call(const WaitUntilNoPendingFrame().serialize())
|
||||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||||
result = r;
|
result = r;
|
||||||
}));
|
}));
|
||||||
|
@ -1,202 +0,0 @@
|
|||||||
// Copyright 2019 The Chromium Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
|
||||||
// found in the LICENSE file.
|
|
||||||
|
|
||||||
import 'package:flutter_driver/src/common/wait.dart';
|
|
||||||
|
|
||||||
import '../common.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
group('WaitForCondition', () {
|
|
||||||
test('WaitForCondition serialize', () {
|
|
||||||
expect(
|
|
||||||
const WaitForCondition(NoTransientCallbacksCondition()).serialize(),
|
|
||||||
<String, String>{'command': 'waitForCondition', 'conditionName': 'NoTransientCallbacksCondition'});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('WaitForCondition serialize with timeout', () {
|
|
||||||
expect(
|
|
||||||
const WaitForCondition(NoTransientCallbacksCondition(), timeout: Duration(milliseconds: 10)).serialize(),
|
|
||||||
<String, String>{'command': 'waitForCondition', 'timeout': '10', 'conditionName': 'NoTransientCallbacksCondition'});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('WaitForCondition deserialize', () {
|
|
||||||
final Map<String, String> jsonMap = <String, String>{
|
|
||||||
'command': 'waitForCondition',
|
|
||||||
'conditionName': 'NoTransientCallbacksCondition',
|
|
||||||
};
|
|
||||||
final WaitForCondition waitForCondition = WaitForCondition.deserialize(jsonMap);
|
|
||||||
expect(waitForCondition.kind, 'waitForCondition');
|
|
||||||
expect(waitForCondition.condition, equals(const NoTransientCallbacksCondition()));
|
|
||||||
});
|
|
||||||
|
|
||||||
test('WaitForCondition deserialize with timeout', () {
|
|
||||||
final Map<String, String> jsonMap = <String, String>{
|
|
||||||
'command': 'waitForCondition',
|
|
||||||
'timeout': '10',
|
|
||||||
'conditionName': 'NoTransientCallbacksCondition',
|
|
||||||
};
|
|
||||||
final WaitForCondition waitForCondition = WaitForCondition.deserialize(jsonMap);
|
|
||||||
expect(waitForCondition.kind, 'waitForCondition');
|
|
||||||
expect(waitForCondition.condition, equals(const NoTransientCallbacksCondition()));
|
|
||||||
expect(waitForCondition.timeout, equals(const Duration(milliseconds: 10)));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
group('NoTransientCallbacksCondition', () {
|
|
||||||
test('NoTransientCallbacksCondition serialize', () {
|
|
||||||
expect(
|
|
||||||
const NoTransientCallbacksCondition().serialize(),
|
|
||||||
<String, String>{'conditionName': 'NoTransientCallbacksCondition'});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('NoTransientCallbacksCondition deserialize', () {
|
|
||||||
final Map<String, String> jsonMap = <String, String>{
|
|
||||||
'conditionName': 'NoTransientCallbacksCondition',
|
|
||||||
};
|
|
||||||
final NoTransientCallbacksCondition condition =
|
|
||||||
NoTransientCallbacksCondition.deserialize(jsonMap);
|
|
||||||
expect(condition, equals(const NoTransientCallbacksCondition()));
|
|
||||||
expect(condition.serialize(), equals(jsonMap));
|
|
||||||
});
|
|
||||||
|
|
||||||
test('NoTransientCallbacksCondition deserialize error', () {
|
|
||||||
expect(
|
|
||||||
() => NoTransientCallbacksCondition.deserialize(<String, String>{'conditionName': 'Unknown'}),
|
|
||||||
throwsA(predicate<SerializationException>((SerializationException e) =>
|
|
||||||
e.message == 'Error occurred during deserializing the NoTransientCallbacksCondition JSON string: {conditionName: Unknown}')));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
group('NoPendingFrameCondition', () {
|
|
||||||
test('NoPendingFrameCondition serialize', () {
|
|
||||||
expect(const NoPendingFrameCondition().serialize(), <String, String>{
|
|
||||||
'conditionName': 'NoPendingFrameCondition',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('NoPendingFrameCondition deserialize', () {
|
|
||||||
final Map<String, String> jsonMap = <String, String>{
|
|
||||||
'conditionName': 'NoPendingFrameCondition',
|
|
||||||
};
|
|
||||||
final NoPendingFrameCondition condition =
|
|
||||||
NoPendingFrameCondition.deserialize(jsonMap);
|
|
||||||
expect(condition, equals(const NoPendingFrameCondition()));
|
|
||||||
expect(condition.serialize(), equals(jsonMap));
|
|
||||||
});
|
|
||||||
|
|
||||||
test('NoPendingFrameCondition deserialize error', () {
|
|
||||||
expect(
|
|
||||||
() => NoPendingFrameCondition.deserialize(<String, String>{'conditionName': 'Unknown'}),
|
|
||||||
throwsA(predicate<SerializationException>((SerializationException e) =>
|
|
||||||
e.message == 'Error occurred during deserializing the NoPendingFrameCondition JSON string: {conditionName: Unknown}')));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
group('FirstFrameRasterizedCondition', () {
|
|
||||||
test('FirstFrameRasterizedCondition serialize', () {
|
|
||||||
expect(
|
|
||||||
const FirstFrameRasterizedCondition().serialize(),
|
|
||||||
<String, String>{'conditionName': 'FirstFrameRasterizedCondition'});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('FirstFrameRasterizedCondition deserialize', () {
|
|
||||||
final Map<String, String> jsonMap = <String, String>{
|
|
||||||
'conditionName': 'FirstFrameRasterizedCondition',
|
|
||||||
};
|
|
||||||
final FirstFrameRasterizedCondition condition =
|
|
||||||
FirstFrameRasterizedCondition.deserialize(jsonMap);
|
|
||||||
expect(condition, equals(const FirstFrameRasterizedCondition()));
|
|
||||||
expect(condition.serialize(), equals(jsonMap));
|
|
||||||
});
|
|
||||||
|
|
||||||
test('FirstFrameRasterizedCondition deserialize error', () {
|
|
||||||
expect(
|
|
||||||
() => FirstFrameRasterizedCondition.deserialize(<String, String>{'conditionName': 'Unknown'}),
|
|
||||||
throwsA(predicate<SerializationException>((SerializationException e) =>
|
|
||||||
e.message == 'Error occurred during deserializing the FirstFrameRasterizedCondition JSON string: {conditionName: Unknown}')));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
group('CombinedCondition', () {
|
|
||||||
test('CombinedCondition serialize', () {
|
|
||||||
const CombinedCondition combinedCondition =
|
|
||||||
CombinedCondition(<WaitCondition>[
|
|
||||||
NoTransientCallbacksCondition(),
|
|
||||||
NoPendingFrameCondition()
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(combinedCondition.serialize(), <String, String>{
|
|
||||||
'conditionName': 'CombinedCondition',
|
|
||||||
'conditions':
|
|
||||||
'[{"conditionName":"NoTransientCallbacksCondition"},{"conditionName":"NoPendingFrameCondition"}]',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('CombinedCondition serialize - empty condition list', () {
|
|
||||||
const CombinedCondition combinedCondition = CombinedCondition(<WaitCondition>[]);
|
|
||||||
|
|
||||||
expect(combinedCondition.serialize(), <String, String>{
|
|
||||||
'conditionName': 'CombinedCondition',
|
|
||||||
'conditions': '[]',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('CombinedCondition deserialize - empty condition list', () {
|
|
||||||
final Map<String, String> jsonMap = <String, String>{
|
|
||||||
'conditionName': 'CombinedCondition',
|
|
||||||
'conditions': '[]',
|
|
||||||
};
|
|
||||||
final CombinedCondition condition = CombinedCondition.deserialize(jsonMap);
|
|
||||||
expect(condition.conditions, equals(<WaitCondition>[]));
|
|
||||||
expect(condition.serialize(), equals(jsonMap));
|
|
||||||
});
|
|
||||||
|
|
||||||
test('CombinedCondition deserialize', () {
|
|
||||||
final Map<String, String> jsonMap = <String, String>{
|
|
||||||
'conditionName': 'CombinedCondition',
|
|
||||||
'conditions':
|
|
||||||
'[{"conditionName":"NoPendingFrameCondition"},{"conditionName":"NoTransientCallbacksCondition"}]',
|
|
||||||
};
|
|
||||||
final CombinedCondition condition =
|
|
||||||
CombinedCondition.deserialize(jsonMap);
|
|
||||||
expect(
|
|
||||||
condition.conditions,
|
|
||||||
equals(<WaitCondition>[
|
|
||||||
const NoPendingFrameCondition(),
|
|
||||||
const NoTransientCallbacksCondition(),
|
|
||||||
]));
|
|
||||||
expect(condition.serialize(), jsonMap);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('CombinedCondition deserialize - no condition list', () {
|
|
||||||
final CombinedCondition condition =
|
|
||||||
CombinedCondition.deserialize(<String, String>{'conditionName': 'CombinedCondition',});
|
|
||||||
expect(condition.conditions, equals(<WaitCondition>[]));
|
|
||||||
expect(condition.serialize(), <String, String>{
|
|
||||||
'conditionName': 'CombinedCondition',
|
|
||||||
'conditions': '[]',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('CombinedCondition deserialize error', () {
|
|
||||||
expect(
|
|
||||||
() => CombinedCondition.deserialize(<String, String>{'conditionName': 'Unknown'}),
|
|
||||||
throwsA(predicate<SerializationException>((SerializationException e) =>
|
|
||||||
e.message == 'Error occurred during deserializing the CombinedCondition JSON string: {conditionName: Unknown}')));
|
|
||||||
});
|
|
||||||
|
|
||||||
test('CombinedCondition deserialize error - Unknown condition type', () {
|
|
||||||
expect(
|
|
||||||
() {
|
|
||||||
return CombinedCondition.deserialize(<String, String>{
|
|
||||||
'conditionName': 'CombinedCondition',
|
|
||||||
'conditions':
|
|
||||||
'[{"conditionName":"UnknownCondition"},{"conditionName":"NoTransientCallbacksCondition"}]',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
throwsA(predicate<SerializationException>((SerializationException e) =>
|
|
||||||
e.message == 'Unsupported wait condition UnknownCondition in the JSON string {conditionName: UnknownCondition}')));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user