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
b93f71f9
Unverified
Commit
b93f71f9
authored
Oct 12, 2020
by
Justin McCandless
Committed by
GitHub
Oct 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NNDB TextField tests (#67696)
Just another nnbd conversion PR.
parent
23c7ee9d
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
145 additions
and
156 deletions
+145
-156
text_field_test.dart
packages/flutter/test/material/text_field_test.dart
+120
-125
text_form_field_test.dart
packages/flutter/test/material/text_form_field_test.dart
+14
-16
text_selection_test.dart
packages/flutter/test/material/text_selection_test.dart
+8
-10
text_selection_theme_test.dart
...ages/flutter/test/material/text_selection_theme_test.dart
+3
-5
No files found.
packages/flutter/test/material/text_field_test.dart
View file @
b93f71f9
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/text_form_field_test.dart
View file @
b93f71f9
...
...
@@ -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'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -173,7 +171,7 @@ void main() {
});
testWidgets
(
'onChanged callbacks are called'
,
(
WidgetTester
tester
)
async
{
String
_value
;
late
String
_value
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -203,7 +201,7 @@ void main() {
child:
Center
(
child:
TextFormField
(
autovalidateMode:
AutovalidateMode
.
always
,
validator:
(
String
value
)
{
validator:
(
String
?
value
)
{
_validateCalled
++;
return
null
;
},
...
...
@@ -229,7 +227,7 @@ void main() {
child:
TextFormField
(
enabled:
true
,
autovalidateMode:
AutovalidateMode
.
always
,
validator:
(
String
value
)
{
validator:
(
String
?
value
)
{
_validateCalled
+=
1
;
return
null
;
},
...
...
@@ -272,25 +270,25 @@ void main() {
await
tester
.
pumpWidget
(
buildFrame
(
true
,
false
));
Text
helperWidget
=
tester
.
widget
(
find
.
text
(
helperText
));
Text
counterWidget
=
tester
.
widget
(
find
.
text
(
counterText
));
expect
(
helperWidget
.
style
.
color
,
isNot
(
equals
(
Colors
.
transparent
)));
expect
(
counterWidget
.
style
.
color
,
isNot
(
equals
(
Colors
.
transparent
)));
expect
(
helperWidget
.
style
!
.
color
,
isNot
(
equals
(
Colors
.
transparent
)));
expect
(
counterWidget
.
style
!
.
color
,
isNot
(
equals
(
Colors
.
transparent
)));
await
tester
.
pumpWidget
(
buildFrame
(
true
,
true
));
counterWidget
=
tester
.
widget
(
find
.
text
(
counterText
));
Text
errorWidget
=
tester
.
widget
(
find
.
text
(
errorText
));
expect
(
helperWidget
.
style
.
color
,
isNot
(
equals
(
Colors
.
transparent
)));
expect
(
errorWidget
.
style
.
color
,
isNot
(
equals
(
Colors
.
transparent
)));
expect
(
helperWidget
.
style
!
.
color
,
isNot
(
equals
(
Colors
.
transparent
)));
expect
(
errorWidget
.
style
!
.
color
,
isNot
(
equals
(
Colors
.
transparent
)));
// When enabled is false, the helper/error and counter are not visible.
await
tester
.
pumpWidget
(
buildFrame
(
false
,
false
));
helperWidget
=
tester
.
widget
(
find
.
text
(
helperText
));
counterWidget
=
tester
.
widget
(
find
.
text
(
counterText
));
expect
(
helperWidget
.
style
.
color
,
equals
(
Colors
.
transparent
));
expect
(
counterWidget
.
style
.
color
,
equals
(
Colors
.
transparent
));
expect
(
helperWidget
.
style
!
.
color
,
equals
(
Colors
.
transparent
));
expect
(
counterWidget
.
style
!
.
color
,
equals
(
Colors
.
transparent
));
await
tester
.
pumpWidget
(
buildFrame
(
false
,
true
));
errorWidget
=
tester
.
widget
(
find
.
text
(
errorText
));
counterWidget
=
tester
.
widget
(
find
.
text
(
counterText
));
expect
(
counterWidget
.
style
.
color
,
equals
(
Colors
.
transparent
));
expect
(
errorWidget
.
style
.
color
,
equals
(
Colors
.
transparent
));
expect
(
counterWidget
.
style
!
.
color
,
equals
(
Colors
.
transparent
));
expect
(
errorWidget
.
style
!
.
color
,
equals
(
Colors
.
transparent
));
});
testWidgets
(
'passing a buildCounter shows returned widget'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -298,7 +296,7 @@ void main() {
home:
Material
(
child:
Center
(
child:
TextFormField
(
buildCounter:
(
BuildContext
context
,
{
int
currentLength
,
int
maxLength
,
bool
isFocused
})
{
buildCounter:
(
BuildContext
context
,
{
int
?
currentLength
,
int
?
maxLength
,
bool
?
isFocused
})
{
return
Text
(
'
${currentLength.toString()}
of
${maxLength.toString()}
'
);
},
maxLength:
10
,
...
...
@@ -434,7 +432,7 @@ void main() {
testWidgets
(
'onChanged callbacks value and FormFieldState.value are sync'
,
(
WidgetTester
tester
)
async
{
bool
_called
=
false
;
FormFieldState
<
String
>
state
;
late
FormFieldState
<
String
>
state
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -484,7 +482,7 @@ void main() {
child:
Scaffold
(
body:
TextFormField
(
autovalidateMode:
AutovalidateMode
.
onUserInteraction
,
validator:
(
String
value
)
{
validator:
(
String
?
value
)
{
_validateCalled
++;
return
null
;
},
...
...
packages/flutter/test/material/text_selection_test.dart
View file @
b93f71f9
...
...
@@ -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'
;
...
...
@@ -21,7 +19,7 @@ class MockClipboard {
case
'Clipboard.getData'
:
return
_clipboardData
;
case
'Clipboard.setData'
:
_clipboardData
=
methodCall
.
arguments
;
_clipboardData
=
methodCall
.
arguments
as
Object
;
break
;
}
}
...
...
@@ -38,9 +36,9 @@ void main() {
group
(
'canSelectAll'
,
()
{
Widget
createEditableText
({
Key
key
,
String
text
,
TextSelection
selection
,
required
Key
key
,
String
?
text
,
TextSelection
?
selection
,
})
{
final
TextEditingController
controller
=
TextEditingController
(
text:
text
)
..
selection
=
selection
??
const
TextSelection
.
collapsed
(
offset:
-
1
);
...
...
@@ -59,7 +57,7 @@ void main() {
testWidgets
(
'should return false when there is no text'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
<
EditableTextState
>
key
=
GlobalKey
();
await
tester
.
pumpWidget
(
createEditableText
(
key:
key
));
expect
(
materialTextSelectionControls
.
canSelectAll
(
key
.
currentState
),
false
);
expect
(
materialTextSelectionControls
.
canSelectAll
(
key
.
currentState
!
),
false
);
});
testWidgets
(
'should return true when there is text and collapsed selection'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -68,7 +66,7 @@ void main() {
key:
key
,
text:
'123'
,
));
expect
(
materialTextSelectionControls
.
canSelectAll
(
key
.
currentState
),
true
);
expect
(
materialTextSelectionControls
.
canSelectAll
(
key
.
currentState
!
),
true
);
});
testWidgets
(
'should return true when there is text and partial uncollapsed selection'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -78,7 +76,7 @@ void main() {
text:
'123'
,
selection:
const
TextSelection
(
baseOffset:
1
,
extentOffset:
2
),
));
expect
(
materialTextSelectionControls
.
canSelectAll
(
key
.
currentState
),
true
);
expect
(
materialTextSelectionControls
.
canSelectAll
(
key
.
currentState
!
),
true
);
});
testWidgets
(
'should return false when there is text and full selection'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -88,7 +86,7 @@ void main() {
text:
'123'
,
selection:
const
TextSelection
(
baseOffset:
0
,
extentOffset:
3
),
));
expect
(
materialTextSelectionControls
.
canSelectAll
(
key
.
currentState
),
false
);
expect
(
materialTextSelectionControls
.
canSelectAll
(
key
.
currentState
!
),
false
);
});
});
...
...
packages/flutter/test/material/text_selection_theme_test.dart
View file @
b93f71f9
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -74,7 +72,7 @@ void main() {
final
EditableTextState
editableTextState
=
tester
.
firstState
(
find
.
byType
(
EditableText
));
final
RenderEditable
renderEditable
=
editableTextState
.
renderEditable
;
expect
(
renderEditable
.
cursorColor
,
defaultCursorColor
);
expect
(
Color
(
renderEditable
.
selectionColor
.
value
),
defaultSelectionColor
);
expect
(
Color
(
renderEditable
.
selectionColor
!
.
value
),
defaultSelectionColor
);
// Test the selection handle color.
await
tester
.
pumpWidget
(
...
...
@@ -117,7 +115,7 @@ void main() {
await
tester
.
pumpAndSettle
();
final
EditableTextState
editableTextState
=
tester
.
firstState
(
find
.
byType
(
EditableText
));
final
RenderEditable
renderEditable
=
editableTextState
.
renderEditable
;
expect
(
renderEditable
.
cursorColor
,
textSelectionTheme
.
cursorColor
.
withAlpha
(
0
));
expect
(
renderEditable
.
cursorColor
,
textSelectionTheme
.
cursorColor
!
.
withAlpha
(
0
));
expect
(
renderEditable
.
selectionColor
,
textSelectionTheme
.
selectionColor
);
// Test the selection handle color.
...
...
@@ -170,7 +168,7 @@ void main() {
await
tester
.
pumpAndSettle
();
final
EditableTextState
editableTextState
=
tester
.
firstState
(
find
.
byType
(
EditableText
));
final
RenderEditable
renderEditable
=
editableTextState
.
renderEditable
;
expect
(
renderEditable
.
cursorColor
,
widgetTextSelectionTheme
.
cursorColor
.
withAlpha
(
0
));
expect
(
renderEditable
.
cursorColor
,
widgetTextSelectionTheme
.
cursorColor
!
.
withAlpha
(
0
));
expect
(
renderEditable
.
selectionColor
,
widgetTextSelectionTheme
.
selectionColor
);
// Test the selection handle color.
...
...
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