diff --git a/lib/abs/icon_generator.dart b/lib/abs/icon_generator.dart index 1576ddb939..10f3086268 100644 --- a/lib/abs/icon_generator.dart +++ b/lib/abs/icon_generator.dart @@ -55,6 +55,9 @@ class IconGeneratorContext { /// Shortcut for `config.webConfig` WebConfig? get webConfig => config.webConfig; + + /// Shortcut for `config.windowsConfig` + WindowsConfig? get windowsConfig => config.windowsConfig; } /// Generates Icon for given platforms diff --git a/lib/constants.dart b/lib/constants.dart index 638249f4cf..0133f802a1 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -42,6 +42,20 @@ String webIndexFilePath = path.join(webDirPath, 'index.html'); /// Relative pubspec.yaml path String pubspecFilePath = path.join('pubspec.yaml'); +// Windows +/// Relative path to windows directory +String windowsDirPath = path.join('windows'); + +/// Relative path to windows resources directory +String windowsResourcesDirPath = path.join(windowsDirPath, 'runner', 'resources'); + +/// Relative path to windows icon file path +String windowsIconFilePath = path.join(windowsResourcesDirPath, 'app_icon.ico'); + +/// Default windows icon size for flutter +/// +const int windowsDefaultIconSize = 48; + const String errorMissingImagePath = 'Missing "image_path" or "image_path_android" + "image_path_ios" within configuration'; const String errorMissingPlatform = 'No platform specified within config to generate icons for.'; diff --git a/lib/flutter_launcher_icons_config.dart b/lib/flutter_launcher_icons_config.dart index 1f5d0bc895..f386bee11f 100644 --- a/lib/flutter_launcher_icons_config.dart +++ b/lib/flutter_launcher_icons_config.dart @@ -46,6 +46,10 @@ class FlutterLauncherIconsConfig { @JsonKey(name: 'web') final WebConfig? webConfig; + /// Windows platform config + @JsonKey(name: 'windows') + final WindowsConfig? windowsConfig; + /// Creates an instance of [FlutterLauncherIconsConfig] const FlutterLauncherIconsConfig({ this.imagePath, @@ -56,6 +60,7 @@ class FlutterLauncherIconsConfig { this.adaptiveIconForeground, this.adaptiveIconBackground, this.webConfig, + this.windowsConfig, }); /// Creates [FlutterLauncherIconsConfig] icons from [json] @@ -161,3 +166,37 @@ class WebConfig { @override String toString() => 'WebConfig: ${toJson()}'; } + +/// A Configs for Windows +@JsonSerializable( + anyMap: true, + checked: true, +) +class WindowsConfig { + /// Specifies weather to generate icons for web + final bool generate; + + /// Image path for web + @JsonKey(name: 'image_path') + final String? imagePath; + + /// Size of the icon to generate + @JsonKey(name: 'icon_size') + final int? iconSize; + + /// Creates a instance of [WindowsConfig] + const WindowsConfig({ + this.generate = false, + this.imagePath, + this.iconSize, + }); + + /// Creates [WindowsConfig] from [json] + factory WindowsConfig.fromJson(Map json) => _$WindowsConfigFromJson(json); + + /// Creates [Map] from [WindowsConfig] + Map toJson() => _$WindowsConfigToJson(this); + + @override + String toString() => 'WindowsConfig: ${toJson()}'; +} diff --git a/lib/flutter_launcher_icons_config.g.dart b/lib/flutter_launcher_icons_config.g.dart index c3d85f33a5..7e9c9eb621 100644 --- a/lib/flutter_launcher_icons_config.g.dart +++ b/lib/flutter_launcher_icons_config.g.dart @@ -24,6 +24,8 @@ FlutterLauncherIconsConfig _$FlutterLauncherIconsConfigFromJson(Map json) => $checkedConvert('adaptive_icon_background', (v) => v as String?), webConfig: $checkedConvert( 'web', (v) => v == null ? null : WebConfig.fromJson(v as Map)), + windowsConfig: $checkedConvert('windows', + (v) => v == null ? null : WindowsConfig.fromJson(v as Map)), ); return val; }, @@ -33,7 +35,8 @@ FlutterLauncherIconsConfig _$FlutterLauncherIconsConfigFromJson(Map json) => 'imagePathIOS': 'image_path_ios', 'adaptiveIconForeground': 'adaptive_icon_foreground', 'adaptiveIconBackground': 'adaptive_icon_background', - 'webConfig': 'web' + 'webConfig': 'web', + 'windowsConfig': 'windows' }, ); @@ -48,6 +51,7 @@ Map _$FlutterLauncherIconsConfigToJson( 'adaptive_icon_foreground': instance.adaptiveIconForeground, 'adaptive_icon_background': instance.adaptiveIconBackground, 'web': instance.webConfig, + 'windows': instance.windowsConfig, }; WebConfig _$WebConfigFromJson(Map json) => $checkedCreate( @@ -76,3 +80,24 @@ Map _$WebConfigToJson(WebConfig instance) => { 'background_color': instance.backgroundColor, 'theme_color': instance.themeColor, }; + +WindowsConfig _$WindowsConfigFromJson(Map json) => $checkedCreate( + 'WindowsConfig', + json, + ($checkedConvert) { + final val = WindowsConfig( + generate: $checkedConvert('generate', (v) => v as bool? ?? false), + imagePath: $checkedConvert('image_path', (v) => v as String?), + iconSize: $checkedConvert('icon_size', (v) => v as int?), + ); + return val; + }, + fieldKeyMap: const {'imagePath': 'image_path', 'iconSize': 'icon_size'}, + ); + +Map _$WindowsConfigToJson(WindowsConfig instance) => + { + 'generate': instance.generate, + 'image_path': instance.imagePath, + 'icon_size': instance.iconSize, + }; diff --git a/lib/main.dart b/lib/main.dart index 5cffcc4bfb..f6c9b5dd5d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -10,6 +10,7 @@ import 'package:flutter_launcher_icons/flutter_launcher_icons_config.dart'; import 'package:flutter_launcher_icons/ios.dart' as ios_launcher_icons; import 'package:flutter_launcher_icons/logger.dart'; import 'package:flutter_launcher_icons/web/web_icon_generator.dart'; +import 'package:flutter_launcher_icons/windows/windows_icon_generator.dart'; import 'package:path/path.dart' as path; import 'package:yaml/yaml.dart'; @@ -55,7 +56,7 @@ Future createIconsFromArguments(List arguments) async { // creating logger based on -v flag final logger = FLILogger(argResults[verboseFlag]); - logger.verbose('Recieved args ${argResults.arguments}'); + logger.verbose('Received args ${argResults.arguments}'); if (argResults[helpFlag]) { stdout.writeln('Generates icons for iOS and Android'); @@ -63,7 +64,7 @@ Future createIconsFromArguments(List arguments) async { exit(0); } - // Flavors manangement + // Flavors management final flavors = getFlavors(); final hasFlavors = flavors.isNotEmpty; @@ -151,6 +152,7 @@ Future createIconsFromConfig( flavor: flavor, platforms: (context) => [ WebIconGenerator(context), + WindowsIconGenerator(context), // todo: add other platforms ], ); diff --git a/lib/utils.dart b/lib/utils.dart index d87e9d0601..5a5acfffe8 100644 --- a/lib/utils.dart +++ b/lib/utils.dart @@ -33,6 +33,8 @@ String generateError(Exception e, String? error) { return '\n✗ ERROR: ${(e).runtimeType.toString()}$errorOutput'; } +// TODO(RatakondalaArun): Remove nullable return type +// this can never return null value since it already throws exception Image? decodeImageFile(String filePath) { final image = decodeImage(File(filePath).readAsBytesSync()); if (image == null) { diff --git a/lib/windows/windows_icon_generator.dart b/lib/windows/windows_icon_generator.dart new file mode 100644 index 0000000000..eab73479b2 --- /dev/null +++ b/lib/windows/windows_icon_generator.dart @@ -0,0 +1,75 @@ +import 'package:flutter_launcher_icons/abs/icon_generator.dart'; +import 'package:flutter_launcher_icons/constants.dart' as constants; +import 'package:flutter_launcher_icons/custom_exceptions.dart'; +import 'package:flutter_launcher_icons/utils.dart' as utils; +import 'package:image/image.dart'; +import 'package:path/path.dart' as path; + +/// A Implementation of [IconGenerator] for Windows +class WindowsIconGenerator extends IconGenerator { + /// Creates a instance of [WindowsIconGenerator] + WindowsIconGenerator(IconGeneratorContext context) : super(context, 'Windows'); + + @override + void createIcons() { + final imgFilePath = path.join( + context.prefixPath, + context.windowsConfig!.imagePath ?? context.config.imagePath, + ); + + context.logger.verbose('Decoding and loading image file from $imgFilePath...'); + final imgFile = utils.decodeImageFile(imgFilePath); + // TODO(RatakondalaArun): remove null check + // #utils.decodeImageFile never returns null instead it throws Exception + if (imgFile == null) { + context.logger.error('Image File not found at given path $imgFilePath...'); + throw FileNotFoundException(imgFilePath); + } + + context.logger.verbose('Generating icon from $imgFilePath...'); + _generateIcon(imgFile); + } + + @override + bool validateRequirements() { + context.logger.verbose('Validating windows config...'); + final windowsConfig = context.windowsConfig; + if (windowsConfig == null || !windowsConfig.generate) { + context.logger.error('Windows config is not provided or windows.generate is false. Skipped...'); + return false; + } + + if (windowsConfig.imagePath == null && context.config.imagePath == null) { + context.logger.error('Invalid config. Either provide windows.image_path or image_path'); + return false; + } + + // if icon_size is given it should be between 48<=icon_size<=256 + // because .ico only supports this size + if (windowsConfig.iconSize != null && (windowsConfig.iconSize! < 48 || windowsConfig.iconSize! > 256)) { + context.logger.error( + 'Invalid windows.icon_size=${windowsConfig.iconSize}. Icon size should be between 48<=icon_size<=256', + ); + return false; + } + final entitesToCheck = [ + path.join(context.prefixPath, constants.windowsDirPath), + path.join(context.prefixPath, windowsConfig.imagePath ?? context.config.imagePath), + ]; + + final failedEntityPath = utils.areFSEntiesExist(entitesToCheck); + if (failedEntityPath != null) { + context.logger.error('$failedEntityPath this file or folder is required to generate web icons'); + return false; + } + + return true; + } + + void _generateIcon(Image image) { + final favIcon = + utils.createResizedImage(context.windowsConfig!.iconSize ?? constants.windowsDefaultIconSize, image); + final favIconFile = utils.createFileIfNotExist(path.join(context.prefixPath, constants.windowsIconFilePath)); + favIconFile.writeAsBytesSync(encodeIco(favIcon)); + } +} diff --git a/test/abs/icon_generator_test.dart b/test/abs/icon_generator_test.dart index 6edc3f4f44..b0ab1de564 100644 --- a/test/abs/icon_generator_test.dart +++ b/test/abs/icon_generator_test.dart @@ -56,7 +56,7 @@ void main() { verifyNever(mockGenerator.createIcons()); }); - test('should skip platform if any exception occured', () { + test('should skip platform if any exception occurred', () { when(mockGenerator.validateRequirements()).thenReturn(true); when(mockGenerator.createIcons()).thenThrow(Exception('should-skip-platform')); generateIconsFor( diff --git a/test/abs/icon_generator_test.mocks.dart b/test/abs/icon_generator_test.mocks.dart index e75828592b..b849b992cf 100644 --- a/test/abs/icon_generator_test.mocks.dart +++ b/test/abs/icon_generator_test.mocks.dart @@ -3,7 +3,8 @@ // Do not manually edit this file. import 'package:flutter_launcher_icons/abs/icon_generator.dart' as _i2; -import 'package:flutter_launcher_icons/flutter_launcher_icons_config.dart' as _i3; +import 'package:flutter_launcher_icons/flutter_launcher_icons_config.dart' + as _i3; import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: type=lint @@ -16,19 +17,22 @@ import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: unnecessary_parenthesis // ignore_for_file: camel_case_types -class _FakeIconGeneratorContext_0 extends _i1.Fake implements _i2.IconGeneratorContext {} +class _FakeIconGeneratorContext_0 extends _i1.Fake + implements _i2.IconGeneratorContext {} /// A class which mocks [FlutterLauncherIconsConfig]. /// /// See the documentation for Mockito's code generation for more information. -class MockFlutterLauncherIconsConfig extends _i1.Mock implements _i3.FlutterLauncherIconsConfig { +class MockFlutterLauncherIconsConfig extends _i1.Mock + implements _i3.FlutterLauncherIconsConfig { MockFlutterLauncherIconsConfig() { _i1.throwOnMissingStub(this); } @override Map toJson() => - (super.noSuchMethod(Invocation.method(#toJson, []), returnValue: {}) as Map); + (super.noSuchMethod(Invocation.method(#toJson, []), + returnValue: {}) as Map); } /// A class which mocks [IconGenerator]. @@ -40,14 +44,18 @@ class MockIconGenerator extends _i1.Mock implements _i2.IconGenerator { } @override - _i2.IconGeneratorContext get context => - (super.noSuchMethod(Invocation.getter(#context), returnValue: _FakeIconGeneratorContext_0()) - as _i2.IconGeneratorContext); + _i2.IconGeneratorContext get context => (super.noSuchMethod( + Invocation.getter(#context), + returnValue: _FakeIconGeneratorContext_0()) as _i2.IconGeneratorContext); @override - String get platformName => (super.noSuchMethod(Invocation.getter(#platformName), returnValue: '') as String); + String get platformName => + (super.noSuchMethod(Invocation.getter(#platformName), returnValue: '') + as String); @override - void createIcons() => super.noSuchMethod(Invocation.method(#createIcons, []), returnValueForMissingStub: null); + void createIcons() => super.noSuchMethod(Invocation.method(#createIcons, []), + returnValueForMissingStub: null); @override bool validateRequirements() => - (super.noSuchMethod(Invocation.method(#validateRequirments, []), returnValue: false) as bool); + (super.noSuchMethod(Invocation.method(#validateRequirements, []), + returnValue: false) as bool); } diff --git a/test/all_tests.dart b/test/all_tests.dart index 2ae13005cf..04a1f2a01f 100644 --- a/test/all_tests.dart +++ b/test/all_tests.dart @@ -5,8 +5,9 @@ import 'android_test.dart' as android_test; import 'flutter_launcher_icons_config_test.dart' as fli_config; import 'main_test.dart' as main_test; import 'utils_test.dart' as utils_test; -import 'web/web_template_test.dart' as web_template_test; import 'web/web_icon_generator_test.dart' as web_icon_gen_test; +import 'web/web_template_test.dart' as web_template_test; +import 'windows/windows_icon_generator_test.dart' as windows_icon_gen_test; void main() { group('Flutter launcher icons', () { @@ -21,5 +22,7 @@ void main() { // web web_template_test.main(); web_icon_gen_test.main(); + // windows + windows_icon_gen_test.main(); }); } diff --git a/test/flutter_launcher_icons_config_test.dart b/test/flutter_launcher_icons_config_test.dart index a73e414410..df770e7e90 100644 --- a/test/flutter_launcher_icons_config_test.dart +++ b/test/flutter_launcher_icons_config_test.dart @@ -46,6 +46,19 @@ void main() { 'theme_color': '#0175C2', }), ); + // windows + expect(configs.windowsConfig, isNotNull); + expect(configs.windowsConfig!.generate, isNotNull); + expect(configs.windowsConfig!.iconSize, isNotNull); + expect(configs.windowsConfig!.imagePath, isNotNull); + expect( + configs.windowsConfig!.toJson(), + equals({ + 'generate': true, + 'image_path': 'app_icon.png', + 'icon_size': 48, + }), + ); }); test('should return null when invalid filePath is given', () { @@ -96,6 +109,19 @@ void main() { 'theme_color': '#0175C2', }), ); + // windows + expect(configs.windowsConfig, isNotNull); + expect(configs.windowsConfig!.generate, isNotNull); + expect(configs.windowsConfig!.iconSize, isNotNull); + expect(configs.windowsConfig!.imagePath, isNotNull); + expect( + configs.windowsConfig!.toJson(), + equals({ + 'generate': true, + 'image_path': 'app_icon.png', + 'icon_size': 48, + }), + ); }); group('should throw', () { @@ -146,6 +172,19 @@ void main() { 'theme_color': '#0175C2', }), ); + // windows + expect(configs.windowsConfig, isNotNull); + expect(configs.windowsConfig!.generate, isNotNull); + expect(configs.windowsConfig!.iconSize, isNotNull); + expect(configs.windowsConfig!.imagePath, isNotNull); + expect( + configs.windowsConfig!.toJson(), + equals({ + 'generate': true, + 'image_path': 'app_icon.png', + 'icon_size': 48, + }), + ); }); }); }); diff --git a/test/templates.dart b/test/templates.dart index 013e48db0e..d88d384120 100644 --- a/test/templates.dart +++ b/test/templates.dart @@ -14,6 +14,10 @@ flutter_icons: theme_color: "#0175C2" # hex_color apple_mobile_web_app_title: "demo" apple_mobile_web_app_status_bar_style: "hex_color" + windows: + generate: true + image_path: "app_icon.png" + icon_size: 48 '''; const flavorFLIConfigTemplate = fliConfigTemplate; @@ -29,6 +33,31 @@ flutter_icons: apple_mobile_web_app_status_bar_style: "hex_color" '''; +const fliWindowsConfig = r''' +flutter_icons: + windows: + generate: true + image_path: "app_icon.png" + icon_size: 48 +'''; + +const fliWindowsConfigWithInvalidIconSize = r''' +flutter_icons: + windows: + generate: true + image_path: "app_icon.png" + icon_size: 258 +'''; + +const fliWindowsConfigWithNullImagePath = r''' +flutter_icons: + image_path: null + windows: + generate: true + image_path: null + icon_size: 258 +'''; + const invlaidfliConfigTemplate = r''' # flutter_icons android: true @@ -101,6 +130,10 @@ flutter_icons: theme_color: "#0175C2" # hex_color apple_mobile_web_app_title: "demo" apple_mobile_web_app_status_bar_style: "hex_color" + windows: + generate: true + image_path: "app_icon.png" + icon_size: 48 '''; const invalidPubspecTemplate = r''' @@ -157,6 +190,10 @@ flutter_icons: theme_color: "#0175C2" # hex_color apple_mobile_web_app_title: "demo" apple_mobile_web_app_status_bar_style: "hex_color" + windows: + generate: true + image_path: "app_icon.png" + icon_size: 48 '''; const webManifestTemplate = r''' diff --git a/test/windows/windows_icon_generator_test.dart b/test/windows/windows_icon_generator_test.dart new file mode 100644 index 0000000000..bbea772faa --- /dev/null +++ b/test/windows/windows_icon_generator_test.dart @@ -0,0 +1,150 @@ +import 'dart:io'; + +import 'package:flutter_launcher_icons/abs/icon_generator.dart'; +import 'package:flutter_launcher_icons/flutter_launcher_icons_config.dart'; +import 'package:flutter_launcher_icons/logger.dart'; +import 'package:flutter_launcher_icons/windows/windows_icon_generator.dart'; +import 'package:mockito/annotations.dart'; +import 'package:mockito/mockito.dart'; +import 'package:path/path.dart' as path; +import 'package:test/test.dart'; +import 'package:test_descriptor/test_descriptor.dart' as d; + +import '../templates.dart' as templates; +import 'windows_icon_generator_test.mocks.dart'; + +@GenerateMocks([FlutterLauncherIconsConfig, WindowsConfig, FLILogger]) +void main() { + group('WindowsIconGenerator', () { + late IconGeneratorContext context; + late IconGenerator generator; + late FlutterLauncherIconsConfig mockConfig; + late WindowsConfig mockWindowsConfig; + late String prefixPath; + late File testImageFile; + late MockFLILogger mockLogger; + final assetPath = path.join(Directory.current.path, 'test', 'assets'); + + group('#validateRequirments', () { + setUpAll(() { + // make sure test file exists before starting test + testImageFile = File(path.join(assetPath, 'app_icon.png')); + expect(testImageFile.existsSync(), isTrue); + }); + setUp(() async { + prefixPath = path.join(d.sandbox, 'fli_test'); + mockConfig = MockFlutterLauncherIconsConfig(); + mockWindowsConfig = MockWindowsConfig(); + mockLogger = MockFLILogger(); + context = IconGeneratorContext(config: mockConfig, prefixPath: prefixPath, logger: mockLogger); + generator = WindowsIconGenerator(context); + // initilize mock defaults + when(mockLogger.error(argThat(anything))).thenReturn(anything); + when(mockLogger.verbose(argThat(anything))).thenReturn(anything); + when(mockLogger.isVerbose).thenReturn(false); + when(mockConfig.windowsConfig).thenReturn(mockWindowsConfig); + when(mockWindowsConfig.generate).thenReturn(true); + when(mockWindowsConfig.imagePath).thenReturn(path.join(prefixPath, 'app_icon.png')); + when(mockConfig.imagePath).thenReturn(path.join(prefixPath, 'app_icon.png')); + when(mockWindowsConfig.iconSize).thenReturn(48); + }); + + test('should return false when windows config is not provided', () { + when(mockConfig.windowsConfig).thenReturn(null); + expect(generator.validateRequirements(), isFalse); + verify(mockConfig.windowsConfig).called(equals(1)); + }); + + test('should return false when windowsConfig is not null but windows.generate is false', () { + when(mockConfig.windowsConfig).thenReturn(mockWindowsConfig); + when(mockWindowsConfig.generate).thenReturn(false); + expect(generator.validateRequirements(), isFalse); + verify(mockConfig.windowsConfig).called(equals(1)); + verify(mockWindowsConfig.generate).called(equals(1)); + }); + + test('should return false when windows.image_path and imagePath is null', () { + when(mockWindowsConfig.imagePath).thenReturn(null); + when(mockConfig.imagePath).thenReturn(null); + expect(generator.validateRequirements(), isFalse); + + verifyInOrder([ + mockWindowsConfig.imagePath, + mockConfig.imagePath, + ]); + }); + + test('should return false when windows.icon_size is not between 48 and 256', () { + when(mockWindowsConfig.iconSize).thenReturn(40); + expect(generator.validateRequirements(), isFalse); + verify(mockWindowsConfig.iconSize).called(equals(3)); + + when(mockWindowsConfig.iconSize).thenReturn(257); + expect(generator.validateRequirements(), isFalse); + verify(mockWindowsConfig.iconSize).called(equals(4)); + }); + + test('should return false when windows dir does not exist', () async { + await d.dir('fli_test', [ + d.file('app_icon.png', testImageFile.readAsBytesSync()), + ]).create(); + await expectLater( + d.dir('fli_test', [ + d.file('app_icon.png', anything), + ]).validate(), + completes, + ); + expect(generator.validateRequirements(), isFalse); + }); + + test('should return false when image file does not exist', () async { + await d.dir('fli_test', [d.dir('windows')]).create(); + await expectLater( + d.dir('fli_test', [d.dir('windows')]).validate(), + completes, + ); + expect(generator.validateRequirements(), isFalse); + }); + }); + }); + + group('WindowsIconGenerator end-to-end', () { + late IconGeneratorContext context; + late IconGenerator generator; + late FlutterLauncherIconsConfig config; + late String prefixPath; + final assetPath = path.join(Directory.current.path, 'test', 'assets'); + + setUp(() async { + final imageFile = File(path.join(assetPath, 'app_icon.png')); + expect(imageFile.existsSync(), isTrue); + await d.dir('fli_test', [ + d.dir('windows'), + d.file('flutter_launcher_icons.yaml', templates.fliWindowsConfig), + d.file('pubspec.yaml', templates.pubspecTemplate), + d.file('app_icon.png', imageFile.readAsBytesSync()), + ]).create(); + prefixPath = path.join(d.sandbox, 'fli_test'); + config = FlutterLauncherIconsConfig.loadConfigFromPath('flutter_launcher_icons.yaml', prefixPath)!; + context = IconGeneratorContext(config: config, prefixPath: prefixPath, logger: FLILogger(false)); + generator = WindowsIconGenerator(context); + }); + + test('should generate valid icons', () async { + expect(generator.validateRequirements(), isTrue); + generator.createIcons(); + await expectLater( + d.dir('fli_test', [ + d.dir('windows', [ + d.dir('runner', [ + d.dir('resources', [ + d.file('app_icon.ico', anything), + ]), + ]), + ]), + ]).validate(), + completes, + ); + }); + }); +} diff --git a/test/windows/windows_icon_generator_test.mocks.dart b/test/windows/windows_icon_generator_test.mocks.dart new file mode 100644 index 0000000000..0436a54ada --- /dev/null +++ b/test/windows/windows_icon_generator_test.mocks.dart @@ -0,0 +1,89 @@ +// Mocks generated by Mockito 5.2.0 from annotations +// in flutter_launcher_icons/test/windows/windows_icon_generator_test.dart. +// Do not manually edit this file. + +import 'package:cli_util/cli_logging.dart' as _i2; +import 'package:flutter_launcher_icons/flutter_launcher_icons_config.dart' + as _i3; +import 'package:flutter_launcher_icons/logger.dart' as _i4; +import 'package:mockito/mockito.dart' as _i1; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types + +class _FakeLogger_0 extends _i1.Fake implements _i2.Logger {} + +class _FakeProgress_1 extends _i1.Fake implements _i2.Progress {} + +/// A class which mocks [FlutterLauncherIconsConfig]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockFlutterLauncherIconsConfig extends _i1.Mock + implements _i3.FlutterLauncherIconsConfig { + MockFlutterLauncherIconsConfig() { + _i1.throwOnMissingStub(this); + } + + @override + Map toJson() => + (super.noSuchMethod(Invocation.method(#toJson, []), + returnValue: {}) as Map); +} + +/// A class which mocks [WindowsConfig]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockWindowsConfig extends _i1.Mock implements _i3.WindowsConfig { + MockWindowsConfig() { + _i1.throwOnMissingStub(this); + } + + @override + bool get generate => + (super.noSuchMethod(Invocation.getter(#generate), returnValue: false) + as bool); + @override + Map toJson() => + (super.noSuchMethod(Invocation.method(#toJson, []), + returnValue: {}) as Map); +} + +/// A class which mocks [FLILogger]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockFLILogger extends _i1.Mock implements _i4.FLILogger { + MockFLILogger() { + _i1.throwOnMissingStub(this); + } + + @override + bool get isVerbose => + (super.noSuchMethod(Invocation.getter(#isVerbose), returnValue: false) + as bool); + @override + _i2.Logger get rawLogger => (super.noSuchMethod(Invocation.getter(#rawLogger), + returnValue: _FakeLogger_0()) as _i2.Logger); + @override + void error(Object? message) => + super.noSuchMethod(Invocation.method(#error, [message]), + returnValueForMissingStub: null); + @override + void verbose(Object? message) => + super.noSuchMethod(Invocation.method(#verbose, [message]), + returnValueForMissingStub: null); + @override + void info(Object? message) => + super.noSuchMethod(Invocation.method(#info, [message]), + returnValueForMissingStub: null); + @override + _i2.Progress progress(String? message) => + (super.noSuchMethod(Invocation.method(#progress, [message]), + returnValue: _FakeProgress_1()) as _i2.Progress); +}