flutter/packages/flutter_test/test/accessibility_window_test.dart
Darren Austin 2532584bf3
Update parameters to the styleFrom button methods. (#105291)
* Update parameters to the `styleFrom` button methods.

* Updated the Flutter fix data to point to this PR.

* Updated handling of background color to better maintain backwards compatibility with previous API.
2022-06-21 19:08:22 -07:00

45 lines
1.6 KiB
Dart

// 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_test/flutter_test.dart';
void main() {
testWidgets('Fails correctly with configured screen size - small', (WidgetTester tester) async {
tester.binding.window.devicePixelRatioTestValue = 1.2;
tester.binding.window.physicalSizeTestValue = const Size(250, 300);
final Widget invalidButton = ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
foregroundColor: Colors.orange,
backgroundColor: Colors.orangeAccent,
),
child: const Text('Button'),
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: invalidButton)));
final Evaluation result = await textContrastGuideline.evaluate(tester);
expect(result.passed, false);
});
testWidgets('Fails correctly with configured screen size - large', (WidgetTester tester) async {
tester.binding.window.devicePixelRatioTestValue = 4.2;
tester.binding.window.physicalSizeTestValue = const Size(2500, 3000);
final Widget invalidButton = ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
foregroundColor: Colors.orange,
backgroundColor: Colors.orangeAccent,
),
child: const Text('Button'),
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: invalidButton)));
final Evaluation result = await textContrastGuideline.evaluate(tester);
expect(result.passed, false);
});
}