Skip to content

Commit

Permalink
fix: upgrade to flutter 3.13 (#95)
Browse files Browse the repository at this point in the history
* Increase Flutter Version in Workflow

* Update Signature of TestWidgetsFn

* Fix Vertices Error

* Fix Warnings

* Update Goldens

* Remove extra MediaQuery Widget
  • Loading branch information
ABausG authored Sep 11, 2023
1 parent 0a8b653 commit b54138c
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 45 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

- uses: subosito/flutter-action@v2
with:
flutter-version: '3.7.0'
flutter-version: '3.13.0'
channel: 'stable'
cache: true

Expand Down Expand Up @@ -39,7 +39,7 @@ jobs:

- uses: subosito/flutter-action@v2
with:
flutter-version: '3.7.0'
flutter-version: '3.13.0'
channel: 'stable'
cache: true

Expand Down
4 changes: 2 additions & 2 deletions example/lib/home/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class HomePage extends StatelessWidget {
appBar: AppBar(
title: const Text('Alchemist Example App'),
),
body: SizedBox.expand(
body: const SizedBox.expand(
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
children: [
SizedBox(height: 16),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16),
Expand Down
25 changes: 10 additions & 15 deletions lib/src/golden_test_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ typedef TestWidgetsFn = FutureOr<void> Function(
Future<void> Function(WidgetTester) callback, {
bool? skip,
Timeout? timeout,
Duration? initialTimeout,
bool semanticsEnabled,
TestVariant<Object?> variant,
dynamic tags,
int? retry,
});

/// The signature of the `tearDown` and `setUp` test functions.
Expand Down Expand Up @@ -231,9 +231,8 @@ class FlutterGoldenTestAdapter extends GoldenTestAdapter {
required PumpWidget pumpWidget,
required Widget widget,
}) async {
tester.binding.window.devicePixelRatioTestValue = 1.0;
tester.binding.window.platformDispatcher.textScaleFactorTestValue =
textScaleFactor;
tester.view.devicePixelRatio = 1.0;
tester.platformDispatcher.textScaleFactorTestValue = textScaleFactor;

await pumpWidget(
tester,
Expand Down Expand Up @@ -279,7 +278,7 @@ class FlutterGoldenTestAdapter extends GoldenTestAdapter {
final childSize = tester.getSize(find.byKey(childKey));

await tester.binding.setSurfaceSize(childSize);
tester.binding.window.physicalSizeTestValue = childSize;
tester.view.physicalSize = childSize;

await tester.pump();
}
Expand All @@ -291,7 +290,7 @@ class FlutterGoldenTestAdapter extends GoldenTestAdapter {
}) async {
var renderObject = tester.renderObject(finder);
while (!renderObject.isRepaintBoundary) {
renderObject = renderObject.parent! as RenderObject;
renderObject = renderObject.parent!;
}
final layer = renderObject.debugLayer! as OffsetLayer;
paintingContextBuilder(
Expand Down Expand Up @@ -383,15 +382,11 @@ class FlutterGoldenTestWrapper extends StatelessWidget {

@override
Widget build(BuildContext context) {
return MediaQuery(
data: MediaQuery.maybeOf(context) ??
MediaQueryData.fromWindow(WidgetsBinding.instance.window),
child: _LocalizationWrapper(
child: Theme(
data: _resolveThemeOf(context),
child: _NavigatorWrapper(
child: child,
),
return _LocalizationWrapper(
child: Theme(
data: _resolveThemeOf(context),
child: _NavigatorWrapper(
child: child,
),
),
);
Expand Down
4 changes: 2 additions & 2 deletions lib/src/golden_test_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ class FlutterGoldenTestRunner extends GoldenTestRunner {
debugDisableShadows = mementoDebugDisableShadows;

await tester.binding.setSurfaceSize(null);
tester.binding.window.clearPhysicalSizeTestValue();
tester.binding.window.clearDevicePixelRatioTestValue();
tester.view.resetPhysicalSize();
tester.view.resetDevicePixelRatio();
}
}
}
Binary file modified test/smoke_tests/goldens/ci/composited_transform_smoke_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/smoke_tests/goldens/ci/dropdown_smoke_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/smoke_tests/goldens/ci/interactions_smoke_test_pressed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/smoke_tests/goldens/ci/interactions_smoke_test_regular.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/smoke_tests/goldens/ci/timer_button_smoke_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions test/src/blocked_text_canvas_adapter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class MockCanvas extends Mock implements ui.Canvas {}

class MockParagraph extends Mock implements ui.Paragraph {}

class FakeVertices extends Fake implements ui.Vertices {}

class FakeImage extends Fake implements ui.Image {}

class FakePicture extends Fake implements ui.Picture {}
Expand Down Expand Up @@ -281,7 +279,7 @@ void main() {
});

test('drawVertices delegates to parent implementation', () {
final vertices = FakeVertices();
final vertices = ui.Vertices(ui.VertexMode.triangles, [Offset.zero]);
const blendMode = ui.BlendMode.color;
final paint = ui.Paint();
subject.drawVertices(vertices, blendMode, paint);
Expand Down
16 changes: 8 additions & 8 deletions test/src/blocked_text_painting_context_golden_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ void main() {
const goldenFilePath = 'blocked_text_image_reference.png';

Future<void> setUpSurface(WidgetTester tester) async {
final originalSize = tester.binding.window.physicalSize;
final originalSize = tester.view.physicalSize;
const adjustedSize = Size(250, 100);

tester.binding.window.physicalSizeTestValue = adjustedSize;
tester.view.physicalSize = adjustedSize;
await tester.binding.setSurfaceSize(adjustedSize);
tester.binding.window.devicePixelRatioTestValue = 1.0;
tester.view.devicePixelRatio = 1.0;

addTearDown(tester.binding.window.clearPhysicalSizeTestValue);
addTearDown(tester.view.resetPhysicalSize);
addTearDown(() => tester.binding.setSurfaceSize(originalSize));
addTearDown(tester.binding.window.clearDevicePixelRatioTestValue);
addTearDown(tester.view.resetDevicePixelRatio);
}

Widget buildSubject({
Expand All @@ -50,12 +50,12 @@ void main() {
return MaterialApp(
key: key,
debugShowCheckedModeBanner: false,
home: Scaffold(
home: const Scaffold(
body: Padding(
padding: const EdgeInsets.all(8),
padding: EdgeInsets.all(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
children: [
Text(
'black text',
style: TextStyle(color: Color(0xFF000000)),
Expand Down
11 changes: 6 additions & 5 deletions test/src/golden_test_adapter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ void main() {
Future<void> Function(WidgetTester) callback, {
bool? skip,
Timeout? timeout,
Duration? initialTimeout,
bool semanticsEnabled = false,
TestVariant<Object?> variant = const DefaultTestVariant(),
dynamic tags,
int? retry,
}) {}

test('overrides value', () {
Expand Down Expand Up @@ -293,7 +293,7 @@ void main() {

final targetSize = tester.getSize(find.byKey(groupKey));

expect(tester.binding.window.physicalSize, targetSize);
expect(tester.view.physicalSize, targetSize);
},
);

Expand All @@ -310,7 +310,7 @@ void main() {
widget: buildGroup(),
);

expect(tester.binding.window.textScaleFactor, 2.0);
expect(tester.platformDispatcher.textScaleFactor, 2.0);
});

testWidgets(
Expand Down Expand Up @@ -421,8 +421,9 @@ void main() {
),
);

final windowMediaQuery =
MediaQueryData.fromWindow(tester.binding.window);
final windowMediaQuery = MediaQueryData.fromView(
tester.binding.platformDispatcher.views.first,
);

expect(find.byType(MediaQuery), findsOneWidget);
expect(
Expand Down
2 changes: 1 addition & 1 deletion test/src/golden_test_group_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Matcher hasColumns(int amount) {
(t) => t.children.isEmpty ? null : t.children.first,
'first row',
isA<TableRow>().having(
(r) => r.children?.length,
(r) => r.children.length,
'column count',
amount,
),
Expand Down
8 changes: 4 additions & 4 deletions test/src/golden_test_runner_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void main() {

testWidgets('resets window size after the test has run', (tester) async {
late final Size sizeDuringTestRun;
final originalSize = tester.binding.window.physicalSize;
final originalSize = tester.view.physicalSize;
when(
() => goldenTestAdapter.pumpGoldenTest(
rootKey: any(named: 'rootKey'),
Expand All @@ -168,7 +168,7 @@ void main() {
variantConfigTheme: any(named: 'variantConfigTheme'),
),
).thenAnswer((_) async {
tester.binding.window.physicalSizeTestValue = Size.zero;
tester.view.physicalSize = Size.zero;
});

final givenException = Exception();
Expand All @@ -179,14 +179,14 @@ void main() {
renderShadows: true,
widget: const SizedBox.square(dimension: 200),
whilePerforming: (testerDuringTestRun) {
sizeDuringTestRun = testerDuringTestRun.binding.window.physicalSize;
sizeDuringTestRun = testerDuringTestRun.view.physicalSize;
throw givenException;
},
),
throwsA(same(givenException)),
);

expect(tester.binding.window.physicalSize, originalSize);
expect(tester.view.physicalSize, originalSize);
expect(sizeDuringTestRun, Size.zero);
});

Expand Down
2 changes: 1 addition & 1 deletion test/src/golden_test_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ class FakeGoldenTestAdapter extends Mock implements GoldenTestAdapter {
Future<void> Function(WidgetTester) callback, {
bool? skip,
Timeout? timeout,
Duration? initialTimeout,
bool semanticsEnabled = true,
TestVariant<Object?> variant = const DefaultTestVariant(),
dynamic tags,
int? retry,
}) async {
for (final value in variant.values) {
await variant.setUp(value);
Expand Down
6 changes: 4 additions & 2 deletions test/src/utilities_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,16 @@ to avoid unnecessary overhead.''',

group('TestAssetBundle', () {
setUp(() {
ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler(
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMessageHandler(
'flutter/assets',
(message) async => message,
);
});

tearDown(() {
ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler(
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMessageHandler(
'flutter/assets',
null,
);
Expand Down

0 comments on commit b54138c

Please sign in to comment.