More beautiful linear_gradient sample (#99298)
This commit is contained in:
committed by
GitHub
parent
96426230af
commit
00f3f2b14f
14
examples/api/test/flutter_test_config.dart
Normal file
14
examples/api/test/flutter_test_config.dart
Normal file
@@ -0,0 +1,14 @@
|
||||
// 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:async';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'goldens_io.dart' if (dart.library.html) 'goldens_web.dart' as flutter_goldens;
|
||||
|
||||
Future<void> testExecutable(FutureOr<void> Function() testMain) {
|
||||
// Enable golden file testing using Skia Gold.
|
||||
return flutter_goldens.testExecutable(testMain, namePrefix: 'api');
|
||||
}
|
||||
5
examples/api/test/goldens_io.dart
Normal file
5
examples/api/test/goldens_io.dart
Normal file
@@ -0,0 +1,5 @@
|
||||
// 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.
|
||||
|
||||
export 'package:flutter_goldens/flutter_goldens.dart' show testExecutable;
|
||||
8
examples/api/test/goldens_web.dart
Normal file
8
examples/api/test/goldens_web.dart
Normal file
@@ -0,0 +1,8 @@
|
||||
// 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:async';
|
||||
|
||||
// package:flutter_goldens is not used as part of the test process for web.
|
||||
Future<void> testExecutable(FutureOr<void> Function() testMain) async => testMain();
|
||||
39
examples/api/test/painting/linear_gradient.0_test.dart
Normal file
39
examples/api/test/painting/linear_gradient.0_test.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
// 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 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_api_samples/painting/gradient/linear_gradient.0.dart'
|
||||
as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('finds a gradient', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: example.MoodyGradient(),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(example.MoodyGradient), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('gradient matches golden', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: SizedBox(
|
||||
width: 800,
|
||||
height: 600,
|
||||
child: RepaintBoundary(
|
||||
child: example.MoodyGradient(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await expectLater(
|
||||
find.byType(example.MoodyGradient),
|
||||
matchesGoldenFile('linear_gradient.0_test.png'),
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user