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
cfc08594
Unverified
Commit
cfc08594
authored
Jun 04, 2021
by
Alexandre Ardhuin
Committed by
GitHub
Jun 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enable lint use_test_throws_matchers (#83943)
parent
f890e9ca
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
553 additions
and
556 deletions
+553
-556
analysis_options.yaml
analysis_options.yaml
+1
-0
tween_test.dart
packages/flutter/test/animation/tween_test.dart
+48
-64
expansion_tile_test.dart
packages/flutter/test/material/expansion_tile_test.dart
+14
-15
reorderable_list_test.dart
packages/flutter/test/material/reorderable_list_test.dart
+4
-5
platform_channel_test.dart
packages/flutter/test/services/platform_channel_test.dart
+35
-37
raw_keyboard_test.dart
packages/flutter/test/services/raw_keyboard_test.dart
+14
-10
selectable_text_test.dart
packages/flutter/test/widgets/selectable_text_test.dart
+19
-16
generate_localizations_test.dart
...tools/test/general.shard/generate_localizations_test.dart
+418
-409
No files found.
analysis_options.yaml
View file @
cfc08594
...
...
@@ -228,6 +228,7 @@ linter:
-
use_rethrow_when_possible
# - use_setters_to_change_properties # not yet tested
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
-
use_test_throws_matchers
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
-
valid_regexps
-
void_checks
packages/flutter/test/animation/tween_test.dart
View file @
cfc08594
...
...
@@ -14,22 +14,18 @@ void main() {
end:
Object
(),
);
FlutterError
?
error
;
try
{
objectTween
.
transform
(
0.1
);
}
on
FlutterError
catch
(
err
)
{
error
=
err
;
}
if
(
error
==
null
)
{
fail
(
'Expected Tween.transform to throw a FlutterError'
);
}
expect
(
error
.
diagnostics
.
map
((
DiagnosticsNode
node
)
=>
node
.
toString
()),
<
String
>[
expect
(
()
=>
objectTween
.
transform
(
0.1
),
throwsA
(
isA
<
FlutterError
>().
having
(
(
FlutterError
error
)
=>
error
.
diagnostics
.
map
((
DiagnosticsNode
node
)
=>
node
.
toString
()),
'diagnostics'
,
<
String
>[
'Cannot lerp between "Instance of
\'
Object
\'
" and "Instance of
\'
Object
\'
".'
,
'The type Object might not fully implement `+`, `-`, and/or `*`.
$kApiDocsLink
'
,
'There may be a dedicated "ObjectTween" for this type, or you may need to create one.'
,
]);
],
)),
);
});
test
(
'throws flutter error when tweening types that do not fully satisfy tween requirements - Color'
,
()
{
...
...
@@ -38,22 +34,18 @@ void main() {
end:
const
Color
(
0xFFFFFFFF
),
);
FlutterError
?
error
;
try
{
colorTween
.
transform
(
0.1
);
}
on
FlutterError
catch
(
err
)
{
error
=
err
;
}
if
(
error
==
null
)
{
fail
(
'Expected Tween.transform to throw a FlutterError'
);
}
expect
(
error
.
diagnostics
.
map
((
DiagnosticsNode
node
)
=>
node
.
toString
()),
<
String
>[
expect
(
()
=>
colorTween
.
transform
(
0.1
),
throwsA
(
isA
<
FlutterError
>().
having
(
(
FlutterError
error
)
=>
error
.
diagnostics
.
map
((
DiagnosticsNode
node
)
=>
node
.
toString
()),
'diagnostics'
,
<
String
>[
'Cannot lerp between "Color(0xff000000)" and "Color(0xffffffff)".'
,
'The type Color might not fully implement `+`, `-`, and/or `*`.
$kApiDocsLink
'
,
'To lerp colors, consider ColorTween instead.'
,
]);
],
)),
);
});
test
(
'throws flutter error when tweening types that do not fully satisfy tween requirements - Rect'
,
()
{
...
...
@@ -62,22 +54,18 @@ void main() {
end:
const
Rect
.
fromLTWH
(
2
,
2
,
2
,
2
),
);
FlutterError
?
error
;
try
{
rectTween
.
transform
(
0.1
);
}
on
FlutterError
catch
(
err
)
{
error
=
err
;
}
if
(
error
==
null
)
{
fail
(
'Expected Tween.transform to throw a FlutterError'
);
}
expect
(
error
.
diagnostics
.
map
((
DiagnosticsNode
node
)
=>
node
.
toString
()),
<
String
>[
expect
(
()
=>
rectTween
.
transform
(
0.1
),
throwsA
(
isA
<
FlutterError
>().
having
(
(
FlutterError
error
)
=>
error
.
diagnostics
.
map
((
DiagnosticsNode
node
)
=>
node
.
toString
()),
'diagnostics'
,
<
String
>[
'Cannot lerp between "Rect.fromLTRB(0.0, 0.0, 10.0, 10.0)" and "Rect.fromLTRB(2.0, 2.0, 4.0, 4.0)".'
,
'The type Rect might not fully implement `+`, `-`, and/or `*`.
$kApiDocsLink
'
,
'To lerp rects, consider RectTween instead.'
,
]);
],
)),
);
});
test
(
'throws flutter error when tweening types that do not fully satisfy tween requirements - int'
,
()
{
...
...
@@ -86,22 +74,18 @@ void main() {
end:
1
,
);
FlutterError
?
error
;
try
{
colorTween
.
transform
(
0.1
);
}
on
FlutterError
catch
(
err
)
{
error
=
err
;
}
if
(
error
==
null
)
{
fail
(
'Expected Tween.transform to throw a FlutterError'
);
}
expect
(
error
.
diagnostics
.
map
((
DiagnosticsNode
node
)
=>
node
.
toString
()),
<
String
>[
expect
(
()
=>
colorTween
.
transform
(
0.1
),
throwsA
(
isA
<
FlutterError
>().
having
(
(
FlutterError
error
)
=>
error
.
diagnostics
.
map
((
DiagnosticsNode
node
)
=>
node
.
toString
()),
'diagnostics'
,
<
String
>[
'Cannot lerp between "0" and "1".'
,
'The type int returned a double after multiplication with a double value.
$kApiDocsLink
'
,
'To lerp int values, consider IntTween or StepTween instead.'
,
]);
],
)),
);
});
test
(
'Can chain tweens'
,
()
{
...
...
packages/flutter/test/material/expansion_tile_test.dart
View file @
cfc08594
...
...
@@ -371,7 +371,8 @@ void main() {
});
testWidgets
(
'CrossAxisAlignment.baseline is not allowed'
,
(
WidgetTester
tester
)
async
{
try
{
expect
(
()
{
MaterialApp
(
home:
Material
(
child:
ExpansionTile
(
...
...
@@ -381,14 +382,12 @@ void main() {
),
),
);
}
on
AssertionError
catch
(
error
)
{
expect
(
error
.
toString
()
,
contains
(
},
throwsA
(
isA
<
AssertionError
>().
having
((
AssertionError
error
)
=>
error
.
toString
(),
'.toString()'
,
contains
(
'CrossAxisAlignment.baseline is not supported since the expanded'
' children are aligned in a column, not a row. Try to use another constant.'
,
));
return
;
}
fail
(
'AssertionError was not thrown when expandedCrossAxisAlignment is CrossAxisAlignment.baseline.'
);
))),
);
});
testWidgets
(
'expandedCrossAxisAlignment and expandedAlignment default values'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/material/reorderable_list_test.dart
View file @
cfc08594
...
...
@@ -485,11 +485,10 @@ void main() {
),
),
);
try
{
await
tester
.
pumpWidget
(
boilerplate
);
}
catch
(
e
)
{
fail
(
'Expected no error, but got
$e
'
);
}
await
expectLater
(
()
=>
tester
.
pumpWidget
(
boilerplate
),
returnsNormally
,
);
});
group
(
'Accessibility (a11y/Semantics)'
,
()
{
...
...
packages/flutter/test/services/platform_channel_test.dart
View file @
cfc08594
...
...
@@ -128,16 +128,15 @@ void main() {
]);
},
);
try
{
await
channel
.
invokeMethod
<
dynamic
>(
'sayHello'
,
'hello'
);
fail
(
'Exception expected'
);
}
on
PlatformException
catch
(
e
)
{
expect
(
e
.
code
,
equals
(
'bad'
));
expect
(
e
.
message
,
equals
(
'Something happened'
));
expect
(
e
.
details
,
equals
(<
String
,
dynamic
>{
'a'
:
42
,
'b'
:
3.14
}));
}
catch
(
e
)
{
fail
(
'PlatformException expected'
);
}
expect
(
()
=>
channel
.
invokeMethod
<
dynamic
>(
'sayHello'
,
'hello'
),
throwsA
(
isA
<
PlatformException
>()
.
having
((
PlatformException
e
)
=>
e
.
code
,
'code'
,
equals
(
'bad'
))
.
having
((
PlatformException
e
)
=>
e
.
message
,
'message'
,
equals
(
'Something happened'
))
.
having
((
PlatformException
e
)
=>
e
.
details
,
'details'
,
equals
(<
String
,
dynamic
>{
'a'
:
42
,
'b'
:
3.14
})),
),
);
});
test
(
'can invoke unimplemented method'
,
()
async
{
...
...
@@ -145,15 +144,16 @@ void main() {
'ch7'
,
(
ByteData
?
message
)
async
=>
null
,
);
try
{
await
channel
.
invokeMethod
<
void
>(
'sayHello'
,
'hello'
);
fail
(
'Exception expected'
);
}
on
MissingPluginException
catch
(
e
)
{
expect
(
e
.
message
,
contains
(
'sayHello'
));
expect
(
e
.
message
,
contains
(
'ch7'
));
}
catch
(
e
)
{
fail
(
'MissingPluginException expected'
);
}
expect
(
()
=>
channel
.
invokeMethod
<
void
>(
'sayHello'
,
'hello'
),
throwsA
(
isA
<
MissingPluginException
>()
.
having
((
MissingPluginException
e
)
=>
e
.
message
,
'message'
,
allOf
(
contains
(
'sayHello'
),
contains
(
'ch7'
),
)),
),
);
});
test
(
'can invoke unimplemented method (optional)'
,
()
async
{
...
...
@@ -218,15 +218,14 @@ void main() {
await
TestDefaultBinaryMessengerBinding
.
instance
!.
defaultBinaryMessenger
.
handlePlatformMessage
(
'ch7'
,
call
,
(
ByteData
?
result
)
{
envelope
=
result
;
});
try
{
jsonMethod
.
decodeEnvelope
(
envelope
!);
fail
(
'Exception expected'
);
}
on
PlatformException
catch
(
e
)
{
expect
(
e
.
code
,
equals
(
'bad'
));
expect
(
e
.
message
,
equals
(
'sayHello failed'
));
}
catch
(
e
)
{
fail
(
'PlatformException expected'
);
}
expect
(
()
=>
jsonMethod
.
decodeEnvelope
(
envelope
!),
throwsA
(
isA
<
PlatformException
>()
.
having
((
PlatformException
e
)
=>
e
.
code
,
'code'
,
equals
(
'bad'
))
.
having
((
PlatformException
e
)
=>
e
.
message
,
'message'
,
equals
(
'sayHello failed'
)),
),
);
});
test
(
'can handle method call with other error result'
,
()
async
{
...
...
@@ -238,15 +237,14 @@ void main() {
await
TestDefaultBinaryMessengerBinding
.
instance
!.
defaultBinaryMessenger
.
handlePlatformMessage
(
'ch7'
,
call
,
(
ByteData
?
result
)
{
envelope
=
result
;
});
try
{
jsonMethod
.
decodeEnvelope
(
envelope
!);
fail
(
'Exception expected'
);
}
on
PlatformException
catch
(
e
)
{
expect
(
e
.
code
,
equals
(
'error'
));
expect
(
e
.
message
,
equals
(
'Invalid argument(s): bad'
));
}
catch
(
e
)
{
fail
(
'PlatformException expected'
);
}
expect
(
()
=>
jsonMethod
.
decodeEnvelope
(
envelope
!),
throwsA
(
isA
<
PlatformException
>()
.
having
((
PlatformException
e
)
=>
e
.
code
,
'code'
,
equals
(
'error'
))
.
having
((
PlatformException
e
)
=>
e
.
message
,
'message'
,
equals
(
'Invalid argument(s): bad'
)),
),
);
});
test
(
'can check the mock handler'
,
()
async
{
...
...
packages/flutter/test/services/raw_keyboard_test.dart
View file @
cfc08594
...
...
@@ -686,16 +686,20 @@ void main() {
};
}
try
{
expect
(
()
async
{
await
TestDefaultBinaryMessengerBinding
.
instance
!.
defaultBinaryMessenger
.
handlePlatformMessage
(
SystemChannels
.
keyEvent
.
name
,
SystemChannels
.
keyEvent
.
codec
.
encodeMessage
(
keyEventMessage
),
(
ByteData
?
data
)
{
},
);
fail
(
'Expected an exception, but did not get one.'
);
}
on
AssertionError
catch
(
error
)
{
expect
(
error
.
toString
(),
contains
(
'Attempted to send a key down event when no keys are in keysPressed'
));
}
},
throwsA
(
isA
<
AssertionError
>().
having
(
(
AssertionError
error
)
=>
error
.
toString
(),
'.toString()'
,
contains
(
'Attempted to send a key down event when no keys are in keysPressed'
),
)),
);
});
});
...
...
packages/flutter/test/widgets/selectable_text_test.dart
View file @
cfc08594
...
...
@@ -1303,7 +1303,8 @@ void main() {
});
testWidgets
(
'minLines cannot be greater than maxLines'
,
(
WidgetTester
tester
)
async
{
try
{
expect
(
()
async
{
await
tester
.
pumpWidget
(
overlay
(
child:
SizedBox
(
...
...
@@ -1316,11 +1317,13 @@ void main() {
),
),
);
}
on
AssertionError
catch
(
e
)
{
expect
(
e
.
toString
(),
contains
(
"minLines can't be greater than maxLines"
));
return
;
}
fail
(
'An assert should be triggered when minLines is greater than maxLines'
);
},
throwsA
(
isA
<
AssertionError
>().
having
(
(
AssertionError
error
)
=>
error
.
toString
(),
'.toString()'
,
contains
(
"minLines can't be greater than maxLines"
),
)),
);
});
testWidgets
(
'Selectable height with minLine'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter_tools/test/general.shard/generate_localizations_test.dart
View file @
cfc08594
This diff is collapsed.
Click to expand it.
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