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
cbf1e135
Unverified
Commit
cbf1e135
authored
Oct 03, 2020
by
Michael Goderbauer
Committed by
GitHub
Oct 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate non-test files in flutter/test (#67098)
parent
ddb81770
Changes
21
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
307 additions
and
331 deletions
+307
-331
decoration_test.dart
packages/flutter/test/painting/decoration_test.dart
+9
-4
fake_codec.dart
packages/flutter/test/painting/fake_codec.dart
+2
-4
fake_image_provider.dart
packages/flutter/test/painting/fake_image_provider.dart
+0
-2
image_test_utils.dart
packages/flutter/test/painting/image_test_utils.dart
+1
-3
mocks_for_image_cache.dart
packages/flutter/test/painting/mocks_for_image_cache.dart
+5
-7
painting_utils.dart
packages/flutter/test/painting/painting_utils.dart
+1
-3
mock_canvas.dart
packages/flutter/test/rendering/mock_canvas.dart
+119
-121
mouse_tracking_test_utils.dart
...ges/flutter/test/rendering/mouse_tracking_test_utils.dart
+8
-10
recording_canvas.dart
packages/flutter/test/rendering/recording_canvas.dart
+26
-20
rendering_tester.dart
packages/flutter/test/rendering/rendering_tester.dart
+28
-25
restoration.dart
packages/flutter/test/services/restoration.dart
+5
-7
editable_text_utils.dart
packages/flutter/test/widgets/editable_text_utils.dart
+1
-3
gesture_utils.dart
packages/flutter/test/widgets/gesture_utils.dart
+0
-2
observer_tester.dart
packages/flutter/test/widgets/observer_tester.dart
+16
-18
restoration.dart
packages/flutter/test/widgets/restoration.dart
+3
-5
semantics_tester.dart
packages/flutter/test/widgets/semantics_tester.dart
+64
-66
states.dart
packages/flutter/test/widgets/states.dart
+0
-2
test_border.dart
packages/flutter/test/widgets/test_border.dart
+3
-5
test_widgets.dart
packages/flutter/test/widgets/test_widgets.dart
+2
-4
text.dart
packages/flutter/test/widgets/text.dart
+1
-3
widget_inspector_test_utils.dart
...ges/flutter/test/widgets/widget_inspector_test_utils.dart
+13
-17
No files found.
packages/flutter/test/painting/decoration_test.dart
View file @
cbf1e135
...
...
@@ -58,6 +58,10 @@ class SynchronousErrorTestImageProvider extends ImageProvider<int> {
}
class
AsyncTestImageProvider
extends
ImageProvider
<
int
>
{
AsyncTestImageProvider
(
this
.
image
);
final
ui
.
Image
image
;
@override
Future
<
int
>
obtainKey
(
ImageConfiguration
configuration
)
{
return
Future
<
int
>.
value
(
2
);
...
...
@@ -66,7 +70,7 @@ class AsyncTestImageProvider extends ImageProvider<int> {
@override
ImageStreamCompleter
load
(
int
key
,
DecoderCallback
decode
)
{
return
OneFrameImageStreamCompleter
(
Future
<
ImageInfo
>.
value
(
TestImageInfo
(
key
))
Future
<
ImageInfo
>.
value
(
TestImageInfo
(
key
,
image:
image
))
);
}
}
...
...
@@ -147,9 +151,10 @@ void main() {
expect
(
onChangedCalled
,
equals
(
false
));
});
test
(
'BoxDecorationImageListenerAsync'
,
()
{
FakeAsync
().
run
((
FakeAsync
async
)
{
final
ImageProvider
imageProvider
=
AsyncTestImageProvider
();
test
(
'BoxDecorationImageListenerAsync'
,
()
async
{
final
ui
.
Image
image
=
await
createTestImage
(
width:
10
,
height:
10
);
FakeAsync
().
run
((
FakeAsync
async
)
{
final
ImageProvider
imageProvider
=
AsyncTestImageProvider
(
image
);
final
DecorationImage
backgroundImage
=
DecorationImage
(
image:
imageProvider
);
final
BoxDecoration
boxDecoration
=
BoxDecoration
(
image:
backgroundImage
);
...
...
packages/flutter/test/painting/fake_codec.dart
View file @
cbf1e135
...
...
@@ -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:typed_data'
;
import
'dart:ui'
as
ui
show
Codec
,
FrameInfo
,
instantiateImageCodec
;
...
...
@@ -28,9 +26,9 @@ class FakeCodec implements ui.Codec {
static
Future
<
FakeCodec
>
fromData
(
Uint8List
data
)
async
{
final
ui
.
Codec
codec
=
await
ui
.
instantiateImageCodec
(
data
);
final
int
frameCount
=
codec
.
frameCount
;
final
List
<
ui
.
FrameInfo
>
frameInfos
=
List
<
ui
.
FrameInfo
>(
frameCount
)
;
final
List
<
ui
.
FrameInfo
>
frameInfos
=
<
ui
.
FrameInfo
>[]
;
for
(
int
i
=
0
;
i
<
frameCount
;
i
+=
1
)
frameInfos
[
i
]
=
await
codec
.
getNextFrame
(
);
frameInfos
.
add
(
await
codec
.
getNextFrame
()
);
return
FakeCodec
.
_
(
frameCount
,
codec
.
repetitionCount
,
frameInfos
);
}
...
...
packages/flutter/test/painting/fake_image_provider.dart
View file @
cbf1e135
...
...
@@ -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
show
Codec
;
import
'package:flutter/foundation.dart'
;
...
...
packages/flutter/test/painting/image_test_utils.dart
View file @
cbf1e135
...
...
@@ -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:ui'
as
ui
;
...
...
@@ -19,7 +17,7 @@ class TestImageProvider extends ImageProvider<TestImageProvider> {
final
ui
.
Image
testImage
;
final
Completer
<
ImageInfo
>
_completer
=
Completer
<
ImageInfo
>.
sync
();
ImageConfiguration
configuration
;
ImageConfiguration
?
configuration
;
int
loadCallCount
=
0
;
@override
...
...
packages/flutter/test/painting/mocks_for_image_cache.dart
View file @
cbf1e135
...
...
@@ -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:ui'
as
ui
show
Image
;
...
...
@@ -11,7 +9,7 @@ import 'package:flutter/foundation.dart';
import
'package:flutter/painting.dart'
;
class
TestImageInfo
implements
ImageInfo
{
const
TestImageInfo
(
this
.
value
,
{
this
.
image
,
this
.
scale
=
1.0
,
this
.
debugLabel
});
const
TestImageInfo
(
this
.
value
,
{
required
this
.
image
,
this
.
scale
=
1.0
,
this
.
debugLabel
});
@override
final
ui
.
Image
image
;
...
...
@@ -20,7 +18,7 @@ class TestImageInfo implements ImageInfo {
final
double
scale
;
@override
final
String
debugLabel
;
final
String
?
debugLabel
;
final
int
value
;
...
...
@@ -29,7 +27,7 @@ class TestImageInfo implements ImageInfo {
}
class
TestImageProvider
extends
ImageProvider
<
int
>
{
const
TestImageProvider
(
this
.
key
,
this
.
imageValue
,
{
@
required
this
.
image
})
const
TestImageProvider
(
this
.
key
,
this
.
imageValue
,
{
required
this
.
image
})
:
assert
(
image
!=
null
);
final
int
key
;
...
...
@@ -53,7 +51,7 @@ class TestImageProvider extends ImageProvider<int> {
}
class
FailingTestImageProvider
extends
TestImageProvider
{
const
FailingTestImageProvider
(
int
key
,
int
imageValue
,
{
ui
.
Image
image
})
:
super
(
key
,
imageValue
,
image:
image
);
const
FailingTestImageProvider
(
int
key
,
int
imageValue
,
{
required
ui
.
Image
image
})
:
super
(
key
,
imageValue
,
image:
image
);
@override
ImageStreamCompleter
load
(
int
key
,
DecoderCallback
decode
)
{
...
...
@@ -63,7 +61,7 @@ class FailingTestImageProvider extends TestImageProvider {
Future
<
ImageInfo
>
extractOneFrame
(
ImageStream
stream
)
{
final
Completer
<
ImageInfo
>
completer
=
Completer
<
ImageInfo
>();
ImageStreamListener
listener
;
late
ImageStreamListener
listener
;
listener
=
ImageStreamListener
((
ImageInfo
image
,
bool
synchronousCall
)
{
completer
.
complete
(
image
);
stream
.
removeListener
(
listener
);
...
...
packages/flutter/test/painting/painting_utils.dart
View file @
cbf1e135
...
...
@@ -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:typed_data'
;
import
'dart:ui'
as
ui
;
...
...
@@ -17,7 +15,7 @@ class PaintingBindingSpy extends BindingBase with SchedulerBinding, ServicesBind
int
get
instantiateImageCodecCalledCount
=>
counter
;
@override
Future
<
ui
.
Codec
>
instantiateImageCodec
(
Uint8List
list
,
{
int
cacheWidth
,
int
cacheHeight
,
bool
allowUpscaling
=
false
})
{
Future
<
ui
.
Codec
>
instantiateImageCodec
(
Uint8List
list
,
{
int
?
cacheWidth
,
int
?
cacheHeight
,
bool
allowUpscaling
=
false
})
{
counter
++;
return
ui
.
instantiateImageCodec
(
list
);
}
...
...
packages/flutter/test/rendering/mock_canvas.dart
View file @
cbf1e135
This diff is collapsed.
Click to expand it.
packages/flutter/test/rendering/mouse_tracking_test_utils.dart
View file @
cbf1e135
...
...
@@ -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/cupertino.dart'
;
...
...
@@ -20,7 +18,7 @@ class _TestHitTester extends RenderBox {
final
BoxHitTest
hitTestOverride
;
@override
bool
hitTest
(
BoxHitTestResult
result
,
{
ui
.
Offset
position
})
{
bool
hitTest
(
BoxHitTestResult
result
,
{
required
ui
.
Offset
position
})
{
return
hitTestOverride
(
result
,
position
);
}
}
...
...
@@ -39,7 +37,7 @@ class TestMouseTrackerFlutterBinding extends BindingBase
renderView
.
child
=
_TestHitTester
(
hitTest
);
}
SchedulerPhase
_overridePhase
;
SchedulerPhase
?
_overridePhase
;
@override
SchedulerPhase
get
schedulerPhase
=>
_overridePhase
??
super
.
schedulerPhase
;
...
...
@@ -48,7 +46,7 @@ class TestMouseTrackerFlutterBinding extends BindingBase
// In real apps this is done by the renderer binding, but in tests we have to
// bypass the phase assertion of [MouseTracker.schedulePostFrameCheck].
void
scheduleMouseTrackerPostFrameCheck
()
{
final
SchedulerPhase
lastPhase
=
_overridePhase
;
final
SchedulerPhase
?
lastPhase
=
_overridePhase
;
_overridePhase
=
SchedulerPhase
.
persistentCallbacks
;
addPostFrameCallback
((
_
)
{
mouseTracker
.
updateAllDevices
(
renderView
.
hitTestMouseTrackers
);
...
...
@@ -77,13 +75,13 @@ class TestAnnotationTarget with Diagnosticable implements MouseTrackerAnnotation
const
TestAnnotationTarget
({
this
.
onEnter
,
this
.
onHover
,
this
.
onExit
,
this
.
cursor
=
MouseCursor
.
defer
});
@override
final
PointerEnterEventListener
onEnter
;
final
PointerEnterEventListener
?
onEnter
;
@override
final
PointerHoverEventListener
onHover
;
final
PointerHoverEventListener
?
onHover
;
@override
final
PointerExitEventListener
onExit
;
final
PointerExitEventListener
?
onExit
;
@override
final
MouseCursor
cursor
;
...
...
@@ -92,14 +90,14 @@ class TestAnnotationTarget with Diagnosticable implements MouseTrackerAnnotation
void
handleEvent
(
PointerEvent
event
,
HitTestEntry
entry
)
{
if
(
event
is
PointerHoverEvent
)
if
(
onHover
!=
null
)
onHover
(
event
);
onHover
!
(
event
);
}
}
// A hit test entry that can be assigned with a [TestAnnotationTarget] and an
// optional transform matrix.
class
TestAnnotationEntry
extends
HitTestEntry
{
TestAnnotationEntry
(
TestAnnotationTarget
target
,
[
Matrix4
transform
])
TestAnnotationEntry
(
TestAnnotationTarget
target
,
[
Matrix4
?
transform
])
:
transform
=
transform
??
Matrix4
.
identity
(),
super
(
target
);
@override
...
...
packages/flutter/test/rendering/recording_canvas.dart
View file @
cbf1e135
...
...
@@ -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/rendering.dart'
;
import
'package:flutter/src/rendering/layer.dart'
;
...
...
@@ -13,7 +11,7 @@ import 'package:flutter/src/rendering/layer.dart';
/// Used by [TestRecordingCanvas] to trace canvas calls.
class
RecordedInvocation
{
/// Create a record for an invocation list.
const
RecordedInvocation
(
this
.
invocation
,
{
this
.
stack
});
const
RecordedInvocation
(
this
.
invocation
,
{
required
this
.
stack
});
/// The method that was called and its arguments.
///
...
...
@@ -74,7 +72,7 @@ class TestRecordingCanvas implements Canvas {
}
@override
void
saveLayer
(
Rect
bounds
,
Paint
paint
)
{
void
saveLayer
(
Rect
?
bounds
,
Paint
paint
)
{
_saveCount
+=
1
;
invocations
.
add
(
RecordedInvocation
(
_MethodCall
(
#saveLayer
,
<
dynamic
>[
bounds
,
paint
]),
stack:
StackTrace
.
current
));
}
...
...
@@ -106,27 +104,27 @@ class TestRecordingPaintingContext extends ClipContext implements PaintingContex
}
@override
ClipRectLayer
pushClipRect
(
ClipRectLayer
?
pushClipRect
(
bool
needsCompositing
,
Offset
offset
,
Rect
clipRect
,
PaintingContextCallback
painter
,
{
Clip
clipBehavior
=
Clip
.
hardEdge
,
ClipRectLayer
oldLayer
,
ClipRectLayer
?
oldLayer
,
})
{
clipRectAndPaint
(
clipRect
.
shift
(
offset
),
clipBehavior
,
clipRect
.
shift
(
offset
),
()
=>
painter
(
this
,
offset
));
return
null
;
}
@override
ClipRRectLayer
pushClipRRect
(
ClipRRectLayer
?
pushClipRRect
(
bool
needsCompositing
,
Offset
offset
,
Rect
bounds
,
RRect
clipRRect
,
PaintingContextCallback
painter
,
{
Clip
clipBehavior
=
Clip
.
antiAlias
,
ClipRRectLayer
oldLayer
,
ClipRRectLayer
?
oldLayer
,
})
{
assert
(
clipBehavior
!=
null
);
clipRRectAndPaint
(
clipRRect
.
shift
(
offset
),
clipBehavior
,
bounds
.
shift
(
offset
),
()
=>
painter
(
this
,
offset
));
...
...
@@ -134,26 +132,26 @@ class TestRecordingPaintingContext extends ClipContext implements PaintingContex
}
@override
ClipPathLayer
pushClipPath
(
ClipPathLayer
?
pushClipPath
(
bool
needsCompositing
,
Offset
offset
,
Rect
bounds
,
Path
clipPath
,
PaintingContextCallback
painter
,
{
Clip
clipBehavior
=
Clip
.
antiAlias
,
ClipPathLayer
oldLayer
,
ClipPathLayer
?
oldLayer
,
})
{
clipPathAndPaint
(
clipPath
.
shift
(
offset
),
clipBehavior
,
bounds
.
shift
(
offset
),
()
=>
painter
(
this
,
offset
));
return
null
;
}
@override
TransformLayer
pushTransform
(
TransformLayer
?
pushTransform
(
bool
needsCompositing
,
Offset
offset
,
Matrix4
transform
,
PaintingContextCallback
painter
,
{
TransformLayer
oldLayer
,
TransformLayer
?
oldLayer
,
})
{
canvas
.
save
();
canvas
.
transform
(
transform
.
storage
);
...
...
@@ -163,17 +161,25 @@ class TestRecordingPaintingContext extends ClipContext implements PaintingContex
}
@override
OpacityLayer
pushOpacity
(
Offset
offset
,
int
alpha
,
PaintingContextCallback
painter
,
{
OpacityLayer
oldLayer
})
{
canvas
.
saveLayer
(
null
,
null
);
// TODO(ianh): Expose the alpha somewhere.
OpacityLayer
pushOpacity
(
Offset
offset
,
int
alpha
,
PaintingContextCallback
painter
,
{
OpacityLayer
?
oldLayer
,
})
{
canvas
.
saveLayer
(
null
,
Paint
());
// TODO(ianh): Expose the alpha somewhere.
painter
(
this
,
offset
);
canvas
.
restore
();
return
null
;
return
OpacityLayer
()
;
}
@override
void
pushLayer
(
Layer
childLayer
,
PaintingContextCallback
painter
,
Offset
offset
,
{
Rect
childPaintBounds
})
{
void
pushLayer
(
Layer
childLayer
,
PaintingContextCallback
painter
,
Offset
offset
,
{
Rect
?
childPaintBounds
,
})
{
painter
(
this
,
offset
);
}
...
...
@@ -204,7 +210,7 @@ class _MethodCall implements Invocation {
List
<
Type
>
get
typeArguments
=>
_typeArguments
;
}
String
_valueName
(
Object
value
)
{
String
_valueName
(
Object
?
value
)
{
if
(
value
is
double
)
return
value
.
toStringAsFixed
(
1
);
return
value
.
toString
();
...
...
@@ -228,7 +234,7 @@ String _describeInvocation(Invocation call) {
buffer
.
write
(
'('
);
buffer
.
writeAll
(
call
.
positionalArguments
.
map
<
String
>(
_valueName
),
', '
);
String
separator
=
call
.
positionalArguments
.
isEmpty
?
''
:
', '
;
call
.
namedArguments
.
forEach
((
Symbol
name
,
Object
value
)
{
call
.
namedArguments
.
forEach
((
Symbol
name
,
Object
?
value
)
{
buffer
.
write
(
separator
);
buffer
.
write
(
_symbolName
(
name
));
buffer
.
write
(
': '
);
...
...
packages/flutter/test/rendering/rendering_tester.dart
View file @
cbf1e135
...
...
@@ -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'
;
...
...
@@ -29,7 +27,7 @@ class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, Ser
TestRenderingFlutterBinding
({
this
.
onErrors
})
{
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
FlutterError
.
dumpErrorToConsole
(
details
);
Zone
.
current
.
parent
.
handleUncaughtError
(
details
.
exception
,
details
.
stack
);
Zone
.
current
.
parent
!.
handleUncaughtError
(
details
.
exception
as
Object
,
details
.
stack
!
);
};
}
...
...
@@ -40,14 +38,14 @@ class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, Ser
/// This function is expected to inspect these errors and decide whether they
/// are expected or not. Use [takeFlutterErrorDetails] to take one error at a
/// time, or [takeAllFlutterErrorDetails] to iterate over all errors.
VoidCallback
onErrors
;
VoidCallback
?
onErrors
;
/// Returns the error least recently caught by [FlutterError] and removes it
/// from the list of captured errors.
///
/// Returns null if no errors were captures, or if the list was exhausted by
/// calling this method repeatedly.
FlutterErrorDetails
takeFlutterErrorDetails
()
{
FlutterErrorDetails
?
takeFlutterErrorDetails
()
{
if
(
_errors
.
isEmpty
)
{
return
null
;
}
...
...
@@ -87,7 +85,7 @@ class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, Ser
@override
void
drawFrame
()
{
assert
(
phase
!=
EnginePhase
.
build
,
'rendering_tester does not support testing the build phase; use flutter_test instead'
);
final
FlutterExceptionHandler
oldErrorHandler
=
FlutterError
.
onError
;
final
FlutterExceptionHandler
?
oldErrorHandler
=
FlutterError
.
onError
;
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
_errors
.
add
(
details
);
};
...
...
@@ -113,7 +111,7 @@ class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, Ser
FlutterError
.
onError
=
oldErrorHandler
;
if
(
_errors
.
isNotEmpty
)
{
if
(
onErrors
!=
null
)
{
onErrors
();
onErrors
!
();
if
(
_errors
.
isNotEmpty
)
{
_errors
.
forEach
(
FlutterError
.
dumpErrorToConsole
);
fail
(
'There are more errors than the test inspected using TestRenderingFlutterBinding.takeFlutterErrorDetails.'
);
...
...
@@ -127,11 +125,9 @@ class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, Ser
}
}
TestRenderingFlutterBinding
_renderer
;
TestRenderingFlutterBinding
get
renderer
{
_renderer
??=
TestRenderingFlutterBinding
();
return
_renderer
;
}
late
final
TestRenderingFlutterBinding
_renderer
=
TestRenderingFlutterBinding
();
TestRenderingFlutterBinding
get
renderer
=>
_renderer
;
/// Place the box in the render tree, at the given size and with the given
/// alignment on the screen.
...
...
@@ -149,10 +145,10 @@ TestRenderingFlutterBinding get renderer {
/// If `onErrors` is not null, it is set as [TestRenderingFlutterBinding.onError].
void
layout
(
RenderBox
box
,
{
BoxConstraints
constraints
,
BoxConstraints
?
constraints
,
Alignment
alignment
=
Alignment
.
center
,
EnginePhase
phase
=
EnginePhase
.
layout
,
VoidCallback
onErrors
,
VoidCallback
?
onErrors
,
})
{
assert
(
box
!=
null
);
// If you want to just repump the last box, call pumpFrame().
assert
(
box
.
parent
==
null
);
// We stick the box in another, so you can't reuse it easily, sorry.
...
...
@@ -175,7 +171,7 @@ void layout(
/// Pumps a single frame.
///
/// If `onErrors` is not null, it is set as [TestRenderingFlutterBinding.onError].
void
pumpFrame
(
{
EnginePhase
phase
=
EnginePhase
.
layout
,
VoidCallback
onErrors
})
{
void
pumpFrame
(
{
EnginePhase
phase
=
EnginePhase
.
layout
,
VoidCallback
?
onErrors
})
{
assert
(
renderer
!=
null
);
assert
(
renderer
.
renderView
!=
null
);
assert
(
renderer
.
renderView
.
child
!=
null
);
// call layout() first!
...
...
@@ -189,7 +185,7 @@ void pumpFrame({ EnginePhase phase = EnginePhase.layout, VoidCallback onErrors }
}
class
TestCallbackPainter
extends
CustomPainter
{
const
TestCallbackPainter
({
this
.
onPaint
});
const
TestCallbackPainter
({
required
this
.
onPaint
});
final
VoidCallback
onPaint
;
...
...
@@ -251,25 +247,25 @@ class FakeTickerProvider implements TickerProvider {
class
FakeTicker
implements
Ticker
{
@override
bool
muted
;
bool
muted
=
false
;
@override
void
absorbTicker
(
Ticker
originalTicker
)
{
}
@override
String
get
debugLabel
=>
null
;
String
?
get
debugLabel
=>
null
;
@override
bool
get
isActive
=>
null
;
bool
get
isActive
=>
throw
UnimplementedError
()
;
@override
bool
get
isTicking
=>
null
;
bool
get
isTicking
=>
throw
UnimplementedError
()
;
@override
bool
get
scheduled
=>
null
;
bool
get
scheduled
=>
throw
UnimplementedError
()
;
@override
bool
get
shouldScheduleTick
=>
null
;
bool
get
shouldScheduleTick
=>
throw
UnimplementedError
()
;
@override
void
dispose
()
{
}
...
...
@@ -279,7 +275,7 @@ class FakeTicker implements Ticker {
@override
TickerFuture
start
()
{
return
null
;
throw
UnimplementedError
()
;
}
@override
...
...
@@ -301,7 +297,14 @@ class TestClipPaintingContext extends PaintingContext {
TestClipPaintingContext
()
:
super
(
ContainerLayer
(),
Rect
.
zero
);
@override
ClipRectLayer
pushClipRect
(
bool
needsCompositing
,
Offset
offset
,
Rect
clipRect
,
PaintingContextCallback
painter
,
{
Clip
clipBehavior
=
Clip
.
hardEdge
,
ClipRectLayer
oldLayer
})
{
ClipRectLayer
?
pushClipRect
(
bool
needsCompositing
,
Offset
offset
,
Rect
clipRect
,
PaintingContextCallback
painter
,
{
Clip
clipBehavior
=
Clip
.
hardEdge
,
ClipRectLayer
?
oldLayer
,
})
{
this
.
clipBehavior
=
clipBehavior
;
return
null
;
}
...
...
@@ -310,7 +313,7 @@ class TestClipPaintingContext extends PaintingContext {
}
void
expectOverflowedErrors
(
)
{
final
FlutterErrorDetails
errorDetails
=
renderer
.
takeFlutterErrorDetails
();
final
FlutterErrorDetails
errorDetails
=
renderer
.
takeFlutterErrorDetails
()
!
;
final
bool
overflowed
=
errorDetails
.
toString
().
contains
(
'overflowed'
);
if
(!
overflowed
)
{
FlutterError
.
reportError
(
errorDetails
);
...
...
packages/flutter/test/services/restoration.dart
View file @
cbf1e135
...
...
@@ -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:typed_data'
;
import
'package:flutter/services.dart'
;
...
...
@@ -53,15 +51,15 @@ class MockRestorationManager extends TestRestorationManager {
int
rootBucketAccessed
=
0
;
@override
Future
<
RestorationBucket
>
get
rootBucket
{
Future
<
RestorationBucket
?
>
get
rootBucket
{
rootBucketAccessed
++;
return
_rootBucket
;
}
Future
<
RestorationBucket
>
_rootBucket
;
set
rootBucket
(
Future
<
RestorationBucket
>
value
)
{
late
Future
<
RestorationBucket
?
>
_rootBucket
;
set
rootBucket
(
Future
<
RestorationBucket
?
>
value
)
{
_rootBucket
=
value
;
_isRestoring
=
true
;
ServicesBinding
.
instance
.
addPostFrameCallback
((
Duration
_
)
{
ServicesBinding
.
instance
!
.
addPostFrameCallback
((
Duration
_
)
{
_isRestoring
=
false
;
});
notifyListeners
();
...
...
@@ -69,7 +67,7 @@ class MockRestorationManager extends TestRestorationManager {
@override
bool
get
isReplacing
=>
_isRestoring
;
bool
_isRestoring
;
bool
_isRestoring
=
false
;
@override
Future
<
void
>
sendToEngine
(
Uint8List
encodedData
)
{
...
...
packages/flutter/test/widgets/editable_text_utils.dart
View file @
cbf1e135
...
...
@@ -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/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
...
...
@@ -13,7 +11,7 @@ RenderEditable findRenderEditable(WidgetTester tester) {
final
RenderObject
root
=
tester
.
renderObject
(
find
.
byType
(
EditableText
));
expect
(
root
,
isNotNull
);
RenderEditable
renderEditable
;
late
RenderEditable
renderEditable
;
void
recursiveFinder
(
RenderObject
child
)
{
if
(
child
is
RenderEditable
)
{
renderEditable
=
child
;
...
...
packages/flutter/test/widgets/gesture_utils.dart
View file @
cbf1e135
...
...
@@ -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/gestures.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
packages/flutter/test/widgets/observer_tester.dart
View file @
cbf1e135
...
...
@@ -2,49 +2,47 @@
// 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/material.dart'
;
typedef
OnObservation
=
void
Function
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
);
typedef
OnObservation
=
void
Function
(
Route
<
dynamic
>
?
route
,
Route
<
dynamic
>?
previousRoute
);
/// A trivial observer for testing the navigator.
class
TestObserver
extends
NavigatorObserver
{
OnObservation
onPushed
;
OnObservation
onPopped
;
OnObservation
onRemoved
;
OnObservation
onReplaced
;
OnObservation
onStartUserGesture
;
OnObservation
?
onPushed
;
OnObservation
?
onPopped
;
OnObservation
?
onRemoved
;
OnObservation
?
onReplaced
;
OnObservation
?
onStartUserGesture
;
@override
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
?
previousRoute
)
{
if
(
onPushed
!=
null
)
{
onPushed
(
route
,
previousRoute
);
onPushed
!
(
route
,
previousRoute
);
}
}
@override
void
didPop
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
void
didPop
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
?
previousRoute
)
{
if
(
onPopped
!=
null
)
{
onPopped
(
route
,
previousRoute
);
onPopped
!
(
route
,
previousRoute
);
}
}
@override
void
didRemove
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
void
didRemove
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
?
previousRoute
)
{
if
(
onRemoved
!=
null
)
onRemoved
(
route
,
previousRoute
);
onRemoved
!
(
route
,
previousRoute
);
}
@override
void
didReplace
({
Route
<
dynamic
>
oldRoute
,
Route
<
dynamic
>
newRoute
})
{
void
didReplace
({
Route
<
dynamic
>
?
oldRoute
,
Route
<
dynamic
>?
newRoute
})
{
if
(
onReplaced
!=
null
)
onReplaced
(
newRoute
,
oldRoute
);
onReplaced
!
(
newRoute
,
oldRoute
);
}
@override
void
didStartUserGesture
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
void
didStartUserGesture
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
?
previousRoute
)
{
if
(
onStartUserGesture
!=
null
)
onStartUserGesture
(
route
,
previousRoute
);
onStartUserGesture
!
(
route
,
previousRoute
);
}
}
packages/flutter/test/widgets/restoration.dart
View file @
cbf1e135
...
...
@@ -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/services.dart'
;
import
'package:flutter/widgets.dart'
;
export
'../services/restoration.dart'
;
class
BucketSpy
extends
StatefulWidget
{
const
BucketSpy
({
Key
key
,
this
.
child
})
:
super
(
key:
key
);
const
BucketSpy
({
Key
?
key
,
this
.
child
})
:
super
(
key:
key
);
final
Widget
child
;
final
Widget
?
child
;
@override
State
<
BucketSpy
>
createState
()
=>
BucketSpyState
();
}
class
BucketSpyState
extends
State
<
BucketSpy
>
{
RestorationBucket
bucket
;
RestorationBucket
?
bucket
;
@override
void
didChangeDependencies
()
{
...
...
packages/flutter/test/widgets/semantics_tester.dart
View file @
cbf1e135
This diff is collapsed.
Click to expand it.
packages/flutter/test/widgets/states.dart
View file @
cbf1e135
...
...
@@ -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
const
List
<
String
>
kStates
=
<
String
>[
'Alabama'
,
'Alaska'
,
...
...
packages/flutter/test/widgets/test_border.dart
View file @
cbf1e135
...
...
@@ -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/material.dart'
;
typedef
Logger
=
void
Function
(
String
caller
);
...
...
@@ -20,19 +18,19 @@ class TestBorder extends ShapeBorder {
ShapeBorder
scale
(
double
t
)
=>
TestBorder
(
onLog
);
@override
Path
getInnerPath
(
Rect
rect
,
{
TextDirection
textDirection
})
{
Path
getInnerPath
(
Rect
rect
,
{
TextDirection
?
textDirection
})
{
onLog
(
'getInnerPath
$rect
$textDirection
'
);
return
Path
();
}
@override
Path
getOuterPath
(
Rect
rect
,
{
TextDirection
textDirection
})
{
Path
getOuterPath
(
Rect
rect
,
{
TextDirection
?
textDirection
})
{
onLog
(
'getOuterPath
$rect
$textDirection
'
);
return
Path
();
}
@override
void
paint
(
Canvas
canvas
,
Rect
rect
,
{
TextDirection
textDirection
})
{
void
paint
(
Canvas
canvas
,
Rect
rect
,
{
TextDirection
?
textDirection
})
{
onLog
(
'paint
$rect
$textDirection
'
);
}
}
packages/flutter/test/widgets/test_widgets.dart
View file @
cbf1e135
...
...
@@ -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'
;
...
...
@@ -21,7 +19,7 @@ const BoxDecoration kBoxDecorationC = BoxDecoration(
);
class
TestBuildCounter
extends
StatelessWidget
{
const
TestBuildCounter
({
Key
key
})
:
super
(
key:
key
);
const
TestBuildCounter
({
Key
?
key
})
:
super
(
key:
key
);
static
int
buildCount
=
0
;
...
...
@@ -34,7 +32,7 @@ class TestBuildCounter extends StatelessWidget {
class
FlipWidget
extends
StatefulWidget
{
const
FlipWidget
({
Key
key
,
this
.
left
,
this
.
right
})
:
super
(
key:
key
);
const
FlipWidget
({
Key
?
key
,
required
this
.
left
,
required
this
.
right
})
:
super
(
key:
key
);
final
Widget
left
;
final
Widget
right
;
...
...
packages/flutter/test/widgets/text.dart
View file @
cbf1e135
...
...
@@ -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/material.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -14,7 +12,7 @@ RenderEditable findRenderEditable(WidgetTester tester) {
final
RenderObject
root
=
tester
.
renderObject
(
find
.
byType
(
EditableText
));
expect
(
root
,
isNotNull
);
RenderEditable
renderEditable
;
late
RenderEditable
renderEditable
;
void
recursiveFinder
(
RenderObject
child
)
{
if
(
child
is
RenderEditable
)
{
renderEditable
=
child
;
...
...
packages/flutter/test/widgets/widget_inspector_test_utils.dart
View file @
cbf1e135
...
...
@@ -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'
;
...
...
@@ -12,48 +10,46 @@ import 'package:flutter/material.dart';
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
typedef
InspectorServiceExtensionCallback
=
FutureOr
<
Map
<
String
,
Object
>>
Function
(
Map
<
String
,
String
>
parameters
);
class
TestWidgetInspectorService
extends
Object
with
WidgetInspectorService
{
final
Map
<
String
,
InspectorServiceExtensionCallback
>
extensions
=
<
String
,
Inspector
ServiceExtensionCallback
>{};
final
Map
<
String
,
ServiceExtensionCallback
>
extensions
=
<
String
,
ServiceExtensionCallback
>{};
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
ServiceExtensionCallback
callback
,
})
{
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
)
{
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
<
Object
>
testExtension
(
String
name
,
Map
<
String
,
String
>
arguments
)
async
{
Future
<
Object
?
>
testExtension
(
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
)))[
'result'
];
return
json
.
decode
(
json
.
encode
(
await
extensions
[
name
]
!
(
arguments
)))[
'result'
];
}
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
;
}
int
rebuildCount
=
0
;
...
...
@@ -61,10 +57,10 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
@override
Future
<
void
>
forceRebuild
()
async
{
rebuildCount
++;
final
WidgetsBinding
binding
=
WidgetsBinding
.
instance
;
final
WidgetsBinding
binding
=
WidgetsBinding
.
instance
!
;
if
(
binding
.
renderViewElement
!=
null
)
{
binding
.
buildOwner
.
reassemble
(
binding
.
renderViewElement
);
binding
.
buildOwner
!.
reassemble
(
binding
.
renderViewElement
!
);
}
}
}
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