Add golden tests for Opacity with offset (#24253)

See https://github.com/flutter/flutter/issues/23890
This commit is contained in:
liyuqian 2018-11-14 15:00:39 -08:00 committed by GitHub
parent 07c5c0ac1b
commit ba635a643a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 1 deletions

View File

@ -1 +1 @@
8c478bbaf27447f3d612959705b305e7d1293526
e07cc0cb4fdf912062e71a6fd97cc91478d6e3b9

View File

@ -1142,6 +1142,7 @@ class OpacityLayer extends ContainerLayer {
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(IntProperty('alpha', alpha));
properties.add(DiagnosticsProperty<Offset>('offset', offset));
}
}

View File

@ -2,8 +2,11 @@
// 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/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';
import '../rendering/mock_canvas.dart';
import 'semantics_tester.dart';
@ -147,4 +150,37 @@ void main() {
semantics.dispose();
});
testWidgets('offset is correctly handled in Opacity', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: SingleChildScrollView(
child: RepaintBoundary(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: List<Widget>.generate(10, (int index) {
return Opacity(
opacity: 0.5,
child: Padding(
padding: const EdgeInsets.all(5.0),
child: Container(
color: Colors.blue,
height: 50
),
)
);
}),
),
)
)
)
)
);
await expectLater(
find.byType(RepaintBoundary).first,
matchesGoldenFile('opacity_test.offset.1.png'),
skip: !Platform.isLinux,
);
});
}