Unverified Commit f0656ac3 authored by Shi-Hao Hong's avatar Shi-Hao Hong Committed by GitHub

Explain const values in MediaQuery test file (#39059)

parent 8a258dca
...@@ -15,8 +15,8 @@ void main() { ...@@ -15,8 +15,8 @@ void main() {
tested = true; tested = true;
MediaQuery.of(context); // should throw MediaQuery.of(context); // should throw
return Container(); return Container();
} },
) ),
); );
expect(tested, isTrue); expect(tested, isTrue);
expect(tester.takeException(), isFlutterError); expect(tester.takeException(), isFlutterError);
...@@ -31,8 +31,8 @@ void main() { ...@@ -31,8 +31,8 @@ void main() {
expect(data, isNull); expect(data, isNull);
tested = true; tested = true;
return Container(); return Container();
} },
) ),
); );
expect(tested, isTrue); expect(tested, isTrue);
}); });
...@@ -70,16 +70,27 @@ void main() { ...@@ -70,16 +70,27 @@ void main() {
}); });
testWidgets('MediaQuery.copyWith copies specified values', (WidgetTester tester) async { testWidgets('MediaQuery.copyWith copies specified values', (WidgetTester tester) async {
// Random and unique double values are used to ensure that the correct
// values are copied over exactly
const Size customSize = Size(3.14, 2.72);
const double customDevicePixelRatio = 1.41;
const double customTextScaleFactor = 1.62;
const EdgeInsets customPadding = EdgeInsets.all(9.10938);
const EdgeInsets customViewPadding = EdgeInsets.all(11.24031);
const EdgeInsets customViewInsets = EdgeInsets.all(1.67262);
const EdgeInsets customSystemGestureInsets = EdgeInsets.all(1.5556);
const double customPhysicalDepth = 120.0;
final MediaQueryData data = MediaQueryData.fromWindow(WidgetsBinding.instance.window); final MediaQueryData data = MediaQueryData.fromWindow(WidgetsBinding.instance.window);
final MediaQueryData copied = data.copyWith( final MediaQueryData copied = data.copyWith(
size: const Size(3.14, 2.72), size: customSize,
devicePixelRatio: 1.41, devicePixelRatio: customDevicePixelRatio,
textScaleFactor: 1.62, textScaleFactor: customTextScaleFactor,
padding: const EdgeInsets.all(9.10938), padding: customPadding,
viewPadding: const EdgeInsets.all(11.24031), viewPadding: customViewPadding,
viewInsets: const EdgeInsets.all(1.67262), viewInsets: customViewInsets,
systemGestureInsets: const EdgeInsets.all(1.5556), systemGestureInsets: customSystemGestureInsets,
physicalDepth: 120.0, physicalDepth: customPhysicalDepth,
alwaysUse24HourFormat: true, alwaysUse24HourFormat: true,
accessibleNavigation: true, accessibleNavigation: true,
invertColors: true, invertColors: true,
...@@ -87,14 +98,14 @@ void main() { ...@@ -87,14 +98,14 @@ void main() {
boldText: true, boldText: true,
platformBrightness: Brightness.dark, platformBrightness: Brightness.dark,
); );
expect(copied.size, const Size(3.14, 2.72)); expect(copied.size, customSize);
expect(copied.devicePixelRatio, 1.41); expect(copied.devicePixelRatio, customDevicePixelRatio);
expect(copied.textScaleFactor, 1.62); expect(copied.textScaleFactor, customTextScaleFactor);
expect(copied.padding, const EdgeInsets.all(9.10938)); expect(copied.padding, customPadding);
expect(copied.viewPadding, const EdgeInsets.all(11.24031)); expect(copied.viewPadding, customViewPadding);
expect(copied.viewInsets, const EdgeInsets.all(1.67262)); expect(copied.viewInsets, customViewInsets);
expect(copied.systemGestureInsets, const EdgeInsets.all(1.5556)); expect(copied.systemGestureInsets, customSystemGestureInsets);
expect(copied.physicalDepth, 120.0); expect(copied.physicalDepth, customPhysicalDepth);
expect(copied.alwaysUse24HourFormat, true); expect(copied.alwaysUse24HourFormat, true);
expect(copied.accessibleNavigation, true); expect(copied.accessibleNavigation, true);
expect(copied.invertColors, true); expect(copied.invertColors, true);
...@@ -139,12 +150,12 @@ void main() { ...@@ -139,12 +150,12 @@ void main() {
builder: (BuildContext context) { builder: (BuildContext context) {
unpadded = MediaQuery.of(context); unpadded = MediaQuery.of(context);
return Container(); return Container();
} },
), ),
); );
}, },
), ),
) ),
); );
expect(unpadded.size, size); expect(unpadded.size, size);
...@@ -196,12 +207,12 @@ void main() { ...@@ -196,12 +207,12 @@ void main() {
builder: (BuildContext context) { builder: (BuildContext context) {
unpadded = MediaQuery.of(context); unpadded = MediaQuery.of(context);
return Container(); return Container();
} },
), ),
); );
}, },
), ),
) ),
); );
expect(unpadded.size, size); expect(unpadded.size, size);
...@@ -253,12 +264,12 @@ void main() { ...@@ -253,12 +264,12 @@ void main() {
builder: (BuildContext context) { builder: (BuildContext context) {
unpadded = MediaQuery.of(context); unpadded = MediaQuery.of(context);
return Container(); return Container();
} },
), ),
); );
}, },
), ),
) ),
); );
expect(unpadded.size, size); expect(unpadded.size, size);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment