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
73208301
Unverified
Commit
73208301
authored
Aug 04, 2020
by
Jonah Williams
Committed by
GitHub
Aug 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[null-safety] remove mockito from text control a11y test (#62869)
parent
3aa0b48a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
22 deletions
+67
-22
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+67
-22
No files found.
packages/flutter/test/widgets/editable_text_test.dart
View file @
73208301
...
...
@@ -13,9 +13,9 @@ import 'package:flutter/material.dart';
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/services.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:flutter/foundation.dart'
;
import
'../flutter_test_alternative.dart'
show
Fake
;
import
'../rendering/mock_canvas.dart'
;
import
'editable_text_utils.dart'
;
import
'semantics_tester.dart'
;
...
...
@@ -2559,18 +2559,15 @@ void main() {
TextSelection
.
collapsed
(
offset:
controller
.
text
.
length
);
controls
=
MockTextSelectionControls
();
when
(
controls
.
buildHandle
(
any
,
any
,
any
)).
thenReturn
(
Container
());
when
(
controls
.
buildToolbar
(
any
,
any
,
any
,
any
,
any
,
any
,
any
))
.
thenReturn
(
Container
());
});
testWidgets
(
'are exposed'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
addTearDown
(
semantics
.
dispose
);
when
(
controls
.
canCopy
(
any
)).
thenReturn
(
false
)
;
when
(
controls
.
canCut
(
any
)).
thenReturn
(
false
)
;
when
(
controls
.
canPaste
(
any
)).
thenReturn
(
false
)
;
controls
.
testCanCopy
=
false
;
controls
.
testCanCut
=
false
;
controls
.
testCanPaste
=
false
;
await
_buildApp
(
controls
,
tester
);
await
tester
.
tap
(
find
.
byType
(
EditableText
));
...
...
@@ -2588,7 +2585,7 @@ void main() {
),
);
when
(
controls
.
canCopy
(
any
)).
thenReturn
(
true
)
;
controls
.
testCanCopy
=
true
;
await
_buildApp
(
controls
,
tester
);
expect
(
semantics
,
...
...
@@ -2603,8 +2600,8 @@ void main() {
),
);
when
(
controls
.
canCopy
(
any
)).
thenReturn
(
false
)
;
when
(
controls
.
canPaste
(
any
)).
thenReturn
(
true
)
;
controls
.
testCanCopy
=
false
;
controls
.
testCanPaste
=
true
;
await
_buildApp
(
controls
,
tester
);
await
tester
.
pumpAndSettle
();
expect
(
...
...
@@ -2620,8 +2617,8 @@ void main() {
),
);
when
(
controls
.
canPaste
(
any
)).
thenReturn
(
false
)
;
when
(
controls
.
canCut
(
any
)).
thenReturn
(
true
)
;
controls
.
testCanPaste
=
false
;
controls
.
testCanCut
=
true
;
await
_buildApp
(
controls
,
tester
);
expect
(
semantics
,
...
...
@@ -2636,9 +2633,9 @@ void main() {
),
);
when
(
controls
.
canCopy
(
any
)).
thenReturn
(
true
)
;
when
(
controls
.
canCut
(
any
)).
thenReturn
(
true
)
;
when
(
controls
.
canPaste
(
any
)).
thenReturn
(
true
)
;
controls
.
testCanCopy
=
true
;
controls
.
testCanCut
=
true
;
controls
.
testCanPaste
=
true
;
await
_buildApp
(
controls
,
tester
);
expect
(
semantics
,
...
...
@@ -2659,9 +2656,9 @@ void main() {
testWidgets
(
'can copy/cut/paste with a11y'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
when
(
controls
.
canCopy
(
any
)).
thenReturn
(
true
)
;
when
(
controls
.
canCut
(
any
)).
thenReturn
(
true
)
;
when
(
controls
.
canPaste
(
any
)).
thenReturn
(
true
)
;
controls
.
testCanCopy
=
true
;
controls
.
testCanCut
=
true
;
controls
.
testCanPaste
=
true
;
await
_buildApp
(
controls
,
tester
);
await
tester
.
tap
(
find
.
byType
(
EditableText
));
await
tester
.
pump
();
...
...
@@ -2717,13 +2714,13 @@ void main() {
);
owner
.
performAction
(
expectedNodeId
,
SemanticsAction
.
copy
);
verify
(
controls
.
handleCopy
(
any
,
any
)).
called
(
1
);
expect
(
controls
.
copyCount
,
1
);
owner
.
performAction
(
expectedNodeId
,
SemanticsAction
.
cut
);
verify
(
controls
.
handleCut
(
any
)).
called
(
1
);
expect
(
controls
.
cutCount
,
1
);
owner
.
performAction
(
expectedNodeId
,
SemanticsAction
.
paste
);
verify
(
controls
.
handlePaste
(
any
)).
called
(
1
);
expect
(
controls
.
pasteCount
,
1
);
semantics
.
dispose
();
});
...
...
@@ -5263,7 +5260,17 @@ class MockTextFormatter extends TextInputFormatter {
}
}
class
MockTextSelectionControls
extends
Mock
implements
TextSelectionControls
{
class
MockTextSelectionControls
extends
Fake
implements
TextSelectionControls
{
@override
Widget
buildToolbar
(
BuildContext
context
,
Rect
globalEditableRegion
,
double
textLineHeight
,
Offset
position
,
List
<
TextSelectionPoint
>
endpoints
,
TextSelectionDelegate
delegate
,
ClipboardStatusNotifier
clipboardStatus
)
{
return
Container
();
}
@override
Widget
buildHandle
(
BuildContext
context
,
TextSelectionHandleType
type
,
double
textLineHeight
)
{
return
Container
();
}
@override
Size
getHandleSize
(
double
textLineHeight
)
{
return
Size
.
zero
;
...
...
@@ -5273,6 +5280,44 @@ class MockTextSelectionControls extends Mock implements TextSelectionControls {
Offset
getHandleAnchor
(
TextSelectionHandleType
type
,
double
textLineHeight
)
{
return
Offset
.
zero
;
}
bool
testCanCut
=
false
;
bool
testCanCopy
=
false
;
bool
testCanPaste
=
false
;
int
cutCount
=
0
;
int
pasteCount
=
0
;
int
copyCount
=
0
;
@override
void
handleCopy
(
TextSelectionDelegate
delegate
,
ClipboardStatusNotifier
clipboardStatus
)
{
copyCount
+=
1
;
}
@override
Future
<
void
>
handlePaste
(
TextSelectionDelegate
delegate
)
async
{
pasteCount
+=
1
;
}
@override
void
handleCut
(
TextSelectionDelegate
delegate
)
{
cutCount
+=
1
;
}
@override
bool
canCut
(
TextSelectionDelegate
delegate
)
{
return
testCanCut
;
}
@override
bool
canCopy
(
TextSelectionDelegate
delegate
)
{
return
testCanCopy
;
}
@override
bool
canPaste
(
TextSelectionDelegate
delegate
)
{
return
testCanPaste
;
}
}
class
CustomStyleEditableText
extends
EditableText
{
...
...
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