analyzer_testing: Add many imports and some elements to flutter mocks;

Work towards https://github.com/dart-lang/sdk/issues/61597

* DiagnosticsTreeStyle is used just below in DiagnosticsProperty.
* BoxConstraints is used in the `flutter_completion_benchmark`.
* Constraints is the superclass of BoxConstraints.
* The vector_math export is so that a few tests have access to the
  Matrix4 class.
* FutureBuilder and StreamBuilder are needed for the
  flutter_wrap_builder correction producer.

All of these changes bring the mocks/stubs closer to the real sources
(none are a divergence).


Change-Id: I80d746db3372417d7125aa1f3c2b0604a143f43b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476144
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
Sam Rawlins
2026-01-28 12:58:49 -08:00
committed by Commit Queue
parent 03980b59ac
commit ae41760d93
14 changed files with 65 additions and 1 deletions
@@ -34,6 +34,7 @@ export 'package:meta/meta.dart'
visibleForTesting;
export 'src/foundation/assertions.dart';
export 'src/foundation/change_notifier.dart';
export 'src/foundation/constants.dart';
export 'src/foundation/diagnostics.dart';
export 'src/foundation/key.dart';
@@ -7,6 +7,8 @@ import 'package:analyzer_testing/src/mock_packages/mock_library.dart';
final foundationAssertionsLibrary = MockLibraryUnit(
'lib/src/foundation/assertions.dart',
r'''
import 'diagnostics.dart';
class FlutterErrorDetails with Diagnosticable {
const FlutterErrorDetails({
required Object exception,
@@ -26,6 +26,10 @@ class DiagnosticPropertiesBuilder {
abstract class DiagnosticsNode {}
enum DiagnosticsTreeStyle {
singleLine;
}
class DiagnosticsProperty<T> extends DiagnosticsNode {
DiagnosticsProperty(
String? name,
@@ -5,7 +5,10 @@
import 'package:analyzer_testing/src/mock_packages/mock_library.dart';
final renderingLibrary = MockLibraryUnit('lib/rendering.dart', r'''
export 'package:vector_math/vector_math.dart';
export 'painting.dart';
export 'src/rendering/box.dart';
export 'src/rendering/flex.dart';
export 'src/rendering/paragraph.dart';
export 'src/rendering/object.dart';
''');
@@ -0,0 +1,11 @@
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. 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:analyzer_testing/src/mock_packages/mock_library.dart';
final renderingBoxLibrary = MockLibraryUnit('lib/src/rendering/box.dart', r'''
import 'object.dart';
class BoxConstraints extends Constraints {}
''');
@@ -0,0 +1,12 @@
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. 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:analyzer_testing/src/mock_packages/mock_library.dart';
final renderingObjectLibrary = MockLibraryUnit(
'lib/src/rendering/object.dart',
r'''
abstract class Constraints {}
''',
);
@@ -11,12 +11,16 @@ export 'foundation.dart' show UniqueKey;
export 'src/widgets/async.dart';
export 'src/widgets/basic.dart';
export 'src/widgets/container.dart';
export 'src/widgets/decorated_sliver.dart';
export 'src/widgets/framework.dart';
export 'src/widgets/gesture_detector.dart';
export 'src/widgets/icon_data.dart';
export 'src/widgets/icon.dart';
export 'src/widgets/inherited_theme.dart';
export 'src/widgets/navigator.dart';
export 'src/widgets/placeholder.dart';
export 'src/widgets/scroll_view.dart';
export 'src/widgets/sliver.dart';
export 'src/widgets/text.dart';
export 'src/widgets/ticker_provider.dart';
export 'src/widgets/value_listenable_builder.dart';
@@ -13,6 +13,10 @@ typedef AsyncWidgetBuilder<T> =
@immutable
class AsyncSnapshot<T> {}
class FutureBuilder<T> extends StatefulWidget {
const FutureBuilder({super.key, required this.future, this.initialData, required this.builder});
}
class StreamBuilder<T> extends StreamBuilderBase<T, AsyncSnapshot<T>> {
final T? initialData;
@@ -25,4 +29,6 @@ class StreamBuilder<T> extends StreamBuilderBase<T, AsyncSnapshot<T>> {
required this.builder,
});
}
abstract class StreamBuilderBase<T, S> extends StatefulWidget {}
''');
@@ -10,6 +10,7 @@ import 'package:flutter/rendering.dart';
import 'framework.dart';
export 'package:flutter/animation.dart';
export 'package:flutter/foundation.dart';
export 'package:flutter/painting.dart';
export 'package:flutter/rendering.dart';
@@ -7,6 +7,11 @@ import 'package:analyzer_testing/src/mock_packages/mock_library.dart';
final widgetsDecoratedSliverLibrary = MockLibraryUnit(
'lib/src/widgets/decorated_sliver.dart',
r'''
import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart';
import 'framework.dart';
class DecoratedSliver extends SingleChildRenderObjectWidget {
const DecoratedSliver({
super.key,
@@ -5,7 +5,12 @@
import 'package:analyzer_testing/src/mock_packages/mock_library.dart';
final widgetsIconLibrary = MockLibraryUnit('lib/src/widgets/icon.dart', r'''
import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart';
import 'basic.dart';
import 'framework.dart';
import 'icon_data.dart';
class Icon extends StatelessWidget {
final IconData? icon;
@@ -7,6 +7,8 @@ import 'package:analyzer_testing/src/mock_packages/mock_library.dart';
final widgetsNavigatorLibrary = MockLibraryUnit(
'lib/src/widgets/navigator.dart',
r'''
import 'framework.dart';
class Navigator extends StatefulWidget {
static NavigatorState of(
BuildContext context, {
@@ -7,6 +7,12 @@ import 'package:analyzer_testing/src/mock_packages/mock_library.dart';
final widgetsScrollViewLibrary = MockLibraryUnit(
'lib/src/widgets/scroll_view.dart',
r'''
import 'package:flutter/rendering.dart';
import 'basic.dart';
import 'framework.dart';
import 'sliver.dart';
abstract class ScrollView extends StatelessWidget {
const ScrollView({
super.key,
@@ -7,6 +7,8 @@ import 'package:analyzer_testing/src/mock_packages/mock_library.dart';
final widgetsValueListenableBuilderLibrary = MockLibraryUnit(
'lib/src/widgets/value_listenable_builder.dart',
r'''
import 'package:flutter/foundation.dart';
import 'framework.dart';
typedef ValueWidgetBuilder<T> =