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() {
tested
=
true
;
MediaQuery
.
of
(
context
);
// should throw
return
Container
();
}
)
}
,
)
,
);
expect
(
tested
,
isTrue
);
expect
(
tester
.
takeException
(),
isFlutterError
);
...
...
@@ -31,8 +31,8 @@ void main() {
expect
(
data
,
isNull
);
tested
=
true
;
return
Container
();
}
)
}
,
)
,
);
expect
(
tested
,
isTrue
);
});
...
...
@@ -70,16 +70,27 @@ void main() {
});
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
copied
=
data
.
copyWith
(
size:
c
onst
Size
(
3.14
,
2.72
)
,
devicePixelRatio:
1.41
,
textScaleFactor:
1.62
,
padding:
c
onst
EdgeInsets
.
all
(
9.10938
)
,
viewPadding:
c
onst
EdgeInsets
.
all
(
11.24031
)
,
viewInsets:
c
onst
EdgeInsets
.
all
(
1.67262
)
,
systemGestureInsets:
c
onst
EdgeInsets
.
all
(
1.5556
)
,
physicalDepth:
120.0
,
size:
c
ustomSize
,
devicePixelRatio:
customDevicePixelRatio
,
textScaleFactor:
customTextScaleFactor
,
padding:
c
ustomPadding
,
viewPadding:
c
ustomViewPadding
,
viewInsets:
c
ustomViewInsets
,
systemGestureInsets:
c
ustomSystemGestureInsets
,
physicalDepth:
customPhysicalDepth
,
alwaysUse24HourFormat:
true
,
accessibleNavigation:
true
,
invertColors:
true
,
...
...
@@ -87,14 +98,14 @@ void main() {
boldText:
true
,
platformBrightness:
Brightness
.
dark
,
);
expect
(
copied
.
size
,
c
onst
Size
(
3.14
,
2.72
)
);
expect
(
copied
.
devicePixelRatio
,
1.41
);
expect
(
copied
.
textScaleFactor
,
1.62
);
expect
(
copied
.
padding
,
c
onst
EdgeInsets
.
all
(
9.10938
)
);
expect
(
copied
.
viewPadding
,
c
onst
EdgeInsets
.
all
(
11.24031
)
);
expect
(
copied
.
viewInsets
,
c
onst
EdgeInsets
.
all
(
1.67262
)
);
expect
(
copied
.
systemGestureInsets
,
c
onst
EdgeInsets
.
all
(
1.5556
)
);
expect
(
copied
.
physicalDepth
,
120.0
);
expect
(
copied
.
size
,
c
ustomSize
);
expect
(
copied
.
devicePixelRatio
,
customDevicePixelRatio
);
expect
(
copied
.
textScaleFactor
,
customTextScaleFactor
);
expect
(
copied
.
padding
,
c
ustomPadding
);
expect
(
copied
.
viewPadding
,
c
ustomViewPadding
);
expect
(
copied
.
viewInsets
,
c
ustomViewInsets
);
expect
(
copied
.
systemGestureInsets
,
c
ustomSystemGestureInsets
);
expect
(
copied
.
physicalDepth
,
customPhysicalDepth
);
expect
(
copied
.
alwaysUse24HourFormat
,
true
);
expect
(
copied
.
accessibleNavigation
,
true
);
expect
(
copied
.
invertColors
,
true
);
...
...
@@ -139,12 +150,12 @@ void main() {
builder:
(
BuildContext
context
)
{
unpadded
=
MediaQuery
.
of
(
context
);
return
Container
();
}
}
,
),
);
},
),
)
)
,
);
expect
(
unpadded
.
size
,
size
);
...
...
@@ -196,12 +207,12 @@ void main() {
builder:
(
BuildContext
context
)
{
unpadded
=
MediaQuery
.
of
(
context
);
return
Container
();
}
}
,
),
);
},
),
)
)
,
);
expect
(
unpadded
.
size
,
size
);
...
...
@@ -253,12 +264,12 @@ void main() {
builder:
(
BuildContext
context
)
{
unpadded
=
MediaQuery
.
of
(
context
);
return
Container
();
}
}
,
),
);
},
),
)
)
,
);
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