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
c083f02f
Unverified
Commit
c083f02f
authored
Oct 09, 2020
by
Greg Spencer
Committed by
GitHub
Oct 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate more material tests to NNBD (#67674)
This migrates more material tests to NNBD.
parent
dcb5975d
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
183 additions
and
230 deletions
+183
-230
about_test.dart
packages/flutter/test/material/about_test.dart
+2
-4
animated_icons_test.dart
packages/flutter/test/material/animated_icons_test.dart
+14
-16
app_bar_test.dart
packages/flutter/test/material/app_bar_test.dart
+18
-33
app_bar_theme_test.dart
packages/flutter/test/material/app_bar_theme_test.dart
+15
-17
app_builder_test.dart
packages/flutter/test/material/app_builder_test.dart
+5
-7
app_test.dart
packages/flutter/test/material/app_test.dart
+51
-53
arc_test.dart
packages/flutter/test/material/arc_test.dart
+0
-2
back_button_test.dart
packages/flutter/test/material/back_button_test.dart
+2
-4
banner_test.dart
packages/flutter/test/material/banner_test.dart
+1
-3
banner_theme_test.dart
packages/flutter/test/material/banner_theme_test.dart
+2
-4
bottom_app_bar_test.dart
packages/flutter/test/material/bottom_app_bar_test.dart
+11
-13
bottom_app_bar_theme_test.dart
...ages/flutter/test/material/bottom_app_bar_theme_test.dart
+0
-2
bottom_navigation_bar_test.dart
...ges/flutter/test/material/bottom_navigation_bar_test.dart
+30
-32
bottom_navigation_bar_theme_test.dart
...utter/test/material/bottom_navigation_bar_theme_test.dart
+5
-7
bottom_sheet_test.dart
packages/flutter/test/material/bottom_sheet_test.dart
+24
-26
bottom_sheet_theme_test.dart
packages/flutter/test/material/bottom_sheet_theme_test.dart
+0
-2
button_bar_test.dart
packages/flutter/test/material/button_bar_test.dart
+3
-5
No files found.
packages/flutter/test/material/about_test.dart
View file @
c083f02f
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
...
@@ -733,7 +731,7 @@ class LicensePageObserver extends NavigatorObserver {
...
@@ -733,7 +731,7 @@ class LicensePageObserver extends NavigatorObserver {
int
licensePageCount
=
0
;
int
licensePageCount
=
0
;
@override
@override
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
?
previousRoute
)
{
if
(
route
is
MaterialPageRoute
<
dynamic
>)
{
if
(
route
is
MaterialPageRoute
<
dynamic
>)
{
licensePageCount
++;
licensePageCount
++;
}
}
...
@@ -745,7 +743,7 @@ class AboutDialogObserver extends NavigatorObserver {
...
@@ -745,7 +743,7 @@ class AboutDialogObserver extends NavigatorObserver {
int
dialogCount
=
0
;
int
dialogCount
=
0
;
@override
@override
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
?
previousRoute
)
{
if
(
route
.
toString
().
contains
(
'_DialogRoute'
))
{
if
(
route
.
toString
().
contains
(
'_DialogRoute'
))
{
dialogCount
++;
dialogCount
++;
}
}
...
...
packages/flutter/test/material/animated_icons_test.dart
View file @
c083f02f
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import
'dart:math'
as
math
show
pi
;
import
'dart:math'
as
math
show
pi
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
...
@@ -13,8 +11,8 @@ import '../flutter_test_alternative.dart' show Fake;
...
@@ -13,8 +11,8 @@ import '../flutter_test_alternative.dart' show Fake;
import
'../widgets/semantics_tester.dart'
;
import
'../widgets/semantics_tester.dart'
;
class
MockCanvas
extends
Fake
implements
Canvas
{
class
MockCanvas
extends
Fake
implements
Canvas
{
Path
capturedPath
;
late
Path
capturedPath
;
Paint
capturedPaint
;
late
Paint
capturedPaint
;
@override
@override
void
drawPath
(
Path
path
,
Paint
paint
)
{
void
drawPath
(
Path
path
,
Paint
paint
)
{
...
@@ -22,13 +20,13 @@ class MockCanvas extends Fake implements Canvas {
...
@@ -22,13 +20,13 @@ class MockCanvas extends Fake implements Canvas {
capturedPaint
=
paint
;
capturedPaint
=
paint
;
}
}
double
capturedSx
;
late
double
capturedSx
;
double
capturedSy
;
late
double
capturedSy
;
@override
@override
void
scale
(
double
sx
,
[
double
sy
])
{
void
scale
(
double
sx
,
[
double
?
sy
])
{
capturedSx
=
sx
;
capturedSx
=
sx
;
capturedSy
=
sy
;
capturedSy
=
sy
!
;
}
}
final
List
<
RecordedCanvasCall
>
invocations
=
<
RecordedCanvasCall
>[];
final
List
<
RecordedCanvasCall
>
invocations
=
<
RecordedCanvasCall
>[];
...
@@ -96,7 +94,7 @@ void main() {
...
@@ -96,7 +94,7 @@ void main() {
);
);
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
MockCanvas
canvas
=
MockCanvas
();
final
MockCanvas
canvas
=
MockCanvas
();
customPaint
.
painter
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
customPaint
.
painter
!
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
expect
(
canvas
.
capturedPaint
,
hasColor
(
0xFF666666
));
expect
(
canvas
.
capturedPaint
,
hasColor
(
0xFF666666
));
});
});
...
@@ -118,7 +116,7 @@ void main() {
...
@@ -118,7 +116,7 @@ void main() {
);
);
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
MockCanvas
canvas
=
MockCanvas
();
final
MockCanvas
canvas
=
MockCanvas
();
customPaint
.
painter
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
customPaint
.
painter
!
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
expect
(
canvas
.
capturedPaint
,
hasColor
(
0x80666666
));
expect
(
canvas
.
capturedPaint
,
hasColor
(
0x80666666
));
});
});
...
@@ -140,7 +138,7 @@ void main() {
...
@@ -140,7 +138,7 @@ void main() {
);
);
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
MockCanvas
canvas
=
MockCanvas
();
final
MockCanvas
canvas
=
MockCanvas
();
customPaint
.
painter
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
customPaint
.
painter
!
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
expect
(
canvas
.
capturedPaint
,
hasColor
(
0xFF0000FF
));
expect
(
canvas
.
capturedPaint
,
hasColor
(
0xFF0000FF
));
});
});
...
@@ -162,7 +160,7 @@ void main() {
...
@@ -162,7 +160,7 @@ void main() {
);
);
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
MockCanvas
canvas
=
MockCanvas
();
final
MockCanvas
canvas
=
MockCanvas
();
customPaint
.
painter
.
paint
(
canvas
,
const
Size
(
12.0
,
12.0
));
customPaint
.
painter
!
.
paint
(
canvas
,
const
Size
(
12.0
,
12.0
));
// arrow_menu default size is 48x48 so we expect it to be scaled by 0.25.
// arrow_menu default size is 48x48 so we expect it to be scaled by 0.25.
expect
(
canvas
.
capturedSx
,
0.25
);
expect
(
canvas
.
capturedSx
,
0.25
);
expect
(
canvas
.
capturedSy
,
0.25
);
expect
(
canvas
.
capturedSy
,
0.25
);
...
@@ -187,7 +185,7 @@ void main() {
...
@@ -187,7 +185,7 @@ void main() {
);
);
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
MockCanvas
canvas
=
MockCanvas
();
final
MockCanvas
canvas
=
MockCanvas
();
customPaint
.
painter
.
paint
(
canvas
,
const
Size
(
12.0
,
12.0
));
customPaint
.
painter
!
.
paint
(
canvas
,
const
Size
(
12.0
,
12.0
));
// arrow_menu default size is 48x48 so we expect it to be scaled by 2.
// arrow_menu default size is 48x48 so we expect it to be scaled by 2.
expect
(
canvas
.
capturedSx
,
2
);
expect
(
canvas
.
capturedSx
,
2
);
expect
(
canvas
.
capturedSy
,
2
);
expect
(
canvas
.
capturedSy
,
2
);
...
@@ -230,7 +228,7 @@ void main() {
...
@@ -230,7 +228,7 @@ void main() {
);
);
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
MockCanvas
canvas
=
MockCanvas
();
final
MockCanvas
canvas
=
MockCanvas
();
customPaint
.
painter
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
customPaint
.
painter
!
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
expect
(
canvas
.
invocations
,
const
<
RecordedCanvasCall
>[
expect
(
canvas
.
invocations
,
const
<
RecordedCanvasCall
>[
RecordedRotate
(
math
.
pi
),
RecordedRotate
(
math
.
pi
),
RecordedTranslate
(-
48
,
-
48
),
RecordedTranslate
(-
48
,
-
48
),
...
@@ -254,7 +252,7 @@ void main() {
...
@@ -254,7 +252,7 @@ void main() {
);
);
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
MockCanvas
canvas
=
MockCanvas
();
final
MockCanvas
canvas
=
MockCanvas
();
customPaint
.
painter
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
customPaint
.
painter
!
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
expect
(
canvas
.
invocations
,
isEmpty
);
expect
(
canvas
.
invocations
,
isEmpty
);
});
});
...
@@ -276,7 +274,7 @@ void main() {
...
@@ -276,7 +274,7 @@ void main() {
);
);
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
MockCanvas
canvas
=
MockCanvas
();
final
MockCanvas
canvas
=
MockCanvas
();
customPaint
.
painter
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
customPaint
.
painter
!
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
expect
(
canvas
.
invocations
,
const
<
RecordedCanvasCall
>[
expect
(
canvas
.
invocations
,
const
<
RecordedCanvasCall
>[
RecordedRotate
(
math
.
pi
),
RecordedRotate
(
math
.
pi
),
RecordedTranslate
(-
48
,
-
48
),
RecordedTranslate
(-
48
,
-
48
),
...
...
packages/flutter/test/material/app_bar_test.dart
View file @
c083f02f
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
...
@@ -14,10 +12,10 @@ import '../rendering/mock_canvas.dart';
...
@@ -14,10 +12,10 @@ import '../rendering/mock_canvas.dart';
import
'../widgets/semantics_tester.dart'
;
import
'../widgets/semantics_tester.dart'
;
Widget
buildSliverAppBarApp
(
{
Widget
buildSliverAppBarApp
(
{
bool
floating
,
bool
floating
=
false
,
bool
pinned
,
bool
pinned
=
false
,
double
collapsedHeight
,
double
?
collapsedHeight
,
double
expandedHeight
,
double
?
expandedHeight
,
bool
snap
=
false
,
bool
snap
=
false
,
double
toolbarHeight
=
kToolbarHeight
,
double
toolbarHeight
=
kToolbarHeight
,
})
{
})
{
...
@@ -65,7 +63,7 @@ Widget buildSliverAppBarApp({
...
@@ -65,7 +63,7 @@ Widget buildSliverAppBarApp({
}
}
ScrollController
primaryScrollController
(
WidgetTester
tester
)
{
ScrollController
primaryScrollController
(
WidgetTester
tester
)
{
return
PrimaryScrollController
.
of
(
tester
.
element
(
find
.
byType
(
CustomScrollView
)));
return
PrimaryScrollController
.
of
(
tester
.
element
(
find
.
byType
(
CustomScrollView
)))
!
;
}
}
double
appBarHeight
(
WidgetTester
tester
)
=>
tester
.
getSize
(
find
.
byType
(
AppBar
,
skipOffstage:
false
)).
height
;
double
appBarHeight
(
WidgetTester
tester
)
=>
tester
.
getSize
(
find
.
byType
(
AppBar
,
skipOffstage:
false
)).
height
;
...
@@ -303,7 +301,7 @@ void main() {
...
@@ -303,7 +301,7 @@ void main() {
final
Key
titleKey
=
UniqueKey
();
final
Key
titleKey
=
UniqueKey
();
Widget
leading
=
Container
();
Widget
leading
=
Container
();
List
<
Widget
>
actions
;
List
<
Widget
>
actions
=
<
Widget
>[]
;
Widget
buildApp
()
{
Widget
buildApp
()
{
return
MaterialApp
(
return
MaterialApp
(
...
@@ -360,8 +358,8 @@ void main() {
...
@@ -360,8 +358,8 @@ void main() {
final
Key
titleKey
=
UniqueKey
();
final
Key
titleKey
=
UniqueKey
();
double
titleWidth
=
700.0
;
double
titleWidth
=
700.0
;
Widget
leading
=
Container
();
Widget
?
leading
=
Container
();
List
<
Widget
>
actions
;
List
<
Widget
>
actions
=
<
Widget
>[]
;
Widget
buildApp
()
{
Widget
buildApp
()
{
return
MaterialApp
(
return
MaterialApp
(
...
@@ -412,8 +410,8 @@ void main() {
...
@@ -412,8 +410,8 @@ void main() {
final
Key
titleKey
=
UniqueKey
();
final
Key
titleKey
=
UniqueKey
();
double
titleWidth
=
700.0
;
double
titleWidth
=
700.0
;
Widget
leading
=
Container
();
Widget
?
leading
=
Container
();
List
<
Widget
>
actions
;
List
<
Widget
>
actions
=
<
Widget
>[]
;
Widget
buildApp
()
{
Widget
buildApp
()
{
return
MaterialApp
(
return
MaterialApp
(
...
@@ -1952,14 +1950,14 @@ void main() {
...
@@ -1952,14 +1950,14 @@ void main() {
});
});
testWidgets
(
'AppBars title has upper limit on text scaling, textScaleFactor = 1, 1.34, 2'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'AppBars title has upper limit on text scaling, textScaleFactor = 1, 1.34, 2'
,
(
WidgetTester
tester
)
async
{
double
textScaleFactor
;
late
double
textScaleFactor
;
Widget
buildFrame
()
{
Widget
buildFrame
()
{
return
MaterialApp
(
return
MaterialApp
(
home:
Builder
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
return
MediaQuery
(
return
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
textScaleFactor:
textScaleFactor
),
data:
MediaQuery
.
of
(
context
)
!
.
copyWith
(
textScaleFactor:
textScaleFactor
),
child:
Scaffold
(
child:
Scaffold
(
appBar:
AppBar
(
appBar:
AppBar
(
centerTitle:
false
,
centerTitle:
false
,
...
@@ -1988,9 +1986,9 @@ void main() {
...
@@ -1988,9 +1986,9 @@ void main() {
});
});
testWidgets
(
'AppBars with jumbo titles, textScaleFactor = 3, 3.5, 4'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'AppBars with jumbo titles, textScaleFactor = 3, 3.5, 4'
,
(
WidgetTester
tester
)
async
{
double
textScaleFactor
;
double
textScaleFactor
=
1.0
;
TextDirection
textDirection
;
TextDirection
textDirection
=
TextDirection
.
ltr
;
bool
centerTitle
;
bool
centerTitle
=
false
;
Widget
buildFrame
()
{
Widget
buildFrame
()
{
return
MaterialApp
(
return
MaterialApp
(
...
@@ -2004,7 +2002,7 @@ void main() {
...
@@ -2004,7 +2002,7 @@ void main() {
appBar:
AppBar
(
appBar:
AppBar
(
centerTitle:
centerTitle
,
centerTitle:
centerTitle
,
title:
MediaQuery
(
title:
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
textScaleFactor:
textScaleFactor
),
data:
MediaQuery
.
of
(
context
)
!
.
copyWith
(
textScaleFactor:
textScaleFactor
),
child:
const
Text
(
'Jumbo'
),
child:
const
Text
(
'Jumbo'
),
),
),
),
),
...
@@ -2023,10 +2021,8 @@ void main() {
...
@@ -2023,10 +2021,8 @@ void main() {
// Overall screen size is 800x600
// Overall screen size is 800x600
// Left or right justified title is padded by 16 on the "start" side.
// Left or right justified title is padded by 16 on the "start" side.
// Toolbar height is 56.
// Toolbar height is 56.
// "Jumbo" title is 100x20.
textScaleFactor
=
1
;
// "Jumbo" title is 100x20.
textDirection
=
TextDirection
.
ltr
;
centerTitle
=
false
;
await
tester
.
pumpWidget
(
buildFrame
());
await
tester
.
pumpWidget
(
buildFrame
());
expect
(
tester
.
getRect
(
appBarTitle
),
const
Rect
.
fromLTRB
(
16
,
18
,
116
,
38
));
expect
(
tester
.
getRect
(
appBarTitle
),
const
Rect
.
fromLTRB
(
16
,
18
,
116
,
38
));
expect
(
tester
.
getCenter
(
appBarTitle
).
dy
,
tester
.
getCenter
(
toolbar
).
dy
);
expect
(
tester
.
getCenter
(
appBarTitle
).
dy
,
tester
.
getCenter
(
toolbar
).
dy
);
...
@@ -2058,7 +2054,7 @@ void main() {
...
@@ -2058,7 +2054,7 @@ void main() {
});
});
testWidgets
(
'SliverAppBar configures the delegate properly'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'SliverAppBar configures the delegate properly'
,
(
WidgetTester
tester
)
async
{
Future
<
void
>
buildAndVerifyDelegate
({
bool
pinned
,
bool
floating
,
bool
snap
})
async
{
Future
<
void
>
buildAndVerifyDelegate
({
required
bool
pinned
,
required
bool
floating
,
required
bool
snap
})
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
home:
CustomScrollView
(
home:
CustomScrollView
(
...
@@ -2150,17 +2146,6 @@ void main() {
...
@@ -2150,17 +2146,6 @@ void main() {
expect
(
appBarHeight
(
tester
),
collapsedHeight
+
initialTabBarHeight
);
expect
(
appBarHeight
(
tester
),
collapsedHeight
+
initialTabBarHeight
);
});
});
test
(
'SliverApp toolbarHeight cannot be null'
,
()
{
try
{
SliverAppBar
(
toolbarHeight:
null
,
);
}
on
AssertionError
catch
(
error
)
{
expect
(
error
.
toString
(),
contains
(
'toolbarHeight != null'
));
expect
(
error
.
toString
(),
contains
(
'is not true'
));
}
});
testWidgets
(
'AppBar respects leadingWidth'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'AppBar respects leadingWidth'
,
(
WidgetTester
tester
)
async
{
const
Key
key
=
Key
(
'leading'
);
const
Key
key
=
Key
(
'leading'
);
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
packages/flutter/test/material/app_bar_theme_test.dart
View file @
c083f02f
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
...
@@ -31,14 +29,14 @@ void main() {
...
@@ -31,14 +29,14 @@ void main() {
final
RichText
actionIconText
=
_getAppBarIconRichText
(
tester
);
final
RichText
actionIconText
=
_getAppBarIconRichText
(
tester
);
final
DefaultTextStyle
text
=
_getAppBarText
(
tester
);
final
DefaultTextStyle
text
=
_getAppBarText
(
tester
);
expect
(
SystemChrome
.
latestStyle
.
statusBarBrightness
,
Brightness
.
dark
);
expect
(
SystemChrome
.
latestStyle
!
.
statusBarBrightness
,
Brightness
.
dark
);
expect
(
widget
.
color
,
Colors
.
blue
);
expect
(
widget
.
color
,
Colors
.
blue
);
expect
(
widget
.
elevation
,
4.0
);
expect
(
widget
.
elevation
,
4.0
);
expect
(
widget
.
shadowColor
,
Colors
.
black
);
expect
(
widget
.
shadowColor
,
Colors
.
black
);
expect
(
iconTheme
.
data
,
const
IconThemeData
(
color:
Colors
.
white
));
expect
(
iconTheme
.
data
,
const
IconThemeData
(
color:
Colors
.
white
));
expect
(
actionsIconTheme
.
data
,
const
IconThemeData
(
color:
Colors
.
white
));
expect
(
actionsIconTheme
.
data
,
const
IconThemeData
(
color:
Colors
.
white
));
expect
(
actionIconText
.
text
.
style
.
color
,
Colors
.
white
);
expect
(
actionIconText
.
text
.
style
!
.
color
,
Colors
.
white
);
expect
(
text
.
style
,
Typography
.
material2014
().
englishLike
.
bodyText2
.
merge
(
Typography
.
material2014
().
white
.
bodyText2
));
expect
(
text
.
style
,
Typography
.
material2014
().
englishLike
.
bodyText2
!
.
merge
(
Typography
.
material2014
().
white
.
bodyText2
));
});
});
testWidgets
(
'AppBar uses values from AppBarTheme'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'AppBar uses values from AppBarTheme'
,
(
WidgetTester
tester
)
async
{
...
@@ -60,14 +58,14 @@ void main() {
...
@@ -60,14 +58,14 @@ void main() {
final
RichText
actionIconText
=
_getAppBarIconRichText
(
tester
);
final
RichText
actionIconText
=
_getAppBarIconRichText
(
tester
);
final
DefaultTextStyle
text
=
_getAppBarText
(
tester
);
final
DefaultTextStyle
text
=
_getAppBarText
(
tester
);
expect
(
SystemChrome
.
latestStyle
.
statusBarBrightness
,
appBarTheme
.
brightness
);
expect
(
SystemChrome
.
latestStyle
!
.
statusBarBrightness
,
appBarTheme
.
brightness
);
expect
(
widget
.
color
,
appBarTheme
.
color
);
expect
(
widget
.
color
,
appBarTheme
.
color
);
expect
(
widget
.
elevation
,
appBarTheme
.
elevation
);
expect
(
widget
.
elevation
,
appBarTheme
.
elevation
);
expect
(
widget
.
shadowColor
,
appBarTheme
.
shadowColor
);
expect
(
widget
.
shadowColor
,
appBarTheme
.
shadowColor
);
expect
(
iconTheme
.
data
,
appBarTheme
.
iconTheme
);
expect
(
iconTheme
.
data
,
appBarTheme
.
iconTheme
);
expect
(
actionsIconTheme
.
data
,
appBarTheme
.
actionsIconTheme
);
expect
(
actionsIconTheme
.
data
,
appBarTheme
.
actionsIconTheme
);
expect
(
actionIconText
.
text
.
style
.
color
,
appBarTheme
.
actionsIconTheme
.
color
);
expect
(
actionIconText
.
text
.
style
!.
color
,
appBarTheme
.
actionsIconTheme
!
.
color
);
expect
(
text
.
style
,
appBarTheme
.
textTheme
.
bodyText2
);
expect
(
text
.
style
,
appBarTheme
.
textTheme
!
.
bodyText2
);
});
});
testWidgets
(
'AppBar widget properties take priority over theme'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'AppBar widget properties take priority over theme'
,
(
WidgetTester
tester
)
async
{
...
@@ -103,13 +101,13 @@ void main() {
...
@@ -103,13 +101,13 @@ void main() {
final
RichText
actionIconText
=
_getAppBarIconRichText
(
tester
);
final
RichText
actionIconText
=
_getAppBarIconRichText
(
tester
);
final
DefaultTextStyle
text
=
_getAppBarText
(
tester
);
final
DefaultTextStyle
text
=
_getAppBarText
(
tester
);
expect
(
SystemChrome
.
latestStyle
.
statusBarBrightness
,
brightness
);
expect
(
SystemChrome
.
latestStyle
!
.
statusBarBrightness
,
brightness
);
expect
(
widget
.
color
,
color
);
expect
(
widget
.
color
,
color
);
expect
(
widget
.
elevation
,
elevation
);
expect
(
widget
.
elevation
,
elevation
);
expect
(
widget
.
shadowColor
,
shadowColor
);
expect
(
widget
.
shadowColor
,
shadowColor
);
expect
(
iconTheme
.
data
,
iconThemeData
);
expect
(
iconTheme
.
data
,
iconThemeData
);
expect
(
actionsIconTheme
.
data
,
actionsIconThemeData
);
expect
(
actionsIconTheme
.
data
,
actionsIconThemeData
);
expect
(
actionIconText
.
text
.
style
.
color
,
actionsIconThemeData
.
color
);
expect
(
actionIconText
.
text
.
style
!
.
color
,
actionsIconThemeData
.
color
);
expect
(
text
.
style
,
textTheme
.
bodyText2
);
expect
(
text
.
style
,
textTheme
.
bodyText2
);
});
});
...
@@ -132,7 +130,7 @@ void main() {
...
@@ -132,7 +130,7 @@ void main() {
));
));
final
RichText
actionIconText
=
_getAppBarIconRichText
(
tester
);
final
RichText
actionIconText
=
_getAppBarIconRichText
(
tester
);
expect
(
actionIconText
.
text
.
style
.
color
,
color
);
expect
(
actionIconText
.
text
.
style
!
.
color
,
color
);
});
});
testWidgets
(
'AppBarTheme properties take priority over ThemeData properties'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'AppBarTheme properties take priority over ThemeData properties'
,
(
WidgetTester
tester
)
async
{
...
@@ -154,14 +152,14 @@ void main() {
...
@@ -154,14 +152,14 @@ void main() {
final
RichText
actionIconText
=
_getAppBarIconRichText
(
tester
);
final
RichText
actionIconText
=
_getAppBarIconRichText
(
tester
);
final
DefaultTextStyle
text
=
_getAppBarText
(
tester
);
final
DefaultTextStyle
text
=
_getAppBarText
(
tester
);
expect
(
SystemChrome
.
latestStyle
.
statusBarBrightness
,
appBarTheme
.
brightness
);
expect
(
SystemChrome
.
latestStyle
!
.
statusBarBrightness
,
appBarTheme
.
brightness
);
expect
(
widget
.
color
,
appBarTheme
.
color
);
expect
(
widget
.
color
,
appBarTheme
.
color
);
expect
(
widget
.
elevation
,
appBarTheme
.
elevation
);
expect
(
widget
.
elevation
,
appBarTheme
.
elevation
);
expect
(
widget
.
shadowColor
,
appBarTheme
.
shadowColor
);
expect
(
widget
.
shadowColor
,
appBarTheme
.
shadowColor
);
expect
(
iconTheme
.
data
,
appBarTheme
.
iconTheme
);
expect
(
iconTheme
.
data
,
appBarTheme
.
iconTheme
);
expect
(
actionsIconTheme
.
data
,
appBarTheme
.
actionsIconTheme
);
expect
(
actionsIconTheme
.
data
,
appBarTheme
.
actionsIconTheme
);
expect
(
actionIconText
.
text
.
style
.
color
,
appBarTheme
.
actionsIconTheme
.
color
);
expect
(
actionIconText
.
text
.
style
!.
color
,
appBarTheme
.
actionsIconTheme
!
.
color
);
expect
(
text
.
style
,
appBarTheme
.
textTheme
.
bodyText2
);
expect
(
text
.
style
,
appBarTheme
.
textTheme
!
.
bodyText2
);
});
});
testWidgets
(
'ThemeData properties are used when no AppBarTheme is set'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ThemeData properties are used when no AppBarTheme is set'
,
(
WidgetTester
tester
)
async
{
...
@@ -182,15 +180,15 @@ void main() {
...
@@ -182,15 +180,15 @@ void main() {
final
RichText
actionIconText
=
_getAppBarIconRichText
(
tester
);
final
RichText
actionIconText
=
_getAppBarIconRichText
(
tester
);
final
DefaultTextStyle
text
=
_getAppBarText
(
tester
);
final
DefaultTextStyle
text
=
_getAppBarText
(
tester
);
expect
(
SystemChrome
.
latestStyle
.
statusBarBrightness
,
themeData
.
brightness
);
expect
(
SystemChrome
.
latestStyle
!
.
statusBarBrightness
,
themeData
.
brightness
);
expect
(
widget
.
color
,
themeData
.
primaryColor
);
expect
(
widget
.
color
,
themeData
.
primaryColor
);
expect
(
widget
.
elevation
,
4.0
);
expect
(
widget
.
elevation
,
4.0
);
expect
(
widget
.
shadowColor
,
Colors
.
black
);
expect
(
widget
.
shadowColor
,
Colors
.
black
);
expect
(
iconTheme
.
data
,
themeData
.
primaryIconTheme
);
expect
(
iconTheme
.
data
,
themeData
.
primaryIconTheme
);
expect
(
actionsIconTheme
.
data
,
themeData
.
primaryIconTheme
);
expect
(
actionsIconTheme
.
data
,
themeData
.
primaryIconTheme
);
expect
(
actionIconText
.
text
.
style
.
color
,
themeData
.
primaryIconTheme
.
color
);
expect
(
actionIconText
.
text
.
style
!
.
color
,
themeData
.
primaryIconTheme
.
color
);
// Default value for ThemeData.typography is Typography.material2014()
// Default value for ThemeData.typography is Typography.material2014()
expect
(
text
.
style
,
Typography
.
material2014
().
englishLike
.
bodyText2
.
merge
(
Typography
.
material2014
().
white
.
bodyText2
).
merge
(
themeData
.
primaryTextTheme
.
bodyText2
));
expect
(
text
.
style
,
Typography
.
material2014
().
englishLike
.
bodyText2
!
.
merge
(
Typography
.
material2014
().
white
.
bodyText2
).
merge
(
themeData
.
primaryTextTheme
.
bodyText2
));
});
});
testWidgets
(
'AppBar uses AppBarTheme.centerTitle when centerTitle is null'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'AppBar uses AppBarTheme.centerTitle when centerTitle is null'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/material/app_builder_test.dart
View file @
c083f02f
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
...
@@ -15,9 +13,9 @@ void main() {
...
@@ -15,9 +13,9 @@ void main() {
primarySwatch:
Colors
.
green
,
primarySwatch:
Colors
.
green
,
),
),
home:
const
Placeholder
(),
home:
const
Placeholder
(),
builder:
(
BuildContext
context
,
Widget
child
)
{
builder:
(
BuildContext
context
,
Widget
?
child
)
{
log
.
add
(
'build'
);
log
.
add
(
'build'
);
expect
(
Theme
.
of
(
context
).
primaryColor
,
Colors
.
green
);
expect
(
Theme
.
of
(
context
)
!
.
primaryColor
,
Colors
.
green
);
expect
(
Directionality
.
of
(
context
),
TextDirection
.
ltr
);
expect
(
Directionality
.
of
(
context
),
TextDirection
.
ltr
);
expect
(
child
,
isA
<
Navigator
>());
expect
(
child
,
isA
<
Navigator
>());
return
const
Placeholder
();
return
const
Placeholder
();
...
@@ -49,15 +47,15 @@ void main() {
...
@@ -49,15 +47,15 @@ void main() {
home:
Builder
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
log
.
add
(
'build'
);
log
.
add
(
'build'
);
expect
(
Theme
.
of
(
context
).
primaryColor
,
Colors
.
yellow
);
expect
(
Theme
.
of
(
context
)
!
.
primaryColor
,
Colors
.
yellow
);
expect
(
Directionality
.
of
(
context
),
TextDirection
.
rtl
);
expect
(
Directionality
.
of
(
context
),
TextDirection
.
rtl
);
return
const
Placeholder
();
return
const
Placeholder
();
},
},
),
),
builder:
(
BuildContext
context
,
Widget
child
)
{
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
Directionality
(
return
Directionality
(
textDirection:
TextDirection
.
rtl
,
textDirection:
TextDirection
.
rtl
,
child:
child
,
child:
child
!
,
);
);
},
},
),
),
...
...
packages/flutter/test/material/app_test.dart
View file @
c083f02f
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/semantics.dart'
;
import
'package:flutter/semantics.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
...
@@ -12,21 +10,21 @@ import 'package:flutter/cupertino.dart';
...
@@ -12,21 +10,21 @@ import 'package:flutter/cupertino.dart';
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
class
StateMarker
extends
StatefulWidget
{
class
StateMarker
extends
StatefulWidget
{
const
StateMarker
({
Key
key
,
this
.
child
})
:
super
(
key:
key
);
const
StateMarker
({
Key
?
key
,
this
.
child
})
:
super
(
key:
key
);
final
Widget
child
;
final
Widget
?
child
;
@override
@override
StateMarkerState
createState
()
=>
StateMarkerState
();
StateMarkerState
createState
()
=>
StateMarkerState
();
}
}
class
StateMarkerState
extends
State
<
StateMarker
>
{
class
StateMarkerState
extends
State
<
StateMarker
>
{
String
marker
;
late
String
marker
;
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
if
(
widget
.
child
!=
null
)
if
(
widget
.
child
!=
null
)
return
widget
.
child
;
return
widget
.
child
!
;
return
Container
();
return
Container
();
}
}
}
}
...
@@ -102,7 +100,7 @@ void main() {
...
@@ -102,7 +100,7 @@ void main() {
return
Material
(
return
Material
(
child:
ElevatedButton
(
child:
ElevatedButton
(
child:
const
Text
(
'X'
),
child:
const
Text
(
'X'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pushNamed
(
'/next'
);
},
onPressed:
()
{
Navigator
.
of
(
context
)
!
.
pushNamed
(
'/next'
);
},
),
),
);
);
}
}
...
@@ -251,7 +249,7 @@ void main() {
...
@@ -251,7 +249,7 @@ void main() {
});
});
testWidgets
(
'Return value from pop is correct'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Return value from pop is correct'
,
(
WidgetTester
tester
)
async
{
Future
<
Object
>
result
;
late
Future
<
Object
>
result
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
home:
Builder
(
home:
Builder
(
...
@@ -260,7 +258,7 @@ void main() {
...
@@ -260,7 +258,7 @@ void main() {
child:
ElevatedButton
(
child:
ElevatedButton
(
child:
const
Text
(
'X'
),
child:
const
Text
(
'X'
),
onPressed:
()
async
{
onPressed:
()
async
{
result
=
Navigator
.
of
(
context
).
pushNamed
(
'/a'
);
result
=
Navigator
.
of
(
context
)
!
.
pushNamed
(
'/a'
);
},
},
),
),
);
);
...
@@ -272,7 +270,7 @@ void main() {
...
@@ -272,7 +270,7 @@ void main() {
child:
ElevatedButton
(
child:
ElevatedButton
(
child:
const
Text
(
'Y'
),
child:
const
Text
(
'Y'
),
onPressed:
()
{
onPressed:
()
{
Navigator
.
of
(
context
).
pop
(
'all done'
);
Navigator
.
of
(
context
)
!
.
pop
(
'all done'
);
},
},
),
),
);
);
...
@@ -394,7 +392,7 @@ void main() {
...
@@ -394,7 +392,7 @@ void main() {
// Regression test for https://github.com/flutter/flutter/issues/18904
// Regression test for https://github.com/flutter/flutter/issues/18904
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
builder:
(
BuildContext
context
,
Widget
child
)
{
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
const
SizedBox
();
return
const
SizedBox
();
},
},
),
),
...
@@ -463,10 +461,10 @@ void main() {
...
@@ -463,10 +461,10 @@ void main() {
});
});
testWidgets
(
'Can get text scale from media query'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Can get text scale from media query'
,
(
WidgetTester
tester
)
async
{
double
textScaleFactor
;
double
?
textScaleFactor
;
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
home:
Builder
(
builder:
(
BuildContext
context
)
{
textScaleFactor
=
MediaQuery
.
of
(
context
).
textScaleFactor
;
textScaleFactor
=
MediaQuery
.
of
(
context
)
!
.
textScaleFactor
;
return
Container
();
return
Container
();
}),
}),
));
));
...
@@ -502,8 +500,8 @@ void main() {
...
@@ -502,8 +500,8 @@ void main() {
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
return
Column
(
return
Column
(
children:
<
Widget
>[
children:
<
Widget
>[
Text
(
MaterialLocalizations
.
of
(
context
).
selectAllButtonLabel
),
Text
(
MaterialLocalizations
.
of
(
context
)
!
.
selectAllButtonLabel
),
Text
(
CupertinoLocalizations
.
of
(
context
).
selectAllButtonLabel
),
Text
(
CupertinoLocalizations
.
of
(
context
)
!
.
selectAllButtonLabel
),
],
],
);
);
},
},
...
@@ -521,7 +519,7 @@ void main() {
...
@@ -521,7 +519,7 @@ void main() {
// Mock the Window to explicitly report a light platformBrightness.
// Mock the Window to explicitly report a light platformBrightness.
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
theme:
ThemeData
(
theme:
ThemeData
(
...
@@ -533,7 +531,7 @@ void main() {
...
@@ -533,7 +531,7 @@ void main() {
themeMode:
ThemeMode
.
light
,
themeMode:
ThemeMode
.
light
,
home:
Builder
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
return
const
SizedBox
();
},
},
),
),
...
@@ -554,7 +552,7 @@ void main() {
...
@@ -554,7 +552,7 @@ void main() {
themeMode:
ThemeMode
.
light
,
themeMode:
ThemeMode
.
light
,
home:
Builder
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
return
const
SizedBox
();
},
},
),
),
...
@@ -567,7 +565,7 @@ void main() {
...
@@ -567,7 +565,7 @@ void main() {
// Mock the Window to explicitly report a light platformBrightness.
// Mock the Window to explicitly report a light platformBrightness.
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
theme:
ThemeData
(
theme:
ThemeData
(
...
@@ -579,7 +577,7 @@ void main() {
...
@@ -579,7 +577,7 @@ void main() {
themeMode:
ThemeMode
.
dark
,
themeMode:
ThemeMode
.
dark
,
home:
Builder
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
return
const
SizedBox
();
},
},
),
),
...
@@ -600,7 +598,7 @@ void main() {
...
@@ -600,7 +598,7 @@ void main() {
themeMode:
ThemeMode
.
dark
,
themeMode:
ThemeMode
.
dark
,
home:
Builder
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
return
const
SizedBox
();
},
},
),
),
...
@@ -614,7 +612,7 @@ void main() {
...
@@ -614,7 +612,7 @@ void main() {
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
...
@@ -627,7 +625,7 @@ void main() {
...
@@ -627,7 +625,7 @@ void main() {
themeMode:
ThemeMode
.
system
,
themeMode:
ThemeMode
.
system
,
home:
Builder
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
return
const
SizedBox
();
},
},
),
),
...
@@ -641,7 +639,7 @@ void main() {
...
@@ -641,7 +639,7 @@ void main() {
// Mock the Window to explicitly report a dark platformBrightness.
// Mock the Window to explicitly report a dark platformBrightness.
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
theme:
ThemeData
(
theme:
ThemeData
(
...
@@ -653,7 +651,7 @@ void main() {
...
@@ -653,7 +651,7 @@ void main() {
themeMode:
ThemeMode
.
system
,
themeMode:
ThemeMode
.
system
,
home:
Builder
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
return
const
SizedBox
();
},
},
),
),
...
@@ -667,7 +665,7 @@ void main() {
...
@@ -667,7 +665,7 @@ void main() {
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
...
@@ -676,7 +674,7 @@ void main() {
...
@@ -676,7 +674,7 @@ void main() {
),
),
home:
Builder
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
return
const
SizedBox
();
},
},
),
),
...
@@ -691,13 +689,13 @@ void main() {
...
@@ -691,13 +689,13 @@ void main() {
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
home:
Builder
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
return
const
SizedBox
();
},
},
),
),
...
@@ -712,7 +710,7 @@ void main() {
...
@@ -712,7 +710,7 @@ void main() {
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
...
@@ -721,7 +719,7 @@ void main() {
...
@@ -721,7 +719,7 @@ void main() {
),
),
home:
Builder
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
return
const
SizedBox
();
},
},
),
),
...
@@ -736,7 +734,7 @@ void main() {
...
@@ -736,7 +734,7 @@ void main() {
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
...
@@ -748,7 +746,7 @@ void main() {
...
@@ -748,7 +746,7 @@ void main() {
),
),
home:
Builder
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
return
const
SizedBox
();
},
},
),
),
...
@@ -762,7 +760,7 @@ void main() {
...
@@ -762,7 +760,7 @@ void main() {
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
tester
.
binding
.
window
.
accessibilityFeaturesTestValue
=
MockAccessibilityFeature
();
tester
.
binding
.
window
.
accessibilityFeaturesTestValue
=
MockAccessibilityFeature
();
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
...
@@ -774,7 +772,7 @@ void main() {
...
@@ -774,7 +772,7 @@ void main() {
),
),
home:
Builder
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
return
const
SizedBox
();
},
},
),
),
...
@@ -789,7 +787,7 @@ void main() {
...
@@ -789,7 +787,7 @@ void main() {
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
tester
.
binding
.
window
.
accessibilityFeaturesTestValue
=
MockAccessibilityFeature
();
tester
.
binding
.
window
.
accessibilityFeaturesTestValue
=
MockAccessibilityFeature
();
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
...
@@ -807,7 +805,7 @@ void main() {
...
@@ -807,7 +805,7 @@ void main() {
),
),
home:
Builder
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
return
const
SizedBox
();
},
},
),
),
...
@@ -822,7 +820,7 @@ void main() {
...
@@ -822,7 +820,7 @@ void main() {
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
tester
.
binding
.
window
.
accessibilityFeaturesTestValue
=
MockAccessibilityFeature
();
tester
.
binding
.
window
.
accessibilityFeaturesTestValue
=
MockAccessibilityFeature
();
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
...
@@ -834,7 +832,7 @@ void main() {
...
@@ -834,7 +832,7 @@ void main() {
),
),
home:
Builder
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
return
const
SizedBox
();
},
},
),
),
...
@@ -851,8 +849,8 @@ void main() {
...
@@ -851,8 +849,8 @@ void main() {
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
ThemeData
themeBeforeBrightnessChange
;
ThemeData
?
themeBeforeBrightnessChange
;
ThemeData
themeAfterBrightnessChange
;
ThemeData
?
themeAfterBrightnessChange
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
...
@@ -880,8 +878,8 @@ void main() {
...
@@ -880,8 +878,8 @@ void main() {
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
themeBeforeBrightnessChange
.
brightness
,
Brightness
.
light
);
expect
(
themeBeforeBrightnessChange
!
.
brightness
,
Brightness
.
light
);
expect
(
themeAfterBrightnessChange
.
brightness
,
Brightness
.
dark
);
expect
(
themeAfterBrightnessChange
!
.
brightness
,
Brightness
.
dark
);
});
});
testWidgets
(
'MaterialApp can customize initial routes'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MaterialApp can customize initial routes'
,
(
WidgetTester
tester
)
async
{
...
@@ -921,7 +919,7 @@ void main() {
...
@@ -921,7 +919,7 @@ void main() {
expect
(
find
.
text
(
'non-regular page one'
),
findsNothing
);
expect
(
find
.
text
(
'non-regular page one'
),
findsNothing
);
expect
(
find
.
text
(
'regular page one'
),
findsNothing
);
expect
(
find
.
text
(
'regular page one'
),
findsNothing
);
expect
(
find
.
text
(
'regular page two'
),
findsNothing
);
expect
(
find
.
text
(
'regular page two'
),
findsNothing
);
navigatorKey
.
currentState
.
pop
();
navigatorKey
.
currentState
!
.
pop
();
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'non-regular page two'
),
findsNothing
);
expect
(
find
.
text
(
'non-regular page two'
),
findsNothing
);
expect
(
find
.
text
(
'non-regular page one'
),
findsOneWidget
);
expect
(
find
.
text
(
'non-regular page one'
),
findsOneWidget
);
...
@@ -931,7 +929,7 @@ void main() {
...
@@ -931,7 +929,7 @@ void main() {
testWidgets
(
'MaterialApp does create HeroController with the MaterialRectArcTween'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MaterialApp does create HeroController with the MaterialRectArcTween'
,
(
WidgetTester
tester
)
async
{
final
HeroController
controller
=
MaterialApp
.
createMaterialHeroController
();
final
HeroController
controller
=
MaterialApp
.
createMaterialHeroController
();
final
Tween
<
Rect
>
tween
=
controller
.
createRectTween
(
final
Tween
<
Rect
?>
tween
=
controller
.
createRectTween
!
(
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
10.0
,
10.0
),
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
10.0
,
10.0
),
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
20.0
,
20.0
)
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
20.0
,
20.0
)
);
);
...
@@ -962,7 +960,7 @@ void main() {
...
@@ -962,7 +960,7 @@ void main() {
);
);
final
SimpleNavigatorRouterDelegate
delegate
=
SimpleNavigatorRouterDelegate
(
final
SimpleNavigatorRouterDelegate
delegate
=
SimpleNavigatorRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
return
Text
(
information
.
location
);
return
Text
(
information
.
location
!
);
},
},
onPopPage:
(
Route
<
void
>
route
,
void
result
,
SimpleNavigatorRouterDelegate
delegate
)
{
onPopPage:
(
Route
<
void
>
route
,
void
result
,
SimpleNavigatorRouterDelegate
delegate
)
{
delegate
.
routeInformation
=
const
RouteInformation
(
delegate
.
routeInformation
=
const
RouteInformation
(
...
@@ -980,15 +978,15 @@ void main() {
...
@@ -980,15 +978,15 @@ void main() {
// Simulate android back button intent.
// Simulate android back button intent.
final
ByteData
message
=
const
JSONMethodCodec
().
encodeMethodCall
(
const
MethodCall
(
'popRoute'
));
final
ByteData
message
=
const
JSONMethodCodec
().
encodeMethodCall
(
const
MethodCall
(
'popRoute'
));
await
ServicesBinding
.
instance
.
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/navigation'
,
message
,
(
_
)
{
});
await
ServicesBinding
.
instance
!
.
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/navigation'
,
message
,
(
_
)
{
});
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'popped'
),
findsOneWidget
);
expect
(
find
.
text
(
'popped'
),
findsOneWidget
);
});
});
testWidgets
(
'MaterialApp.builder can build app without a Navigator'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MaterialApp.builder can build app without a Navigator'
,
(
WidgetTester
tester
)
async
{
Widget
builderChild
;
Widget
?
builderChild
;
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
builder:
(
BuildContext
context
,
Widget
child
)
{
builder:
(
BuildContext
context
,
Widget
?
child
)
{
builderChild
=
child
;
builderChild
=
child
;
return
Container
();
return
Container
();
},
},
...
@@ -1036,15 +1034,15 @@ class SimpleRouteInformationParser extends RouteInformationParser<RouteInformati
...
@@ -1036,15 +1034,15 @@ class SimpleRouteInformationParser extends RouteInformationParser<RouteInformati
class
SimpleNavigatorRouterDelegate
extends
RouterDelegate
<
RouteInformation
>
with
PopNavigatorRouterDelegateMixin
<
RouteInformation
>,
ChangeNotifier
{
class
SimpleNavigatorRouterDelegate
extends
RouterDelegate
<
RouteInformation
>
with
PopNavigatorRouterDelegateMixin
<
RouteInformation
>,
ChangeNotifier
{
SimpleNavigatorRouterDelegate
({
SimpleNavigatorRouterDelegate
({
@
required
this
.
builder
,
required
this
.
builder
,
this
.
onPopPage
,
required
this
.
onPopPage
,
});
});
@override
@override
GlobalKey
<
NavigatorState
>
navigatorKey
=
GlobalKey
<
NavigatorState
>();
GlobalKey
<
NavigatorState
>
navigatorKey
=
GlobalKey
<
NavigatorState
>();
RouteInformation
get
routeInformation
=>
_routeInformation
;
RouteInformation
get
routeInformation
=>
_routeInformation
;
RouteInformation
_routeInformation
;
late
RouteInformation
_routeInformation
;
set
routeInformation
(
RouteInformation
newValue
)
{
set
routeInformation
(
RouteInformation
newValue
)
{
_routeInformation
=
newValue
;
_routeInformation
=
newValue
;
notifyListeners
();
notifyListeners
();
...
@@ -1075,7 +1073,7 @@ class SimpleNavigatorRouterDelegate extends RouterDelegate<RouteInformation> wit
...
@@ -1075,7 +1073,7 @@ class SimpleNavigatorRouterDelegate extends RouterDelegate<RouteInformation> wit
child:
Text
(
'base'
),
child:
Text
(
'base'
),
),
),
MaterialPage
<
void
>(
MaterialPage
<
void
>(
key:
ValueKey
<
String
>(
routeInformation
?.
location
),
key:
ValueKey
<
String
>(
routeInformation
.
location
!
),
child:
builder
(
context
,
routeInformation
),
child:
builder
(
context
,
routeInformation
),
)
)
],
],
...
...
packages/flutter/test/material/arc_test.dart
View file @
c083f02f
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
...
...
packages/flutter/test/material/back_button_test.dart
View file @
c083f02f
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -132,7 +130,7 @@ void main() {
...
@@ -132,7 +130,7 @@ void main() {
of:
find
.
byType
(
BackButton
),
of:
find
.
byType
(
BackButton
),
matching:
find
.
byType
(
RichText
)
matching:
find
.
byType
(
RichText
)
));
));
expect
(
iconText
.
text
.
style
.
color
,
Colors
.
blue
);
expect
(
iconText
.
text
.
style
!
.
color
,
Colors
.
blue
);
});
});
testWidgets
(
'BackButton semantics'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'BackButton semantics'
,
(
WidgetTester
tester
)
async
{
...
@@ -182,7 +180,7 @@ void main() {
...
@@ -182,7 +180,7 @@ void main() {
of:
find
.
byType
(
CloseButton
),
of:
find
.
byType
(
CloseButton
),
matching:
find
.
byType
(
RichText
)
matching:
find
.
byType
(
RichText
)
));
));
expect
(
iconText
.
text
.
style
.
color
,
Colors
.
red
);
expect
(
iconText
.
text
.
style
!
.
color
,
Colors
.
red
);
});
});
testWidgets
(
'CloseButton onPressed overrides default pop behavior'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'CloseButton onPressed overrides default pop behavior'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/material/banner_test.dart
View file @
c083f02f
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -260,5 +258,5 @@ Container _getContainerFromBanner(WidgetTester tester) {
...
@@ -260,5 +258,5 @@ Container _getContainerFromBanner(WidgetTester tester) {
}
}
RenderParagraph
_getTextRenderObjectFromDialog
(
WidgetTester
tester
,
String
text
)
{
RenderParagraph
_getTextRenderObjectFromDialog
(
WidgetTester
tester
,
String
text
)
{
return
tester
.
element
<
StatelessElement
>(
find
.
descendant
(
of:
find
.
byType
(
MaterialBanner
),
matching:
find
.
text
(
text
))).
renderObject
as
RenderParagraph
;
return
tester
.
element
<
StatelessElement
>(
find
.
descendant
(
of:
find
.
byType
(
MaterialBanner
),
matching:
find
.
text
(
text
))).
renderObject
!
as
RenderParagraph
;
}
}
packages/flutter/test/material/banner_theme_test.dart
View file @
c083f02f
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -70,7 +68,7 @@ void main() {
...
@@ -70,7 +68,7 @@ void main() {
final
RenderParagraph
content
=
_getTextRenderObjectFromDialog
(
tester
,
contentText
);
final
RenderParagraph
content
=
_getTextRenderObjectFromDialog
(
tester
,
contentText
);
expect
(
container
.
color
,
const
Color
(
0xffffffff
));
expect
(
container
.
color
,
const
Color
(
0xffffffff
));
// Default value for ThemeData.typography is Typography.material2014()
// Default value for ThemeData.typography is Typography.material2014()
expect
(
content
.
text
.
style
,
Typography
.
material2014
().
englishLike
.
bodyText2
.
merge
(
Typography
.
material2014
().
black
.
bodyText2
));
expect
(
content
.
text
.
style
,
Typography
.
material2014
().
englishLike
.
bodyText2
!
.
merge
(
Typography
.
material2014
().
black
.
bodyText2
));
});
});
testWidgets
(
'MaterialBanner uses values from MaterialBannerThemeData'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MaterialBanner uses values from MaterialBannerThemeData'
,
(
WidgetTester
tester
)
async
{
...
@@ -185,7 +183,7 @@ Finder _containerFinder() {
...
@@ -185,7 +183,7 @@ Finder _containerFinder() {
}
}
RenderParagraph
_getTextRenderObjectFromDialog
(
WidgetTester
tester
,
String
text
)
{
RenderParagraph
_getTextRenderObjectFromDialog
(
WidgetTester
tester
,
String
text
)
{
return
tester
.
element
<
StatelessElement
>(
_textFinder
(
text
)).
renderObject
as
RenderParagraph
;
return
tester
.
element
<
StatelessElement
>(
_textFinder
(
text
)).
renderObject
!
as
RenderParagraph
;
}
}
Finder
_textFinder
(
String
text
)
{
Finder
_textFinder
(
String
text
)
{
...
...
packages/flutter/test/material/bottom_app_bar_test.dart
View file @
c083f02f
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
...
@@ -90,7 +88,7 @@ void main() {
...
@@ -90,7 +88,7 @@ void main() {
home:
Builder
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
return
Theme
(
return
Theme
(
data:
Theme
.
of
(
context
).
copyWith
(
bottomAppBarColor:
const
Color
(
0xffffff00
)),
data:
Theme
.
of
(
context
)
!
.
copyWith
(
bottomAppBarColor:
const
Color
(
0xffffff00
)),
child:
const
Scaffold
(
child:
const
Scaffold
(
floatingActionButton:
FloatingActionButton
(
floatingActionButton:
FloatingActionButton
(
onPressed:
null
,
onPressed:
null
,
...
@@ -115,7 +113,7 @@ void main() {
...
@@ -115,7 +113,7 @@ void main() {
home:
Builder
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
return
Theme
(
return
Theme
(
data:
Theme
.
of
(
context
).
copyWith
(
bottomAppBarColor:
const
Color
(
0xffffff00
)),
data:
Theme
.
of
(
context
)
!
.
copyWith
(
bottomAppBarColor:
const
Color
(
0xffffff00
)),
child:
const
Scaffold
(
child:
const
Scaffold
(
floatingActionButton:
FloatingActionButton
(
floatingActionButton:
FloatingActionButton
(
onPressed:
null
,
onPressed:
null
,
...
@@ -392,19 +390,19 @@ void main() {
...
@@ -392,19 +390,19 @@ void main() {
class
ClipCachePainter
extends
CustomPainter
{
class
ClipCachePainter
extends
CustomPainter
{
ClipCachePainter
(
this
.
context
);
ClipCachePainter
(
this
.
context
);
Path
value
;
late
Path
value
;
BuildContext
context
;
BuildContext
context
;
@override
@override
void
paint
(
Canvas
canvas
,
Size
size
)
{
void
paint
(
Canvas
canvas
,
Size
size
)
{
final
RenderPhysicalShape
physicalShape
=
findPhysicalShapeChild
(
context
);
final
RenderPhysicalShape
physicalShape
=
findPhysicalShapeChild
(
context
)
!
;
value
=
physicalShape
.
clipper
.
getClip
(
size
);
value
=
physicalShape
.
clipper
!
.
getClip
(
size
);
}
}
RenderPhysicalShape
findPhysicalShapeChild
(
BuildContext
context
)
{
RenderPhysicalShape
?
findPhysicalShapeChild
(
BuildContext
context
)
{
RenderPhysicalShape
result
;
RenderPhysicalShape
?
result
;
context
.
visitChildElements
((
Element
e
)
{
context
.
visitChildElements
((
Element
e
)
{
final
RenderObject
renderObject
=
e
.
findRenderObject
();
final
RenderObject
renderObject
=
e
.
findRenderObject
()
!
;
if
(
renderObject
.
runtimeType
==
RenderPhysicalShape
)
{
if
(
renderObject
.
runtimeType
==
RenderPhysicalShape
)
{
assert
(
result
==
null
);
assert
(
result
==
null
);
result
=
renderObject
as
RenderPhysicalShape
;
result
=
renderObject
as
RenderPhysicalShape
;
...
@@ -422,7 +420,7 @@ class ClipCachePainter extends CustomPainter {
...
@@ -422,7 +420,7 @@ class ClipCachePainter extends CustomPainter {
}
}
class
ShapeListener
extends
StatefulWidget
{
class
ShapeListener
extends
StatefulWidget
{
const
ShapeListener
(
this
.
child
,
{
Key
key
})
:
super
(
key:
key
);
const
ShapeListener
(
this
.
child
,
{
Key
?
key
})
:
super
(
key:
key
);
final
Widget
child
;
final
Widget
child
;
...
@@ -440,7 +438,7 @@ class ShapeListenerState extends State<ShapeListener> {
...
@@ -440,7 +438,7 @@ class ShapeListenerState extends State<ShapeListener> {
);
);
}
}
ClipCachePainter
cache
;
late
ClipCachePainter
cache
;
@override
@override
void
didChangeDependencies
()
{
void
didChangeDependencies
()
{
...
@@ -454,7 +452,7 @@ class RectangularNotch extends NotchedShape {
...
@@ -454,7 +452,7 @@ class RectangularNotch extends NotchedShape {
const
RectangularNotch
();
const
RectangularNotch
();
@override
@override
Path
getOuterPath
(
Rect
host
,
Rect
guest
)
{
Path
getOuterPath
(
Rect
host
,
Rect
?
guest
)
{
if
(
guest
==
null
)
if
(
guest
==
null
)
return
Path
()..
addRect
(
host
);
return
Path
()..
addRect
(
host
);
return
Path
()
return
Path
()
...
...
packages/flutter/test/material/bottom_app_bar_theme_test.dart
View file @
c083f02f
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
packages/flutter/test/material/bottom_navigation_bar_test.dart
View file @
c083f02f
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import
'dart:ui'
;
import
'dart:ui'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
...
@@ -15,7 +13,7 @@ import '../rendering/mock_canvas.dart';
...
@@ -15,7 +13,7 @@ import '../rendering/mock_canvas.dart';
void
main
(
)
{
void
main
(
)
{
testWidgets
(
'BottomNavigationBar callback test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'BottomNavigationBar callback test'
,
(
WidgetTester
tester
)
async
{
int
mutatedIndex
;
late
int
mutatedIndex
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
...
@@ -100,8 +98,8 @@ void main() {
...
@@ -100,8 +98,8 @@ void main() {
const
double
selectedFontSize
=
14.0
;
const
double
selectedFontSize
=
14.0
;
const
double
unselectedFontSize
=
12.0
;
const
double
unselectedFontSize
=
12.0
;
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
;
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
;
final
TextStyle
unselectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
;
final
TextStyle
unselectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
!
;
final
TextStyle
selectedIcon
=
_iconStyle
(
tester
,
Icons
.
ac_unit
);
final
TextStyle
selectedIcon
=
_iconStyle
(
tester
,
Icons
.
ac_unit
);
final
TextStyle
unselectedIcon
=
_iconStyle
(
tester
,
Icons
.
access_alarm
);
final
TextStyle
unselectedIcon
=
_iconStyle
(
tester
,
Icons
.
access_alarm
);
expect
(
selectedFontStyle
.
color
,
equals
(
primaryColor
));
expect
(
selectedFontStyle
.
color
,
equals
(
primaryColor
));
...
@@ -161,13 +159,13 @@ void main() {
...
@@ -161,13 +159,13 @@ void main() {
),
),
);
);
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
;
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
;
final
TextStyle
unselectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
;
final
TextStyle
unselectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
!
;
expect
(
selectedFontStyle
.
fontSize
,
equals
(
selectedTextStyle
.
fontSize
));
expect
(
selectedFontStyle
.
fontSize
,
equals
(
selectedTextStyle
.
fontSize
));
expect
(
selectedFontStyle
.
fontWeight
,
equals
(
selectedTextStyle
.
fontWeight
));
expect
(
selectedFontStyle
.
fontWeight
,
equals
(
selectedTextStyle
.
fontWeight
));
expect
(
expect
(
tester
.
firstWidget
<
Transform
>(
find
.
ancestor
(
of:
find
.
text
(
'Alarm'
),
matching:
find
.
byType
(
Transform
))).
transform
,
tester
.
firstWidget
<
Transform
>(
find
.
ancestor
(
of:
find
.
text
(
'Alarm'
),
matching:
find
.
byType
(
Transform
))).
transform
,
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedTextStyle
.
fontSize
/
selectedTextStyle
.
fontSize
))),
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedTextStyle
.
fontSize
!
/
selectedTextStyle
.
fontSize
!
))),
);
);
expect
(
unselectedFontStyle
.
fontWeight
,
equals
(
unselectedTextStyle
.
fontWeight
));
expect
(
unselectedFontStyle
.
fontWeight
,
equals
(
unselectedTextStyle
.
fontWeight
));
});
});
...
@@ -202,11 +200,11 @@ void main() {
...
@@ -202,11 +200,11 @@ void main() {
),
),
);
);
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
;
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
;
expect
(
selectedFontStyle
.
fontSize
,
equals
(
selectedTextStyle
.
fontSize
));
expect
(
selectedFontStyle
.
fontSize
,
equals
(
selectedTextStyle
.
fontSize
));
expect
(
expect
(
tester
.
firstWidget
<
Transform
>(
find
.
ancestor
(
of:
find
.
text
(
'Alarm'
),
matching:
find
.
byType
(
Transform
))).
transform
,
tester
.
firstWidget
<
Transform
>(
find
.
ancestor
(
of:
find
.
text
(
'Alarm'
),
matching:
find
.
byType
(
Transform
))).
transform
,
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedTextStyle
.
fontSize
/
selectedTextStyle
.
fontSize
))),
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedTextStyle
.
fontSize
!
/
selectedTextStyle
.
fontSize
!
))),
);
);
});
});
...
@@ -274,8 +272,8 @@ void main() {
...
@@ -274,8 +272,8 @@ void main() {
),
),
);
);
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
;
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
;
final
TextStyle
unselectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
;
final
TextStyle
unselectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
!
;
final
TextStyle
selectedIcon
=
_iconStyle
(
tester
,
Icons
.
ac_unit
);
final
TextStyle
selectedIcon
=
_iconStyle
(
tester
,
Icons
.
ac_unit
);
final
TextStyle
unselectedIcon
=
_iconStyle
(
tester
,
Icons
.
access_alarm
);
final
TextStyle
unselectedIcon
=
_iconStyle
(
tester
,
Icons
.
access_alarm
);
expect
(
selectedIcon
.
color
,
equals
(
selectedIconTheme
.
color
));
expect
(
selectedIcon
.
color
,
equals
(
selectedIconTheme
.
color
));
...
@@ -433,8 +431,8 @@ void main() {
...
@@ -433,8 +431,8 @@ void main() {
);
);
const
double
selectedFontSize
=
14.0
;
const
double
selectedFontSize
=
14.0
;
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
.
fontSize
,
selectedFontSize
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
.
fontSize
,
selectedFontSize
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
.
color
,
equals
(
Colors
.
white
));
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
.
color
,
equals
(
Colors
.
white
));
expect
(
_getOpacity
(
tester
,
'Alarm'
),
equals
(
0.0
));
expect
(
_getOpacity
(
tester
,
'Alarm'
),
equals
(
0.0
));
expect
(
_getMaterial
(
tester
).
elevation
,
equals
(
8.0
));
expect
(
_getMaterial
(
tester
).
elevation
,
equals
(
8.0
));
});
});
...
@@ -475,15 +473,15 @@ void main() {
...
@@ -475,15 +473,15 @@ void main() {
),
),
);
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
.
fontSize
,
selectedFontSize
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
.
fontSize
,
selectedFontSize
);
// Unselected label has a font size of 18 but is scaled down to be font size 14.
// Unselected label has a font size of 18 but is scaled down to be font size 14.
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
.
fontSize
,
selectedFontSize
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
!
.
fontSize
,
selectedFontSize
);
expect
(
expect
(
tester
.
firstWidget
<
Transform
>(
find
.
ancestor
(
of:
find
.
text
(
'Alarm'
),
matching:
find
.
byType
(
Transform
))).
transform
,
tester
.
firstWidget
<
Transform
>(
find
.
ancestor
(
of:
find
.
text
(
'Alarm'
),
matching:
find
.
byType
(
Transform
))).
transform
,
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedFontSize
/
selectedFontSize
))),
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedFontSize
/
selectedFontSize
))),
);
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
.
color
,
equals
(
selectedColor
));
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
.
color
,
equals
(
selectedColor
));
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
.
color
,
equals
(
unselectedColor
));
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
!
.
color
,
equals
(
unselectedColor
));
// There should not be any [Opacity] or [FadeTransition] widgets
// There should not be any [Opacity] or [FadeTransition] widgets
// since showUnselectedLabels and showSelectedLabels are true.
// since showUnselectedLabels and showSelectedLabels are true.
final
Finder
findOpacity
=
find
.
descendant
(
final
Finder
findOpacity
=
find
.
descendant
(
...
@@ -535,8 +533,8 @@ void main() {
...
@@ -535,8 +533,8 @@ void main() {
),
),
);
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
.
fontSize
,
selectedFontSize
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
.
fontSize
,
selectedFontSize
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
.
color
,
equals
(
selectedColor
));
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
.
color
,
equals
(
selectedColor
));
expect
(
_getOpacity
(
tester
,
'Alarm'
),
equals
(
0.0
));
expect
(
_getOpacity
(
tester
,
'Alarm'
),
equals
(
0.0
));
});
});
...
@@ -668,7 +666,7 @@ void main() {
...
@@ -668,7 +666,7 @@ void main() {
),
),
);
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
.
color
,
equals
(
fixedColor
));
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
.
color
,
equals
(
fixedColor
));
});
});
testWidgets
(
'setting selectedFontSize to zero hides all labels'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'setting selectedFontSize to zero hides all labels'
,
(
WidgetTester
tester
)
async
{
...
@@ -875,7 +873,7 @@ void main() {
...
@@ -875,7 +873,7 @@ void main() {
await
tester
.
tap
(
find
.
text
(
'Alarm'
));
await
tester
.
tap
(
find
.
text
(
'Alarm'
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'Alarm'
))).
brightness
,
equals
(
Brightness
.
dark
));
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'Alarm'
)))
!
.
brightness
,
equals
(
Brightness
.
dark
));
});
});
testWidgets
(
'BottomNavigationBar inherits shadowed app theme for fixed navbar'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'BottomNavigationBar inherits shadowed app theme for fixed navbar'
,
(
WidgetTester
tester
)
async
{
...
@@ -913,11 +911,11 @@ void main() {
...
@@ -913,11 +911,11 @@ void main() {
await
tester
.
tap
(
find
.
text
(
'Alarm'
));
await
tester
.
tap
(
find
.
text
(
'Alarm'
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'Alarm'
))).
brightness
,
equals
(
Brightness
.
dark
));
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'Alarm'
)))
!
.
brightness
,
equals
(
Brightness
.
dark
));
});
});
testWidgets
(
'BottomNavigationBar iconSize test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'BottomNavigationBar iconSize test'
,
(
WidgetTester
tester
)
async
{
double
builderIconSize
;
late
double
builderIconSize
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
home:
Scaffold
(
home:
Scaffold
(
...
@@ -932,7 +930,7 @@ void main() {
...
@@ -932,7 +930,7 @@ void main() {
label:
'B'
,
label:
'B'
,
icon:
Builder
(
icon:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
builderIconSize
=
IconTheme
.
of
(
context
).
size
;
builderIconSize
=
IconTheme
.
of
(
context
).
size
!
;
return
SizedBox
(
return
SizedBox
(
width:
builderIconSize
,
width:
builderIconSize
,
height:
builderIconSize
,
height:
builderIconSize
,
...
@@ -1101,7 +1099,7 @@ void main() {
...
@@ -1101,7 +1099,7 @@ void main() {
testWidgets
(
'BottomNavigationBar shows tool tips with text scaling on long press when labels are provided'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'BottomNavigationBar shows tool tips with text scaling on long press when labels are provided'
,
(
WidgetTester
tester
)
async
{
const
String
label
=
'Foo'
;
const
String
label
=
'Foo'
;
Widget
buildApp
({
double
textScaleFactor
})
{
Widget
buildApp
({
required
double
textScaleFactor
})
{
return
MediaQuery
(
return
MediaQuery
(
data:
MediaQueryData
(
textScaleFactor:
textScaleFactor
),
data:
MediaQueryData
(
textScaleFactor:
textScaleFactor
),
child:
Localizations
(
child:
Localizations
(
...
@@ -1178,9 +1176,9 @@ void main() {
...
@@ -1178,9 +1176,9 @@ void main() {
final
RenderBox
box
=
tester
.
renderObject
(
find
.
byType
(
BottomNavigationBar
));
final
RenderBox
box
=
tester
.
renderObject
(
find
.
byType
(
BottomNavigationBar
));
expect
(
box
.
size
.
height
,
equals
(
kBottomNavigationBarHeight
));
expect
(
box
.
size
.
height
,
equals
(
kBottomNavigationBarHeight
));
final
RenderBox
itemBoxA
=
tester
.
renderObject
(
find
.
text
(
longTextA
.
data
));
final
RenderBox
itemBoxA
=
tester
.
renderObject
(
find
.
text
(
longTextA
.
data
!
));
expect
(
itemBoxA
.
size
,
equals
(
const
Size
(
400.0
,
14.0
)));
expect
(
itemBoxA
.
size
,
equals
(
const
Size
(
400.0
,
14.0
)));
final
RenderBox
itemBoxB
=
tester
.
renderObject
(
find
.
text
(
longTextB
.
data
));
final
RenderBox
itemBoxB
=
tester
.
renderObject
(
find
.
text
(
longTextB
.
data
!
));
expect
(
itemBoxB
.
size
,
equals
(
const
Size
(
400.0
,
14.0
)));
expect
(
itemBoxB
.
size
,
equals
(
const
Size
(
400.0
,
14.0
)));
});
});
...
@@ -1767,7 +1765,7 @@ void main() {
...
@@ -1767,7 +1765,7 @@ void main() {
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
text
);
expect
(
RendererBinding
.
instance
!
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
text
);
// Test default cursor
// Test default cursor
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
@@ -1786,11 +1784,11 @@ void main() {
...
@@ -1786,11 +1784,11 @@ void main() {
),
),
);
);
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
click
);
expect
(
RendererBinding
.
instance
!
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
click
);
});
});
}
}
Widget
boilerplate
(
{
Widget
bottomNavigationBar
,
@
required
TextDirection
textDirection
})
{
Widget
boilerplate
(
{
Widget
?
bottomNavigationBar
,
required
TextDirection
textDirection
})
{
assert
(
textDirection
!=
null
);
assert
(
textDirection
!=
null
);
return
MaterialApp
(
return
MaterialApp
(
home:
Localizations
(
home:
Localizations
(
...
@@ -1834,7 +1832,7 @@ TextStyle _iconStyle(WidgetTester tester, IconData icon) {
...
@@ -1834,7 +1832,7 @@ TextStyle _iconStyle(WidgetTester tester, IconData icon) {
final
RichText
iconRichText
=
tester
.
widget
<
RichText
>(
final
RichText
iconRichText
=
tester
.
widget
<
RichText
>(
find
.
descendant
(
of:
find
.
byIcon
(
icon
),
matching:
find
.
byType
(
RichText
)),
find
.
descendant
(
of:
find
.
byIcon
(
icon
),
matching:
find
.
byType
(
RichText
)),
);
);
return
iconRichText
.
text
.
style
;
return
iconRichText
.
text
.
style
!
;
}
}
EdgeInsets
_itemPadding
(
WidgetTester
tester
,
IconData
icon
)
{
EdgeInsets
_itemPadding
(
WidgetTester
tester
,
IconData
icon
)
{
...
...
packages/flutter/test/material/bottom_navigation_bar_theme_test.dart
View file @
c083f02f
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -139,14 +137,14 @@ void main() {
...
@@ -139,14 +137,14 @@ void main() {
),
),
);
);
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
;
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
;
final
TextStyle
selectedIcon
=
_iconStyle
(
tester
,
Icons
.
ac_unit
);
final
TextStyle
selectedIcon
=
_iconStyle
(
tester
,
Icons
.
ac_unit
);
final
TextStyle
unselectedIcon
=
_iconStyle
(
tester
,
Icons
.
access_alarm
);
final
TextStyle
unselectedIcon
=
_iconStyle
(
tester
,
Icons
.
access_alarm
);
expect
(
selectedFontStyle
.
fontSize
,
selectedFontStyle
.
fontSize
);
expect
(
selectedFontStyle
.
fontSize
,
selectedFontStyle
.
fontSize
);
// Unselected label has a font size of 22 but is scaled down to be font size 21.
// Unselected label has a font size of 22 but is scaled down to be font size 21.
expect
(
expect
(
tester
.
firstWidget
<
Transform
>(
find
.
ancestor
(
of:
find
.
text
(
'Alarm'
),
matching:
find
.
byType
(
Transform
))).
transform
,
tester
.
firstWidget
<
Transform
>(
find
.
ancestor
(
of:
find
.
text
(
'Alarm'
),
matching:
find
.
byType
(
Transform
))).
transform
,
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedTextStyle
.
fontSize
/
selectedTextStyle
.
fontSize
))),
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedTextStyle
.
fontSize
!
/
selectedTextStyle
.
fontSize
!
))),
);
);
expect
(
selectedIcon
.
color
,
equals
(
selectedItemColor
));
expect
(
selectedIcon
.
color
,
equals
(
selectedItemColor
));
expect
(
selectedIcon
.
fontSize
,
equals
(
selectedIconTheme
.
size
));
expect
(
selectedIcon
.
fontSize
,
equals
(
selectedIconTheme
.
size
));
...
@@ -232,14 +230,14 @@ void main() {
...
@@ -232,14 +230,14 @@ void main() {
),
),
);
);
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
;
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
;
final
TextStyle
selectedIcon
=
_iconStyle
(
tester
,
Icons
.
ac_unit
);
final
TextStyle
selectedIcon
=
_iconStyle
(
tester
,
Icons
.
ac_unit
);
final
TextStyle
unselectedIcon
=
_iconStyle
(
tester
,
Icons
.
access_alarm
);
final
TextStyle
unselectedIcon
=
_iconStyle
(
tester
,
Icons
.
access_alarm
);
expect
(
selectedFontStyle
.
fontSize
,
selectedFontStyle
.
fontSize
);
expect
(
selectedFontStyle
.
fontSize
,
selectedFontStyle
.
fontSize
);
// Unselected label has a font size of 22 but is scaled down to be font size 21.
// Unselected label has a font size of 22 but is scaled down to be font size 21.
expect
(
expect
(
tester
.
firstWidget
<
Transform
>(
find
.
ancestor
(
of:
find
.
text
(
'Alarm'
),
matching:
find
.
byType
(
Transform
))).
transform
,
tester
.
firstWidget
<
Transform
>(
find
.
ancestor
(
of:
find
.
text
(
'Alarm'
),
matching:
find
.
byType
(
Transform
))).
transform
,
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedTextStyle
.
fontSize
/
selectedTextStyle
.
fontSize
))),
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedTextStyle
.
fontSize
!
/
selectedTextStyle
.
fontSize
!
))),
);
);
expect
(
selectedIcon
.
color
,
equals
(
selectedItemColor
));
expect
(
selectedIcon
.
color
,
equals
(
selectedItemColor
));
expect
(
selectedIcon
.
fontSize
,
equals
(
selectedIconTheme
.
size
));
expect
(
selectedIcon
.
fontSize
,
equals
(
selectedIconTheme
.
size
));
...
@@ -266,7 +264,7 @@ TextStyle _iconStyle(WidgetTester tester, IconData icon) {
...
@@ -266,7 +264,7 @@ TextStyle _iconStyle(WidgetTester tester, IconData icon) {
final
RichText
iconRichText
=
tester
.
widget
<
RichText
>(
final
RichText
iconRichText
=
tester
.
widget
<
RichText
>(
find
.
descendant
(
of:
find
.
byIcon
(
icon
),
matching:
find
.
byType
(
RichText
)),
find
.
descendant
(
of:
find
.
byIcon
(
icon
),
matching:
find
.
byType
(
RichText
)),
);
);
return
iconRichText
.
text
.
style
;
return
iconRichText
.
text
.
style
!
;
}
}
Material
_material
(
WidgetTester
tester
)
{
Material
_material
(
WidgetTester
tester
)
{
...
...
packages/flutter/test/material/bottom_sheet_test.dart
View file @
c083f02f
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
...
@@ -28,7 +26,7 @@ void main() {
...
@@ -28,7 +26,7 @@ void main() {
}
}
testWidgets
(
'Tapping on a modal BottomSheet should not dismiss it'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Tapping on a modal BottomSheet should not dismiss it'
,
(
WidgetTester
tester
)
async
{
BuildContext
savedContext
;
late
BuildContext
savedContext
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
...
@@ -64,7 +62,7 @@ void main() {
...
@@ -64,7 +62,7 @@ void main() {
});
});
testWidgets
(
'Tapping outside a modal BottomSheet should dismiss it by default'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Tapping outside a modal BottomSheet should dismiss it by default'
,
(
WidgetTester
tester
)
async
{
BuildContext
savedContext
;
late
BuildContext
savedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
home:
Builder
(
...
@@ -98,7 +96,7 @@ void main() {
...
@@ -98,7 +96,7 @@ void main() {
});
});
testWidgets
(
'Tapping outside a modal BottomSheet should dismiss it when isDismissible=true'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Tapping outside a modal BottomSheet should dismiss it when isDismissible=true'
,
(
WidgetTester
tester
)
async
{
BuildContext
savedContext
;
late
BuildContext
savedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
home:
Builder
(
...
@@ -133,7 +131,7 @@ void main() {
...
@@ -133,7 +131,7 @@ void main() {
});
});
testWidgets
(
'Verify that the BottomSheet animates non-linearly'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Verify that the BottomSheet animates non-linearly'
,
(
WidgetTester
tester
)
async
{
BuildContext
savedContext
;
late
BuildContext
savedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
home:
Builder
(
...
@@ -165,7 +163,7 @@ void main() {
...
@@ -165,7 +163,7 @@ void main() {
});
});
testWidgets
(
'Tapping outside a modal BottomSheet should not dismiss it when isDismissible=false'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Tapping outside a modal BottomSheet should not dismiss it when isDismissible=false'
,
(
WidgetTester
tester
)
async
{
BuildContext
savedContext
;
late
BuildContext
savedContext
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
...
@@ -202,7 +200,7 @@ void main() {
...
@@ -202,7 +200,7 @@ void main() {
});
});
testWidgets
(
'Swiping down a modal BottomSheet should dismiss it by default'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Swiping down a modal BottomSheet should dismiss it by default'
,
(
WidgetTester
tester
)
async
{
BuildContext
savedContext
;
late
BuildContext
savedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
home:
Builder
(
...
@@ -237,7 +235,7 @@ void main() {
...
@@ -237,7 +235,7 @@ void main() {
});
});
testWidgets
(
'Swiping down a modal BottomSheet should not dismiss it when enableDrag is false'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Swiping down a modal BottomSheet should not dismiss it when enableDrag is false'
,
(
WidgetTester
tester
)
async
{
BuildContext
savedContext
;
late
BuildContext
savedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
home:
Builder
(
...
@@ -273,7 +271,7 @@ void main() {
...
@@ -273,7 +271,7 @@ void main() {
});
});
testWidgets
(
'Swiping down a modal BottomSheet should dismiss it when enableDrag is true'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Swiping down a modal BottomSheet should dismiss it when enableDrag is true'
,
(
WidgetTester
tester
)
async
{
BuildContext
savedContext
;
late
BuildContext
savedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
home:
Builder
(
...
@@ -309,7 +307,7 @@ void main() {
...
@@ -309,7 +307,7 @@ void main() {
});
});
testWidgets
(
'Modal BottomSheet builder should only be called once'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Modal BottomSheet builder should only be called once'
,
(
WidgetTester
tester
)
async
{
BuildContext
savedContext
;
late
BuildContext
savedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
home:
Builder
(
...
@@ -354,7 +352,7 @@ void main() {
...
@@ -354,7 +352,7 @@ void main() {
expect
(
showBottomSheetThenCalled
,
isFalse
);
expect
(
showBottomSheetThenCalled
,
isFalse
);
expect
(
find
.
text
(
'BottomSheet'
),
findsNothing
);
expect
(
find
.
text
(
'BottomSheet'
),
findsNothing
);
scaffoldKey
.
currentState
.
showBottomSheet
<
void
>((
BuildContext
context
)
{
scaffoldKey
.
currentState
!
.
showBottomSheet
<
void
>((
BuildContext
context
)
{
return
Container
(
return
Container
(
margin:
const
EdgeInsets
.
all
(
40.0
),
margin:
const
EdgeInsets
.
all
(
40.0
),
child:
const
Text
(
'BottomSheet'
),
child:
const
Text
(
'BottomSheet'
),
...
@@ -408,7 +406,7 @@ void main() {
...
@@ -408,7 +406,7 @@ void main() {
),
),
));
));
scaffoldKey
.
currentState
.
showBottomSheet
<
void
>((
BuildContext
context
)
{
scaffoldKey
.
currentState
!
.
showBottomSheet
<
void
>((
BuildContext
context
)
{
return
Container
(
return
Container
(
margin:
const
EdgeInsets
.
all
(
40.0
),
margin:
const
EdgeInsets
.
all
(
40.0
),
child:
const
Text
(
'BottomSheet'
),
child:
const
Text
(
'BottomSheet'
),
...
@@ -428,8 +426,8 @@ void main() {
...
@@ -428,8 +426,8 @@ void main() {
});
});
testWidgets
(
'modal BottomSheet has no top MediaQuery'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'modal BottomSheet has no top MediaQuery'
,
(
WidgetTester
tester
)
async
{
BuildContext
outerContext
;
late
BuildContext
outerContext
;
BuildContext
innerContext
;
late
BuildContext
innerContext
;
await
tester
.
pumpWidget
(
Localizations
(
await
tester
.
pumpWidget
(
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
locale:
const
Locale
(
'en'
,
'US'
),
...
@@ -469,11 +467,11 @@ void main() {
...
@@ -469,11 +467,11 @@ void main() {
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
expect
(
MediaQuery
.
of
(
outerContext
).
padding
,
MediaQuery
.
of
(
outerContext
)
!
.
padding
,
const
EdgeInsets
.
all
(
50.0
),
const
EdgeInsets
.
all
(
50.0
),
);
);
expect
(
expect
(
MediaQuery
.
of
(
innerContext
).
padding
,
MediaQuery
.
of
(
innerContext
)
!
.
padding
,
const
EdgeInsets
.
only
(
left:
50.0
,
right:
50.0
,
bottom:
50.0
),
const
EdgeInsets
.
only
(
left:
50.0
,
right:
50.0
,
bottom:
50.0
),
);
);
});
});
...
@@ -490,7 +488,7 @@ void main() {
...
@@ -490,7 +488,7 @@ void main() {
));
));
showModalBottomSheet
<
void
>(
context:
scaffoldKey
.
currentContext
,
builder:
(
BuildContext
context
)
{
showModalBottomSheet
<
void
>(
context:
scaffoldKey
.
currentContext
!
,
builder:
(
BuildContext
context
)
{
return
Container
(
return
Container
(
child:
const
Text
(
'BottomSheet'
),
child:
const
Text
(
'BottomSheet'
),
);
);
...
@@ -545,7 +543,7 @@ void main() {
...
@@ -545,7 +543,7 @@ void main() {
));
));
showModalBottomSheet
<
void
>(
showModalBottomSheet
<
void
>(
context:
scaffoldKey
.
currentContext
,
context:
scaffoldKey
.
currentContext
!
,
backgroundColor:
color
,
backgroundColor:
color
,
barrierColor:
barrierColor
,
barrierColor:
barrierColor
,
elevation:
elevation
,
elevation:
elevation
,
...
@@ -584,7 +582,7 @@ void main() {
...
@@ -584,7 +582,7 @@ void main() {
showModalBottomSheet
<
void
>(
showModalBottomSheet
<
void
>(
context:
scaffoldKey
.
currentContext
,
context:
scaffoldKey
.
currentContext
!
,
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
return
DraggableScrollableSheet
(
return
DraggableScrollableSheet
(
expand:
false
,
expand:
false
,
...
@@ -710,13 +708,13 @@ void main() {
...
@@ -710,13 +708,13 @@ void main() {
),
),
));
));
RouteSettings
retrievedRouteSettings
;
late
RouteSettings
retrievedRouteSettings
;
showModalBottomSheet
<
void
>(
showModalBottomSheet
<
void
>(
context:
scaffoldKey
.
currentContext
,
context:
scaffoldKey
.
currentContext
!
,
routeSettings:
routeSettings
,
routeSettings:
routeSettings
,
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
retrievedRouteSettings
=
ModalRoute
.
of
(
context
).
settings
;
retrievedRouteSettings
=
ModalRoute
.
of
(
context
)
!
.
settings
;
return
Container
(
return
Container
(
child:
const
Text
(
'BottomSheet'
),
child:
const
Text
(
'BottomSheet'
),
);
);
...
@@ -731,9 +729,9 @@ void main() {
...
@@ -731,9 +729,9 @@ void main() {
}
}
class
_TestPage
extends
StatelessWidget
{
class
_TestPage
extends
StatelessWidget
{
const
_TestPage
({
Key
key
,
this
.
useRootNavigator
})
:
super
(
key:
key
);
const
_TestPage
({
Key
?
key
,
this
.
useRootNavigator
})
:
super
(
key:
key
);
final
bool
useRootNavigator
;
final
bool
?
useRootNavigator
;
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
...
@@ -743,7 +741,7 @@ class _TestPage extends StatelessWidget {
...
@@ -743,7 +741,7 @@ class _TestPage extends StatelessWidget {
onPressed:
()
{
onPressed:
()
{
if
(
useRootNavigator
!=
null
)
{
if
(
useRootNavigator
!=
null
)
{
showModalBottomSheet
<
void
>(
showModalBottomSheet
<
void
>(
useRootNavigator:
useRootNavigator
,
useRootNavigator:
useRootNavigator
!
,
context:
context
,
context:
context
,
builder:
(
_
)
=>
const
Text
(
'Modal bottom sheet'
),
builder:
(
_
)
=>
const
Text
(
'Modal bottom sheet'
),
);
);
...
...
packages/flutter/test/material/bottom_sheet_theme_test.dart
View file @
c083f02f
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
...
...
packages/flutter/test/material/button_bar_test.dart
View file @
c083f02f
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -243,7 +241,7 @@ void main() {
...
@@ -243,7 +241,7 @@ void main() {
group
(
'button properties override ButtonTheme'
,
()
{
group
(
'button properties override ButtonTheme'
,
()
{
testWidgets
(
'default button properties override ButtonTheme properties'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'default button properties override ButtonTheme properties'
,
(
WidgetTester
tester
)
async
{
BuildContext
capturedContext
;
late
BuildContext
capturedContext
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
home:
ButtonBar
(
home:
ButtonBar
(
...
@@ -266,7 +264,7 @@ void main() {
...
@@ -266,7 +264,7 @@ void main() {
});
});
testWidgets
(
'ButtonBarTheme button properties override defaults and ButtonTheme properties'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ButtonBarTheme button properties override defaults and ButtonTheme properties'
,
(
WidgetTester
tester
)
async
{
BuildContext
capturedContext
;
late
BuildContext
capturedContext
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
home:
ButtonBarTheme
(
home:
ButtonBarTheme
(
...
@@ -299,7 +297,7 @@ void main() {
...
@@ -299,7 +297,7 @@ void main() {
});
});
testWidgets
(
'ButtonBar button properties override ButtonBarTheme, defaults and ButtonTheme properties'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ButtonBar button properties override ButtonBarTheme, defaults and ButtonTheme properties'
,
(
WidgetTester
tester
)
async
{
BuildContext
capturedContext
;
late
BuildContext
capturedContext
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
home:
ButtonBarTheme
(
home:
ButtonBarTheme
(
...
...
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