setVirtualTimePolicy method

Future<num> setVirtualTimePolicy(
  1. VirtualTimePolicy policy, {
  2. num? budget,
  3. int? maxVirtualTimeTaskStarvationCount,
  4. TimeSinceEpoch? initialVirtualTime,
})

Turns on virtual time for all frames (replacing real-time with a synthetic time source) and sets the current virtual time policy. Note this supersedes any previous time budget. budget If set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent. maxVirtualTimeTaskStarvationCount If set this specifies the maximum number of tasks that can be run before virtual is forced forwards to prevent deadlock. initialVirtualTime If set, base::Time::Now will be overridden to initially return this value. Returns: Absolute timestamp at which virtual time was first enabled (up time in milliseconds).

Implementation

Future<num> setVirtualTimePolicy(VirtualTimePolicy policy,
    {num? budget,
    int? maxVirtualTimeTaskStarvationCount,
    network.TimeSinceEpoch? initialVirtualTime}) async {
  var result = await _client.send('Emulation.setVirtualTimePolicy', {
    'policy': policy,
    if (budget != null) 'budget': budget,
    if (maxVirtualTimeTaskStarvationCount != null)
      'maxVirtualTimeTaskStarvationCount': maxVirtualTimeTaskStarvationCount,
    if (initialVirtualTime != null) 'initialVirtualTime': initialVirtualTime,
  });
  return result['virtualTimeTicksBase'] as num;
}