From 4ab68bd04dcc9ecfb74243e8fc324e45fa904774 Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Sun, 8 May 2022 19:32:14 +0100 Subject: [PATCH] Use consistent date instead of DateTime.now() in evaluation tests (#103269) --- .../expression_evaluation_test.dart | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/flutter_tools/test/integration.shard/expression_evaluation_test.dart b/packages/flutter_tools/test/integration.shard/expression_evaluation_test.dart index 1b72e694221..28b853b4495 100644 --- a/packages/flutter_tools/test/integration.shard/expression_evaluation_test.dart +++ b/packages/flutter_tools/test/integration.shard/expression_evaluation_test.dart @@ -157,19 +157,16 @@ Future evaluateTrivialExpressions(FlutterTestDriver flutter) async { } Future evaluateComplexExpressions(FlutterTestDriver flutter) async { - final ObjRef res = await flutter.evaluateInFrame('new DateTime.now().year'); - expectValueOfType(res, InstanceKind.kInt, DateTime.now().year.toString()); + final ObjRef res = await flutter.evaluateInFrame('new DateTime(2000).year'); + expectValueOfType(res, InstanceKind.kInt, '2000'); } Future evaluateComplexReturningExpressions(FlutterTestDriver flutter) async { - final DateTime now = DateTime.now(); - final ObjRef resp = await flutter.evaluateInFrame('new DateTime.now()'); + final DateTime date = DateTime(2000); + final ObjRef resp = await flutter.evaluateInFrame('new DateTime(2000)'); expectInstanceOfClass(resp, 'DateTime'); - // Ensure we got a reasonable approximation. The more accurate we try to - // make this, the more likely it'll fail due to differences in the time - // in the remote VM and the local VM at the time the code runs. final ObjRef res = await flutter.evaluate(resp.id, r'"$year-$month-$day"'); - expectValue(res, '${now.year}-${now.month}-${now.day}'); + expectValue(res, '${date.year}-${date.month}-${date.day}'); } void expectInstanceOfClass(ObjRef result, String name) {