Skip to content

Commit

Permalink
Remove unused code from tests (flutter#104550)
Browse files Browse the repository at this point in the history
  • Loading branch information
goderbauer authored May 25, 2022
1 parent 0a417c3 commit d5fbc37
Show file tree
Hide file tree
Showing 23 changed files with 4 additions and 411 deletions.
18 changes: 0 additions & 18 deletions packages/flutter/test/foundation/platform_helper.dart

This file was deleted.

2 changes: 0 additions & 2 deletions packages/flutter/test/foundation/print_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import 'package:flutter_test/flutter_test.dart';

import 'capture_output.dart';

String? foo;

void main() {
test('debugPrint', () {
expect(
Expand Down
2 changes: 0 additions & 2 deletions packages/flutter/test/gestures/arena_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
17 changes: 0 additions & 17 deletions packages/flutter/test/gestures/long_press_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
3 changes: 0 additions & 3 deletions packages/flutter/test/gestures/multitap_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import 'package:flutter_test/flutter_test.dart';

import 'gesture_tester.dart';

class TestDrag extends Drag {
}

void main() {
TestWidgetsFlutterBinding.ensureInitialized();

Expand Down
2 changes: 0 additions & 2 deletions packages/flutter/test/material/chip_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
10 changes: 0 additions & 10 deletions packages/flutter/test/material/chip_theme_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
29 changes: 0 additions & 29 deletions packages/flutter/test/material/dropdown_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 0 additions & 3 deletions packages/flutter/test/material/theme_defaults_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
18 changes: 0 additions & 18 deletions packages/flutter/test/painting/image_stream_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
37 changes: 0 additions & 37 deletions packages/flutter/test/rendering/editable_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();

Expand Down
15 changes: 0 additions & 15 deletions packages/flutter/test/widgets/custom_paint_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 0 additions & 17 deletions packages/flutter/test/widgets/multichild_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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 });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>{
Expand Down
44 changes: 0 additions & 44 deletions packages/flutter/test/widgets/routes_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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>(
Expand Down
4 changes: 0 additions & 4 deletions packages/flutter/test/widgets/scrollable_semantics_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit d5fbc37

Please sign in to comment.