DesktopUpdaterController.forTesting constructor

  1. @visibleForTesting
DesktopUpdaterController.forTesting({
  1. required Uri? appArchiveUrl,
  2. DesktopUpdateLocalization? localization,
  3. bool allowUnsignedMacOSUpdates = false,
  4. String channel = "stable",
  5. String? installationIdentity,
  6. UpdatePreferences? preferences,
  7. UpdateRecoveryStore? recoveryStore,
  8. String? diagnosticsLogPath,
  9. DesktopUpdaterTelemetry? telemetry,
  10. MinimumOSSupportChecker? isMinimumOSSupported,
  11. UpdateDiagnosticsRecorder? diagnosticsRecorder,
  12. Future<void> onProblemReport(
    1. UpdateProblemReport report
    )?,
  13. FutureOr<void> onCleanupReport(
    1. UpdateCleanupReport report
    )?,
  14. bool skipInitialVersionCheck = false,
  15. ReleaseNotesLoader? releaseNotesLoader,
  16. Uri? releaseNotesUrl,
  17. ReleaseNotesFetcher? releaseNotesFetcher,
})

Creates a controller with injected collaborators for unit testing.

Identical to the default constructor but accepts an optional releaseNotesFetcher so tests can substitute a fake HTTP layer without exposing that seam in the public API.

Implementation

@visibleForTesting
DesktopUpdaterController.forTesting({
  required Uri? appArchiveUrl,
  this.localization,
  this.allowUnsignedMacOSUpdates = false,
  this.channel = "stable",
  this.installationIdentity,
  this.preferences,
  this.recoveryStore,
  this.diagnosticsLogPath,
  this.telemetry,
  this.isMinimumOSSupported,
  UpdateDiagnosticsRecorder? diagnosticsRecorder,
  Future<void> Function(UpdateProblemReport report)? onProblemReport,
  FutureOr<void> Function(UpdateCleanupReport report)? onCleanupReport,
  bool skipInitialVersionCheck = false,
  ReleaseNotesLoader? releaseNotesLoader,
  Uri? releaseNotesUrl,
  ReleaseNotesFetcher? releaseNotesFetcher,
})  : _skipInitialVersionCheck = skipInitialVersionCheck,
      _diagnosticsRecorder =
          diagnosticsRecorder ?? UpdateDiagnosticsRecorder(channel: channel),
      _onProblemReport = onProblemReport,
      _onCleanupReport = onCleanupReport,
      _releaseNotesLoader = releaseNotesLoader,
      _releaseNotesUrl = releaseNotesUrl,
      _releaseNotesFetcher = releaseNotesFetcher ??
          (releaseNotesUrl == null ? null : ReleaseNotesFetcher()) {
  if (appArchiveUrl != null) {
    init(appArchiveUrl);
  }
}