resolve method

SnapshotElementHandle resolve({
  1. required String observationId,
  2. required String elementId,
})

Implementation

SnapshotElementHandle resolve({
  required String observationId,
  required String elementId,
}) {
  return RunnerBenchmark.sync('locator', 'resolve', () {
    final handles = _byObservation[observationId];
    if (handles == null) {
      throw TestExecutionError(
        code: TestExecutionErrorCode.staleObservation,
        message:
            'Observation "$observationId" is no longer retained or never existed.',
        details: {'observationId': observationId, 'elementId': elementId},
      );
    }
    final handle = handles[elementId];
    if (handle == null) {
      throw TestExecutionError(
        // An element id is only meaningful inside the observation that
        // issued it.  If that observation is still retained but the handle
        // is absent, the target is still stale: it cannot be remapped to a
        // live id or silently resolved by a broad locator.
        code: TestExecutionErrorCode.staleObservation,
        message:
            'Element "$elementId" is not available in observation "$observationId".',
        details: {
          'observationId': observationId,
          'elementId': elementId,
          'reason': 'elementNotRetained',
        },
      );
    }
    return handle;
  });
}