Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
f0656ac3
Unverified
Commit
f0656ac3
authored
Aug 22, 2019
by
Shi-Hao Hong
Committed by
GitHub
Aug 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explain const values in MediaQuery test file (#39059)
parent
8a258dca
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
26 deletions
+37
-26
media_query_test.dart
packages/flutter/test/widgets/media_query_test.dart
+37
-26
No files found.
packages/flutter/test/widgets/media_query_test.dart
View file @
f0656ac3
...
@@ -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:
c
onst
Size
(
3.14
,
2.72
)
,
size:
c
ustomSize
,
devicePixelRatio:
1.41
,
devicePixelRatio:
customDevicePixelRatio
,
textScaleFactor:
1.62
,
textScaleFactor:
customTextScaleFactor
,
padding:
c
onst
EdgeInsets
.
all
(
9.10938
)
,
padding:
c
ustomPadding
,
viewPadding:
c
onst
EdgeInsets
.
all
(
11.24031
)
,
viewPadding:
c
ustomViewPadding
,
viewInsets:
c
onst
EdgeInsets
.
all
(
1.67262
)
,
viewInsets:
c
ustomViewInsets
,
systemGestureInsets:
c
onst
EdgeInsets
.
all
(
1.5556
)
,
systemGestureInsets:
c
ustomSystemGestureInsets
,
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
,
c
onst
Size
(
3.14
,
2.72
)
);
expect
(
copied
.
size
,
c
ustomSize
);
expect
(
copied
.
devicePixelRatio
,
1.41
);
expect
(
copied
.
devicePixelRatio
,
customDevicePixelRatio
);
expect
(
copied
.
textScaleFactor
,
1.62
);
expect
(
copied
.
textScaleFactor
,
customTextScaleFactor
);
expect
(
copied
.
padding
,
c
onst
EdgeInsets
.
all
(
9.10938
)
);
expect
(
copied
.
padding
,
c
ustomPadding
);
expect
(
copied
.
viewPadding
,
c
onst
EdgeInsets
.
all
(
11.24031
)
);
expect
(
copied
.
viewPadding
,
c
ustomViewPadding
);
expect
(
copied
.
viewInsets
,
c
onst
EdgeInsets
.
all
(
1.67262
)
);
expect
(
copied
.
viewInsets
,
c
ustomViewInsets
);
expect
(
copied
.
systemGestureInsets
,
c
onst
EdgeInsets
.
all
(
1.5556
)
);
expect
(
copied
.
systemGestureInsets
,
c
ustomSystemGestureInsets
);
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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment