Unverified Commit 4ab68bd0 authored by Danny Tuppeny's avatar Danny Tuppeny Committed by GitHub

Use consistent date instead of DateTime.now() in evaluation tests (#103269)

parent 955e1ff3
......@@ -157,19 +157,16 @@ Future<void> evaluateTrivialExpressions(FlutterTestDriver flutter) async {
}
Future<void> 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<void> 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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment