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
11fa80bb
Commit
11fa80bb
authored
Apr 27, 2017
by
Ian Hickson
Committed by
GitHub
Apr 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MediaQuery.of shouldn't give a default return value (#9596)
parent
b432af51
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1144 additions
and
914 deletions
+1144
-914
smoke_test.dart
examples/flutter_gallery/test/calculator/smoke_test.dart
+1
-1
app_bar.dart
packages/flutter/lib/src/material/app_bar.dart
+2
-0
drawer_header.dart
packages/flutter/lib/src/material/drawer_header.dart
+1
-0
scaffold.dart
packages/flutter/lib/src/material/scaffold.dart
+1
-0
text_selection.dart
packages/flutter/lib/src/material/text_selection.dart
+1
-0
debug.dart
packages/flutter/lib/src/widgets/debug.dart
+35
-0
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+1
-1
image.dart
packages/flutter/lib/src/widgets/image.dart
+2
-2
media_query.dart
packages/flutter/lib/src/widgets/media_query.dart
+41
-3
text.dart
packages/flutter/lib/src/widgets/text.dart
+1
-1
about_test.dart
packages/flutter/test/material/about_test.dart
+7
-3
app_bar_test.dart
packages/flutter/test/material/app_bar_test.dart
+41
-34
bottom_navigation_bar_test.dart
...ges/flutter/test/material/bottom_navigation_bar_test.dart
+159
-147
drawer_test.dart
packages/flutter/test/material/drawer_test.dart
+20
-18
icon_button_test.dart
packages/flutter/test/material/icon_button_test.dart
+11
-9
mergeable_material_test.dart
packages/flutter/test/material/mergeable_material_test.dart
+680
-624
scaffold_test.dart
packages/flutter/test/material/scaffold_test.dart
+52
-12
text_field_test.dart
packages/flutter/test/material/text_field_test.dart
+25
-19
user_accounts_drawer_header_test.dart
...utter/test/material/user_accounts_drawer_header_test.dart
+37
-33
media_query_test.dart
packages/flutter/test/widgets/media_query_test.dart
+26
-7
No files found.
examples/flutter_gallery/test/calculator/smoke_test.dart
View file @
11fa80bb
...
@@ -14,7 +14,7 @@ void main() {
...
@@ -14,7 +14,7 @@ void main() {
// We press the "1" and the "2" buttons and check that the display
// We press the "1" and the "2" buttons and check that the display
// reads "12".
// reads "12".
testWidgets
(
'Flutter calculator app smoke test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Flutter calculator app smoke test'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
CalculatorDemo
(
));
await
tester
.
pumpWidget
(
new
MaterialApp
(
home:
const
CalculatorDemo
()
));
final
Finder
oneButton
=
find
.
widgetWithText
(
InkResponse
,
'1'
);
final
Finder
oneButton
=
find
.
widgetWithText
(
InkResponse
,
'1'
);
expect
(
oneButton
,
findsOneWidget
);
expect
(
oneButton
,
findsOneWidget
);
...
...
packages/flutter/lib/src/material/app_bar.dart
View file @
11fa80bb
...
@@ -341,6 +341,7 @@ class _AppBarState extends State<AppBar> {
...
@@ -341,6 +341,7 @@ class _AppBarState extends State<AppBar> {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
assert
(!
widget
.
primary
||
debugCheckHasMediaQuery
(
context
));
final
ThemeData
themeData
=
Theme
.
of
(
context
);
final
ThemeData
themeData
=
Theme
.
of
(
context
);
IconThemeData
appBarIconTheme
=
widget
.
iconTheme
??
themeData
.
primaryIconTheme
;
IconThemeData
appBarIconTheme
=
widget
.
iconTheme
??
themeData
.
primaryIconTheme
;
...
@@ -906,6 +907,7 @@ class _SliverAppBarState extends State<SliverAppBar> with TickerProviderStateMix
...
@@ -906,6 +907,7 @@ class _SliverAppBarState extends State<SliverAppBar> with TickerProviderStateMix
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
assert
(!
widget
.
primary
||
debugCheckHasMediaQuery
(
context
));
final
double
topPadding
=
widget
.
primary
?
MediaQuery
.
of
(
context
).
padding
.
top
:
0.0
;
final
double
topPadding
=
widget
.
primary
?
MediaQuery
.
of
(
context
).
padding
.
top
:
0.0
;
final
double
collapsedHeight
=
(
widget
.
pinned
&&
widget
.
floating
&&
widget
.
bottom
!=
null
)
final
double
collapsedHeight
=
(
widget
.
pinned
&&
widget
.
floating
&&
widget
.
bottom
!=
null
)
?
widget
.
bottom
.
preferredSize
.
height
+
topPadding
:
null
;
?
widget
.
bottom
.
preferredSize
.
height
+
topPadding
:
null
;
...
...
packages/flutter/lib/src/material/drawer_header.dart
View file @
11fa80bb
...
@@ -72,6 +72,7 @@ class DrawerHeader extends StatelessWidget {
...
@@ -72,6 +72,7 @@ class DrawerHeader extends StatelessWidget {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterial
(
context
));
assert
(
debugCheckHasMaterial
(
context
));
assert
(
debugCheckHasMediaQuery
(
context
));
final
ThemeData
theme
=
Theme
.
of
(
context
);
final
ThemeData
theme
=
Theme
.
of
(
context
);
final
double
statusBarHeight
=
MediaQuery
.
of
(
context
).
padding
.
top
;
final
double
statusBarHeight
=
MediaQuery
.
of
(
context
).
padding
.
top
;
return
new
Container
(
return
new
Container
(
...
...
packages/flutter/lib/src/material/scaffold.dart
View file @
11fa80bb
...
@@ -769,6 +769,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
...
@@ -769,6 +769,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMediaQuery
(
context
));
EdgeInsets
padding
=
MediaQuery
.
of
(
context
).
padding
;
EdgeInsets
padding
=
MediaQuery
.
of
(
context
).
padding
;
final
ThemeData
themeData
=
Theme
.
of
(
context
);
final
ThemeData
themeData
=
Theme
.
of
(
context
);
if
(!
widget
.
resizeToAvoidBottomPadding
)
if
(!
widget
.
resizeToAvoidBottomPadding
)
...
...
packages/flutter/lib/src/material/text_selection.dart
View file @
11fa80bb
...
@@ -151,6 +151,7 @@ class _MaterialTextSelectionControls extends TextSelectionControls {
...
@@ -151,6 +151,7 @@ class _MaterialTextSelectionControls extends TextSelectionControls {
@override
@override
Widget
buildToolbar
(
Widget
buildToolbar
(
BuildContext
context
,
Offset
position
,
TextSelectionDelegate
delegate
)
{
BuildContext
context
,
Offset
position
,
TextSelectionDelegate
delegate
)
{
assert
(
debugCheckHasMediaQuery
(
context
));
final
Size
screenSize
=
MediaQuery
.
of
(
context
).
size
;
final
Size
screenSize
=
MediaQuery
.
of
(
context
).
size
;
return
new
ConstrainedBox
(
return
new
ConstrainedBox
(
constraints:
new
BoxConstraints
.
loose
(
screenSize
),
constraints:
new
BoxConstraints
.
loose
(
screenSize
),
...
...
packages/flutter/lib/src/widgets/debug.dart
View file @
11fa80bb
...
@@ -5,7 +5,9 @@
...
@@ -5,7 +5,9 @@
import
'dart:collection'
;
import
'dart:collection'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'framework.dart'
;
import
'framework.dart'
;
import
'media_query.dart'
;
import
'table.dart'
;
import
'table.dart'
;
// Any changes to this file should be reflected in the debugAssertAllWidgetVarsUnset()
// Any changes to this file should be reflected in the debugAssertAllWidgetVarsUnset()
...
@@ -153,6 +155,39 @@ bool debugCheckHasTable(BuildContext context) {
...
@@ -153,6 +155,39 @@ bool debugCheckHasTable(BuildContext context) {
return
true
;
return
true
;
}
}
/// Asserts that the given context has a [MediaQuery] ancestor.
///
/// Used by various widgets to make sure that they are only used in an
/// appropriate context.
///
/// To invoke this function, use the following pattern, typically in the
/// relevant Widget's [build] method:
///
/// ```dart
/// assert(debugCheckHasMediaQuery(context));
/// ```
///
/// Does nothing if asserts are disabled. Always returns true.
bool
debugCheckHasMediaQuery
(
BuildContext
context
)
{
assert
(()
{
if
(
context
.
widget
is
!
MediaQuery
&&
context
.
ancestorWidgetOfExactType
(
MediaQuery
)
==
null
)
{
final
Element
element
=
context
;
throw
new
FlutterError
(
'No MediaQuery widget found.
\n
'
'
${context.widget.runtimeType}
widgets require a MediaQuery widget ancestor.
\n
'
'The specific widget that could not find a MediaQuery ancestor was:
\n
'
'
${context.widget}
\n
'
'The ownership chain for the affected widget is:
\n
'
'
${element.debugGetCreatorChain(10)}
\n
'
'Typically, the MediaQuery widget is introduced by the MaterialApp or '
'WidgetsApp widget at the top of your application widget tree.'
);
}
return
true
;
});
return
true
;
}
/// Asserts that the `built` widget is not null.
/// Asserts that the `built` widget is not null.
///
///
/// Used when the given `widget` calls a builder function to check that the
/// Used when the given `widget` calls a builder function to check that the
...
...
packages/flutter/lib/src/widgets/editable_text.dart
View file @
11fa80bb
...
@@ -463,7 +463,7 @@ class EditableTextState extends State<EditableText> implements TextInputClient {
...
@@ -463,7 +463,7 @@ class EditableTextState extends State<EditableText> implements TextInputClient {
showCursor:
_showCursor
,
showCursor:
_showCursor
,
maxLines:
widget
.
maxLines
,
maxLines:
widget
.
maxLines
,
selectionColor:
widget
.
selectionColor
,
selectionColor:
widget
.
selectionColor
,
textScaleFactor:
widget
.
textScaleFactor
??
MediaQuery
.
of
(
context
).
textScaleFactor
,
textScaleFactor:
widget
.
textScaleFactor
??
MediaQuery
.
of
(
context
,
nullOk:
true
)?.
textScaleFactor
??
1.0
,
textAlign:
widget
.
textAlign
,
textAlign:
widget
.
textAlign
,
obscureText:
widget
.
obscureText
,
obscureText:
widget
.
obscureText
,
offset:
offset
,
offset:
offset
,
...
...
packages/flutter/lib/src/widgets/image.dart
View file @
11fa80bb
...
@@ -27,10 +27,10 @@ export 'package:flutter/services.dart' show
...
@@ -27,10 +27,10 @@ export 'package:flutter/services.dart' show
ImageConfiguration
createLocalImageConfiguration
(
BuildContext
context
,
{
Size
size
})
{
ImageConfiguration
createLocalImageConfiguration
(
BuildContext
context
,
{
Size
size
})
{
return
new
ImageConfiguration
(
return
new
ImageConfiguration
(
bundle:
DefaultAssetBundle
.
of
(
context
),
bundle:
DefaultAssetBundle
.
of
(
context
),
devicePixelRatio:
MediaQuery
.
of
(
context
).
devicePixelRatio
,
devicePixelRatio:
MediaQuery
.
of
(
context
,
nullOk:
true
)?.
devicePixelRatio
??
1.0
,
// TODO(ianh): provide the locale
// TODO(ianh): provide the locale
size:
size
,
size:
size
,
platform:
Platform
.
operatingSystem
platform:
Platform
.
operatingSystem
,
);
);
}
}
...
...
packages/flutter/lib/src/widgets/media_query.dart
View file @
11fa80bb
...
@@ -26,6 +26,10 @@ enum Orientation {
...
@@ -26,6 +26,10 @@ enum Orientation {
/// To obtain the current [MediaQueryData] for a given [BuildContext], use the
/// To obtain the current [MediaQueryData] for a given [BuildContext], use the
/// [MediaQuery.of] function. For example, to obtain the size of the current
/// [MediaQuery.of] function. For example, to obtain the size of the current
/// window, use `MediaQuery.of(context).size`.
/// window, use `MediaQuery.of(context).size`.
///
/// If no [MediaQuery] is in scope then the [MediaQuery.of] method will throw an
/// exception, unless the `nullOk` argument is set to true, in which case it
/// returns null.
@immutable
@immutable
class
MediaQueryData
{
class
MediaQueryData
{
/// Creates data for a media query with explicit values.
/// Creates data for a media query with explicit values.
...
@@ -40,6 +44,11 @@ class MediaQueryData {
...
@@ -40,6 +44,11 @@ class MediaQueryData {
});
});
/// Creates data for a media query based on the given window.
/// Creates data for a media query based on the given window.
///
/// If you use this, you should ensure that you also register for
/// notifications so that you can update your [MediaQueryData] when the
/// window's metrics change. For example, see
/// [WidgetsBindingObserver.didChangeMetrics] or [ui.window.onMetricsChanged].
MediaQueryData
.
fromWindow
(
ui
.
Window
window
)
MediaQueryData
.
fromWindow
(
ui
.
Window
window
)
:
size
=
window
.
physicalSize
/
window
.
devicePixelRatio
,
:
size
=
window
.
physicalSize
/
window
.
devicePixelRatio
,
devicePixelRatio
=
window
.
devicePixelRatio
,
devicePixelRatio
=
window
.
devicePixelRatio
,
...
@@ -117,6 +126,16 @@ class MediaQueryData {
...
@@ -117,6 +126,16 @@ class MediaQueryData {
/// Querying the current media using [MediaQuery.of] will cause your widget to
/// Querying the current media using [MediaQuery.of] will cause your widget to
/// rebuild automatically whenever the [MediaQueryData] changes (e.g., if the
/// rebuild automatically whenever the [MediaQueryData] changes (e.g., if the
/// user rotates their device).
/// user rotates their device).
///
/// If no [MediaQuery] is in scope then the [MediaQuery.of] method will throw an
/// exception, unless the `nullOk` argument is set to true, in which case it
/// returns null.
///
/// See also:
///
/// * [WidgetsApp] and [MaterialApp], which introduce a [MediaQuery] and keep
/// it up to date with the current screen metrics as they change.
/// * [MediaQueryData], the data structure that represents the metrics.
class
MediaQuery
extends
InheritedWidget
{
class
MediaQuery
extends
InheritedWidget
{
/// Creates a widget that provides [MediaQueryData] to its descendants.
/// Creates a widget that provides [MediaQueryData] to its descendants.
///
///
...
@@ -135,7 +154,8 @@ class MediaQuery extends InheritedWidget {
...
@@ -135,7 +154,8 @@ class MediaQuery extends InheritedWidget {
/// height of the current window.
/// height of the current window.
final
MediaQueryData
data
;
final
MediaQueryData
data
;
/// The data from the closest instance of this class that encloses the given context.
/// The data from the closest instance of this class that encloses the given
/// context.
///
///
/// You can use this function to query the size an orientation of the screen.
/// You can use this function to query the size an orientation of the screen.
/// When that information changes, your widget will be scheduled to be rebuilt,
/// When that information changes, your widget will be scheduled to be rebuilt,
...
@@ -146,9 +166,27 @@ class MediaQuery extends InheritedWidget {
...
@@ -146,9 +166,27 @@ class MediaQuery extends InheritedWidget {
/// ```dart
/// ```dart
/// MediaQueryData media = MediaQuery.of(context);
/// MediaQueryData media = MediaQuery.of(context);
/// ```
/// ```
static
MediaQueryData
of
(
BuildContext
context
)
{
///
/// If there is no [MediaQuery] in scope, then this will throw an exception.
/// To return null if there is no [MediaQuery], then pass `nullOk: true`.
///
/// If you use this from a widget (e.g. in its build function), consider
/// calling [debugCheckHasMediaQuery].
static
MediaQueryData
of
(
BuildContext
context
,
{
bool
nullOk:
false
})
{
final
MediaQuery
query
=
context
.
inheritFromWidgetOfExactType
(
MediaQuery
);
final
MediaQuery
query
=
context
.
inheritFromWidgetOfExactType
(
MediaQuery
);
return
query
?.
data
??
new
MediaQueryData
.
fromWindow
(
ui
.
window
);
if
(
query
!=
null
)
return
query
.
data
;
if
(
nullOk
)
return
null
;
throw
new
FlutterError
(
'MediaQuery.of() called with a context that does not contain a MediaQuery.
\n
'
'No MediaQuery ancestor could be found starting from the context that was passed '
'to MediaQuery.of(). This can happen because you do not have a WidgetsApp or '
'MaterialApp widget (those widgets introduce a MediaQuery), or it can happen '
'if the context you use comes from a widget above those widgets.
\n
'
'The context used was:
\n
'
'
$context
'
);
}
}
@override
@override
...
...
packages/flutter/lib/src/widgets/text.dart
View file @
11fa80bb
...
@@ -203,7 +203,7 @@ class Text extends StatelessWidget {
...
@@ -203,7 +203,7 @@ class Text extends StatelessWidget {
textAlign:
textAlign
??
defaultTextStyle
.
textAlign
,
textAlign:
textAlign
??
defaultTextStyle
.
textAlign
,
softWrap:
softWrap
??
defaultTextStyle
.
softWrap
,
softWrap:
softWrap
??
defaultTextStyle
.
softWrap
,
overflow:
overflow
??
defaultTextStyle
.
overflow
,
overflow:
overflow
??
defaultTextStyle
.
overflow
,
textScaleFactor:
textScaleFactor
??
MediaQuery
.
of
(
context
).
textScaleFactor
,
textScaleFactor:
textScaleFactor
??
MediaQuery
.
of
(
context
,
nullOk:
true
)?.
textScaleFactor
??
1.0
,
maxLines:
maxLines
??
defaultTextStyle
.
maxLines
,
maxLines:
maxLines
??
defaultTextStyle
.
maxLines
,
text:
new
TextSpan
(
text:
new
TextSpan
(
style:
effectiveTextStyle
,
style:
effectiveTextStyle
,
...
...
packages/flutter/test/material/about_test.dart
View file @
11fa80bb
...
@@ -89,9 +89,13 @@ void main() {
...
@@ -89,9 +89,13 @@ void main() {
]);
]);
});
});
await
tester
.
pumpWidget
(
const
Center
(
await
tester
.
pumpWidget
(
child:
const
LicensePage
()
new
MaterialApp
(
));
home:
const
Center
(
child:
const
LicensePage
()
),
),
);
expect
(
licenseFuture
,
isNotNull
);
expect
(
licenseFuture
,
isNotNull
);
await
licenseFuture
;
await
licenseFuture
;
...
...
packages/flutter/test/material/app_bar_test.dart
View file @
11fa80bb
...
@@ -8,29 +8,32 @@ import 'package:flutter/rendering.dart';
...
@@ -8,29 +8,32 @@ import 'package:flutter/rendering.dart';
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
Widget
buildSliverAppBarApp
(
{
bool
floating
,
bool
pinned
,
double
expandedHeight
,
bool
snap:
false
})
{
Widget
buildSliverAppBarApp
(
{
bool
floating
,
bool
pinned
,
double
expandedHeight
,
bool
snap:
false
})
{
return
new
Scaffold
(
return
new
MediaQuery
(
body:
new
DefaultTabController
(
data:
const
MediaQueryData
(),
length:
3
,
child:
new
Scaffold
(
child:
new
CustomScrollView
(
body:
new
DefaultTabController
(
primary:
true
,
length:
3
,
slivers:
<
Widget
>[
child:
new
CustomScrollView
(
new
SliverAppBar
(
primary:
true
,
title:
const
Text
(
'AppBar Title'
),
slivers:
<
Widget
>[
floating:
floating
,
new
SliverAppBar
(
pinned:
pinned
,
title:
const
Text
(
'AppBar Title'
),
expandedHeight:
expandedHeight
,
floating:
floating
,
snap:
snap
,
pinned:
pinned
,
bottom:
new
TabBar
(
expandedHeight:
expandedHeight
,
tabs:
<
String
>[
'A'
,
'B'
,
'C'
].
map
((
String
t
)
=>
new
Tab
(
text:
'TAB
$t
'
)).
toList
(),
snap:
snap
,
bottom:
new
TabBar
(
tabs:
<
String
>[
'A'
,
'B'
,
'C'
].
map
((
String
t
)
=>
new
Tab
(
text:
'TAB
$t
'
)).
toList
(),
),
),
),
),
new
SliverToBoxAdapter
(
new
SliverToBoxAdapt
er
(
child:
new
Contain
er
(
child:
new
Container
(
height:
1200.0
,
height:
1200.0
,
color:
Colors
.
orange
[
400
]
,
color:
Colors
.
orange
[
400
]
,
)
,
),
),
)
,
]
,
]
,
)
,
),
),
),
),
);
);
...
@@ -246,12 +249,14 @@ void main() {
...
@@ -246,12 +249,14 @@ void main() {
testWidgets
(
'AppBar with no Scaffold'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'AppBar with no Scaffold'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
SizedBox
(
new
MaterialApp
(
height:
kToolbarHeight
,
home:
new
SizedBox
(
child:
new
AppBar
(
height:
kToolbarHeight
,
leading:
const
Text
(
'L'
),
child:
new
AppBar
(
title:
const
Text
(
'No Scaffold'
),
leading:
const
Text
(
'L'
),
actions:
<
Widget
>[
const
Text
(
'A1'
),
const
Text
(
'A2'
)],
title:
const
Text
(
'No Scaffold'
),
actions:
<
Widget
>[
const
Text
(
'A1'
),
const
Text
(
'A2'
)],
),
),
),
),
),
);
);
...
@@ -265,13 +270,15 @@ void main() {
...
@@ -265,13 +270,15 @@ void main() {
testWidgets
(
'AppBar render at zero size'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'AppBar render at zero size'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Center
(
new
MaterialApp
(
child:
new
Container
(
home:
new
Center
(
height:
0.0
,
child:
new
Container
(
width:
0.0
,
height:
0.0
,
child:
new
Scaffold
(
width:
0.0
,
appBar:
new
AppBar
(
child:
new
Scaffold
(
title:
const
Text
(
'X'
),
appBar:
new
AppBar
(
title:
const
Text
(
'X'
),
),
),
),
),
),
),
),
...
...
packages/flutter/test/material/bottom_navigation_bar_test.dart
View file @
11fa80bb
...
@@ -10,21 +10,23 @@ void main() {
...
@@ -10,21 +10,23 @@ void main() {
int
mutatedIndex
;
int
mutatedIndex
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
bottomNavigationBar:
new
BottomNavigationBar
(
home:
new
Scaffold
(
items:
<
BottomNavigationBarItem
>[
bottomNavigationBar:
new
BottomNavigationBar
(
new
BottomNavigationBarItem
(
items:
<
BottomNavigationBarItem
>[
icon:
const
Icon
(
Icons
.
ac_unit
),
new
BottomNavigationBarItem
(
title:
const
Text
(
'AC'
)
icon:
const
Icon
(
Icons
.
ac_unit
),
),
title:
const
Text
(
'AC'
)
new
BottomNavigationBarItem
(
),
icon:
const
Icon
(
Icons
.
access_alarm
),
new
BottomNavigationBarItem
(
title:
const
Text
(
'Alarm'
)
icon:
const
Icon
(
Icons
.
access_alarm
),
)
title:
const
Text
(
'Alarm'
)
],
)
onTap:
(
int
index
)
{
],
mutatedIndex
=
index
;
onTap:
(
int
index
)
{
}
mutatedIndex
=
index
;
}
)
)
)
)
)
);
);
...
@@ -36,18 +38,20 @@ void main() {
...
@@ -36,18 +38,20 @@ void main() {
testWidgets
(
'BottomNavigationBar content test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'BottomNavigationBar content test'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
bottomNavigationBar:
new
BottomNavigationBar
(
home:
new
Scaffold
(
items:
<
BottomNavigationBarItem
>[
bottomNavigationBar:
new
BottomNavigationBar
(
new
BottomNavigationBarItem
(
items:
<
BottomNavigationBarItem
>[
icon:
const
Icon
(
Icons
.
ac_unit
),
new
BottomNavigationBarItem
(
title:
const
Text
(
'AC'
)
icon:
const
Icon
(
Icons
.
ac_unit
),
),
title:
const
Text
(
'AC'
)
new
BottomNavigationBarItem
(
),
icon:
const
Icon
(
Icons
.
access_alarm
),
new
BottomNavigationBarItem
(
title:
const
Text
(
'Alarm'
)
icon:
const
Icon
(
Icons
.
access_alarm
),
)
title:
const
Text
(
'Alarm'
)
]
)
]
)
)
)
)
)
);
);
...
@@ -60,19 +64,21 @@ void main() {
...
@@ -60,19 +64,21 @@ void main() {
testWidgets
(
'BottomNavigationBar action size test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'BottomNavigationBar action size test'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
bottomNavigationBar:
new
BottomNavigationBar
(
home:
new
Scaffold
(
type:
BottomNavigationBarType
.
shifting
,
bottomNavigationBar:
new
BottomNavigationBar
(
items:
<
BottomNavigationBarItem
>[
type:
BottomNavigationBarType
.
shifting
,
new
BottomNavigationBarItem
(
items:
<
BottomNavigationBarItem
>[
icon:
const
Icon
(
Icons
.
ac_unit
),
new
BottomNavigationBarItem
(
title:
const
Text
(
'AC'
)
icon:
const
Icon
(
Icons
.
ac_unit
),
),
title:
const
Text
(
'AC'
)
new
BottomNavigationBarItem
(
),
icon:
const
Icon
(
Icons
.
access_alarm
),
new
BottomNavigationBarItem
(
title:
const
Text
(
'Alarm'
)
icon:
const
Icon
(
Icons
.
access_alarm
),
)
title:
const
Text
(
'Alarm'
)
]
)
]
)
)
)
)
)
);
);
...
@@ -83,20 +89,22 @@ void main() {
...
@@ -83,20 +89,22 @@ void main() {
expect
(
actions
.
elementAt
(
1
).
size
.
width
,
105.6
);
expect
(
actions
.
elementAt
(
1
).
size
.
width
,
105.6
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
bottomNavigationBar:
new
BottomNavigationBar
(
home:
new
Scaffold
(
currentIndex:
1
,
bottomNavigationBar:
new
BottomNavigationBar
(
type:
BottomNavigationBarType
.
shifting
,
currentIndex:
1
,
items:
<
BottomNavigationBarItem
>[
type:
BottomNavigationBarType
.
shifting
,
new
BottomNavigationBarItem
(
items:
<
BottomNavigationBarItem
>[
icon:
const
Icon
(
Icons
.
ac_unit
),
new
BottomNavigationBarItem
(
title:
const
Text
(
'AC'
)
icon:
const
Icon
(
Icons
.
ac_unit
),
),
title:
const
Text
(
'AC'
)
new
BottomNavigationBarItem
(
),
icon:
const
Icon
(
Icons
.
access_alarm
),
new
BottomNavigationBarItem
(
title:
const
Text
(
'Alarm'
)
icon:
const
Icon
(
Icons
.
access_alarm
),
)
title:
const
Text
(
'Alarm'
)
]
)
]
)
)
)
)
)
);
);
...
@@ -111,27 +119,29 @@ void main() {
...
@@ -111,27 +119,29 @@ void main() {
testWidgets
(
'BottomNavigationBar multiple taps test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'BottomNavigationBar multiple taps test'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
bottomNavigationBar:
new
BottomNavigationBar
(
home:
new
Scaffold
(
type:
BottomNavigationBarType
.
shifting
,
bottomNavigationBar:
new
BottomNavigationBar
(
items:
<
BottomNavigationBarItem
>[
type:
BottomNavigationBarType
.
shifting
,
new
BottomNavigationBarItem
(
items:
<
BottomNavigationBarItem
>[
icon:
const
Icon
(
Icons
.
ac_unit
),
new
BottomNavigationBarItem
(
title:
const
Text
(
'AC'
)
icon:
const
Icon
(
Icons
.
ac_unit
),
),
title:
const
Text
(
'AC'
)
new
BottomNavigationBarItem
(
),
icon:
const
Icon
(
Icons
.
access_alarm
),
new
BottomNavigationBarItem
(
title:
const
Text
(
'Alarm'
)
icon:
const
Icon
(
Icons
.
access_alarm
),
),
title:
const
Text
(
'Alarm'
)
new
BottomNavigationBarItem
(
),
icon:
const
Icon
(
Icons
.
access_time
),
new
BottomNavigationBarItem
(
title:
const
Text
(
'Time'
)
icon:
const
Icon
(
Icons
.
access_time
),
),
title:
const
Text
(
'Time'
)
new
BottomNavigationBarItem
(
),
icon:
const
Icon
(
Icons
.
add
),
new
BottomNavigationBarItem
(
title:
const
Text
(
'Add'
)
icon:
const
Icon
(
Icons
.
add
),
)
title:
const
Text
(
'Add'
)
]
)
]
)
)
)
)
)
);
);
...
@@ -167,35 +177,35 @@ void main() {
...
@@ -167,35 +177,35 @@ void main() {
testWidgets
(
'BottomNavigationBar inherits shadowed app theme for shifting navbar'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'BottomNavigationBar inherits shadowed app theme for shifting navbar'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
MaterialApp
(
new
MaterialApp
(
theme:
new
ThemeData
(
brightness:
Brightness
.
light
),
theme:
new
ThemeData
(
brightness:
Brightness
.
light
),
home:
new
Theme
(
home:
new
Theme
(
data:
new
ThemeData
(
brightness:
Brightness
.
dark
),
data:
new
ThemeData
(
brightness:
Brightness
.
dark
),
child:
new
Scaffold
(
child:
new
Scaffold
(
bottomNavigationBar:
new
BottomNavigationBar
(
bottomNavigationBar:
new
BottomNavigationBar
(
type:
BottomNavigationBarType
.
shifting
,
type:
BottomNavigationBarType
.
shifting
,
items:
<
BottomNavigationBarItem
>[
items:
<
BottomNavigationBarItem
>[
new
BottomNavigationBarItem
(
new
BottomNavigationBarItem
(
icon:
const
Icon
(
Icons
.
ac_unit
),
icon:
const
Icon
(
Icons
.
ac_unit
),
title:
const
Text
(
'AC'
)
title:
const
Text
(
'AC'
)
),
),
new
BottomNavigationBarItem
(
new
BottomNavigationBarItem
(
icon:
const
Icon
(
Icons
.
access_alarm
),
icon:
const
Icon
(
Icons
.
access_alarm
),
title:
const
Text
(
'Alarm'
)
title:
const
Text
(
'Alarm'
)
),
),
new
BottomNavigationBarItem
(
new
BottomNavigationBarItem
(
icon:
const
Icon
(
Icons
.
access_time
),
icon:
const
Icon
(
Icons
.
access_time
),
title:
const
Text
(
'Time'
)
title:
const
Text
(
'Time'
)
),
),
new
BottomNavigationBarItem
(
new
BottomNavigationBarItem
(
icon:
const
Icon
(
Icons
.
add
),
icon:
const
Icon
(
Icons
.
add
),
title:
const
Text
(
'Add'
)
title:
const
Text
(
'Add'
)
)
]
)
)
)
]
)
)
)
)
)
)
);
);
await
tester
.
tap
(
find
.
text
(
'Alarm'
));
await
tester
.
tap
(
find
.
text
(
'Alarm'
));
...
@@ -205,35 +215,35 @@ void main() {
...
@@ -205,35 +215,35 @@ void main() {
testWidgets
(
'BottomNavigationBar inherits shadowed app theme for fixed navbar'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'BottomNavigationBar inherits shadowed app theme for fixed navbar'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
MaterialApp
(
new
MaterialApp
(
theme:
new
ThemeData
(
brightness:
Brightness
.
light
),
theme:
new
ThemeData
(
brightness:
Brightness
.
light
),
home:
new
Theme
(
home:
new
Theme
(
data:
new
ThemeData
(
brightness:
Brightness
.
dark
),
data:
new
ThemeData
(
brightness:
Brightness
.
dark
),
child:
new
Scaffold
(
child:
new
Scaffold
(
bottomNavigationBar:
new
BottomNavigationBar
(
bottomNavigationBar:
new
BottomNavigationBar
(
type:
BottomNavigationBarType
.
fixed
,
type:
BottomNavigationBarType
.
fixed
,
items:
<
BottomNavigationBarItem
>[
items:
<
BottomNavigationBarItem
>[
new
BottomNavigationBarItem
(
new
BottomNavigationBarItem
(
icon:
const
Icon
(
Icons
.
ac_unit
),
icon:
const
Icon
(
Icons
.
ac_unit
),
title:
const
Text
(
'AC'
)
title:
const
Text
(
'AC'
)
),
),
new
BottomNavigationBarItem
(
new
BottomNavigationBarItem
(
icon:
const
Icon
(
Icons
.
access_alarm
),
icon:
const
Icon
(
Icons
.
access_alarm
),
title:
const
Text
(
'Alarm'
)
title:
const
Text
(
'Alarm'
)
),
),
new
BottomNavigationBarItem
(
new
BottomNavigationBarItem
(
icon:
const
Icon
(
Icons
.
access_time
),
icon:
const
Icon
(
Icons
.
access_time
),
title:
const
Text
(
'Time'
)
title:
const
Text
(
'Time'
)
),
),
new
BottomNavigationBarItem
(
new
BottomNavigationBarItem
(
icon:
const
Icon
(
Icons
.
add
),
icon:
const
Icon
(
Icons
.
add
),
title:
const
Text
(
'Add'
)
title:
const
Text
(
'Add'
)
)
]
)
)
)
]
)
)
)
)
)
)
);
);
await
tester
.
tap
(
find
.
text
(
'Alarm'
));
await
tester
.
tap
(
find
.
text
(
'Alarm'
));
...
@@ -244,27 +254,29 @@ void main() {
...
@@ -244,27 +254,29 @@ void main() {
testWidgets
(
'BottomNavigationBar iconSize test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'BottomNavigationBar iconSize test'
,
(
WidgetTester
tester
)
async
{
double
builderIconSize
;
double
builderIconSize
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
bottomNavigationBar:
new
BottomNavigationBar
(
home:
new
Scaffold
(
iconSize:
12.0
,
bottomNavigationBar:
new
BottomNavigationBar
(
items:
<
BottomNavigationBarItem
>[
iconSize:
12.0
,
new
BottomNavigationBarItem
(
items:
<
BottomNavigationBarItem
>[
title:
const
Text
(
'A'
),
new
BottomNavigationBarItem
(
icon:
const
Icon
(
Icons
.
ac_unit
),
title:
const
Text
(
'A'
),
),
icon:
const
Icon
(
Icons
.
ac_unit
),
new
BottomNavigationBarItem
(
),
title:
const
Text
(
'B'
),
new
BottomNavigationBarItem
(
icon:
new
Builder
(
title:
const
Text
(
'B'
),
builder:
(
BuildContext
context
)
{
icon:
new
Builder
(
builderIconSize
=
IconTheme
.
of
(
context
).
size
;
builder:
(
BuildContext
context
)
{
return
new
SizedBox
(
builderIconSize
=
IconTheme
.
of
(
context
).
size
;
width:
builderIconSize
,
return
new
SizedBox
(
height:
builderIconSize
,
width:
builderIconSize
,
);
height:
builderIconSize
,
},
);
},
),
),
),
)
,
]
,
]
,
)
,
),
),
),
),
);
);
...
...
packages/flutter/test/material/drawer_test.dart
View file @
11fa80bb
...
@@ -10,24 +10,26 @@ void main() {
...
@@ -10,24 +10,26 @@ void main() {
final
Key
containerKey
=
const
Key
(
'container'
);
final
Key
containerKey
=
const
Key
(
'container'
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
drawer:
new
Drawer
(
home:
new
Scaffold
(
child:
new
ListView
(
drawer:
new
Drawer
(
children:
<
Widget
>[
child:
new
ListView
(
new
DrawerHeader
(
children:
<
Widget
>[
child:
new
Container
(
new
DrawerHeader
(
key:
containerKey
,
child:
new
Container
(
child:
const
Text
(
'header'
)
key:
containerKey
,
)
child:
const
Text
(
'header'
),
),
),
const
ListTile
(
),
leading:
const
Icon
(
Icons
.
archive
),
const
ListTile
(
title:
const
Text
(
'Archive'
)
leading:
const
Icon
(
Icons
.
archive
),
)
title:
const
Text
(
'Archive'
),
]
),
)
],
)
),
)
),
),
),
);
);
expect
(
find
.
text
(
'Archive'
),
findsNothing
);
expect
(
find
.
text
(
'Archive'
),
findsNothing
);
...
...
packages/flutter/test/material/icon_button_test.dart
View file @
11fa80bb
...
@@ -172,15 +172,17 @@ void main() {
...
@@ -172,15 +172,17 @@ void main() {
testWidgets
(
'IconButton AppBar size'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'IconButton AppBar size'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
appBar:
new
AppBar
(
home:
new
Scaffold
(
actions:
<
Widget
>[
appBar:
new
AppBar
(
new
IconButton
(
actions:
<
Widget
>[
padding:
EdgeInsets
.
zero
,
new
IconButton
(
onPressed:
mockOnPressedFunction
,
padding:
EdgeInsets
.
zero
,
icon:
const
Icon
(
Icons
.
ac_unit
),
onPressed:
mockOnPressedFunction
,
),
icon:
const
Icon
(
Icons
.
ac_unit
),
],
),
],
),
),
),
),
),
);
);
...
...
packages/flutter/test/material/mergeable_material_test.dart
View file @
11fa80bb
// Copyright 2016 The Chromium Authors. All rights reserved.
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
...
@@ -64,11 +64,13 @@ BorderRadius getBorderRadius(WidgetTester tester, int index) {
...
@@ -64,11 +64,13 @@ BorderRadius getBorderRadius(WidgetTester tester, int index) {
void
main
(
)
{
void
main
(
)
{
testWidgets
(
'MergeableMaterial empty'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MergeableMaterial empty'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
const
MergeableMaterial
()
body:
new
SingleChildScrollView
(
)
child:
const
MergeableMaterial
()
)
),
),
),
);
);
final
RenderBox
box
=
tester
.
renderObject
(
find
.
byType
(
MergeableMaterial
));
final
RenderBox
box
=
tester
.
renderObject
(
find
.
byType
(
MergeableMaterial
));
...
@@ -77,42 +79,46 @@ void main() {
...
@@ -77,42 +79,46 @@ void main() {
testWidgets
(
'MergeableMaterial update slice'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MergeableMaterial update slice'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
)
),
]
),
)
],
)
),
)
),
),
),
);
);
RenderBox
box
=
tester
.
renderObject
(
find
.
byType
(
MergeableMaterial
));
RenderBox
box
=
tester
.
renderObject
(
find
.
byType
(
MergeableMaterial
));
expect
(
box
.
size
.
height
,
equals
(
100.0
));
expect
(
box
.
size
.
height
,
equals
(
100.0
));
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
200.0
width:
100.0
,
)
height:
200.0
)
),
]
),
)
],
)
),
)
),
),
),
);
);
box
=
tester
.
renderObject
(
find
.
byType
(
MergeableMaterial
));
box
=
tester
.
renderObject
(
find
.
byType
(
MergeableMaterial
));
...
@@ -121,28 +127,30 @@ void main() {
...
@@ -121,28 +127,30 @@ void main() {
testWidgets
(
'MergeableMaterial swap slices'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MergeableMaterial swap slices'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'B'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'B'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
)
),
]
),
)
],
)
),
)
),
),
),
);
);
RenderBox
box
=
tester
.
renderObject
(
find
.
byType
(
MergeableMaterial
));
RenderBox
box
=
tester
.
renderObject
(
find
.
byType
(
MergeableMaterial
));
...
@@ -151,28 +159,30 @@ void main() {
...
@@ -151,28 +159,30 @@ void main() {
matches
(
getBorderRadius
(
tester
,
0
),
RadiusType
.
Round
,
RadiusType
.
Round
);
matches
(
getBorderRadius
(
tester
,
0
),
RadiusType
.
Round
,
RadiusType
.
Round
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'B'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'B'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
)
),
]
),
)
],
)
),
)
),
),
),
);
);
box
=
tester
.
renderObject
(
find
.
byType
(
MergeableMaterial
));
box
=
tester
.
renderObject
(
find
.
byType
(
MergeableMaterial
));
...
@@ -186,21 +196,23 @@ void main() {
...
@@ -186,21 +196,23 @@ void main() {
testWidgets
(
'MergeableMaterial paints shadows'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MergeableMaterial paints shadows'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
)
),
]
),
)
],
)
),
)
),
),
),
);
);
final
BoxShadow
boxShadow
=
kElevationToShadow
[
2
][
0
];
final
BoxShadow
boxShadow
=
kElevationToShadow
[
2
][
0
];
...
@@ -215,31 +227,33 @@ void main() {
...
@@ -215,31 +227,33 @@ void main() {
testWidgets
(
'MergeableMaterial merge gap'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MergeableMaterial merge gap'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'x'
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'x'
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'B'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'B'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
)
),
]
),
)
],
)
),
)
),
),
),
);
);
final
RenderBox
box
=
tester
.
renderObject
(
find
.
byType
(
MergeableMaterial
));
final
RenderBox
box
=
tester
.
renderObject
(
find
.
byType
(
MergeableMaterial
));
...
@@ -249,28 +263,30 @@ void main() {
...
@@ -249,28 +263,30 @@ void main() {
matches
(
getBorderRadius
(
tester
,
1
),
RadiusType
.
Round
,
RadiusType
.
Round
);
matches
(
getBorderRadius
(
tester
,
1
),
RadiusType
.
Round
,
RadiusType
.
Round
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'B'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'B'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
)
),
]
),
)
],
)
),
)
),
),
),
);
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
...
@@ -288,28 +304,30 @@ void main() {
...
@@ -288,28 +304,30 @@ void main() {
testWidgets
(
'MergeableMaterial separate slices'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MergeableMaterial separate slices'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'B'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'B'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
)
),
]
),
)
],
)
),
)
),
),
),
);
);
final
RenderBox
box
=
tester
.
renderObject
(
find
.
byType
(
MergeableMaterial
));
final
RenderBox
box
=
tester
.
renderObject
(
find
.
byType
(
MergeableMaterial
));
...
@@ -318,31 +336,33 @@ void main() {
...
@@ -318,31 +336,33 @@ void main() {
matches
(
getBorderRadius
(
tester
,
0
),
RadiusType
.
Round
,
RadiusType
.
Round
);
matches
(
getBorderRadius
(
tester
,
0
),
RadiusType
.
Round
,
RadiusType
.
Round
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'x'
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'x'
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'B'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'B'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
)
),
]
),
)
],
)
),
)
),
),
),
);
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
...
@@ -360,25 +380,27 @@ void main() {
...
@@ -360,25 +380,27 @@ void main() {
testWidgets
(
'MergeableMaterial separate merge seaparate'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MergeableMaterial separate merge seaparate'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'B'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'B'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
height:
100.0
)
)
)
)
]
]
)
)
)
)
)
)
)
...
@@ -390,28 +412,30 @@ void main() {
...
@@ -390,28 +412,30 @@ void main() {
matches
(
getBorderRadius
(
tester
,
0
),
RadiusType
.
Round
,
RadiusType
.
Round
);
matches
(
getBorderRadius
(
tester
,
0
),
RadiusType
.
Round
,
RadiusType
.
Round
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
height:
100.0
)
),
const
MaterialGap
(
key:
const
ValueKey
<
String
>(
'x'
)
),
const
MaterialSlice
(
key:
const
ValueKey
<
String
>(
'B'
),
child:
const
SizedBox
(
width:
100.0
,
height:
100.0
)
)
)
),
]
const
MaterialGap
(
)
key:
const
ValueKey
<
String
>(
'x'
)
),
const
MaterialSlice
(
key:
const
ValueKey
<
String
>(
'B'
),
child:
const
SizedBox
(
width:
100.0
,
height:
100.0
)
)
]
)
)
)
)
)
)
...
@@ -430,25 +454,27 @@ void main() {
...
@@ -430,25 +454,27 @@ void main() {
matches
(
getBorderRadius
(
tester
,
1
),
RadiusType
.
Round
,
RadiusType
.
Round
);
matches
(
getBorderRadius
(
tester
,
1
),
RadiusType
.
Round
,
RadiusType
.
Round
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'B'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'B'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
height:
100.0
)
)
)
)
]
]
)
)
)
)
)
)
)
...
@@ -467,28 +493,30 @@ void main() {
...
@@ -467,28 +493,30 @@ void main() {
matches
(
getBorderRadius
(
tester
,
1
),
RadiusType
.
Sharp
,
RadiusType
.
Round
);
matches
(
getBorderRadius
(
tester
,
1
),
RadiusType
.
Sharp
,
RadiusType
.
Round
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'x'
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'x'
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'B'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'B'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
height:
100.0
)
)
)
)
]
]
)
)
)
)
)
)
)
...
@@ -509,25 +537,27 @@ void main() {
...
@@ -509,25 +537,27 @@ void main() {
testWidgets
(
'MergeableMaterial insert slice'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MergeableMaterial insert slice'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
height:
100.0
)
),
const
MaterialSlice
(
key:
const
ValueKey
<
String
>(
'C'
),
child:
const
SizedBox
(
width:
100.0
,
height:
100.0
)
)
)
),
]
const
MaterialSlice
(
)
key:
const
ValueKey
<
String
>(
'C'
),
child:
const
SizedBox
(
width:
100.0
,
height:
100.0
)
)
]
)
)
)
)
)
)
...
@@ -539,32 +569,34 @@ void main() {
...
@@ -539,32 +569,34 @@ void main() {
matches
(
getBorderRadius
(
tester
,
0
),
RadiusType
.
Round
,
RadiusType
.
Round
);
matches
(
getBorderRadius
(
tester
,
0
),
RadiusType
.
Round
,
RadiusType
.
Round
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'B'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'B'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
height:
100.0
)
),
const
MaterialSlice
(
key:
const
ValueKey
<
String
>(
'C'
),
child:
const
SizedBox
(
width:
100.0
,
height:
100.0
)
)
)
),
]
const
MaterialSlice
(
)
key:
const
ValueKey
<
String
>(
'C'
),
child:
const
SizedBox
(
width:
100.0
,
height:
100.0
)
)
]
)
)
)
)
)
)
...
@@ -577,32 +609,34 @@ void main() {
...
@@ -577,32 +609,34 @@ void main() {
testWidgets
(
'MergeableMaterial remove slice'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MergeableMaterial remove slice'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'B'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'B'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
height:
100.0
)
),
const
MaterialSlice
(
key:
const
ValueKey
<
String
>(
'C'
),
child:
const
SizedBox
(
width:
100.0
,
height:
100.0
)
)
)
),
]
const
MaterialSlice
(
)
key:
const
ValueKey
<
String
>(
'C'
),
child:
const
SizedBox
(
width:
100.0
,
height:
100.0
)
)
]
)
)
)
)
)
)
...
@@ -614,25 +648,27 @@ void main() {
...
@@ -614,25 +648,27 @@ void main() {
matches
(
getBorderRadius
(
tester
,
0
),
RadiusType
.
Round
,
RadiusType
.
Round
);
matches
(
getBorderRadius
(
tester
,
0
),
RadiusType
.
Round
,
RadiusType
.
Round
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'C'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'C'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
height:
100.0
)
)
)
)
]
]
)
)
)
)
)
)
)
...
@@ -646,25 +682,27 @@ void main() {
...
@@ -646,25 +682,27 @@ void main() {
testWidgets
(
'MergeableMaterial insert chunk'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MergeableMaterial insert chunk'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
height:
100.0
)
),
const
MaterialSlice
(
key:
const
ValueKey
<
String
>(
'C'
),
child:
const
SizedBox
(
width:
100.0
,
height:
100.0
)
)
)
),
]
const
MaterialSlice
(
)
key:
const
ValueKey
<
String
>(
'C'
),
child:
const
SizedBox
(
width:
100.0
,
height:
100.0
)
)
]
)
)
)
)
)
)
...
@@ -676,38 +714,40 @@ void main() {
...
@@ -676,38 +714,40 @@ void main() {
matches
(
getBorderRadius
(
tester
,
0
),
RadiusType
.
Round
,
RadiusType
.
Round
);
matches
(
getBorderRadius
(
tester
,
0
),
RadiusType
.
Round
,
RadiusType
.
Round
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'x'
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'x'
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'B'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'B'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'y'
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'y'
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'C'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'C'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
height:
100.0
)
)
)
)
]
]
)
)
)
)
)
)
)
...
@@ -730,38 +770,40 @@ void main() {
...
@@ -730,38 +770,40 @@ void main() {
testWidgets
(
'MergeableMaterial remove chunk'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MergeableMaterial remove chunk'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'x'
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'x'
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'B'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'B'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'y'
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'y'
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'C'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'C'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
height:
100.0
)
)
)
)
]
]
)
)
)
)
)
)
)
...
@@ -775,25 +817,27 @@ void main() {
...
@@ -775,25 +817,27 @@ void main() {
matches
(
getBorderRadius
(
tester
,
2
),
RadiusType
.
Round
,
RadiusType
.
Round
);
matches
(
getBorderRadius
(
tester
,
2
),
RadiusType
.
Round
,
RadiusType
.
Round
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
height:
100.0
)
),
const
MaterialSlice
(
key:
const
ValueKey
<
String
>(
'C'
),
child:
const
SizedBox
(
width:
100.0
,
height:
100.0
)
)
)
),
]
const
MaterialSlice
(
)
key:
const
ValueKey
<
String
>(
'C'
),
child:
const
SizedBox
(
width:
100.0
,
height:
100.0
)
)
]
)
)
)
)
)
)
...
@@ -814,28 +858,30 @@ void main() {
...
@@ -814,28 +858,30 @@ void main() {
testWidgets
(
'MergeableMaterial replace gap with chunk'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MergeableMaterial replace gap with chunk'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'x'
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'x'
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'C'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'C'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
height:
100.0
)
)
)
)
]
]
)
)
)
)
)
)
)
...
@@ -848,38 +894,40 @@ void main() {
...
@@ -848,38 +894,40 @@ void main() {
matches
(
getBorderRadius
(
tester
,
1
),
RadiusType
.
Round
,
RadiusType
.
Round
);
matches
(
getBorderRadius
(
tester
,
1
),
RadiusType
.
Round
,
RadiusType
.
Round
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'y'
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'y'
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'B'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'B'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'z'
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'z'
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'C'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'C'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
height:
100.0
)
)
)
)
]
]
)
)
)
)
)
)
)
...
@@ -902,38 +950,40 @@ void main() {
...
@@ -902,38 +950,40 @@ void main() {
testWidgets
(
'MergeableMaterial replace chunk with gap'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MergeableMaterial replace chunk with gap'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
height:
100.0
)
),
const
MaterialGap
(
key:
const
ValueKey
<
String
>(
'x'
)
),
const
MaterialSlice
(
key:
const
ValueKey
<
String
>(
'B'
),
child:
const
SizedBox
(
width:
100.0
,
height:
100.0
)
),
const
MaterialGap
(
key:
const
ValueKey
<
String
>(
'y'
)
),
const
MaterialSlice
(
key:
const
ValueKey
<
String
>(
'C'
),
child:
const
SizedBox
(
width:
100.0
,
height:
100.0
)
)
)
),
]
const
MaterialGap
(
)
key:
const
ValueKey
<
String
>(
'x'
)
),
const
MaterialSlice
(
key:
const
ValueKey
<
String
>(
'B'
),
child:
const
SizedBox
(
width:
100.0
,
height:
100.0
)
),
const
MaterialGap
(
key:
const
ValueKey
<
String
>(
'y'
)
),
const
MaterialSlice
(
key:
const
ValueKey
<
String
>(
'C'
),
child:
const
SizedBox
(
width:
100.0
,
height:
100.0
)
)
]
)
)
)
)
)
)
...
@@ -947,28 +997,30 @@ void main() {
...
@@ -947,28 +997,30 @@ void main() {
matches
(
getBorderRadius
(
tester
,
2
),
RadiusType
.
Round
,
RadiusType
.
Round
);
matches
(
getBorderRadius
(
tester
,
2
),
RadiusType
.
Round
,
RadiusType
.
Round
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
children:
<
MergeableMaterialItem
>[
child:
new
MergeableMaterial
(
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'z'
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'z'
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'C'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'C'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
height:
100.0
)
)
)
)
]
]
)
)
)
)
)
)
)
...
@@ -1001,40 +1053,42 @@ void main() {
...
@@ -1001,40 +1053,42 @@ void main() {
testWidgets
(
'MergeableMaterial dividers'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MergeableMaterial dividers'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
hasDividers:
true
,
child:
new
MergeableMaterial
(
children:
<
MergeableMaterialItem
>[
hasDividers:
true
,
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'B'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'B'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'C'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'C'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
height:
100.0
)
),
const
MaterialSlice
(
key:
const
ValueKey
<
String
>(
'D'
),
child:
const
SizedBox
(
width:
100.0
,
height:
100.0
)
)
)
),
]
const
MaterialSlice
(
)
key:
const
ValueKey
<
String
>(
'D'
),
child:
const
SizedBox
(
width:
100.0
,
height:
100.0
)
)
]
)
)
)
)
)
)
...
@@ -1049,43 +1103,45 @@ void main() {
...
@@ -1049,43 +1103,45 @@ void main() {
expect
(
isDivider
(
boxes
[
offset
+
3
],
true
,
false
),
isTrue
);
expect
(
isDivider
(
boxes
[
offset
+
3
],
true
,
false
),
isTrue
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
new
MaterialApp
(
body:
new
SingleChildScrollView
(
home:
new
Scaffold
(
child:
new
MergeableMaterial
(
body:
new
SingleChildScrollView
(
hasDividers:
true
,
child:
new
MergeableMaterial
(
children:
<
MergeableMaterialItem
>[
hasDividers:
true
,
const
MaterialSlice
(
children:
<
MergeableMaterialItem
>[
key:
const
ValueKey
<
String
>(
'A'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'A'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'B'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'B'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'x'
)
const
MaterialGap
(
),
key:
const
ValueKey
<
String
>(
'x'
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'C'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'C'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
)
height:
100.0
),
)
const
MaterialSlice
(
),
key:
const
ValueKey
<
String
>(
'D'
),
const
MaterialSlice
(
child:
const
SizedBox
(
key:
const
ValueKey
<
String
>(
'D'
),
width:
100.0
,
child:
const
SizedBox
(
height:
100.0
width:
100.0
,
height:
100.0
)
)
)
)
]
]
)
)
)
)
)
)
)
...
...
packages/flutter/test/material/scaffold_test.dart
View file @
11fa80bb
...
@@ -11,9 +11,16 @@ void main() {
...
@@ -11,9 +11,16 @@ void main() {
final
Key
bodyKey
=
new
UniqueKey
();
final
Key
bodyKey
=
new
UniqueKey
();
await
tester
.
pumpWidget
(
new
Scaffold
(
await
tester
.
pumpWidget
(
new
Scaffold
(
appBar:
new
AppBar
(
title:
const
Text
(
'Title'
)),
appBar:
new
AppBar
(
title:
const
Text
(
'Title'
)),
body:
new
Container
(
key:
bodyKey
)
body:
new
Container
(
key:
bodyKey
)
,
));
));
expect
(
tester
.
takeException
(),
isFlutterError
);
await
tester
.
pumpWidget
(
new
MaterialApp
(
home:
new
Scaffold
(
appBar:
new
AppBar
(
title:
const
Text
(
'Title'
)),
body:
new
Container
(
key:
bodyKey
),
),
));
RenderBox
bodyBox
=
tester
.
renderObject
(
find
.
byKey
(
bodyKey
));
RenderBox
bodyBox
=
tester
.
renderObject
(
find
.
byKey
(
bodyKey
));
expect
(
bodyBox
.
size
,
equals
(
const
Size
(
800.0
,
544.0
)));
expect
(
bodyBox
.
size
,
equals
(
const
Size
(
800.0
,
544.0
)));
...
@@ -82,37 +89,37 @@ void main() {
...
@@ -82,37 +89,37 @@ void main() {
});
});
testWidgets
(
'Floating action animation'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Floating action animation'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
Scaffold
(
await
tester
.
pumpWidget
(
new
MaterialApp
(
home:
const
Scaffold
(
floatingActionButton:
const
FloatingActionButton
(
floatingActionButton:
const
FloatingActionButton
(
key:
const
Key
(
'one'
),
key:
const
Key
(
'one'
),
onPressed:
null
,
onPressed:
null
,
child:
const
Text
(
"1"
)
child:
const
Text
(
"1"
)
)
)
));
))
)
;
expect
(
tester
.
binding
.
transientCallbackCount
,
0
);
expect
(
tester
.
binding
.
transientCallbackCount
,
0
);
await
tester
.
pumpWidget
(
const
Scaffold
(
await
tester
.
pumpWidget
(
new
MaterialApp
(
home:
const
Scaffold
(
floatingActionButton:
const
FloatingActionButton
(
floatingActionButton:
const
FloatingActionButton
(
key:
const
Key
(
'two'
),
key:
const
Key
(
'two'
),
onPressed:
null
,
onPressed:
null
,
child:
const
Text
(
"2"
)
child:
const
Text
(
"2"
)
)
)
));
))
)
;
expect
(
tester
.
binding
.
transientCallbackCount
,
greaterThan
(
0
));
expect
(
tester
.
binding
.
transientCallbackCount
,
greaterThan
(
0
));
await
tester
.
pumpWidget
(
new
Container
());
await
tester
.
pumpWidget
(
new
Container
());
expect
(
tester
.
binding
.
transientCallbackCount
,
0
);
expect
(
tester
.
binding
.
transientCallbackCount
,
0
);
await
tester
.
pumpWidget
(
const
Scaffold
(
));
await
tester
.
pumpWidget
(
new
MaterialApp
(
home:
const
Scaffold
()
));
expect
(
tester
.
binding
.
transientCallbackCount
,
0
);
expect
(
tester
.
binding
.
transientCallbackCount
,
0
);
await
tester
.
pumpWidget
(
const
Scaffold
(
await
tester
.
pumpWidget
(
new
MaterialApp
(
home:
const
Scaffold
(
floatingActionButton:
const
FloatingActionButton
(
floatingActionButton:
const
FloatingActionButton
(
key:
const
Key
(
'one'
),
key:
const
Key
(
'one'
),
onPressed:
null
,
onPressed:
null
,
child:
const
Text
(
"1"
)
child:
const
Text
(
"1"
)
)
)
));
))
)
;
expect
(
tester
.
binding
.
transientCallbackCount
,
greaterThan
(
0
));
expect
(
tester
.
binding
.
transientCallbackCount
,
greaterThan
(
0
));
});
});
...
@@ -367,7 +374,14 @@ void main() {
...
@@ -367,7 +374,14 @@ void main() {
testWidgets
(
'body size with container'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'body size with container'
,
(
WidgetTester
tester
)
async
{
final
Key
testKey
=
new
UniqueKey
();
final
Key
testKey
=
new
UniqueKey
();
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
body:
new
Container
(
key:
testKey
))
new
MediaQuery
(
data:
const
MediaQueryData
(),
child:
new
Scaffold
(
body:
new
Container
(
key:
testKey
,
),
),
),
);
);
expect
(
tester
.
element
(
find
.
byKey
(
testKey
)).
size
,
const
Size
(
800.0
,
600.0
));
expect
(
tester
.
element
(
find
.
byKey
(
testKey
)).
size
,
const
Size
(
800.0
,
600.0
));
expect
(
tester
.
renderObject
<
RenderBox
>(
find
.
byKey
(
testKey
)).
localToGlobal
(
Offset
.
zero
),
const
Offset
(
0.0
,
0.0
));
expect
(
tester
.
renderObject
<
RenderBox
>(
find
.
byKey
(
testKey
)).
localToGlobal
(
Offset
.
zero
),
const
Offset
(
0.0
,
0.0
));
...
@@ -376,7 +390,15 @@ void main() {
...
@@ -376,7 +390,15 @@ void main() {
testWidgets
(
'body size with sized container'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'body size with sized container'
,
(
WidgetTester
tester
)
async
{
final
Key
testKey
=
new
UniqueKey
();
final
Key
testKey
=
new
UniqueKey
();
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
body:
new
Container
(
key:
testKey
,
height:
100.0
))
new
MediaQuery
(
data:
const
MediaQueryData
(),
child:
new
Scaffold
(
body:
new
Container
(
key:
testKey
,
height:
100.0
,
),
),
),
);
);
expect
(
tester
.
element
(
find
.
byKey
(
testKey
)).
size
,
const
Size
(
800.0
,
100.0
));
expect
(
tester
.
element
(
find
.
byKey
(
testKey
)).
size
,
const
Size
(
800.0
,
100.0
));
expect
(
tester
.
renderObject
<
RenderBox
>(
find
.
byKey
(
testKey
)).
localToGlobal
(
Offset
.
zero
),
const
Offset
(
0.0
,
0.0
));
expect
(
tester
.
renderObject
<
RenderBox
>(
find
.
byKey
(
testKey
)).
localToGlobal
(
Offset
.
zero
),
const
Offset
(
0.0
,
0.0
));
...
@@ -385,7 +407,16 @@ void main() {
...
@@ -385,7 +407,16 @@ void main() {
testWidgets
(
'body size with centered container'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'body size with centered container'
,
(
WidgetTester
tester
)
async
{
final
Key
testKey
=
new
UniqueKey
();
final
Key
testKey
=
new
UniqueKey
();
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
body:
new
Center
(
child:
new
Container
(
key:
testKey
)))
new
MediaQuery
(
data:
const
MediaQueryData
(),
child:
new
Scaffold
(
body:
new
Center
(
child:
new
Container
(
key:
testKey
,
),
),
),
),
);
);
expect
(
tester
.
element
(
find
.
byKey
(
testKey
)).
size
,
const
Size
(
800.0
,
600.0
));
expect
(
tester
.
element
(
find
.
byKey
(
testKey
)).
size
,
const
Size
(
800.0
,
600.0
));
expect
(
tester
.
renderObject
<
RenderBox
>(
find
.
byKey
(
testKey
)).
localToGlobal
(
Offset
.
zero
),
const
Offset
(
0.0
,
0.0
));
expect
(
tester
.
renderObject
<
RenderBox
>(
find
.
byKey
(
testKey
)).
localToGlobal
(
Offset
.
zero
),
const
Offset
(
0.0
,
0.0
));
...
@@ -394,7 +425,16 @@ void main() {
...
@@ -394,7 +425,16 @@ void main() {
testWidgets
(
'body size with button'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'body size with button'
,
(
WidgetTester
tester
)
async
{
final
Key
testKey
=
new
UniqueKey
();
final
Key
testKey
=
new
UniqueKey
();
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Scaffold
(
body:
new
FlatButton
(
key:
testKey
,
onPressed:
()
{
},
child:
const
Text
(
''
)))
new
MediaQuery
(
data:
const
MediaQueryData
(),
child:
new
Scaffold
(
body:
new
FlatButton
(
key:
testKey
,
onPressed:
()
{
},
child:
const
Text
(
''
),
),
),
),
);
);
expect
(
tester
.
element
(
find
.
byKey
(
testKey
)).
size
,
const
Size
(
88.0
,
36.0
));
expect
(
tester
.
element
(
find
.
byKey
(
testKey
)).
size
,
const
Size
(
88.0
,
36.0
));
expect
(
tester
.
renderObject
<
RenderBox
>(
find
.
byKey
(
testKey
)).
localToGlobal
(
Offset
.
zero
),
const
Offset
(
0.0
,
0.0
));
expect
(
tester
.
renderObject
<
RenderBox
>(
find
.
byKey
(
testKey
)).
localToGlobal
(
Offset
.
zero
),
const
Offset
(
0.0
,
0.0
));
...
...
packages/flutter/test/material/text_field_test.dart
View file @
11fa80bb
...
@@ -26,12 +26,15 @@ class MockClipboard {
...
@@ -26,12 +26,15 @@ class MockClipboard {
}
}
Widget
overlay
(
Widget
child
)
{
Widget
overlay
(
Widget
child
)
{
return
new
Overlay
(
return
new
MediaQuery
(
initialEntries:
<
OverlayEntry
>[
data:
const
MediaQueryData
(),
new
OverlayEntry
(
child:
new
Overlay
(
builder:
(
BuildContext
context
)
=>
child
,
initialEntries:
<
OverlayEntry
>[
),
new
OverlayEntry
(
],
builder:
(
BuildContext
context
)
=>
child
,
),
],
),
);
);
}
}
...
@@ -229,20 +232,23 @@ void main() {
...
@@ -229,20 +232,23 @@ void main() {
final
TextEditingController
controller
=
new
TextEditingController
();
final
TextEditingController
controller
=
new
TextEditingController
();
Widget
builder
()
{
Widget
builder
()
{
return
new
Overlay
(
return
new
MediaQuery
(
initialEntries:
<
OverlayEntry
>[
data:
const
MediaQueryData
(),
new
OverlayEntry
(
child:
new
Overlay
(
builder:
(
BuildContext
context
)
{
initialEntries:
<
OverlayEntry
>[
return
new
Center
(
new
OverlayEntry
(
child:
new
Material
(
builder:
(
BuildContext
context
)
{
child:
new
TextField
(
return
new
Center
(
controller:
controller
,
child:
new
Material
(
child:
new
TextField
(
controller:
controller
,
),
),
),
)
,
)
;
);
},
}
,
)
,
)
,
]
,
]
,
)
,
);
);
}
}
...
...
packages/flutter/test/material/user_accounts_drawer_header_test.dart
View file @
11fa80bb
...
@@ -13,31 +13,33 @@ void main() {
...
@@ -13,31 +13,33 @@ void main() {
final
Key
avatarD
=
const
Key
(
'D'
);
final
Key
avatarD
=
const
Key
(
'D'
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Material
(
new
MaterialApp
(
child:
new
Center
(
home:
new
Material
(
child:
new
UserAccountsDrawerHeader
(
child:
new
Center
(
currentAccountPicture:
new
CircleAvatar
(
child:
new
UserAccountsDrawerHeader
(
key:
avatarA
,
currentAccountPicture:
new
CircleAvatar
(
child:
const
Text
(
'A'
),
key:
avatarA
,
),
child:
const
Text
(
'A'
),
otherAccountsPictures:
<
Widget
>[
const
CircleAvatar
(
child:
const
Text
(
'B'
),
),
new
CircleAvatar
(
key:
avatarC
,
child:
const
Text
(
'C'
),
),
new
CircleAvatar
(
key:
avatarD
,
child:
const
Text
(
'D'
),
),
),
const
CircleAvatar
(
otherAccountsPictures:
<
Widget
>[
child:
const
Text
(
'E'
),
const
CircleAvatar
(
)
child:
const
Text
(
'B'
),
],
),
accountName:
const
Text
(
"name"
),
new
CircleAvatar
(
accountEmail:
const
Text
(
"email"
),
key:
avatarC
,
child:
const
Text
(
'C'
),
),
new
CircleAvatar
(
key:
avatarD
,
child:
const
Text
(
'D'
),
),
const
CircleAvatar
(
child:
const
Text
(
'E'
),
)
],
accountName:
const
Text
(
"name"
),
accountEmail:
const
Text
(
"email"
),
),
),
),
),
),
),
),
...
@@ -87,15 +89,17 @@ void main() {
...
@@ -87,15 +89,17 @@ void main() {
VoidCallback
onDetailsPressed
,
VoidCallback
onDetailsPressed
,
EdgeInsets
margin
,
EdgeInsets
margin
,
})
{
})
{
return
new
Material
(
return
new
MaterialApp
(
child:
new
Center
(
home:
new
Material
(
child:
new
UserAccountsDrawerHeader
(
child:
new
Center
(
currentAccountPicture:
currentAccountPicture
,
child:
new
UserAccountsDrawerHeader
(
otherAccountsPictures:
otherAccountsPictures
,
currentAccountPicture:
currentAccountPicture
,
accountName:
accountName
,
otherAccountsPictures:
otherAccountsPictures
,
accountEmail:
accountEmail
,
accountName:
accountName
,
onDetailsPressed:
onDetailsPressed
,
accountEmail:
accountEmail
,
margin:
margin
,
onDetailsPressed:
onDetailsPressed
,
margin:
margin
,
),
),
),
),
),
);
);
...
...
packages/flutter/test/widgets/media_query_test.dart
View file @
11fa80bb
...
@@ -8,21 +8,40 @@ import 'package:flutter_test/flutter_test.dart';
...
@@ -8,21 +8,40 @@ import 'package:flutter_test/flutter_test.dart';
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
void
main
(
)
{
void
main
(
)
{
testWidgets
(
'MediaQuery has a default'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MediaQuery does not have a default'
,
(
WidgetTester
tester
)
async
{
Size
size
;
bool
tested
=
false
;
await
tester
.
pumpWidget
(
new
Builder
(
builder:
(
BuildContext
context
)
{
tested
=
true
;
MediaQuery
.
of
(
context
);
// should throw
return
new
Container
();
}
)
);
expect
(
tested
,
isTrue
);
expect
(
tester
.
takeException
(),
isFlutterError
);
});
testWidgets
(
'MediaQuery defaults to null'
,
(
WidgetTester
tester
)
async
{
bool
tested
=
false
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Builder
(
new
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
final
MediaQueryData
data
=
MediaQuery
.
of
(
context
);
final
MediaQueryData
data
=
MediaQuery
.
of
(
context
,
nullOk:
true
);
expect
(
data
,
hasOneLineDescription
);
expect
(
data
,
isNull
);
expect
(
data
.
hashCode
,
equals
(
data
.
copyWith
().
hashCode
));
tested
=
true
;
size
=
data
.
size
;
return
new
Container
();
return
new
Container
();
}
}
)
)
);
);
expect
(
tested
,
isTrue
);
});
expect
(
size
,
equals
(
ui
.
window
.
physicalSize
/
ui
.
window
.
devicePixelRatio
));
testWidgets
(
'MediaQueryData is sane'
,
(
WidgetTester
tester
)
async
{
final
MediaQueryData
data
=
new
MediaQueryData
.
fromWindow
(
ui
.
window
);
expect
(
data
,
hasOneLineDescription
);
expect
(
data
.
hashCode
,
equals
(
data
.
copyWith
().
hashCode
));
expect
(
data
.
size
,
equals
(
ui
.
window
.
physicalSize
/
ui
.
window
.
devicePixelRatio
));
});
});
}
}
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