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
5e97eed8
Unverified
Commit
5e97eed8
authored
Oct 05, 2020
by
Tong Mu
Committed by
GitHub
Oct 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate foundation test to nullsafety (#62616)
* Migrate
parent
8485580b
Changes
35
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
147 additions
and
231 deletions
+147
-231
diagnostics.dart
packages/flutter/lib/src/foundation/diagnostics.dart
+11
-10
binding.dart
packages/flutter/lib/src/semantics/binding.dart
+0
-1
animation_controller_test.dart
...ges/flutter/test/animation/animation_controller_test.dart
+4
-6
animation_sheet_test.dart
packages/flutter/test/animation/animation_sheet_test.dart
+4
-6
animations_test.dart
packages/flutter/test/animation/animations_test.dart
+3
-5
curves_test.dart
packages/flutter/test/animation/curves_test.dart
+0
-14
futures_test.dart
packages/flutter/test/animation/futures_test.dart
+0
-2
iteration_patterns_test.dart
packages/flutter/test/animation/iteration_patterns_test.dart
+5
-7
tween_test.dart
packages/flutter/test/animation/tween_test.dart
+0
-2
assertions_test.dart
packages/flutter/test/foundation/assertions_test.dart
+2
-4
bit_field_test.dart
packages/flutter/test/foundation/bit_field_test.dart
+0
-2
caching_iterable_test.dart
packages/flutter/test/foundation/caching_iterable_test.dart
+1
-3
capture_output.dart
packages/flutter/test/foundation/capture_output.dart
+0
-2
change_notifier_test.dart
packages/flutter/test/foundation/change_notifier_test.dart
+8
-10
collections_test.dart
packages/flutter/test/foundation/collections_test.dart
+6
-13
consolidate_response_test.dart
...es/flutter/test/foundation/consolidate_response_test.dart
+15
-17
constants_test.dart
packages/flutter/test/foundation/constants_test.dart
+0
-2
covariant_templates_test.dart
...ges/flutter/test/foundation/covariant_templates_test.dart
+1
-3
debug_test.dart
packages/flutter/test/foundation/debug_test.dart
+3
-5
defines_test.dart
packages/flutter/test/foundation/defines_test.dart
+0
-2
diagnostics_json_test.dart
packages/flutter/test/foundation/diagnostics_json_test.dart
+32
-30
diagnostics_test.dart
packages/flutter/test/foundation/diagnostics_test.dart
+20
-23
double_precision_test.dart
packages/flutter/test/foundation/double_precision_test.dart
+0
-2
error_reporting_test.dart
packages/flutter/test/foundation/error_reporting_test.dart
+3
-5
isolates_test.dart
packages/flutter/test/foundation/isolates_test.dart
+0
-2
licenses_test.dart
packages/flutter/test/foundation/licenses_test.dart
+9
-11
observer_list_test.dart
packages/flutter/test/foundation/observer_list_test.dart
+0
-2
platform_helper.dart
packages/flutter/test/foundation/platform_helper.dart
+0
-2
print_test.dart
packages/flutter/test/foundation/print_test.dart
+0
-1
reassemble_test.dart
packages/flutter/test/foundation/reassemble_test.dart
+1
-5
serialization_test.dart
packages/flutter/test/foundation/serialization_test.dart
+0
-2
service_extensions_test.dart
...ages/flutter/test/foundation/service_extensions_test.dart
+15
-20
stack_frame_test.dart
packages/flutter/test/foundation/stack_frame_test.dart
+0
-2
stack_trace_test.dart
packages/flutter/test/foundation/stack_trace_test.dart
+0
-2
synchronous_future_test.dart
...ages/flutter/test/foundation/synchronous_future_test.dart
+4
-6
No files found.
packages/flutter/lib/src/foundation/diagnostics.dart
View file @
5e97eed8
...
...
@@ -1897,7 +1897,7 @@ abstract class _NumProperty<T extends num> extends DiagnosticsProperty<T> {
_NumProperty
.
lazy
(
String
name
,
ComputePropertyValueCallback
<
T
>
computeValue
,
{
ComputePropertyValueCallback
<
T
?
>
computeValue
,
{
String
?
ifNull
,
this
.
unit
,
bool
showName
=
true
,
...
...
@@ -1984,7 +1984,7 @@ class DoubleProperty extends _NumProperty<double> {
/// The [showName] and [level] arguments must not be null.
DoubleProperty
.
lazy
(
String
name
,
ComputePropertyValueCallback
<
double
>
computeValue
,
{
ComputePropertyValueCallback
<
double
?
>
computeValue
,
{
String
?
ifNull
,
bool
showName
=
true
,
String
?
unit
,
...
...
@@ -2480,7 +2480,7 @@ class ObjectFlagProperty<T> extends DiagnosticsProperty<T> {
/// only one flag, and is preferred if there is only one entry.
/// * [IterableProperty], which provides similar functionality describing
/// the values a collection of objects.
class
FlagsSummary
<
T
>
extends
DiagnosticsProperty
<
Map
<
String
,
T
>>
{
class
FlagsSummary
<
T
>
extends
DiagnosticsProperty
<
Map
<
String
,
T
?
>>
{
/// Create a summary for multiple properties, indicating whether each of them
/// is present (non-null) or absent (null).
///
...
...
@@ -2488,7 +2488,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
/// null.
FlagsSummary
(
String
name
,
Map
<
String
,
T
>
value
,
{
Map
<
String
,
T
?
>
value
,
{
String
?
ifEmpty
,
bool
showName
=
true
,
bool
showSeparator
=
true
,
...
...
@@ -2507,7 +2507,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
);
@override
Map
<
String
,
T
>
get
value
=>
super
.
value
!;
Map
<
String
,
T
?
>
get
value
=>
super
.
value
!;
@override
String
valueToString
({
TextTreeConfiguration
?
parentConfiguration
})
{
...
...
@@ -2545,7 +2545,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
return
json
;
}
bool
_hasNonNullEntry
()
=>
value
.
values
.
any
((
T
o
)
=>
o
!=
null
);
bool
_hasNonNullEntry
()
=>
value
.
values
.
any
((
T
?
o
)
=>
o
!=
null
);
// An iterable of each entry's description in [value].
//
...
...
@@ -2554,7 +2554,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
// For a null value, it is omitted unless `includeEmtpy` is true and
// [ifEntryNull] contains a corresponding description.
Iterable
<
String
>
_formattedValues
()
sync
*
{
for
(
final
MapEntry
<
String
,
T
>
entry
in
value
.
entries
)
{
for
(
final
MapEntry
<
String
,
T
?
>
entry
in
value
.
entries
)
{
if
(
entry
.
value
!=
null
)
{
yield
entry
.
key
;
}
...
...
@@ -2567,7 +2567,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
/// May throw exception if accessing the property would throw an exception
/// and callers must handle that case gracefully. For example, accessing a
/// property may trigger an assert that layout constraints were violated.
typedef
ComputePropertyValueCallback
<
T
>
=
T
Function
();
typedef
ComputePropertyValueCallback
<
T
>
=
T
?
Function
();
/// Property with a [value] of type [T].
///
...
...
@@ -2651,7 +2651,7 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
})
:
assert
(
showName
!=
null
),
assert
(
showSeparator
!=
null
),
assert
(
defaultValue
==
kNoDefaultValue
||
defaultValue
is
T
),
assert
(
defaultValue
==
kNoDefaultValue
||
defaultValue
is
T
?
),
assert
(
missingIfNull
!=
null
),
assert
(
style
!=
null
),
assert
(
level
!=
null
),
...
...
@@ -2848,7 +2848,8 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
/// of the property is downgraded to [DiagnosticLevel.fine] as the property
/// value is uninteresting.
///
/// [defaultValue] has type [T] or is [kNoDefaultValue].
/// The [defaultValue] is [kNoDefaultValue] by default. Otherwise it must be of
/// type `T?`.
final
Object
?
defaultValue
;
final
DiagnosticLevel
_defaultLevel
;
...
...
packages/flutter/lib/src/semantics/binding.dart
View file @
5e97eed8
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
show
AccessibilityFeatures
,
SemanticsUpdateBuilder
;
import
'package:flutter/foundation.dart'
;
...
...
packages/flutter/test/animation/animation_controller_test.dart
View file @
5e97eed8
...
...
@@ -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:ui'
as
ui
;
import
'package:flutter/foundation.dart'
;
...
...
@@ -19,7 +17,7 @@ import '../scheduler/scheduler_tester.dart';
void
main
(
)
{
setUp
(()
{
WidgetsFlutterBinding
.
ensureInitialized
();
WidgetsBinding
.
instance
.
resetEpoch
();
WidgetsBinding
.
instance
!
.
resetEpoch
();
ui
.
window
.
onBeginFrame
=
null
;
ui
.
window
.
onDrawFrame
=
null
;
});
...
...
@@ -350,7 +348,7 @@ void main() {
expect
(
controller
.
repeat
,
throwsFlutterError
);
controller
.
dispose
();
FlutterError
result
;
FlutterError
?
result
;
try
{
controller
.
dispose
();
}
on
FlutterError
catch
(
e
)
{
...
...
@@ -358,7 +356,7 @@ void main() {
}
expect
(
result
,
isNotNull
);
expect
(
result
.
toStringDeep
(),
result
!
.
toStringDeep
(),
equalsIgnoringHashCodes
(
'FlutterError
\n
'
' AnimationController.dispose() called more than once.
\n
'
...
...
@@ -482,7 +480,7 @@ void main() {
controller
.
forward
(
from:
0.2
);
expect
(
controller
.
value
,
0.2
);
controller
.
animateTo
(
1.0
,
duration:
Duration
.
zero
);
expect
(
SchedulerBinding
.
instance
.
transientCallbackCount
,
equals
(
0
),
reason:
'Expected no animation.'
);
expect
(
SchedulerBinding
.
instance
!
.
transientCallbackCount
,
equals
(
0
),
reason:
'Expected no animation.'
);
expect
(
controller
.
value
,
1.0
);
});
...
...
packages/flutter/test/animation/animation_sheet_test.dart
View file @
5e97eed8
...
...
@@ -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:ui'
;
import
'package:flutter/cupertino.dart'
;
...
...
@@ -84,8 +82,8 @@ class _DecuplePixels extends StatefulWidget {
State
<
StatefulWidget
>
createState
()
=>
_DecuplePixelsState
();
}
class
_DecuplePixelsState
extends
State
<
_DecuplePixels
>
with
SingleTickerProviderStateMixin
{
AnimationController
_controller
;
class
_DecuplePixelsState
extends
State
<
_DecuplePixels
>
with
SingleTickerProviderStateMixin
<
_DecuplePixels
>
{
late
AnimationController
_controller
;
@override
void
initState
()
{
...
...
@@ -107,7 +105,7 @@ class _DecuplePixelsState extends State<_DecuplePixels> with SingleTickerProvide
Widget
build
(
BuildContext
context
)
{
return
AnimatedBuilder
(
animation:
_controller
.
view
,
builder:
(
BuildContext
context
,
Widget
child
)
{
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
CustomPaint
(
painter:
_PaintDecuplePixels
(
_controller
.
value
),
);
...
...
@@ -132,7 +130,7 @@ class _PaintDecuplePixels extends CustomPainter {
final
Rect
rect
=
RectTween
(
begin:
const
Rect
.
fromLTWH
(
1
,
1
,
1
,
1
),
end:
const
Rect
.
fromLTWH
(
11
,
1
,
1
,
1
),
).
transform
(
value
);
).
transform
(
value
)
!
;
canvas
.
drawRect
(
rect
,
Paint
()..
color
=
Colors
.
yellow
);
final
Paint
black
=
Paint
()..
color
=
Colors
.
black
;
canvas
...
...
packages/flutter/test/animation/animations_test.dart
View file @
5e97eed8
...
...
@@ -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:ui'
as
ui
;
import
'package:flutter/foundation.dart'
;
...
...
@@ -21,7 +19,7 @@ class BogusCurve extends Curve {
void
main
(
)
{
setUp
(()
{
WidgetsFlutterBinding
.
ensureInitialized
();
WidgetsBinding
.
instance
.
resetEpoch
();
WidgetsBinding
.
instance
!
.
resetEpoch
();
ui
.
window
.
onBeginFrame
=
null
;
ui
.
window
.
onDrawFrame
=
null
;
});
...
...
@@ -240,14 +238,14 @@ void main() {
vsync:
const
TestVSync
(),
);
final
CurvedAnimation
curved
=
CurvedAnimation
(
parent:
controller
,
curve:
BogusCurve
());
FlutterError
error
;
FlutterError
?
error
;
try
{
curved
.
value
;
}
on
FlutterError
catch
(
e
)
{
error
=
e
;
}
expect
(
error
,
isNotNull
);
expect
(
error
.
toStringDeep
(),
matches
(
expect
(
error
!
.
toStringDeep
(),
matches
(
// RegExp matcher is required here due to flutter web and flutter mobile generating
// slightly different floating point numbers
// in Flutter web 0.0 sometimes just appears as 0. or 0
...
...
packages/flutter/test/animation/curves_test.dart
View file @
5e97eed8
...
...
@@ -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_test/flutter_test.dart'
;
...
...
@@ -275,9 +273,6 @@ void main() {
});
test
(
'CatmullRomSpline enforces contract'
,
()
{
expect
(()
{
CatmullRomSpline
(
null
);
},
throwsAssertionError
);
expect
(()
{
CatmullRomSpline
(
const
<
Offset
>[]);
},
throwsAssertionError
);
...
...
@@ -327,9 +322,6 @@ void main() {
});
test
(
'CatmullRomSpline enforces contract when precomputed'
,
()
{
expect
(()
{
CatmullRomSpline
.
precompute
(
null
);
},
throwsAssertionError
);
expect
(()
{
CatmullRomSpline
.
precompute
(
const
<
Offset
>[]);
},
throwsAssertionError
);
...
...
@@ -395,9 +387,6 @@ void main() {
});
test
(
'CatmullRomCurve enforces contract'
,
()
{
expect
(()
{
CatmullRomCurve
(
null
);
},
throwsAssertionError
);
expect
(()
{
CatmullRomCurve
(
const
<
Offset
>[]);
},
throwsAssertionError
);
...
...
@@ -517,9 +506,6 @@ void main() {
});
test
(
'CatmullRomCurve enforces contract when precomputed'
,
()
{
expect
(()
{
CatmullRomCurve
.
precompute
(
null
);
},
throwsAssertionError
);
expect
(()
{
CatmullRomCurve
.
precompute
(
const
<
Offset
>[]);
},
throwsAssertionError
);
...
...
packages/flutter/test/animation/futures_test.dart
View file @
5e97eed8
...
...
@@ -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/animation.dart'
;
import
'package:flutter/scheduler.dart'
;
...
...
packages/flutter/test/animation/iteration_patterns_test.dart
View file @
5e97eed8
...
...
@@ -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/animation.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
@@ -11,7 +9,7 @@ import 'package:flutter/widgets.dart';
void
main
(
)
{
setUp
(()
{
WidgetsFlutterBinding
.
ensureInitialized
();
WidgetsBinding
.
instance
.
resetEpoch
();
WidgetsBinding
.
instance
!
.
resetEpoch
();
});
test
(
'AnimationController with mutating listener'
,
()
{
...
...
@@ -92,7 +90,7 @@ void main() {
final
VoidCallback
listener1
=
()
{
log
.
add
(
'listener1'
);
};
final
VoidCallback
badListener
=
()
{
log
.
add
(
'badListener'
);
throw
null
;
throw
ArgumentError
()
;
};
final
VoidCallback
listener2
=
()
{
log
.
add
(
'listener2'
);
};
...
...
@@ -101,7 +99,7 @@ void main() {
controller
.
addListener
(
listener2
);
controller
.
value
=
0.2
;
expect
(
log
,
<
String
>[
'listener1'
,
'badListener'
,
'listener2'
]);
expect
(
tester
.
takeException
(),
is
NullThrown
Error
);
expect
(
tester
.
takeException
(),
is
Argument
Error
);
log
.
clear
();
});
...
...
@@ -115,7 +113,7 @@ void main() {
final
AnimationStatusListener
listener1
=
(
AnimationStatus
status
)
{
log
.
add
(
'listener1'
);
};
final
AnimationStatusListener
badListener
=
(
AnimationStatus
status
)
{
log
.
add
(
'badListener'
);
throw
null
;
throw
ArgumentError
()
;
};
final
AnimationStatusListener
listener2
=
(
AnimationStatus
status
)
{
log
.
add
(
'listener2'
);
};
...
...
@@ -124,7 +122,7 @@ void main() {
controller
.
addStatusListener
(
listener2
);
controller
.
forward
();
expect
(
log
,
<
String
>[
'listener1'
,
'badListener'
,
'listener2'
]);
expect
(
tester
.
takeException
(),
is
NullThrown
Error
);
expect
(
tester
.
takeException
(),
is
Argument
Error
);
log
.
clear
();
controller
.
dispose
();
});
...
...
packages/flutter/test/animation/tween_test.dart
View file @
5e97eed8
...
...
@@ -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/animation.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
packages/flutter/test/foundation/assertions_test.dart
View file @
5e97eed8
...
...
@@ -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
'../flutter_test_alternative.dart'
;
...
...
@@ -442,7 +440,7 @@ void main() {
],
replacement:
'test'
,
);
final
List
<
String
>
reasons
=
List
<
String
>(
2
);
final
List
<
String
?>
reasons
=
List
<
String
?>.
filled
(
2
,
null
);
filter
.
filter
(
const
<
StackFrame
>[
StackFrame
(
className:
'TestClass'
,
method:
'test1'
,
packageScheme:
'package'
,
package:
'test'
,
packagePath:
'blah.dart'
,
line:
1
,
column:
1
,
number:
0
,
source
:
''
),
...
...
@@ -450,6 +448,6 @@ void main() {
],
reasons
,
);
expect
(
reasons
,
List
<
String
>(
2
));
expect
(
reasons
,
List
<
String
?>.
filled
(
2
,
null
));
});
}
packages/flutter/test/foundation/bit_field_test.dart
View file @
5e97eed8
...
...
@@ -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
@TestOn
(
'!chrome'
)
import
'package:flutter/foundation.dart'
;
...
...
packages/flutter/test/foundation/caching_iterable_test.dart
View file @
5e97eed8
...
...
@@ -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/foundation.dart'
;
import
'../flutter_test_alternative.dart'
;
int
yieldCount
;
int
yieldCount
=
0
;
Iterable
<
int
>
range
(
int
start
,
int
end
)
sync
*
{
assert
(
yieldCount
==
0
);
...
...
packages/flutter/test/foundation/capture_output.dart
View file @
5e97eed8
...
...
@@ -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
'package:flutter/foundation.dart'
;
...
...
packages/flutter/test/foundation/change_notifier_test.dart
View file @
5e97eed8
...
...
@@ -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_test/flutter_test.dart'
;
...
...
@@ -41,7 +39,7 @@ void main() {
final
VoidCallback
listener2
=
()
{
log
.
add
(
'listener2'
);
};
final
VoidCallback
badListener
=
()
{
log
.
add
(
'badListener'
);
throw
null
;
throw
ArgumentError
()
;
};
final
TestNotifier
test
=
TestNotifier
();
...
...
@@ -95,7 +93,7 @@ void main() {
test
.
addListener
(
badListener
);
test
.
notify
();
expect
(
log
,
<
String
>[
'listener'
,
'listener2'
,
'listener1'
,
'badListener'
]);
expect
(
tester
.
takeException
(),
is
NullThrown
Error
);
expect
(
tester
.
takeException
(),
is
Argument
Error
);
log
.
clear
();
test
.
addListener
(
listener1
);
...
...
@@ -105,7 +103,7 @@ void main() {
test
.
addListener
(
listener2
);
test
.
notify
();
expect
(
log
,
<
String
>[
'badListener'
,
'listener1'
,
'listener2'
]);
expect
(
tester
.
takeException
(),
is
NullThrown
Error
);
expect
(
tester
.
takeException
(),
is
Argument
Error
);
log
.
clear
();
});
...
...
@@ -238,7 +236,7 @@ void main() {
final
TestNotifier
source2
=
TestNotifier
();
final
List
<
String
>
log
=
<
String
>[];
final
Listenable
merged
=
Listenable
.
merge
(<
Listenable
>[
null
,
source1
,
null
,
source2
,
null
]);
final
Listenable
merged
=
Listenable
.
merge
(<
Listenable
?
>[
null
,
source1
,
null
,
source2
,
null
]);
final
VoidCallback
listener
=
()
{
log
.
add
(
'listener'
);
};
merged
.
addListener
(
listener
);
...
...
@@ -300,7 +298,7 @@ void main() {
Listenable
listenableUnderTest
=
Listenable
.
merge
(<
Listenable
>[]);
expect
(
listenableUnderTest
.
toString
(),
'Listenable.merge([])'
);
listenableUnderTest
=
Listenable
.
merge
(<
Listenable
>[
null
]);
listenableUnderTest
=
Listenable
.
merge
(<
Listenable
?
>[
null
]);
expect
(
listenableUnderTest
.
toString
(),
'Listenable.merge([null])'
);
listenableUnderTest
=
Listenable
.
merge
(<
Listenable
>[
source1
]);
...
...
@@ -315,7 +313,7 @@ void main() {
"Listenable.merge([Instance of 'TestNotifier', Instance of 'TestNotifier'])"
,
);
listenableUnderTest
=
Listenable
.
merge
(<
Listenable
>[
null
,
source2
]);
listenableUnderTest
=
Listenable
.
merge
(<
Listenable
?
>[
null
,
source2
]);
expect
(
listenableUnderTest
.
toString
(),
"Listenable.merge([null, Instance of 'TestNotifier'])"
,
...
...
@@ -382,14 +380,14 @@ void main() {
test
(
'Throws FlutterError when disposed and called'
,
()
{
final
TestNotifier
testNotifier
=
TestNotifier
();
testNotifier
.
dispose
();
FlutterError
error
;
FlutterError
?
error
;
try
{
testNotifier
.
dispose
();
}
on
FlutterError
catch
(
e
)
{
error
=
e
;
}
expect
(
error
,
isNotNull
);
expect
(
error
,
isFlutterError
);
expect
(
error
!
,
isFlutterError
);
expect
(
error
.
toStringDeep
(),
equalsIgnoringHashCodes
(
'FlutterError
\n
'
' A TestNotifier was used after being disposed.
\n
'
...
...
packages/flutter/test/foundation/collections_test.dart
View file @
5e97eed8
...
...
@@ -2,7 +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'
;
import
'package:flutter/src/foundation/collections.dart'
;
...
...
@@ -64,10 +63,8 @@ void main() {
test
(
'MergeSortRandom'
,
()
{
final
Random
random
=
Random
();
for
(
int
i
=
0
;
i
<
250
;
i
+=
1
)
{
final
List
<
int
>
list
=
List
<
int
>(
i
);
for
(
int
j
=
0
;
j
<
i
;
j
++)
{
list
[
j
]
=
random
.
nextInt
(
i
);
// Expect some equal elements.
}
// Expect some equal elements.
final
List
<
int
>
list
=
List
<
int
>.
generate
(
i
,
(
int
j
)
=>
random
.
nextInt
(
i
));
mergeSort
(
list
);
for
(
int
j
=
1
;
j
<
i
;
j
++)
{
expect
(
list
[
j
-
1
],
lessThanOrEqualTo
(
list
[
j
]));
...
...
@@ -80,14 +77,12 @@ void main() {
// larger case where the internal moving insertion sort is used
// larger cases with multiple splittings, numbers just around a power of 2.
for
(
final
int
size
in
<
int
>[
8
,
50
,
511
,
512
,
513
])
{
final
List
<
OrderedComparable
>
list
=
List
<
OrderedComparable
>(
size
);
// Class OC compares using id.
// With size elements with id's in the range 0..size/4, a number of
// collisions are guaranteed. These should be sorted so that the 'order'
// part of the objects are still in order.
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
list
[
i
]
=
OrderedComparable
(
random
.
nextInt
(
size
>>
2
),
i
);
}
final
List
<
OrderedComparable
>
list
=
List
<
OrderedComparable
>.
generate
(
size
,
(
int
i
)
=>
OrderedComparable
(
random
.
nextInt
(
size
>>
2
),
i
));
mergeSort
(
list
);
OrderedComparable
prev
=
list
[
0
];
for
(
int
i
=
1
;
i
<
size
;
i
++)
{
...
...
@@ -126,10 +121,8 @@ void main() {
test
(
'MergeSortSpecialCases'
,
()
{
for
(
final
int
size
in
<
int
>[
511
,
512
,
513
])
{
// All equal.
final
List
<
OrderedComparable
>
list
=
List
<
OrderedComparable
>(
size
);
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
list
[
i
]
=
OrderedComparable
(
0
,
i
);
}
final
List
<
OrderedComparable
>
list
=
List
<
OrderedComparable
>.
generate
(
size
,
(
int
i
)
=>
OrderedComparable
(
0
,
i
));
mergeSort
(
list
);
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
expect
(
list
[
i
].
order
,
equals
(
i
));
...
...
packages/flutter/test/foundation/consolidate_response_test.dart
View file @
5e97eed8
...
...
@@ -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
@TestOn
(
'!chrome'
)
import
'dart:async'
;
...
...
@@ -18,7 +16,7 @@ final Uint8List chunkOne = Uint8List.fromList(<int>[0, 1, 2, 3, 4, 5]);
final
Uint8List
chunkTwo
=
Uint8List
.
fromList
(<
int
>[
6
,
7
,
8
,
9
,
10
]);
void
main
(
)
{
group
(
consolidateHttpClientResponseBytes
,
()
{
MockHttpClientResponse
response
;
late
MockHttpClientResponse
response
;
setUp
(()
{
response
=
MockHttpClientResponse
(
...
...
@@ -54,11 +52,11 @@ void main() {
test
(
'Notifies onBytesReceived for every chunk of bytes'
,
()
async
{
final
int
syntheticTotal
=
(
chunkOne
.
length
+
chunkTwo
.
length
)
*
2
;
response
.
contentLength
=
syntheticTotal
;
final
List
<
int
>
records
=
<
int
>[];
final
List
<
int
?>
records
=
<
int
?
>[];
await
consolidateHttpClientResponseBytes
(
response
,
onBytesReceived:
(
int
cumulative
,
int
total
)
{
records
.
addAll
(<
int
>[
cumulative
,
total
]);
onBytesReceived:
(
int
cumulative
,
int
?
total
)
{
records
.
addAll
(<
int
?
>[
cumulative
,
total
]);
},
);
...
...
@@ -81,7 +79,7 @@ void main() {
response
.
contentLength
=
-
1
;
final
Future
<
List
<
int
>>
result
=
consolidateHttpClientResponseBytes
(
response
,
onBytesReceived:
(
int
cumulative
,
int
total
)
{
onBytesReceived:
(
int
cumulative
,
int
?
total
)
{
throw
'misbehaving callback'
;
},
);
...
...
@@ -113,11 +111,11 @@ void main() {
test
(
'Notifies onBytesReceived with gzipped numbers'
,
()
async
{
response
.
contentLength
=
gzipped
.
length
;
final
List
<
int
>
records
=
<
int
>[];
final
List
<
int
?
>
records
=
<
int
>[];
await
consolidateHttpClientResponseBytes
(
response
,
onBytesReceived:
(
int
cumulative
,
int
total
)
{
records
.
addAll
(<
int
>[
cumulative
,
total
]);
onBytesReceived:
(
int
cumulative
,
int
?
total
)
{
records
.
addAll
(<
int
?
>[
cumulative
,
total
]);
},
);
...
...
@@ -133,15 +131,15 @@ void main() {
final
int
syntheticTotal
=
(
chunkOne
.
length
+
chunkTwo
.
length
)
*
2
;
response
.
compressionState
=
HttpClientResponseCompressionState
.
decompressed
;
response
.
contentLength
=
syntheticTotal
;
final
List
<
int
>
records
=
<
int
>[];
final
List
<
int
?>
records
=
<
int
?
>[];
await
consolidateHttpClientResponseBytes
(
response
,
onBytesReceived:
(
int
cumulative
,
int
total
)
{
records
.
addAll
(<
int
>[
cumulative
,
total
]);
onBytesReceived:
(
int
cumulative
,
int
?
total
)
{
records
.
addAll
(<
int
?
>[
cumulative
,
total
]);
},
);
expect
(
records
,
<
int
>[
expect
(
records
,
<
int
?
>[
gzippedChunkOne
.
length
,
null
,
gzipped
.
length
,
...
...
@@ -153,7 +151,7 @@ void main() {
}
class
MockHttpClientResponse
extends
Fake
implements
HttpClientResponse
{
MockHttpClientResponse
({
this
.
error
,
this
.
chunkOne
,
this
.
chunkTwo
});
MockHttpClientResponse
({
this
.
error
,
this
.
chunkOne
=
const
<
int
>[],
this
.
chunkTwo
=
const
<
int
>[]
});
final
dynamic
error
;
final
List
<
int
>
chunkOne
;
...
...
@@ -166,10 +164,10 @@ class MockHttpClientResponse extends Fake implements HttpClientResponse {
HttpClientResponseCompressionState
compressionState
=
HttpClientResponseCompressionState
.
notCompressed
;
@override
StreamSubscription
<
List
<
int
>>
listen
(
void
Function
(
List
<
int
>
event
)
onData
,
{
Function
onError
,
void
Function
()
onDone
,
bool
cancelOnError
})
{
StreamSubscription
<
List
<
int
>>
listen
(
void
Function
(
List
<
int
>
event
)
?
onData
,
{
Function
?
onError
,
void
Function
()?
onDone
,
bool
?
cancelOnError
})
{
if
(
error
!=
null
)
{
return
Stream
<
List
<
int
>>.
fromFuture
(
Future
<
List
<
int
>>.
error
(
error
)).
listen
(
Future
<
List
<
int
>>.
error
(
error
as
Object
)).
listen
(
onData
,
onDone:
onDone
,
onError:
onError
,
...
...
packages/flutter/test/foundation/constants_test.dart
View file @
5e97eed8
...
...
@@ -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
@TestOn
(
'!chrome'
)
// This test is not intended to run on the web.
import
'package:flutter/foundation.dart'
;
import
'../flutter_test_alternative.dart'
;
...
...
packages/flutter/test/foundation/covariant_templates_test.dart
View file @
5e97eed8
...
...
@@ -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'
;
class
X
{}
...
...
@@ -11,7 +9,7 @@ class X {}
class
Y
extends
X
{}
class
A
<
U
extends
X
>
{
U
u
;
U
?
u
;
}
void
main
(
)
{
...
...
packages/flutter/test/foundation/debug_test.dart
View file @
5e97eed8
...
...
@@ -2,21 +2,19 @@
// 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_test/flutter_test.dart'
;
void
main
(
)
{
group
(
'debugInstrumentAction'
,
()
{
DebugPrintCallback
originalDebugPrintCallback
;
StringBuffer
printBuffer
;
late
DebugPrintCallback
originalDebugPrintCallback
;
late
StringBuffer
printBuffer
;
setUp
(()
{
debugInstrumentationEnabled
=
true
;
printBuffer
=
StringBuffer
();
originalDebugPrintCallback
=
debugPrint
;
debugPrint
=
(
String
message
,
{
int
wrapWidth
})
{
debugPrint
=
(
String
?
message
,
{
int
?
wrapWidth
})
{
printBuffer
.
writeln
(
message
);
};
});
...
...
packages/flutter/test/foundation/defines_test.dart
View file @
5e97eed8
...
...
@@ -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_test/flutter_test.dart'
;
...
...
packages/flutter/test/foundation/diagnostics_json_test.dart
View file @
5e97eed8
This diff is collapsed.
Click to expand it.
packages/flutter/test/foundation/diagnostics_test.dart
View file @
5e97eed8
...
...
@@ -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:convert'
;
import
'dart:ui'
;
...
...
@@ -12,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart';
class
TestTree
extends
Object
with
DiagnosticableTreeMixin
{
TestTree
({
this
.
name
,
this
.
name
=
''
,
this
.
style
,
this
.
children
=
const
<
TestTree
>[],
this
.
properties
=
const
<
DiagnosticsNode
>[],
...
...
@@ -21,7 +19,7 @@ class TestTree extends Object with DiagnosticableTreeMixin {
final
String
name
;
final
List
<
TestTree
>
children
;
final
List
<
DiagnosticsNode
>
properties
;
final
DiagnosticsTreeStyle
style
;
final
DiagnosticsTreeStyle
?
style
;
@override
List
<
DiagnosticsNode
>
debugDescribeChildren
()
=>
<
DiagnosticsNode
>[
...
...
@@ -36,8 +34,7 @@ class TestTree extends Object with DiagnosticableTreeMixin {
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
super
.
debugFillProperties
(
properties
);
if
(
style
!=
null
)
properties
.
defaultDiagnosticsTreeStyle
=
style
;
properties
.
defaultDiagnosticsTreeStyle
=
style
!;
this
.
properties
.
forEach
(
properties
.
add
);
}
}
...
...
@@ -65,7 +62,7 @@ void validateNodeJsonSerializationHelper(Map<String, Object> json, DiagnosticsNo
expect
(
json
[
'level'
]
??
describeEnum
(
DiagnosticLevel
.
info
),
equals
(
describeEnum
(
node
.
level
)));
expect
(
json
[
'showName'
]
??
true
,
equals
(
node
.
showName
));
expect
(
json
[
'emptyBodyDescription'
],
equals
(
node
.
emptyBodyDescription
));
expect
(
json
[
'style'
]
??
describeEnum
(
DiagnosticsTreeStyle
.
sparse
),
equals
(
describeEnum
(
node
.
style
)));
expect
(
json
[
'style'
]
??
describeEnum
(
DiagnosticsTreeStyle
.
sparse
),
equals
(
describeEnum
(
node
.
style
!
)));
expect
(
json
[
'type'
],
equals
(
node
.
runtimeType
.
toString
()));
expect
(
json
[
'hasChildren'
]
??
false
,
equals
(
node
.
getChildren
().
isNotEmpty
));
}
...
...
@@ -122,13 +119,13 @@ void validateObjectFlagPropertyJsonSerialization(ObjectFlagProperty<Object> prop
validatePropertyJsonSerializationHelper
(
json
,
property
);
}
void
validateIterableFlagsPropertyJsonSerialization
(
FlagsSummary
<
Object
>
property
)
{
void
validateIterableFlagsPropertyJsonSerialization
(
FlagsSummary
<
Object
?
>
property
)
{
final
Map
<
String
,
Object
>
json
=
simulateJsonSerialization
(
property
);
if
(
property
.
value
.
isNotEmpty
)
{
expect
(
json
[
'values'
],
equals
(
property
.
value
.
entries
.
where
((
MapEntry
<
String
,
Object
>
entry
)
=>
entry
.
value
!=
null
)
.
map
((
MapEntry
<
String
,
Object
>
entry
)
=>
entry
.
key
).
toList
(),
.
where
((
MapEntry
<
String
,
Object
?
>
entry
)
=>
entry
.
value
!=
null
)
.
map
((
MapEntry
<
String
,
Object
?
>
entry
)
=>
entry
.
key
).
toList
(),
));
}
else
{
expect
(
json
.
containsKey
(
'values'
),
isFalse
);
...
...
@@ -141,7 +138,7 @@ void validateIterablePropertyJsonSerialization(IterableProperty<Object> property
final
Map
<
String
,
Object
>
json
=
simulateJsonSerialization
(
property
);
if
(
property
.
value
!=
null
)
{
final
List
<
Object
>
valuesJson
=
json
[
'values'
]
as
List
<
Object
>;
final
List
<
String
>
expectedValues
=
property
.
value
.
map
<
String
>((
Object
value
)
=>
value
.
toString
()).
toList
();
final
List
<
String
>
expectedValues
=
property
.
value
!
.
map
<
String
>((
Object
value
)
=>
value
.
toString
()).
toList
();
expect
(
listEquals
(
valuesJson
,
expectedValues
),
isTrue
);
}
else
{
expect
(
json
.
containsKey
(
'values'
),
isFalse
);
...
...
@@ -194,8 +191,8 @@ void main() {
test
(
'TreeDiagnosticsMixin control test'
,
()
async
{
void
goldenStyleTest
(
String
description
,
{
DiagnosticsTreeStyle
style
,
DiagnosticsTreeStyle
lastChildStyle
,
DiagnosticsTreeStyle
?
style
,
DiagnosticsTreeStyle
?
lastChildStyle
,
String
golden
=
''
,
})
{
final
TestTree
tree
=
TestTree
(
children:
<
TestTree
>[
...
...
@@ -367,11 +364,11 @@ void main() {
test
(
'TreeDiagnosticsMixin tree with properties test'
,
()
async
{
void
goldenStyleTest
(
String
description
,
{
String
name
,
DiagnosticsTreeStyle
style
,
DiagnosticsTreeStyle
lastChildStyle
,
String
?
name
,
DiagnosticsTreeStyle
?
style
,
DiagnosticsTreeStyle
?
lastChildStyle
,
DiagnosticsTreeStyle
propertyStyle
=
DiagnosticsTreeStyle
.
singleLine
,
@
required
String
golden
,
required
String
golden
,
})
{
final
TestTree
tree
=
TestTree
(
properties:
<
DiagnosticsNode
>[
...
...
@@ -1696,7 +1693,7 @@ void main() {
// Partially empty property
{
final
Function
onClick
=
()
{
};
final
Map
<
String
,
Function
>
value
=
<
String
,
Function
>{
final
Map
<
String
,
Function
?>
value
=
<
String
,
Function
?
>{
'move'
:
null
,
'click'
:
onClick
,
};
...
...
@@ -1711,7 +1708,7 @@ void main() {
// Empty property (without ifEmpty)
{
final
Map
<
String
,
Function
>
value
=
<
String
,
Function
>{
final
Map
<
String
,
Function
?>
value
=
<
String
,
Function
?
>{
'enter'
:
null
,
};
final
FlagsSummary
<
Function
>
flags
=
FlagsSummary
<
Function
>(
...
...
@@ -1724,7 +1721,7 @@ void main() {
// Empty property (without ifEmpty)
{
final
Map
<
String
,
Function
>
value
=
<
String
,
Function
>{
final
Map
<
String
,
Function
?>
value
=
<
String
,
Function
?
>{
'enter'
:
null
,
};
final
FlagsSummary
<
Function
>
flags
=
FlagsSummary
<
Function
>(
...
...
@@ -1922,14 +1919,14 @@ void main() {
expect
(
messageProperty
.
name
,
equals
(
'diagnostics'
));
expect
(
messageProperty
.
value
,
isNull
);
expect
(
messageProperty
.
showName
,
isTrue
);
validatePropertyJsonSerialization
(
messageProperty
as
MessageProperty
);
validatePropertyJsonSerialization
(
messageProperty
as
DiagnosticsProperty
<
Object
>
);
});
test
(
'error message style wrap test'
,
()
{
// This tests wrapping of properties with styles typical for error messages.
DiagnosticsNode
createTreeWithWrappingNodes
({
DiagnosticsTreeStyle
rootStyle
,
DiagnosticsTreeStyle
propertyStyle
,
DiagnosticsTreeStyle
?
rootStyle
,
required
DiagnosticsTreeStyle
propertyStyle
,
})
{
return
TestTree
(
name:
'Test tree'
,
...
...
packages/flutter/test/foundation/double_precision_test.dart
View file @
5e97eed8
...
...
@@ -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
'../flutter_test_alternative.dart'
;
...
...
packages/flutter/test/foundation/error_reporting_test.dart
View file @
5e97eed8
...
...
@@ -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
@TestOn
(
'!chrome'
)
// web has different stack traces
import
'package:flutter/foundation.dart'
;
...
...
@@ -41,13 +39,13 @@ Future<StackTrace> getSampleStack() async {
}
Future
<
void
>
main
()
async
{
final
List
<
String
>
console
=
<
String
>[];
final
List
<
String
?>
console
=
<
String
?
>[];
final
StackTrace
sampleStack
=
await
getSampleStack
();
setUp
(()
async
{
expect
(
debugPrint
,
equals
(
debugPrintThrottled
));
debugPrint
=
(
String
message
,
{
int
wrapWidth
})
{
debugPrint
=
(
String
?
message
,
{
int
?
wrapWidth
})
{
console
.
add
(
message
);
};
});
...
...
@@ -160,7 +158,7 @@ Future<void> main() async {
test
(
'Error reporting - NoSuchMethodError'
,
()
async
{
expect
(
console
,
isEmpty
);
final
dynamic
exception
=
NoSuchMethodError
.
withInvocation
(
5
,
final
Object
exception
=
NoSuchMethodError
.
withInvocation
(
5
,
Invocation
.
method
(
#foo
,
<
dynamic
>[
2
,
4
]));
FlutterError
.
dumpErrorToConsole
(
FlutterErrorDetails
(
...
...
packages/flutter/test/foundation/isolates_test.dart
View file @
5e97eed8
...
...
@@ -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
@TestOn
(
'!chrome'
)
// isolates not supported on the web.
import
'package:flutter/foundation.dart'
;
...
...
packages/flutter/test/foundation/licenses_test.dart
View file @
5e97eed8
...
...
@@ -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
'../flutter_test_alternative.dart'
;
...
...
@@ -11,7 +9,7 @@ void main() {
test
(
'LicenseEntryWithLineBreaks - most cases'
,
()
{
// There's some trailing spaces in this string.
// To avoid IDEs stripping them, I've escaped them as \u0020.
final
List
<
LicenseParagraph
>
paragraphs
=
const
LicenseEntryWithLineBreaks
(
null
,
'''
final
List
<
LicenseParagraph
>
paragraphs
=
const
LicenseEntryWithLineBreaks
(
<
String
>[]
,
'''
A
A
A
...
...
@@ -159,17 +157,17 @@ S
});
test
(
'LicenseEntryWithLineBreaks - leading and trailing whitespace'
,
()
{
expect
(
const
LicenseEntryWithLineBreaks
(
null
,
'
\n\n
'
).
paragraphs
.
toList
(),
isEmpty
);
expect
(
const
LicenseEntryWithLineBreaks
(
null
,
'
\r\n\r\n
'
).
paragraphs
.
toList
(),
isEmpty
);
expect
(
const
LicenseEntryWithLineBreaks
(
<
String
>[]
,
'
\n\n
'
).
paragraphs
.
toList
(),
isEmpty
);
expect
(
const
LicenseEntryWithLineBreaks
(
<
String
>[]
,
'
\r\n\r\n
'
).
paragraphs
.
toList
(),
isEmpty
);
List
<
LicenseParagraph
>
paragraphs
;
paragraphs
=
const
LicenseEntryWithLineBreaks
(
null
,
'
\n
A
\n
'
).
paragraphs
.
toList
();
paragraphs
=
const
LicenseEntryWithLineBreaks
(
<
String
>[]
,
'
\n
A
\n
'
).
paragraphs
.
toList
();
expect
(
paragraphs
[
0
].
text
,
'A'
);
expect
(
paragraphs
[
0
].
indent
,
0
);
expect
(
paragraphs
,
hasLength
(
1
));
paragraphs
=
const
LicenseEntryWithLineBreaks
(
null
,
'
\n\n\n
A
\n\n\n
'
).
paragraphs
.
toList
();
paragraphs
=
const
LicenseEntryWithLineBreaks
(
<
String
>[]
,
'
\n\n\n
A
\n\n\n
'
).
paragraphs
.
toList
();
expect
(
paragraphs
[
0
].
text
,
'A'
);
expect
(
paragraphs
[
0
].
indent
,
0
);
expect
(
paragraphs
,
hasLength
(
1
));
...
...
@@ -178,12 +176,12 @@ S
test
(
'LicenseRegistry'
,
()
async
{
expect
(
await
LicenseRegistry
.
licenses
.
toList
(),
isEmpty
);
LicenseRegistry
.
addLicense
(()
async
*
{
yield
const
LicenseEntryWithLineBreaks
(
null
,
'A'
);
yield
const
LicenseEntryWithLineBreaks
(
null
,
'B'
);
yield
const
LicenseEntryWithLineBreaks
(
<
String
>[]
,
'A'
);
yield
const
LicenseEntryWithLineBreaks
(
<
String
>[]
,
'B'
);
});
LicenseRegistry
.
addLicense
(()
async
*
{
yield
const
LicenseEntryWithLineBreaks
(
null
,
'C'
);
yield
const
LicenseEntryWithLineBreaks
(
null
,
'D'
);
yield
const
LicenseEntryWithLineBreaks
(
<
String
>[]
,
'C'
);
yield
const
LicenseEntryWithLineBreaks
(
<
String
>[]
,
'D'
);
});
expect
(
await
LicenseRegistry
.
licenses
.
toList
(),
hasLength
(
4
));
final
List
<
LicenseEntry
>
licenses
=
await
LicenseRegistry
.
licenses
.
toList
();
...
...
packages/flutter/test/foundation/observer_list_test.dart
View file @
5e97eed8
...
...
@@ -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_test/flutter_test.dart'
;
...
...
packages/flutter/test/foundation/platform_helper.dart
View file @
5e97eed8
...
...
@@ -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:io'
show
Platform
;
/// Returns [Platform.pathSeparator], suitably escaped so as to be usable in a
...
...
packages/flutter/test/foundation/print_test.dart
View file @
5e97eed8
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.10
import
'package:flutter/foundation.dart'
;
import
'package:fake_async/fake_async.dart'
;
import
'../flutter_test_alternative.dart'
;
...
...
packages/flutter/test/foundation/reassemble_test.dart
View file @
5e97eed8
...
...
@@ -2,14 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
@TestOn
(
'!chrome'
)
import
'package:flutter/foundation.dart'
;
import
'../flutter_test_alternative.dart'
;
class
TestFoundationFlutterBinding
extends
BindingBase
{
bool
wasLocked
;
bool
?
wasLocked
;
@override
Future
<
void
>
performReassemble
()
async
{
...
...
@@ -21,8 +19,6 @@ class TestFoundationFlutterBinding extends BindingBase {
TestFoundationFlutterBinding
binding
=
TestFoundationFlutterBinding
();
void
main
(
)
{
binding
??=
TestFoundationFlutterBinding
();
test
(
'Pointer events are locked during reassemble'
,
()
async
{
await
binding
.
reassembleApplication
();
expect
(
binding
.
wasLocked
,
isTrue
);
...
...
packages/flutter/test/foundation/serialization_test.dart
View file @
5e97eed8
...
...
@@ -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
@TestOn
(
'!chrome'
)
// web does not support certain 64bit behavior
import
'dart:typed_data'
;
...
...
packages/flutter/test/foundation/service_extensions_test.dart
View file @
5e97eed8
...
...
@@ -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'
;
import
'dart:typed_data'
;
...
...
@@ -31,9 +29,10 @@ class TestServiceExtensionsBinding extends BindingBase
final
Map
<
String
,
List
<
Map
<
String
,
dynamic
>>>
eventsDispatched
=
<
String
,
List
<
Map
<
String
,
dynamic
>>>{};
@override
@protected
void
registerServiceExtension
({
@
required
String
name
,
@
required
ServiceExtensionCallback
callback
,
required
String
name
,
required
ServiceExtensionCallback
callback
,
})
{
expect
(
extensions
.
containsKey
(
name
),
isFalse
);
extensions
[
name
]
=
callback
;
...
...
@@ -55,7 +54,7 @@ class TestServiceExtensionsBinding extends BindingBase
Future
<
Map
<
String
,
dynamic
>>
testExtension
(
String
name
,
Map
<
String
,
String
>
arguments
)
{
expect
(
extensions
.
containsKey
(
name
),
isTrue
);
return
extensions
[
name
](
arguments
);
return
extensions
[
name
]
!
(
arguments
);
}
int
reassembled
=
0
;
...
...
@@ -75,13 +74,10 @@ class TestServiceExtensionsBinding extends BindingBase
}
Future
<
void
>
doFrame
()
async
{
frameScheduled
=
false
;
if
(
ui
.
window
.
onBeginFrame
!=
null
)
ui
.
window
.
onBeginFrame
(
Duration
.
zero
);
ui
.
window
.
onBeginFrame
?.
call
(
Duration
.
zero
);
await
flushMicrotasks
();
if
(
ui
.
window
.
onDrawFrame
!=
null
)
ui
.
window
.
onDrawFrame
();
if
(
ui
.
window
.
onReportTimings
!=
null
)
ui
.
window
.
onReportTimings
(<
ui
.
FrameTiming
>[]);
ui
.
window
.
onDrawFrame
?.
call
();
ui
.
window
.
onReportTimings
?.
call
(<
ui
.
FrameTiming
>[]);
}
@override
...
...
@@ -102,7 +98,7 @@ class TestServiceExtensionsBinding extends BindingBase
}
}
TestServiceExtensionsBinding
binding
;
late
TestServiceExtensionsBinding
binding
;
Future
<
Map
<
String
,
dynamic
>>
hasReassemble
(
Future
<
Map
<
String
,
dynamic
>>
pendingResult
)
async
{
bool
completed
=
false
;
...
...
@@ -120,7 +116,7 @@ Future<Map<String, dynamic>> hasReassemble(Future<Map<String, dynamic>> pendingR
}
void
main
(
)
{
final
List
<
String
>
console
=
<
String
>[];
final
List
<
String
?>
console
=
<
String
?
>[];
setUpAll
(()
async
{
binding
=
TestServiceExtensionsBinding
()..
scheduleFrame
();
...
...
@@ -150,7 +146,7 @@ void main() {
expect
(
binding
.
frameScheduled
,
isFalse
);
expect
(
debugPrint
,
equals
(
debugPrintThrottled
));
debugPrint
=
(
String
message
,
{
int
wrapWidth
})
{
debugPrint
=
(
String
?
message
,
{
int
?
wrapWidth
})
{
console
.
add
(
message
);
};
});
...
...
@@ -208,7 +204,7 @@ void main() {
bool
lastValue
=
false
;
Future
<
void
>
_updateAndCheck
(
bool
newValue
)
async
{
Map
<
String
,
dynamic
>
result
;
Map
<
String
,
dynamic
>
?
result
;
binding
.
testExtension
(
'debugCheckElevationsEnabled'
,
<
String
,
String
>{
'enabled'
:
'
$newValue
'
},
...
...
@@ -458,8 +454,8 @@ void main() {
bool
completed
;
completed
=
false
;
ServicesBinding
.
instance
.
defaultBinaryMessenger
.
setMockMessageHandler
(
'flutter/assets'
,
(
ByteData
message
)
async
{
expect
(
utf8
.
decode
(
message
.
buffer
.
asUint8List
()),
'test'
);
ServicesBinding
.
instance
!.
defaultBinaryMessenger
.
setMockMessageHandler
(
'flutter/assets'
,
(
ByteData
?
message
)
async
{
expect
(
utf8
.
decode
(
message
!
.
buffer
.
asUint8List
()),
'test'
);
completed
=
true
;
return
ByteData
(
5
);
// 0x0000000000
});
...
...
@@ -472,8 +468,7 @@ void main() {
expect
(
completed
,
isTrue
);
completed
=
false
;
data
=
await
rootBundle
.
loadStructuredData
(
'test'
,
(
String
value
)
async
{
expect
(
true
,
isFalse
);
return
null
;
throw
Error
();
});
expect
(
data
,
isTrue
);
expect
(
completed
,
isFalse
);
...
...
@@ -486,7 +481,7 @@ void main() {
});
expect
(
data
,
isFalse
);
expect
(
completed
,
isTrue
);
ServicesBinding
.
instance
.
defaultBinaryMessenger
.
setMockMessageHandler
(
'flutter/assets'
,
null
);
ServicesBinding
.
instance
!
.
defaultBinaryMessenger
.
setMockMessageHandler
(
'flutter/assets'
,
null
);
});
test
(
'Service extensions - exit'
,
()
async
{
...
...
packages/flutter/test/foundation/stack_frame_test.dart
View file @
5e97eed8
...
...
@@ -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
'../flutter_test_alternative.dart'
;
...
...
packages/flutter/test/foundation/stack_trace_test.dart
View file @
5e97eed8
...
...
@@ -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
@TestOn
(
'!chrome'
)
// web has different stack traces
import
'package:flutter/foundation.dart'
;
...
...
packages/flutter/test/foundation/synchronous_future_test.dart
View file @
5e97eed8
...
...
@@ -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
'../flutter_test_alternative.dart'
;
...
...
@@ -11,7 +9,7 @@ void main() {
test
(
'SynchronousFuture control test'
,
()
async
{
final
Future
<
int
>
future
=
SynchronousFuture
<
int
>(
42
);
int
result
;
int
?
result
;
future
.
then
<
void
>((
int
value
)
{
result
=
value
;
});
expect
(
result
,
equals
(
42
));
...
...
@@ -39,16 +37,16 @@ void main() {
expect
(
await
completeResult
,
equals
(
42
));
Object
exception
;
Object
?
exception
;
try
{
await
future
.
whenComplete
(()
{
throw
null
;
throw
ArgumentError
()
;
});
// Unreached.
expect
(
false
,
isTrue
);
}
catch
(
e
)
{
exception
=
e
;
}
expect
(
exception
,
is
NullThrown
Error
);
expect
(
exception
,
is
Argument
Error
);
});
}
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