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
3c33bb46
Commit
3c33bb46
authored
Jan 12, 2017
by
Adam Barth
Committed by
GitHub
Jan 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some more framework.dart tests (#7469)
parent
67377120
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
93 additions
and
6 deletions
+93
-6
build_scope_test.dart
packages/flutter/test/widgets/build_scope_test.dart
+2
-2
framework_test.dart
packages/flutter/test/widgets/framework_test.dart
+66
-1
parent_data_test.dart
packages/flutter/test/widgets/parent_data_test.dart
+18
-2
matchers.dart
packages/flutter_test/lib/src/matchers.dart
+7
-1
No files found.
packages/flutter/test/widgets/build_scope_test.dart
View file @
3c33bb46
...
@@ -156,7 +156,7 @@ void main() {
...
@@ -156,7 +156,7 @@ void main() {
testWidgets
(
'Setting parent state during build is forbidden'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Setting parent state during build is forbidden'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
new
BadWidgetParent
());
await
tester
.
pumpWidget
(
new
BadWidgetParent
());
expect
(
tester
.
takeException
(),
is
NotNull
);
expect
(
tester
.
takeException
(),
is
FlutterError
);
await
tester
.
pumpWidget
(
new
Container
());
await
tester
.
pumpWidget
(
new
Container
());
});
});
...
@@ -225,4 +225,4 @@ void main() {
...
@@ -225,4 +225,4 @@ void main() {
}
}
});
});
}
}
\ No newline at end of file
packages/flutter/test/widgets/framework_test.dart
View file @
3c33bb46
...
@@ -3,8 +3,14 @@
...
@@ -3,8 +3,14 @@
// found in the LICENSE file.
// found in the LICENSE file.
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
class
TestState
extends
State
<
StatefulWidget
>
{
@override
Widget
build
(
BuildContext
context
)
=>
null
;
}
void
main
(
)
{
void
main
(
)
{
testWidgets
(
'UniqueKey control test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'UniqueKey control test'
,
(
WidgetTester
tester
)
async
{
Key
key
=
new
UniqueKey
();
Key
key
=
new
UniqueKey
();
...
@@ -25,6 +31,19 @@ void main() {
...
@@ -25,6 +31,19 @@ void main() {
expect
(
keyA
,
isNot
(
equals
(
keyB
)));
expect
(
keyA
,
isNot
(
equals
(
keyB
)));
});
});
testWidgets
(
'GlobalObjectKey control test'
,
(
WidgetTester
tester
)
async
{
Object
a
=
new
Object
();
Object
b
=
new
Object
();
Key
keyA
=
new
GlobalObjectKey
(
a
);
Key
keyA2
=
new
GlobalObjectKey
(
a
);
Key
keyB
=
new
GlobalObjectKey
(
b
);
expect
(
keyA
,
hasOneLineDescription
);
expect
(
keyA
,
equals
(
keyA2
));
expect
(
keyA
.
hashCode
,
equals
(
keyA2
.
hashCode
));
expect
(
keyA
,
isNot
(
equals
(
keyB
)));
});
testWidgets
(
'GlobalKey duplication'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'GlobalKey duplication'
,
(
WidgetTester
tester
)
async
{
Key
key
=
new
GlobalKey
(
debugLabel:
'problematic'
);
Key
key
=
new
GlobalKey
(
debugLabel:
'problematic'
);
...
@@ -55,7 +74,7 @@ void main() {
...
@@ -55,7 +74,7 @@ void main() {
],
],
));
));
expect
(
tester
.
takeException
(),
is
NotNull
);
expect
(
tester
.
takeException
(),
is
FlutterError
);
});
});
testWidgets
(
'GlobalKey notification exception handling'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'GlobalKey notification exception handling'
,
(
WidgetTester
tester
)
async
{
...
@@ -78,4 +97,50 @@ void main() {
...
@@ -78,4 +97,50 @@ void main() {
expect
(
tester
.
takeException
(),
isNotNull
);
expect
(
tester
.
takeException
(),
isNotNull
);
expect
(
didReceiveCallback
,
isTrue
);
expect
(
didReceiveCallback
,
isTrue
);
});
});
testWidgets
(
'Defunct setState throws exception'
,
(
WidgetTester
tester
)
async
{
StateSetter
setState
;
await
tester
.
pumpWidget
(
new
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setter
)
{
setState
=
setter
;
return
new
Container
();
},
));
// Control check that setState doesn't throw an exception.
setState
(()
{
});
await
tester
.
pumpWidget
(
new
Container
());
expect
(()
{
setState
(()
{
});
},
throwsFlutterError
);
});
testWidgets
(
'State toString'
,
(
WidgetTester
tester
)
async
{
TestState
state
=
new
TestState
();
expect
(
state
.
toString
(),
contains
(
'no config'
));
});
testWidgets
(
'debugPrintGlobalKeyedWidgetLifecycle control test'
,
(
WidgetTester
tester
)
async
{
expect
(
debugPrintGlobalKeyedWidgetLifecycle
,
isFalse
);
final
DebugPrintCallback
oldCallback
=
debugPrint
;
debugPrintGlobalKeyedWidgetLifecycle
=
true
;
List
<
String
>
log
=
<
String
>[];
debugPrint
=
(
String
message
,
{
int
wrapWidth
})
{
log
.
add
(
message
);
};
GlobalKey
key
=
new
GlobalKey
();
await
tester
.
pumpWidget
(
new
Container
(
key:
key
));
expect
(
log
,
isEmpty
);
await
tester
.
pumpWidget
(
new
Placeholder
());
debugPrint
=
oldCallback
;
debugPrintGlobalKeyedWidgetLifecycle
=
false
;
expect
(
log
.
length
,
equals
(
2
));
expect
(
log
[
0
],
matches
(
'Deactivated'
));
expect
(
log
[
1
],
matches
(
'Discarding .+ from inactive elements list.'
));
});
}
}
packages/flutter/test/widgets/parent_data_test.dart
View file @
3c33bb46
...
@@ -257,7 +257,7 @@ void main() {
...
@@ -257,7 +257,7 @@ void main() {
]
]
)
)
);
);
expect
(
tester
.
takeException
(),
is
NotNull
);
expect
(
tester
.
takeException
(),
is
FlutterError
);
await
tester
.
pumpWidget
(
new
Stack
());
await
tester
.
pumpWidget
(
new
Stack
());
...
@@ -276,7 +276,7 @@ void main() {
...
@@ -276,7 +276,7 @@ void main() {
)
)
)
)
);
);
expect
(
tester
.
takeException
(),
is
NotNull
);
expect
(
tester
.
takeException
(),
is
FlutterError
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
new
Stack
()
new
Stack
()
...
@@ -339,4 +339,20 @@ void main() {
...
@@ -339,4 +339,20 @@ void main() {
new
TestParentData
(
top:
10.0
,
left:
10.0
),
new
TestParentData
(
top:
10.0
,
left:
10.0
),
]);
]);
});
});
testWidgets
(
'Parent data invalid ancestor'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
new
Row
(
children:
<
Widget
>[
new
Stack
(
children:
<
Widget
>[
new
Expanded
(
child:
new
Container
()
),
],
),
],
));
expect
(
tester
.
takeException
(),
isFlutterError
);
});
}
}
packages/flutter_test/lib/src/matchers.dart
View file @
3c33bb46
...
@@ -66,6 +66,12 @@ const Matcher isNotInCard = const _IsNotInCard();
...
@@ -66,6 +66,12 @@ const Matcher isNotInCard = const _IsNotInCard();
/// empty, and does not contain the default `Instance of ...` string.
/// empty, and does not contain the default `Instance of ...` string.
const
Matcher
hasOneLineDescription
=
const
_HasOneLineDescription
();
const
Matcher
hasOneLineDescription
=
const
_HasOneLineDescription
();
/// A matcher for functions that throw [FlutterError].
const
Matcher
throwsFlutterError
=
const
Throws
(
isFlutterError
);
/// A matcher for [FlutterError].
const
Matcher
isFlutterError
=
const
isInstanceOf
<
FlutterError
>();
/// Asserts that two [double]s are equal, within some tolerated error.
/// Asserts that two [double]s are equal, within some tolerated error.
///
///
/// Two values are considered equal if the difference between them is within
/// Two values are considered equal if the difference between them is within
...
@@ -268,4 +274,4 @@ class _MoreOrLessEquals extends Matcher {
...
@@ -268,4 +274,4 @@ class _MoreOrLessEquals extends Matcher {
@override
@override
Description
describe
(
Description
description
)
=>
description
.
add
(
'
$value
(±
$epsilon
)'
);
Description
describe
(
Description
description
)
=>
description
.
add
(
'
$value
(±
$epsilon
)'
);
}
}
\ No newline at end of file
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