Rename binding abstract classes (#3482)
The old names were getting silly and started stepping on valuable namespace. The new names are consistent and clear.
This commit is contained in:
@@ -14,6 +14,7 @@ import 'package:quiver/time.dart';
|
||||
import 'instrumentation.dart';
|
||||
|
||||
/// Enumeration of possible phases to reach in pumpWidget.
|
||||
// TODO(ianh): Merge with identical code in the rendering test code.
|
||||
enum EnginePhase {
|
||||
layout,
|
||||
compositingBits,
|
||||
@@ -23,7 +24,7 @@ enum EnginePhase {
|
||||
sendSemanticsTree
|
||||
}
|
||||
|
||||
class _SteppedWidgetFlutterBinding extends WidgetFlutterBinding { // TODO(ianh): refactor so we're not extending a concrete binding
|
||||
class _SteppedWidgetFlutterBinding extends WidgetsFlutterBinding { // TODO(ianh): refactor so we're not extending a concrete binding
|
||||
_SteppedWidgetFlutterBinding(this.async);
|
||||
|
||||
final FakeAsync async;
|
||||
@@ -31,10 +32,10 @@ class _SteppedWidgetFlutterBinding extends WidgetFlutterBinding { // TODO(ianh):
|
||||
/// Creates and initializes the binding. This constructor is
|
||||
/// idempotent; calling it a second time will just return the
|
||||
/// previously-created instance.
|
||||
static Widgeteer ensureInitialized(FakeAsync async) {
|
||||
if (Widgeteer.instance == null)
|
||||
static WidgetsBinding ensureInitialized(FakeAsync async) {
|
||||
if (WidgetsBinding.instance == null)
|
||||
new _SteppedWidgetFlutterBinding(async);
|
||||
return Widgeteer.instance;
|
||||
return WidgetsBinding.instance;
|
||||
}
|
||||
|
||||
EnginePhase phase = EnginePhase.sendSemanticsTree;
|
||||
@@ -47,7 +48,7 @@ class _SteppedWidgetFlutterBinding extends WidgetFlutterBinding { // TODO(ianh):
|
||||
buildOwner.finalizeTree();
|
||||
}
|
||||
|
||||
// Cloned from Renderer.beginFrame() but with early-exit semantics.
|
||||
// Cloned from RendererBinding.beginFrame() but with early-exit semantics.
|
||||
void _beginFrame() {
|
||||
assert(renderView != null);
|
||||
pipelineOwner.flushLayout();
|
||||
@@ -125,7 +126,7 @@ class ElementTreeTester extends Instrumentation {
|
||||
if (duration != null)
|
||||
async.elapse(duration);
|
||||
if (binding is _SteppedWidgetFlutterBinding) {
|
||||
// Some tests call WidgetFlutterBinding.ensureInitialized() manually, so
|
||||
// Some tests call WidgetsFlutterBinding.ensureInitialized() manually, so
|
||||
// we can't actually be sure we have a stepped binding.
|
||||
_SteppedWidgetFlutterBinding steppedBinding = binding;
|
||||
steppedBinding.phase = phase ?? EnginePhase.sendSemanticsTree;
|
||||
@@ -187,7 +188,7 @@ void testElementTree(callback(ElementTreeTester tester)) {
|
||||
callback(tester);
|
||||
runApp(new Container(key: new UniqueKey())); // Unmount any remaining widgets.
|
||||
async.flushMicrotasks();
|
||||
assert(Scheduler.instance.debugAssertNoTransientCallbacks(
|
||||
assert(SchedulerBinding.instance.debugAssertNoTransientCallbacks(
|
||||
'An animation is still running even after the widget tree was disposed.'
|
||||
));
|
||||
assert(() {
|
||||
|
||||
@@ -15,10 +15,10 @@ typedef Point SizeToPointFunction(Size size);
|
||||
/// This class provides hooks for accessing the rendering tree and dispatching
|
||||
/// fake tap/drag/etc. events.
|
||||
class Instrumentation {
|
||||
Instrumentation({ Widgeteer binding })
|
||||
: this.binding = binding ?? WidgetFlutterBinding.ensureInitialized();
|
||||
Instrumentation({ WidgetsBinding binding })
|
||||
: this.binding = binding ?? WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
final Widgeteer binding;
|
||||
final WidgetsBinding binding;
|
||||
|
||||
/// Returns a list of all the [Layer] objects in the rendering.
|
||||
List<Layer> get layers => _layers(binding.renderView.layer);
|
||||
|
||||
@@ -29,7 +29,7 @@ class ServiceMocker {
|
||||
|
||||
// Provide a mock implementation for a Mojo interface.
|
||||
// Make sure you initialise the binding before calling this.
|
||||
// For example, by calling `WidgetFlutterBinding.ensureInitialized();`
|
||||
// For example, by calling `WidgetsFlutterBinding.ensureInitialized();`
|
||||
void registerMockService(String interfaceName, Object mock) {
|
||||
_interfaceMocks[interfaceName] = mock;
|
||||
}
|
||||
|
||||
@@ -125,13 +125,13 @@ class TestGesture {
|
||||
}) {
|
||||
// hit test
|
||||
final HitTestResult result = new HitTestResult();
|
||||
target ??= Gesturer.instance;
|
||||
target ??= GestureBinding.instance;
|
||||
assert(target != null);
|
||||
target.hitTest(result, downLocation);
|
||||
|
||||
// dispatch down event
|
||||
final TestPointer testPointer = new TestPointer(pointer);
|
||||
dispatcher ??= Gesturer.instance;
|
||||
dispatcher ??= GestureBinding.instance;
|
||||
assert(dispatcher != null);
|
||||
dispatcher.dispatchEvent(testPointer.down(downLocation), result);
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class WidgetTester {
|
||||
|
||||
/// The binding instance that the widget tester is using when it
|
||||
/// needs a binding (e.g. for event dispatch).
|
||||
Widgeteer get binding => elementTreeTester.binding;
|
||||
WidgetsBinding get binding => elementTreeTester.binding;
|
||||
|
||||
/// Renders the UI from the given [widget].
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user