mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Use consistent date instead of DateTime.now() in evaluation tests (#103269)
This commit is contained in:
parent
955e1ff346
commit
4ab68bd04d
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user