Skip to content

Commit 4ab68bd

Browse files
authored
Use consistent date instead of DateTime.now() in evaluation tests (#103269)
1 parent 955e1ff commit 4ab68bd

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

packages/flutter_tools/test/integration.shard/expression_evaluation_test.dart

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,16 @@ Future<void> evaluateTrivialExpressions(FlutterTestDriver flutter) async {
157157
}
158158

159159
Future<void> evaluateComplexExpressions(FlutterTestDriver flutter) async {
160-
final ObjRef res = await flutter.evaluateInFrame('new DateTime.now().year');
161-
expectValueOfType(res, InstanceKind.kInt, DateTime.now().year.toString());
160+
final ObjRef res = await flutter.evaluateInFrame('new DateTime(2000).year');
161+
expectValueOfType(res, InstanceKind.kInt, '2000');
162162
}
163163

164164
Future<void> evaluateComplexReturningExpressions(FlutterTestDriver flutter) async {
165-
final DateTime now = DateTime.now();
166-
final ObjRef resp = await flutter.evaluateInFrame('new DateTime.now()');
165+
final DateTime date = DateTime(2000);
166+
final ObjRef resp = await flutter.evaluateInFrame('new DateTime(2000)');
167167
expectInstanceOfClass(resp, 'DateTime');
168-
// Ensure we got a reasonable approximation. The more accurate we try to
169-
// make this, the more likely it'll fail due to differences in the time
170-
// in the remote VM and the local VM at the time the code runs.
171168
final ObjRef res = await flutter.evaluate(resp.id, r'"$year-$month-$day"');
172-
expectValue(res, '${now.year}-${now.month}-${now.day}');
169+
expectValue(res, '${date.year}-${date.month}-${date.day}');
173170
}
174171

175172
void expectInstanceOfClass(ObjRef result, String name) {

0 commit comments

Comments
 (0)