getDevice method

  1. @protected
Device getDevice({
  1. required Application app,
  2. required TestDeviceInfo deviceInfo,
  3. required TestControllerState testControllerState,
})

Helper function to get a Device from the cache based on the deviceInfo. A Device will exist in the cache in the event it was previously connected and now attempting to reconnect.

Implementation

@protected
Device getDevice({
  required Application app,
  required TestDeviceInfo deviceInfo,
  required TestControllerState testControllerState,
}) {
  var result = app.devices[deviceInfo.id];

  if (result == null) {
    result = Device(
      app: app,
      appIdentifier: app.appIdentifier,
      device: deviceInfo,
      testControllerState: testControllerState,
    );
    app.devices[deviceInfo.id] = result;
  }
  result.testControllerState = testControllerState;

  return result;
}