PlatformAutomator constructor

PlatformAutomator({
  1. PlatformAutomatorConfig? config,
})

Creates a new PlatformAutomator.

Implementation

PlatformAutomator({PlatformAutomatorConfig? config}) {
  final androidConfig =
      config?.androidConfig ?? const AndroidAutomatorConfig();
  final iosConfig = config?.iosConfig ?? const IOSAutomatorConfig();
  final webConfig = config?.webConfig ?? const WebAutomatorConfig();

  android = action.fallback(
    android: (config?.androidEnabled ?? false)
        ? () =>
              native_android_automator.AndroidAutomator(config: androidConfig)
        : null,
    fallback: () =>
        empty_android_automator.AndroidAutomator(config: androidConfig),
  );

  ios = action.fallback(
    ios: (config?.iosEnabled ?? false)
        ? () => native_ios_automator.IOSAutomator(config: iosConfig)
        : null,
    // TODO: Create MacOSAutomator when such class will be implemented
    // For now we reuse the IOSAutomator for native communication on MacOS
    // The reason is that the only native interaction on MacOS is marking the app service ready
    macos: (config?.iosEnabled ?? false)
        ? () => native_ios_automator.IOSAutomator(config: iosConfig)
        : null,
    fallback: () => empty_ios_automator.IOSAutomator(config: iosConfig),
  );

  web = action.fallback(
    web: (config?.webEnabled ?? false)
        ? () => native_web_automator.WebAutomator(config: webConfig)
        : null,
    fallback: () => empty_web_automator.WebAutomator(config: webConfig),
  );

  final desktopConfig =
      config?.desktopConfig ?? const DesktopAutomatorConfig();
  desktop = DesktopAutomator(config: desktopConfig);

  mobile = MobileAutomator(platform: this);
}