Set highContrast value from AccessibilityFeatures into MediaQueryData (#48811)

This commit is contained in:
Miguel Beltran 2020-02-26 22:36:02 +01:00 committed by GitHub
parent 9da15d8f2e
commit 7ff3a50fe7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 1 deletions

View File

@ -124,7 +124,7 @@ class MediaQueryData {
invertColors = window.accessibilityFeatures.invertColors,
disableAnimations = window.accessibilityFeatures.disableAnimations,
boldText = window.accessibilityFeatures.boldText,
highContrast = false,
highContrast = window.accessibilityFeatures.highContrast,
alwaysUse24HourFormat = window.alwaysUse24HourFormat;
/// The size of the media in logical pixels (e.g, the size of the screen).

View File

@ -67,6 +67,7 @@ void main() {
expect(data.invertColors, false);
expect(data.disableAnimations, false);
expect(data.boldText, false);
expect(data.highContrast, false);
expect(data.platformBrightness, Brightness.light);
expect(data.physicalDepth, equals(WidgetsBinding.instance.window.physicalDepth));
});
@ -87,6 +88,7 @@ void main() {
expect(copied.invertColors, data.invertColors);
expect(copied.disableAnimations, data.disableAnimations);
expect(copied.boldText, data.boldText);
expect(copied.highContrast, data.highContrast);
expect(copied.platformBrightness, data.platformBrightness);
});
@ -117,6 +119,7 @@ void main() {
invertColors: true,
disableAnimations: true,
boldText: true,
highContrast: true,
platformBrightness: Brightness.dark,
);
expect(copied.size, customSize);
@ -132,6 +135,7 @@ void main() {
expect(copied.invertColors, true);
expect(copied.disableAnimations, true);
expect(copied.boldText, true);
expect(copied.highContrast, true);
expect(copied.platformBrightness, Brightness.dark);
});
@ -158,6 +162,7 @@ void main() {
invertColors: true,
disableAnimations: true,
boldText: true,
highContrast: true,
),
child: Builder(
builder: (BuildContext context) {
@ -190,6 +195,7 @@ void main() {
expect(unpadded.invertColors, true);
expect(unpadded.disableAnimations, true);
expect(unpadded.boldText, true);
expect(unpadded.highContrast, true);
});
testWidgets('MediaQuery.removePadding only removes specified padding', (WidgetTester tester) async {
@ -215,6 +221,7 @@ void main() {
invertColors: true,
disableAnimations: true,
boldText: true,
highContrast: true,
),
child: Builder(
builder: (BuildContext context) {
@ -244,6 +251,7 @@ void main() {
expect(unpadded.invertColors, true);
expect(unpadded.disableAnimations, true);
expect(unpadded.boldText, true);
expect(unpadded.highContrast, true);
});
testWidgets('MediaQuery.removeViewInsets removes specified viewInsets', (WidgetTester tester) async {
@ -269,6 +277,7 @@ void main() {
invertColors: true,
disableAnimations: true,
boldText: true,
highContrast: true,
),
child: Builder(
builder: (BuildContext context) {
@ -301,6 +310,7 @@ void main() {
expect(unpadded.invertColors, true);
expect(unpadded.disableAnimations, true);
expect(unpadded.boldText, true);
expect(unpadded.highContrast, true);
});
testWidgets('MediaQuery.removeViewInsets removes only specified viewInsets', (WidgetTester tester) async {
@ -326,6 +336,7 @@ void main() {
invertColors: true,
disableAnimations: true,
boldText: true,
highContrast: true,
),
child: Builder(
builder: (BuildContext context) {
@ -355,6 +366,7 @@ void main() {
expect(unpadded.invertColors, true);
expect(unpadded.disableAnimations, true);
expect(unpadded.boldText, true);
expect(unpadded.highContrast, true);
});
testWidgets('MediaQuery.removeViewPadding removes specified viewPadding', (WidgetTester tester) async {
@ -380,6 +392,7 @@ void main() {
invertColors: true,
disableAnimations: true,
boldText: true,
highContrast: true,
),
child: Builder(
builder: (BuildContext context) {
@ -412,6 +425,7 @@ void main() {
expect(unpadded.invertColors, true);
expect(unpadded.disableAnimations, true);
expect(unpadded.boldText, true);
expect(unpadded.highContrast, true);
});
testWidgets('MediaQuery.removeViewPadding removes only specified viewPadding', (WidgetTester tester) async {
@ -437,6 +451,7 @@ void main() {
invertColors: true,
disableAnimations: true,
boldText: true,
highContrast: true,
),
child: Builder(
builder: (BuildContext context) {
@ -466,6 +481,7 @@ void main() {
expect(unpadded.invertColors, true);
expect(unpadded.disableAnimations, true);
expect(unpadded.boldText, true);
expect(unpadded.highContrast, true);
});
testWidgets('MediaQuery.textScaleFactorOf', (WidgetTester tester) async {

View File

@ -256,6 +256,7 @@ class FakeAccessibilityFeatures implements AccessibilityFeatures {
this.disableAnimations = false,
this.boldText = false,
this.reduceMotion = false,
this.highContrast = false,
});
@override
@ -273,6 +274,9 @@ class FakeAccessibilityFeatures implements AccessibilityFeatures {
@override
final bool reduceMotion;
@override
final bool highContrast;
/// This gives us some grace time when the dart:ui side adds something to
/// [AccessibilityFeatures], and makes things easier when we do rolls to
/// give us time to catch up.