Unverified Commit d5fbc375 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Remove unused code from tests (#104550)

parent 0a417c3b
// Copyright 2014 The Flutter 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:io' show Platform;
/// Returns [Platform.pathSeparator], suitably escaped so as to be usable in a
/// regular expression.
String get pathSeparatorForRegExp {
switch (Platform.pathSeparator) {
case r'/':
return r'/';
case r'\':
return r'\\'; // because dividerRegExp gets inserted into regexps
default:
throw 'Unsupported platform.';
}
}
......@@ -8,8 +8,6 @@ import 'package:flutter_test/flutter_test.dart';
import 'capture_output.dart';
String? foo;
void main() {
test('debugPrint', () {
expect(
......
......@@ -5,8 +5,6 @@
import 'package:flutter/gestures.dart';
import 'package:flutter_test/flutter_test.dart';
typedef GestureArenaCallback = void Function(Object key);
const int primaryKey = 4;
class TestGestureArenaMember extends GestureArenaMember {
......
......@@ -41,23 +41,6 @@ const PointerDownEvent down3 = PointerDownEvent(
buttons: kSecondaryButton,
);
const PointerUpEvent up3 = PointerUpEvent(
pointer: 7,
position: Offset(31, 29),
);
// Down/up pair 4: tap sequence with tertiary button
const PointerDownEvent down4 = PointerDownEvent(
pointer: 8,
position: Offset(42, 24),
buttons: kTertiaryButton,
);
const PointerUpEvent up4 = PointerUpEvent(
pointer: 8,
position: Offset(43, 23),
);
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
......
......@@ -7,9 +7,6 @@ import 'package:flutter_test/flutter_test.dart';
import 'gesture_tester.dart';
class TestDrag extends Drag {
}
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
......
......@@ -67,8 +67,6 @@ double getSelectProgress(WidgetTester tester) => getRenderChip(tester)?.checkmar
double getAvatarDrawerProgress(WidgetTester tester) => getRenderChip(tester)?.avatarDrawerAnimation?.value as double;
// ignore: avoid_dynamic_calls
double getDeleteDrawerProgress(WidgetTester tester) => getRenderChip(tester)?.deleteDrawerAnimation?.value as double;
// ignore: avoid_dynamic_calls
double getEnableProgress(WidgetTester tester) => getRenderChip(tester)?.enableAnimation?.value as double;
/// Adds the basic requirements for a Chip.
Widget wrapForChip({
......
......@@ -27,16 +27,6 @@ Material getMaterial(WidgetTester tester) {
);
}
IconThemeData getIconData(WidgetTester tester) {
final IconTheme iconTheme = tester.firstWidget(
find.descendant(
of: find.byType(RawChip),
matching: find.byType(IconTheme),
),
);
return iconTheme.data;
}
DefaultTextStyle getLabelStyle(WidgetTester tester) {
return tester.widget(
find.descendant(
......
......@@ -252,29 +252,6 @@ void checkSelectedItemTextGeometry(WidgetTester tester, String value) {
expect(box0.size, equals(box1.size));
}
void verifyPaintedShadow(Finder customPaint, int elevation) {
const Rect originalRectangle = Rect.fromLTRB(0.0, 0.0, 800, 208.0);
final List<BoxShadow> boxShadows = List<BoxShadow>.generate(3, (int index) => kElevationToShadow[elevation]![index]);
final List<RRect> rrects = List<RRect>.generate(3, (int index) {
return RRect.fromRectAndRadius(
originalRectangle.shift(
boxShadows[index].offset,
).inflate(boxShadows[index].spreadRadius),
const Radius.circular(2.0),
);
});
expect(
customPaint,
paints
..save()
..rrect(rrect: rrects[0], color: boxShadows[0].color, hasMaskFilter: true)
..rrect(rrect: rrects[1], color: boxShadows[1].color, hasMaskFilter: true)
..rrect(rrect: rrects[2], color: boxShadows[2].color, hasMaskFilter: true),
);
}
Future<void> checkDropdownColor(WidgetTester tester, {Color? color, bool isFormField = false }) async {
const String text = 'foo';
await tester.pumpWidget(
......@@ -325,12 +302,6 @@ Future<void> checkDropdownColor(WidgetTester tester, {Color? color, bool isFormF
);
}
bool sameGeometry(RenderBox box1, RenderBox box2) {
expect(box1.localToGlobal(Offset.zero), equals(box2.localToGlobal(Offset.zero)));
expect(box1.size.height, equals(box2.size.height));
return true;
}
void main() {
testWidgets('Default dropdown golden', (WidgetTester tester) async {
final Key buttonKey = UniqueKey();
......
......@@ -5,9 +5,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
const ShapeBorder defaultButtonShape = RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(2.0)));
const EdgeInsets defaultButtonPadding = EdgeInsets.only(left: 16.0, right: 16.0);
const BoxConstraints defaultButtonConstraints = BoxConstraints(minWidth: 88.0, minHeight: 36.0);
const Duration defaultButtonDuration = Duration(milliseconds: 200);
void main() {
......
......@@ -79,24 +79,6 @@ class FakeEventReportingImageStreamCompleter extends ImageStreamCompleter {
}
}
class SynchronousTestImageProvider extends ImageProvider<int> {
const SynchronousTestImageProvider(this.image);
final Image image;
@override
Future<int> obtainKey(ImageConfiguration configuration) {
return SynchronousFuture<int>(1);
}
@override
ImageStreamCompleter load(int key, DecoderCallback decode) {
return OneFrameImageStreamCompleter(
SynchronousFuture<ImageInfo>(TestImageInfo(key, image: image)),
);
}
}
void main() {
late Image image20x10;
late Image image200x100;
......
......@@ -13,11 +13,6 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:meta/meta.dart';
// The test_api package is not for general use... it's literally for our use.
// ignore: deprecated_member_use
import 'package:test_api/test_api.dart' as test_package;
import 'mock_canvas.dart';
import 'recording_canvas.dart';
......@@ -55,38 +50,6 @@ class _FakeEditableTextState with TextSelectionDelegate {
void copySelection(SelectionChangedCause cause) { }
}
@isTest
void testVariants(
String description,
AsyncValueGetter<void> callback, {
bool? skip,
test_package.Timeout? timeout,
TestVariant<Object?> variant = const DefaultTestVariant(),
dynamic tags,
}) {
assert(variant != null);
assert(variant.values.isNotEmpty, 'There must be at least one value to test in the testing variant.');
for (final dynamic value in variant.values) {
final String variationDescription = variant.describeValue(value);
final String combinedDescription = variationDescription.isNotEmpty ? '$description ($variationDescription)' : description;
test(
combinedDescription,
() async {
Object? memento;
try {
memento = await variant.setUp(value);
await callback();
} finally {
await variant.tearDown(value, memento);
}
},
skip: skip, // [intended] just part of the API.
timeout: timeout,
tags: tags,
);
}
}
void main() {
TestRenderingFlutterBinding.ensureInitialized();
......
......@@ -21,21 +21,6 @@ class TestCustomPainter extends CustomPainter {
bool shouldRepaint(TestCustomPainter oldPainter) => true;
}
class TestCustomPainterWithCustomSemanticsBuilder extends TestCustomPainter {
TestCustomPainterWithCustomSemanticsBuilder() : super(log: <String>[]);
@override
SemanticsBuilderCallback get semanticsBuilder => (Size size) {
const Key key = Key('0');
const Rect rect = Rect.zero;
const SemanticsProperties semanticsProperties = SemanticsProperties();
return <CustomPainterSemantics>[
const CustomPainterSemantics(key: key, rect: rect, properties: semanticsProperties),
const CustomPainterSemantics(key: key, rect: rect, properties: semanticsProperties),
];
};
}
class MockCanvas extends Fake implements Canvas {
int saveCount = 0;
int saveCountDelta = 1;
......
......@@ -41,20 +41,6 @@ class SizeChangerState extends State<SizeChanger> {
}
}
class Wrapper extends StatelessWidget {
const Wrapper({
super.key,
required this.child,
});
final Widget child;
@override
Widget build(BuildContext context) {
return child;
}
}
void main() {
testWidgets('Applying parent data inside a LayoutBuilder', (WidgetTester tester) async {
int frame = 1;
......
......@@ -31,16 +31,6 @@ void checkTree(WidgetTester tester, List<BoxDecoration> expectedDecorations) {
}
}
class MockMultiChildRenderObjectWidget extends MultiChildRenderObjectWidget {
MockMultiChildRenderObjectWidget({ super.key, required super.children });
@override
RenderObject createRenderObject(BuildContext context) {
assert(false);
return FakeRenderObject();
}
}
void main() {
testWidgets('MultiChildRenderObjectElement control test', (WidgetTester tester) async {
......@@ -357,13 +347,6 @@ void main() {
});
}
class FakeRenderObject extends RenderBox {
@override
void performLayout() {
size = constraints.biggest;
}
}
class DummyWidget extends StatelessWidget {
const DummyWidget({ super.key, required this.child });
......
......@@ -29,13 +29,6 @@ class OnTapPage extends StatelessWidget {
}
}
Map<String, dynamic> convertRouteInformationToMap(RouteInformation routeInformation) {
return <String, dynamic>{
'location': routeInformation.location,
'state': routeInformation.state,
};
}
void main() {
testWidgets('Push and Pop should send platform messages', (WidgetTester tester) async {
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
......
......@@ -2296,50 +2296,6 @@ class WidgetWithNoLocalHistoryState extends State<WidgetWithNoLocalHistory> {
}
}
class TransitionDetector extends DefaultTransitionDelegate<void> {
bool hasTransition = false;
@override
Iterable<RouteTransitionRecord> resolve({
required List<RouteTransitionRecord> newPageRouteHistory,
required Map<RouteTransitionRecord?, RouteTransitionRecord> locationToExitingPageRoute,
required Map<RouteTransitionRecord?, List<RouteTransitionRecord>> pageRouteToPagelessRoutes,
}) {
hasTransition = true;
return super.resolve(
newPageRouteHistory: newPageRouteHistory,
locationToExitingPageRoute: locationToExitingPageRoute,
pageRouteToPagelessRoutes: pageRouteToPagelessRoutes,
);
}
}
Widget buildNavigator({
required List<Page<dynamic>> pages,
required PopPageCallback onPopPage,
GlobalKey<NavigatorState>? key,
TransitionDelegate<dynamic>? transitionDelegate,
}) {
return MediaQuery(
data: MediaQueryData.fromWindow(WidgetsBinding.instance.window),
child: Localizations(
locale: const Locale('en', 'US'),
delegates: const <LocalizationsDelegate<dynamic>>[
DefaultMaterialLocalizations.delegate,
DefaultWidgetsLocalizations.delegate,
],
child: Directionality(
textDirection: TextDirection.ltr,
child: Navigator(
key: key,
pages: pages,
onPopPage: onPopPage,
transitionDelegate: transitionDelegate ?? const DefaultTransitionDelegate<dynamic>(),
),
),
),
);
}
class _RestorableDialogTestWidget extends StatelessWidget {
static Route<Object?> _dialogBuilder(BuildContext context, Object? arguments) {
return RawDialogRoute<void>(
......
......@@ -643,10 +643,6 @@ Future<void> flingUp(WidgetTester tester, { int repetitions = 1 }) => fling(test
Future<void> flingDown(WidgetTester tester, { int repetitions = 1 }) => fling(tester, const Offset(0.0, 200.0), repetitions);
Future<void> flingRight(WidgetTester tester, { int repetitions = 1 }) => fling(tester, const Offset(200.0, 0.0), repetitions);
Future<void> flingLeft(WidgetTester tester, { int repetitions = 1 }) => fling(tester, const Offset(-200.0, 0.0), repetitions);
Future<void> fling(WidgetTester tester, Offset offset, int repetitions) async {
while (repetitions-- > 0) {
await tester.fling(find.byType(ListView), offset, 1000.0);
......
......@@ -1041,95 +1041,3 @@ class RenderSelectionSpy extends RenderProxyBox
@override
void pushHandleLayers(LayerLink? startHandle, LayerLink? endHandle) { }
}
class TextTextSelectionControls extends TextSelectionControls {
static final UniqueKey leftHandle = UniqueKey();
static final UniqueKey rightHandle = UniqueKey();
static final UniqueKey toolbar = UniqueKey();
@override
Size getHandleSize(double textLineHeight) => Size(textLineHeight, textLineHeight);
@override
Widget buildToolbar(
BuildContext context,
Rect globalEditableRegion,
double textLineHeight,
Offset selectionMidpoint,
List<TextSelectionPoint> endpoints,
TextSelectionDelegate delegate,
ClipboardStatusNotifier? clipboardStatus,
Offset? lastSecondaryTapDownPosition,
) {
return TestToolbar(
key: toolbar,
globalEditableRegion: globalEditableRegion,
textLineHeight: textLineHeight,
selectionMidpoint: selectionMidpoint,
endpoints: endpoints,
delegate: delegate,
clipboardStatus: clipboardStatus,
lastSecondaryTapDownPosition: lastSecondaryTapDownPosition,
);
}
@override
Widget buildHandle(BuildContext context, TextSelectionHandleType type, double textHeight, [VoidCallback? onTap]) {
return TestHandle(
key: type == TextSelectionHandleType.left ? leftHandle : rightHandle,
type: type,
textHeight: textHeight,
);
}
@override
Offset getHandleAnchor(TextSelectionHandleType type, double textLineHeight) {
return Offset.zero;
}
@override
bool canSelectAll(TextSelectionDelegate delegate) => true;
}
class TestHandle extends StatelessWidget {
const TestHandle({
super.key,
required this.type,
required this.textHeight,
});
final TextSelectionHandleType type;
final double textHeight;
@override
Widget build(BuildContext context) {
return SizedBox(width: textHeight, height: textHeight);
}
}
class TestToolbar extends StatelessWidget {
const TestToolbar({
super.key,
required this.globalEditableRegion,
required this.textLineHeight,
required this.selectionMidpoint,
required this.endpoints,
required this.delegate,
required this.clipboardStatus,
required this.lastSecondaryTapDownPosition,
});
final Rect globalEditableRegion;
final double textLineHeight;
final Offset selectionMidpoint;
final List<TextSelectionPoint> endpoints;
final TextSelectionDelegate delegate;
final ClipboardStatusNotifier? clipboardStatus;
final Offset? lastSecondaryTapDownPosition;
@override
Widget build(BuildContext context) {
return SizedBox(width: textLineHeight, height: textLineHeight);
}
}
......@@ -103,15 +103,6 @@ Future<void> skipPastScrollingAnimation(WidgetTester tester) async {
await tester.pump(const Duration(milliseconds: 200));
}
double getOpacity(WidgetTester tester, Finder finder) {
return tester.widget<FadeTransition>(
find.ancestor(
of: finder,
matching: find.byType(FadeTransition),
),
).opacity.value;
}
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
final MockClipboard mockClipboard = MockClipboard();
......
......@@ -1737,8 +1737,6 @@ class _TestCallbackRegistrationState extends State<TestCallbackRegistration> {
}
}
typedef PostInvokeCallback = void Function({Action<Intent> action, Intent intent, BuildContext? context, ActionDispatcher dispatcher});
class TestAction extends CallbackAction<Intent> {
TestAction({
required super.onInvoke,
......@@ -1747,19 +1745,6 @@ class TestAction extends CallbackAction<Intent> {
static const LocalKey key = ValueKey<Type>(TestAction);
}
class TestDispatcher extends ActionDispatcher {
const TestDispatcher({this.postInvoke});
final PostInvokeCallback? postInvoke;
@override
Object? invokeAction(Action<TestIntent> action, Intent intent, [BuildContext? context]) {
final Object? result = super.invokeAction(action, intent, context);
postInvoke?.call(action: action, intent: intent, context: context, dispatcher: this);
return result;
}
}
/// An activator that accepts down events that has [key] as the logical key.
///
/// This class is used only to tests. It is intentionally designed poorly by
......
......@@ -56,21 +56,6 @@ class TestScrollPhysics extends ClampingScrollPhysics {
Tolerance get tolerance => const Tolerance(velocity: 20.0, distance: 1.0);
}
class TestViewportScrollPosition extends ScrollPositionWithSingleContext {
TestViewportScrollPosition({
required super.physics,
required super.context,
super.oldPosition,
});
@override
bool applyContentDimensions(double minScrollExtent, double maxScrollExtent) {
expect(minScrollExtent, moreOrLessEquals(-3895.0));
expect(maxScrollExtent, moreOrLessEquals(8575.0));
return super.applyContentDimensions(minScrollExtent, maxScrollExtent);
}
}
void main() {
testWidgets('Evil test of sliver features - 1', (WidgetTester tester) async {
final GlobalKey centerKey = GlobalKey();
......
......@@ -1426,37 +1426,6 @@ class FakeRenderEditable extends RenderEditable {
bool hasFocus = false;
}
class CustomTextSelectionControls extends TextSelectionControls {
@override
Widget buildHandle(BuildContext context, TextSelectionHandleType type, double textLineHeight, [VoidCallback? onTap]) {
throw UnimplementedError();
}
@override
Widget buildToolbar(
BuildContext context,
Rect globalEditableRegion,
double textLineHeight,
Offset position,
List<TextSelectionPoint> endpoints,
TextSelectionDelegate delegate,
ClipboardStatusNotifier? clipboardStatus,
Offset? lastSecondaryTapDownPosition,
) {
throw UnimplementedError();
}
@override
Offset getHandleAnchor(TextSelectionHandleType type, double textLineHeight) {
throw UnimplementedError();
}
@override
Size getHandleSize(double textLineHeight) {
throw UnimplementedError();
}
}
class TextSelectionControlsSpy extends TextSelectionControls {
UniqueKey leftHandleKey = UniqueKey();
UniqueKey rightHandleKey = UniqueKey();
......
......@@ -14,7 +14,6 @@
@TestOn('!chrome')
import 'dart:async';
import 'dart:convert';
import 'dart:math';
import 'dart:ui' as ui;
......@@ -160,8 +159,6 @@ class _CreationLocation {
String? name;
}
typedef InspectorServiceExtensionCallback = FutureOr<Map<String, Object>> Function(Map<String, String> parameters);
class RenderRepaintBoundaryWithDebugPaint extends RenderRepaintBoundary {
@override
void debugPaintSize(PaintingContext context, Offset offset) {
......@@ -1999,7 +1996,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
_CreationLocation location = knownLocations[id]!;
expect(location.file, equals(file));
// ClockText widget.
expect(location.line, equals(64));
expect(location.line, equals(63));
expect(location.column, equals(9));
expect(location.name, equals('ClockText'));
expect(count, equals(1));
......@@ -2009,7 +2006,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
location = knownLocations[id]!;
expect(location.file, equals(file));
// Text widget in _ClockTextState build method.
expect(location.line, equals(102));
expect(location.line, equals(101));
expect(location.column, equals(12));
expect(location.name, equals('Text'));
expect(count, equals(1));
......@@ -2036,7 +2033,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
location = knownLocations[id]!;
expect(location.file, equals(file));
// ClockText widget.
expect(location.line, equals(64));
expect(location.line, equals(63));
expect(location.column, equals(9));
expect(location.name, equals('ClockText'));
expect(count, equals(3)); // 3 clock widget instances rebuilt.
......@@ -2046,7 +2043,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
location = knownLocations[id]!;
expect(location.file, equals(file));
// Text widget in _ClockTextState build method.
expect(location.line, equals(102));
expect(location.line, equals(101));
expect(location.column, equals(12));
expect(location.name, equals('Text'));
expect(count, equals(3)); // 3 clock widget instances rebuilt.
......
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