mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Add tests for color_filtered.0.dart example. (#151064)
This PR contributes to https://github.com/flutter/flutter/issues/130459 ### Description - Adds tests for `examples/api/lib/widgets/color_filter/color_filtered.0.dart`
This commit is contained in:
parent
55520b842c
commit
bff15689fd
@ -380,7 +380,6 @@ final Set<String> _knownMissingTests = <String>{
|
|||||||
'examples/api/test/widgets/restoration/restoration_mixin.0_test.dart',
|
'examples/api/test/widgets/restoration/restoration_mixin.0_test.dart',
|
||||||
'examples/api/test/widgets/actions/action_listener.0_test.dart',
|
'examples/api/test/widgets/actions/action_listener.0_test.dart',
|
||||||
'examples/api/test/widgets/actions/focusable_action_detector.0_test.dart',
|
'examples/api/test/widgets/actions/focusable_action_detector.0_test.dart',
|
||||||
'examples/api/test/widgets/color_filter/color_filtered.0_test.dart',
|
|
||||||
'examples/api/test/widgets/focus_scope/focus_scope.0_test.dart',
|
'examples/api/test/widgets/focus_scope/focus_scope.0_test.dart',
|
||||||
'examples/api/test/widgets/scroll_view/custom_scroll_view.1_test.dart',
|
'examples/api/test/widgets/scroll_view/custom_scroll_view.1_test.dart',
|
||||||
'examples/api/test/animation/curves/curve2_d.0_test.dart',
|
'examples/api/test/animation/curves/curve2_d.0_test.dart',
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
// 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';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
|
import 'package:flutter_api_samples/widgets/color_filter/color_filtered.0.dart'
|
||||||
|
as example;
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
// The app being tested loads images via HTTP which the test
|
||||||
|
// framework defeats by default.
|
||||||
|
setUpAll(() {
|
||||||
|
HttpOverrides.global = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Color filters are applied to the images', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
const example.ColorFilteredExampleApp(),
|
||||||
|
);
|
||||||
|
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
// Verify that two images are displayed.
|
||||||
|
expect(find.byType(Image), findsNWidgets(2));
|
||||||
|
|
||||||
|
RenderObject renderObject = tester.firstRenderObject(
|
||||||
|
find.byType(ColorFiltered).first,
|
||||||
|
);
|
||||||
|
ColorFilterLayer colorFilterLayer =
|
||||||
|
renderObject.debugLayer! as ColorFilterLayer;
|
||||||
|
|
||||||
|
// Verify that red colored filter with modulate blend mode is applied to the first image.
|
||||||
|
expect(
|
||||||
|
colorFilterLayer.colorFilter,
|
||||||
|
equals(const ColorFilter.mode(Colors.red, BlendMode.modulate)),
|
||||||
|
);
|
||||||
|
|
||||||
|
renderObject = tester.firstRenderObject(
|
||||||
|
find.byType(ColorFiltered).last,
|
||||||
|
);
|
||||||
|
colorFilterLayer = renderObject.debugLayer! as ColorFilterLayer;
|
||||||
|
|
||||||
|
// Verify that grey colored filter with saturation blend mode is applied to the first image.
|
||||||
|
expect(
|
||||||
|
colorFilterLayer.colorFilter,
|
||||||
|
equals(const ColorFilter.mode(Colors.grey, BlendMode.saturation)),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user