Reduce noise on the memory benchmarks (#19630)
- Check memory usage in release builds, not profile. - Use multiple runs and average the results.
This commit is contained in:
@@ -15,8 +15,12 @@ import 'test_pointer.dart';
|
||||
|
||||
/// Class that programmatically interacts with widgets.
|
||||
///
|
||||
/// For a variant of this class suited specifically for unit tests, see [WidgetTester].
|
||||
class WidgetController {
|
||||
/// For a variant of this class suited specifically for unit tests, see
|
||||
/// [WidgetTester]. For one suitable for live tests on a device, consider
|
||||
/// [LiveWidgetController].
|
||||
///
|
||||
/// Concrete subclasses must implement the [pump] method.
|
||||
abstract class WidgetController {
|
||||
/// Creates a widget controller that uses the given binding.
|
||||
WidgetController(this.binding);
|
||||
|
||||
@@ -392,10 +396,11 @@ class WidgetController {
|
||||
/// This is invoked by [flingFrom], for instance, so that the sequence of
|
||||
/// pointer events occurs over time.
|
||||
///
|
||||
/// The default implementation does nothing.
|
||||
///
|
||||
/// The [WidgetTester] subclass implements this by deferring to the [binding].
|
||||
Future<Null> pump(Duration duration) => new Future<Null>.value(null);
|
||||
///
|
||||
/// See also [SchedulerBinding.endOfFrame], which returns a future that could
|
||||
/// be appropriate to return in the implementation of this method.
|
||||
Future<Null> pump(Duration duration);
|
||||
|
||||
/// Attempts to drag the given widget by the given offset, by
|
||||
/// starting a drag in the middle of the widget.
|
||||
@@ -516,3 +521,20 @@ class WidgetController {
|
||||
/// the widget's render object has been laid out at least once.
|
||||
Rect getRect(Finder finder) => getTopLeft(finder) & getSize(finder);
|
||||
}
|
||||
|
||||
/// Variant of [WidgetController] that can be used in tests running
|
||||
/// on a device.
|
||||
///
|
||||
/// This is used, for instance, by [FlutterDriver].
|
||||
class LiveWidgetController extends WidgetController {
|
||||
/// Creates a widget controller that uses the given binding.
|
||||
LiveWidgetController(WidgetsBinding binding) : super(binding);
|
||||
|
||||
@override
|
||||
Future<Null> pump(Duration duration) async {
|
||||
if (duration != null)
|
||||
await new Future<void>.delayed(duration);
|
||||
binding.scheduleFrame();
|
||||
await binding.endOfFrame;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user