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
aaaf3741
Unverified
Commit
aaaf3741
authored
Oct 15, 2020
by
Michael Goderbauer
Committed by
GitHub
Oct 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate last batch of tests (#68163)
parent
bf6460f9
Changes
11
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
293 additions
and
311 deletions
+293
-311
tweens.dart
packages/flutter/lib/src/rendering/tweens.dart
+2
-2
value_listenable_builder.dart
...ges/flutter/lib/src/widgets/value_listenable_builder.dart
+2
-2
transitions_test.dart
packages/flutter/test/widgets/transitions_test.dart
+16
-18
tween_animation_builder_test.dart
...es/flutter/test/widgets/tween_animation_builder_test.dart
+23
-25
unique_widget_test.dart
packages/flutter/test/widgets/unique_widget_test.dart
+2
-4
value_listenable_builder_test.dart
...s/flutter/test/widgets/value_listenable_builder_test.dart
+9
-11
visibility_test.dart
packages/flutter/test/widgets/visibility_test.dart
+1
-3
widget_inspector_init_with_structured_error_test.dart
...ets/widget_inspector_init_with_structured_error_test.dart
+3
-5
widget_inspector_structure_error_test.dart
...r/test/widgets/widget_inspector_structure_error_test.dart
+13
-15
widget_inspector_test.dart
packages/flutter/test/widgets/widget_inspector_test.dart
+222
-224
wrap_test.dart
packages/flutter/test/widgets/wrap_test.dart
+0
-2
No files found.
packages/flutter/lib/src/rendering/tweens.dart
View file @
aaaf3741
...
...
@@ -39,7 +39,7 @@ class FractionalOffsetTween extends Tween<FractionalOffset?> {
///
/// * [AlignmentGeometryTween], which interpolates between two
/// [AlignmentGeometry] objects.
class
AlignmentTween
extends
Tween
<
Alignment
?
>
{
class
AlignmentTween
extends
Tween
<
Alignment
>
{
/// Creates a fractional offset tween.
///
/// The [begin] and [end] properties may be null; the null value
...
...
@@ -49,7 +49,7 @@ class AlignmentTween extends Tween<Alignment?> {
/// Returns the value this variable has at the given animation clock value.
@override
Alignment
?
lerp
(
double
t
)
=>
Alignment
.
lerp
(
begin
,
end
,
t
)
;
Alignment
lerp
(
double
t
)
=>
Alignment
.
lerp
(
begin
,
end
,
t
)!
;
}
/// An interpolation between two [AlignmentGeometry].
...
...
packages/flutter/lib/src/widgets/value_listenable_builder.dart
View file @
aaaf3741
...
...
@@ -16,7 +16,7 @@ import 'framework.dart';
///
/// * [ValueListenableBuilder], a widget which invokes this builder each time
/// a [ValueListenable] changes value.
typedef
ValueWidgetBuilder
<
T
>
=
Widget
Function
(
BuildContext
context
,
T
?
value
,
Widget
?
child
);
typedef
ValueWidgetBuilder
<
T
>
=
Widget
Function
(
BuildContext
context
,
T
value
,
Widget
?
child
);
/// A widget whose content stays synced with a [ValueListenable].
///
...
...
@@ -153,7 +153,7 @@ class ValueListenableBuilder<T> extends StatefulWidget {
}
class
_ValueListenableBuilderState
<
T
>
extends
State
<
ValueListenableBuilder
<
T
>>
{
T
?
value
;
late
T
value
;
@override
void
initState
()
{
...
...
packages/flutter/test/widgets/transitions_test.dart
View file @
aaaf3741
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'dart:math'
as
math
;
import
'package:flutter/material.dart'
;
...
...
@@ -50,7 +48,7 @@ void main() {
),
);
AnimationController
controller
;
late
AnimationController
controller
;
setUp
(()
{
controller
=
AnimationController
(
vsync:
const
TestVSync
());
...
...
@@ -71,9 +69,9 @@ void main() {
BoxDecoration
actualDecoration
=
actualBox
.
decoration
as
BoxDecoration
;
expect
(
actualDecoration
.
color
,
const
Color
(
0xFFFFFFFF
));
expect
(
actualDecoration
.
boxShadow
[
0
].
blurRadius
,
10.0
);
expect
(
actualDecoration
.
boxShadow
[
0
].
spreadRadius
,
4.0
);
expect
(
actualDecoration
.
boxShadow
[
0
].
color
,
const
Color
(
0x66000000
));
expect
(
actualDecoration
.
boxShadow
!
[
0
].
blurRadius
,
10.0
);
expect
(
actualDecoration
.
boxShadow
!
[
0
].
spreadRadius
,
4.0
);
expect
(
actualDecoration
.
boxShadow
!
[
0
].
color
,
const
Color
(
0x66000000
));
controller
.
value
=
0.5
;
...
...
@@ -83,16 +81,16 @@ void main() {
expect
(
actualDecoration
.
color
,
const
Color
(
0xFF7F7F7F
));
expect
(
actualDecoration
.
border
,
isA
<
Border
>());
final
Border
border
=
actualDecoration
.
border
as
Border
;
final
Border
border
=
actualDecoration
.
border
!
as
Border
;
expect
(
border
.
left
.
width
,
2.5
);
expect
(
border
.
left
.
style
,
BorderStyle
.
solid
);
expect
(
border
.
left
.
color
,
const
Color
(
0xFF101010
));
expect
(
actualDecoration
.
borderRadius
,
BorderRadius
.
circular
(
5.0
));
expect
(
actualDecoration
.
shape
,
BoxShape
.
rectangle
);
expect
(
actualDecoration
.
boxShadow
[
0
].
blurRadius
,
5.0
);
expect
(
actualDecoration
.
boxShadow
[
0
].
spreadRadius
,
2.0
);
expect
(
actualDecoration
.
boxShadow
!
[
0
].
blurRadius
,
5.0
);
expect
(
actualDecoration
.
boxShadow
!
[
0
].
spreadRadius
,
2.0
);
// Scaling a shadow doesn't change the color.
expect
(
actualDecoration
.
boxShadow
[
0
].
color
,
const
Color
(
0x66000000
));
expect
(
actualDecoration
.
boxShadow
!
[
0
].
color
,
const
Color
(
0x66000000
));
controller
.
value
=
1.0
;
...
...
@@ -126,9 +124,9 @@ void main() {
BoxDecoration
actualDecoration
=
actualBox
.
decoration
as
BoxDecoration
;
expect
(
actualDecoration
.
color
,
const
Color
(
0xFFFFFFFF
));
expect
(
actualDecoration
.
boxShadow
[
0
].
blurRadius
,
10.0
);
expect
(
actualDecoration
.
boxShadow
[
0
].
spreadRadius
,
4.0
);
expect
(
actualDecoration
.
boxShadow
[
0
].
color
,
const
Color
(
0x66000000
));
expect
(
actualDecoration
.
boxShadow
!
[
0
].
blurRadius
,
10.0
);
expect
(
actualDecoration
.
boxShadow
!
[
0
].
spreadRadius
,
4.0
);
expect
(
actualDecoration
.
boxShadow
!
[
0
].
color
,
const
Color
(
0x66000000
));
controller
.
value
=
0.5
;
...
...
@@ -140,16 +138,16 @@ void main() {
// tween's end values given the easeOut curve.
expect
(
actualDecoration
.
color
,
const
Color
(
0xFF505050
));
expect
(
actualDecoration
.
border
,
isA
<
Border
>());
final
Border
border
=
actualDecoration
.
border
as
Border
;
final
Border
border
=
actualDecoration
.
border
!
as
Border
;
expect
(
border
.
left
.
width
,
moreOrLessEquals
(
1.9
,
epsilon:
0.1
));
expect
(
border
.
left
.
style
,
BorderStyle
.
solid
);
expect
(
border
.
left
.
color
,
const
Color
(
0xFF151515
));
expect
(
actualDecoration
.
borderRadius
.
resolve
(
TextDirection
.
ltr
).
topLeft
.
x
,
moreOrLessEquals
(
6.8
,
epsilon:
0.1
));
expect
(
actualDecoration
.
borderRadius
!
.
resolve
(
TextDirection
.
ltr
).
topLeft
.
x
,
moreOrLessEquals
(
6.8
,
epsilon:
0.1
));
expect
(
actualDecoration
.
shape
,
BoxShape
.
rectangle
);
expect
(
actualDecoration
.
boxShadow
[
0
].
blurRadius
,
moreOrLessEquals
(
3.1
,
epsilon:
0.1
));
expect
(
actualDecoration
.
boxShadow
[
0
].
spreadRadius
,
moreOrLessEquals
(
1.2
,
epsilon:
0.1
));
expect
(
actualDecoration
.
boxShadow
!
[
0
].
blurRadius
,
moreOrLessEquals
(
3.1
,
epsilon:
0.1
));
expect
(
actualDecoration
.
boxShadow
!
[
0
].
spreadRadius
,
moreOrLessEquals
(
1.2
,
epsilon:
0.1
));
// Scaling a shadow doesn't change the color.
expect
(
actualDecoration
.
boxShadow
[
0
].
color
,
const
Color
(
0x66000000
));
expect
(
actualDecoration
.
boxShadow
!
[
0
].
color
,
const
Color
(
0x66000000
));
});
});
...
...
packages/flutter/test/widgets/tween_animation_builder_test.dart
View file @
aaaf3741
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
@@ -15,7 +13,7 @@ void main() {
TweenAnimationBuilder
<
int
>(
duration:
const
Duration
(
seconds:
1
),
tween:
IntTween
(
begin:
10
,
end:
110
),
builder:
(
BuildContext
context
,
int
i
,
Widget
child
)
{
builder:
(
BuildContext
context
,
int
i
,
Widget
?
child
)
{
values
.
add
(
i
);
return
const
Placeholder
();
},
...
...
@@ -46,7 +44,7 @@ void main() {
TweenAnimationBuilder
<
int
>(
duration:
const
Duration
(
seconds:
1
),
tween:
IntTween
(
end:
100
),
builder:
(
BuildContext
context
,
int
i
,
Widget
child
)
{
builder:
(
BuildContext
context
,
int
i
,
Widget
?
child
)
{
values
.
add
(
i
);
return
const
Placeholder
();
},
...
...
@@ -70,7 +68,7 @@ void main() {
TweenAnimationBuilder
<
int
>(
duration:
const
Duration
(
seconds:
1
),
tween:
IntTween
(
begin:
100
,
end:
100
),
builder:
(
BuildContext
context
,
int
i
,
Widget
child
)
{
builder:
(
BuildContext
context
,
int
i
,
Widget
?
child
)
{
values
.
add
(
i
);
return
const
Placeholder
();
},
...
...
@@ -88,11 +86,11 @@ void main() {
testWidgets
(
'Replace tween animates new tween'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
values
=
<
int
>[];
Widget
buildWidget
({
IntTween
tween
})
{
Widget
buildWidget
({
required
IntTween
tween
})
{
return
TweenAnimationBuilder
<
int
>(
duration:
const
Duration
(
seconds:
1
),
tween:
tween
,
builder:
(
BuildContext
context
,
int
i
,
Widget
child
)
{
builder:
(
BuildContext
context
,
int
i
,
Widget
?
child
)
{
values
.
add
(
i
);
return
const
Placeholder
();
},
...
...
@@ -116,12 +114,12 @@ void main() {
testWidgets
(
'Curve is respected'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
values
=
<
int
>[];
Widget
buildWidget
({
IntTween
tween
,
Curve
curve
})
{
Widget
buildWidget
({
required
IntTween
tween
,
required
Curve
curve
})
{
return
TweenAnimationBuilder
<
int
>(
duration:
const
Duration
(
seconds:
1
),
tween:
tween
,
curve:
curve
,
builder:
(
BuildContext
context
,
int
i
,
Widget
child
)
{
builder:
(
BuildContext
context
,
int
i
,
Widget
?
child
)
{
values
.
add
(
i
);
return
const
Placeholder
();
},
...
...
@@ -146,11 +144,11 @@ void main() {
testWidgets
(
'Duration is respected'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
values
=
<
int
>[];
Widget
buildWidget
({
IntTween
tween
,
Duration
duration
})
{
Widget
buildWidget
({
required
IntTween
tween
,
required
Duration
duration
})
{
return
TweenAnimationBuilder
<
int
>(
tween:
tween
,
duration:
duration
,
builder:
(
BuildContext
context
,
int
i
,
Widget
child
)
{
builder:
(
BuildContext
context
,
int
i
,
Widget
?
child
)
{
values
.
add
(
i
);
return
const
Placeholder
();
},
...
...
@@ -179,8 +177,8 @@ void main() {
child:
TweenAnimationBuilder
<
int
>(
tween:
IntTween
(
begin:
0
,
end:
100
),
duration:
const
Duration
(
seconds:
1
),
builder:
(
BuildContext
context
,
int
i
,
Widget
child
)
{
return
child
;
builder:
(
BuildContext
context
,
int
i
,
Widget
?
child
)
{
return
child
!
;
},
child:
const
Text
(
'Hello World'
),
),
...
...
@@ -193,11 +191,11 @@ void main() {
group
(
'Change tween gapless while'
,
()
{
testWidgets
(
'running forward'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
values
=
<
int
>[];
Widget
buildWidget
({
IntTween
tween
})
{
Widget
buildWidget
({
required
IntTween
tween
})
{
return
TweenAnimationBuilder
<
int
>(
tween:
tween
,
duration:
const
Duration
(
seconds:
1
),
builder:
(
BuildContext
context
,
int
i
,
Widget
child
)
{
builder:
(
BuildContext
context
,
int
i
,
Widget
?
child
)
{
values
.
add
(
i
);
return
const
Placeholder
();
},
...
...
@@ -228,11 +226,11 @@ void main() {
testWidgets
(
'running forward and then reverse with same tween instance'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
values
=
<
int
>[];
Widget
buildWidget
({
IntTween
tween
})
{
Widget
buildWidget
({
required
IntTween
tween
})
{
return
TweenAnimationBuilder
<
int
>(
tween:
tween
,
duration:
const
Duration
(
seconds:
1
),
builder:
(
BuildContext
context
,
int
i
,
Widget
child
)
{
builder:
(
BuildContext
context
,
int
i
,
Widget
?
child
)
{
values
.
add
(
i
);
return
const
Placeholder
();
},
...
...
@@ -258,11 +256,11 @@ void main() {
testWidgets
(
'Changing tween while gapless tween change is in progress'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
values
=
<
int
>[];
Widget
buildWidget
({
IntTween
tween
})
{
Widget
buildWidget
({
required
IntTween
tween
})
{
return
TweenAnimationBuilder
<
int
>(
tween:
tween
,
duration:
const
Duration
(
seconds:
1
),
builder:
(
BuildContext
context
,
int
i
,
Widget
child
)
{
builder:
(
BuildContext
context
,
int
i
,
Widget
?
child
)
{
values
.
add
(
i
);
return
const
Placeholder
();
},
...
...
@@ -298,12 +296,12 @@ void main() {
testWidgets
(
'Changing curve while no animation is running does not trigger animation'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
values
=
<
int
>[];
Widget
buildWidget
({
Curve
curve
})
{
Widget
buildWidget
({
required
Curve
curve
})
{
return
TweenAnimationBuilder
<
int
>(
tween:
IntTween
(
begin:
0
,
end:
100
),
curve:
curve
,
duration:
const
Duration
(
seconds:
1
),
builder:
(
BuildContext
context
,
int
i
,
Widget
child
)
{
builder:
(
BuildContext
context
,
int
i
,
Widget
?
child
)
{
values
.
add
(
i
);
return
const
Placeholder
();
},
...
...
@@ -327,11 +325,11 @@ void main() {
testWidgets
(
'Setting same tween and direction does not trigger animation'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
values
=
<
int
>[];
Widget
buildWidget
({
IntTween
tween
})
{
Widget
buildWidget
({
required
IntTween
tween
})
{
return
TweenAnimationBuilder
<
int
>(
tween:
tween
,
duration:
const
Duration
(
seconds:
1
),
builder:
(
BuildContext
context
,
int
i
,
Widget
child
)
{
builder:
(
BuildContext
context
,
int
i
,
Widget
?
child
)
{
values
.
add
(
i
);
return
const
Placeholder
();
},
...
...
@@ -356,11 +354,11 @@ void main() {
testWidgets
(
'Setting same tween and direction while gapless animation is in progress works'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
values
=
<
int
>[];
Widget
buildWidget
({
IntTween
tween
})
{
Widget
buildWidget
({
required
IntTween
tween
})
{
return
TweenAnimationBuilder
<
int
>(
tween:
tween
,
duration:
const
Duration
(
seconds:
1
),
builder:
(
BuildContext
context
,
int
i
,
Widget
child
)
{
builder:
(
BuildContext
context
,
int
i
,
Widget
?
child
)
{
values
.
add
(
i
);
return
const
Placeholder
();
},
...
...
packages/flutter/test/widgets/unique_widget_test.dart
View file @
aaaf3741
...
...
@@ -2,13 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
class
TestUniqueWidget
extends
UniqueWidget
<
TestUniqueWidgetState
>
{
const
TestUniqueWidget
({
GlobalKey
<
TestUniqueWidgetState
>
key
})
:
super
(
key:
key
);
const
TestUniqueWidget
({
required
GlobalKey
<
TestUniqueWidgetState
>
key
})
:
super
(
key:
key
);
@override
TestUniqueWidgetState
createState
()
=>
TestUniqueWidgetState
();
...
...
@@ -25,7 +23,7 @@ void main() {
await
tester
.
pumpWidget
(
widget
);
final
TestUniqueWidgetState
state
=
widget
.
currentState
;
final
TestUniqueWidgetState
state
=
widget
.
currentState
!
;
expect
(
state
,
isNotNull
);
...
...
packages/flutter/test/widgets/value_listenable_builder_test.dart
View file @
aaaf3741
...
...
@@ -2,24 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/widgets.dart'
;
void
main
(
)
{
SpyStringValueNotifier
valueListenable
;
Widget
textBuilderUnderTest
;
late
SpyStringValueNotifier
valueListenable
;
late
Widget
textBuilderUnderTest
;
Widget
builderForValueListenable
(
ValueListenable
<
String
>
valueListenable
,
ValueListenable
<
String
?
>
valueListenable
,
)
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
ValueListenableBuilder
<
String
>(
child:
ValueListenableBuilder
<
String
?
>(
valueListenable:
valueListenable
,
builder:
(
BuildContext
context
,
String
value
,
Widget
child
)
{
builder:
(
BuildContext
context
,
String
?
value
,
Widget
?
child
)
{
if
(
value
==
null
)
return
const
Placeholder
();
return
Text
(
value
);
...
...
@@ -67,7 +65,7 @@ void main() {
await
tester
.
pump
();
expect
(
find
.
text
(
'Gilfoyle'
),
findsOneWidget
);
final
ValueListenable
<
String
>
differentListenable
=
final
ValueListenable
<
String
?
>
differentListenable
=
SpyStringValueNotifier
(
'Hendricks'
);
await
tester
.
pumpWidget
(
builderForValueListenable
(
differentListenable
));
...
...
@@ -83,7 +81,7 @@ void main() {
await
tester
.
pump
();
expect
(
find
.
text
(
'Gilfoyle'
),
findsOneWidget
);
final
ValueListenable
<
String
>
differentListenable
=
final
ValueListenable
<
String
?
>
differentListenable
=
SpyStringValueNotifier
(
'Hendricks'
);
await
tester
.
pumpWidget
(
builderForValueListenable
(
differentListenable
));
...
...
@@ -113,8 +111,8 @@ void main() {
});
}
class
SpyStringValueNotifier
extends
ValueNotifier
<
String
>
{
SpyStringValueNotifier
(
String
initialValue
)
:
super
(
initialValue
);
class
SpyStringValueNotifier
extends
ValueNotifier
<
String
?
>
{
SpyStringValueNotifier
(
String
?
initialValue
)
:
super
(
initialValue
);
/// Override for test visibility only.
@override
...
...
packages/flutter/test/widgets/visibility_test.dart
View file @
aaaf3741
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -11,7 +9,7 @@ import '../rendering/mock_canvas.dart';
import
'semantics_tester.dart'
;
class
TestState
extends
StatefulWidget
{
const
TestState
({
Key
key
,
this
.
child
,
this
.
log
})
:
super
(
key:
key
);
const
TestState
({
Key
?
key
,
required
this
.
child
,
required
this
.
log
})
:
super
(
key:
key
);
final
Widget
child
;
final
List
<
String
>
log
;
@override
...
...
packages/flutter/test/widgets/widget_inspector_init_with_structured_error_test.dart
View file @
aaaf3741
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -25,8 +23,8 @@ class StructuredErrorTestService extends TestWidgetInspectorService {
static
void
runTests
()
{
final
StructuredErrorTestService
service
=
StructuredErrorTestService
();
WidgetInspectorService
.
instance
=
service
;
FlutterExceptionHandler
testHandler
;
FlutterExceptionHandler
inspectorServiceErrorHandler
;
FlutterExceptionHandler
?
testHandler
;
FlutterExceptionHandler
?
inspectorServiceErrorHandler
;
setUpAll
(()
{
inspectorServiceErrorHandler
=
FlutterError
.
onError
;
...
...
@@ -42,7 +40,7 @@ class StructuredErrorTestService extends TestWidgetInspectorService {
// what it was after WidgetInspectorService::initServiceExtensions ran.
FlutterError
.
onError
=
inspectorServiceErrorHandler
;
List
<
Map
<
Object
,
Object
>>
flutterErrorEvents
=
List
<
Map
<
Object
,
Object
?
>>
flutterErrorEvents
=
service
.
getEventsDispatched
(
'Flutter.Error'
);
expect
(
flutterErrorEvents
,
hasLength
(
0
));
...
...
packages/flutter/test/widgets/widget_inspector_structure_error_test.dart
View file @
aaaf3741
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:convert'
;
...
...
@@ -16,41 +14,41 @@ void main() {
StructureErrorTestWidgetInspectorService
.
runTests
();
}
typedef
InspectorServiceExtensionCallback
=
FutureOr
<
Map
<
String
,
Object
>>
Function
(
Map
<
String
,
String
>
parameters
);
typedef
InspectorServiceExtensionCallback
=
FutureOr
<
Map
<
String
,
Object
?
>>
Function
(
Map
<
String
,
String
>
parameters
);
class
StructureErrorTestWidgetInspectorService
extends
Object
with
WidgetInspectorService
{
final
Map
<
String
,
InspectorServiceExtensionCallback
>
extensions
=
<
String
,
InspectorServiceExtensionCallback
>{};
final
Map
<
String
,
List
<
Map
<
Object
,
Object
>>>
eventsDispatched
=
<
String
,
List
<
Map
<
Object
,
Object
>>>{};
final
Map
<
String
,
List
<
Map
<
Object
,
Object
?>>>
eventsDispatched
=
<
String
,
List
<
Map
<
Object
,
Object
?
>>>{};
@override
void
registerServiceExtension
({
@
required
String
name
,
@required
FutureOr
<
Map
<
String
,
Object
>>
callback
(
Map
<
String
,
String
>
parameters
),
required
String
name
,
required
FutureOr
<
Map
<
String
,
Object
?
>>
callback
(
Map
<
String
,
String
>
parameters
),
})
{
assert
(!
extensions
.
containsKey
(
name
));
extensions
[
name
]
=
callback
;
}
@override
void
postEvent
(
String
eventKind
,
Map
<
Object
,
Object
>
eventData
)
{
void
postEvent
(
String
eventKind
,
Map
<
Object
,
Object
?
>
eventData
)
{
getEventsDispatched
(
eventKind
).
add
(
eventData
);
}
List
<
Map
<
Object
,
Object
>>
getEventsDispatched
(
String
eventKind
)
{
return
eventsDispatched
.
putIfAbsent
(
eventKind
,
()
=>
<
Map
<
Object
,
Object
>>[]);
List
<
Map
<
Object
,
Object
?
>>
getEventsDispatched
(
String
eventKind
)
{
return
eventsDispatched
.
putIfAbsent
(
eventKind
,
()
=>
<
Map
<
Object
,
Object
?
>>[]);
}
Iterable
<
Map
<
Object
,
Object
>>
getServiceExtensionStateChangedEvents
(
String
extensionName
)
{
Iterable
<
Map
<
Object
,
Object
?
>>
getServiceExtensionStateChangedEvents
(
String
extensionName
)
{
return
getEventsDispatched
(
'Flutter.ServiceExtensionStateChanged'
)
.
where
((
Map
<
Object
,
Object
>
event
)
=>
event
[
'extension'
]
==
extensionName
);
.
where
((
Map
<
Object
,
Object
?
>
event
)
=>
event
[
'extension'
]
==
extensionName
);
}
Future
<
String
>
testBoolExtension
(
String
name
,
Map
<
String
,
String
>
arguments
)
async
{
expect
(
extensions
,
contains
(
name
));
// Encode and decode to JSON to match behavior using a real service
// extension where only JSON is allowed.
return
json
.
decode
(
json
.
encode
(
await
extensions
[
name
](
arguments
)))[
'enabled'
]
as
String
;
return
json
.
decode
(
json
.
encode
(
await
extensions
[
name
]
!
(
arguments
)))[
'enabled'
]
as
String
;
}
...
...
@@ -59,9 +57,9 @@ class StructureErrorTestWidgetInspectorService extends Object with WidgetInspect
WidgetInspectorService
.
instance
=
service
;
test
(
'ext.flutter.inspector.structuredErrors still report error to original on error'
,
()
async
{
final
FlutterExceptionHandler
oldHandler
=
FlutterError
.
onError
;
final
FlutterExceptionHandler
?
oldHandler
=
FlutterError
.
onError
;
FlutterErrorDetails
actualError
;
late
FlutterErrorDetails
actualError
;
// Creates a spy onError. This spy needs to be set before widgets binding
// initializes.
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
...
...
packages/flutter/test/widgets/widget_inspector_test.dart
View file @
aaaf3741
This diff is collapsed.
Click to expand it.
packages/flutter/test/widgets/wrap_test.dart
View file @
aaaf3741
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
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