[macos] add flavor options to commands in the flutter_tool (#118421)
* Add new macos target configured for flavors * Rename Free App copy-Info.plist to Free App Info.plist * Remove bogus entitlements * Remove Generated.xcconfig * Audit project.pbxproj * Remove unused configs * share one info.plist * Modify scheme so that paid app works * Codesign automatic * Pipe flavor as scheme into xcodebuild * Ignore incoming flavor string * pipe flavor for flutter run to work * Add devicelab tests * Error if host and target device are same for flutter install desktop * Avoid bang (!) by promoting a local. Co-authored-by: Jenn Magder <magder@google.com> * Add supportsInstall property * Override in test classes * Add install test on macOS * Refactor application_package and add tests for package directory Co-authored-by: a-wallen <stephenwallen@google.com> Co-authored-by: Jenn Magder <magder@google.com>
This commit is contained in:
@@ -157,6 +157,12 @@ class FakeIOSDevice extends Fake implements IOSDevice {
|
||||
IOSApp app, {
|
||||
String? userIdentifier,
|
||||
}) async => true;
|
||||
|
||||
@override
|
||||
String get name => 'iOS';
|
||||
|
||||
@override
|
||||
bool get supportsInstall => true;
|
||||
}
|
||||
|
||||
// Unfortunately Device, despite not being immutable, has an `operator ==`.
|
||||
@@ -177,4 +183,10 @@ class FakeAndroidDevice extends Fake implements AndroidDevice {
|
||||
AndroidApk app, {
|
||||
String? userIdentifier,
|
||||
}) async => true;
|
||||
|
||||
@override
|
||||
String get name => 'Android';
|
||||
|
||||
@override
|
||||
bool get supportsInstall => true;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ void main() {
|
||||
),
|
||||
]);
|
||||
final FakeDesktopDevice device = setUpDesktopDevice(processManager: processManager, fileSystem: fileSystem);
|
||||
final String? executableName = device.executablePathForDevice(FakeApplicationPackage(), BuildMode.debug);
|
||||
final String? executableName = device.executablePathForDevice(FakeApplicationPackage(), BuildInfo.debug);
|
||||
fileSystem.file(executableName).writeAsStringSync('\n');
|
||||
final FakeApplicationPackage package = FakeApplicationPackage();
|
||||
final LaunchResult result = await device.startApp(
|
||||
@@ -367,11 +367,11 @@ class FakeDesktopDevice extends DesktopDevice {
|
||||
|
||||
// Dummy implementation that just returns the build mode name.
|
||||
@override
|
||||
String? executablePathForDevice(ApplicationPackage package, BuildMode buildMode) {
|
||||
String? executablePathForDevice(ApplicationPackage package, BuildInfo buildInfo) {
|
||||
if (nullExecutablePathForDevice) {
|
||||
return null;
|
||||
}
|
||||
return buildMode == null ? 'null' : getNameForBuildMode(buildMode);
|
||||
return buildInfo == null ? 'null' : getNameForBuildMode(buildInfo.mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -154,9 +154,9 @@ void main() {
|
||||
operatingSystemUtils: FakeOperatingSystemUtils(),
|
||||
);
|
||||
|
||||
expect(device.executablePathForDevice(mockApp, BuildMode.debug), 'debug/executable');
|
||||
expect(device.executablePathForDevice(mockApp, BuildMode.profile), 'profile/executable');
|
||||
expect(device.executablePathForDevice(mockApp, BuildMode.release), 'release/executable');
|
||||
expect(device.executablePathForDevice(mockApp, BuildInfo.debug), 'debug/executable');
|
||||
expect(device.executablePathForDevice(mockApp, BuildInfo.profile), 'profile/executable');
|
||||
expect(device.executablePathForDevice(mockApp, BuildInfo.release), 'release/executable');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/os.dart';
|
||||
import 'package:flutter_tools/src/base/utils.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/ios/plist_parser.dart';
|
||||
import 'package:flutter_tools/src/macos/application_package.dart';
|
||||
@@ -155,6 +156,20 @@ group('PrebuiltMacOSApp', () {
|
||||
expect(macosApp.id, 'com.example.placeholder');
|
||||
expect(macosApp.name, 'macOS');
|
||||
}, overrides: overrides);
|
||||
|
||||
testUsingContext('Chooses the correct directory for application.', () {
|
||||
final MacOSProject project = FlutterProject.fromDirectory(globals.fs.currentDirectory).macos;
|
||||
final BuildableMacOSApp macosApp = MacOSApp.fromMacOSProject(project) as BuildableMacOSApp;
|
||||
|
||||
const BuildInfo vanillaApp = BuildInfo(BuildMode.debug, null, treeShakeIcons: false);
|
||||
String? applicationBundle = macosApp.bundleDirectory(vanillaApp);
|
||||
expect(applicationBundle, 'Debug');
|
||||
|
||||
const BuildInfo flavoredApp = BuildInfo(BuildMode.release, 'flavor', treeShakeIcons: false);
|
||||
applicationBundle = macosApp.bundleDirectory(flavoredApp);
|
||||
expect(applicationBundle, 'Release Flavor');
|
||||
|
||||
}, overrides: overrides);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -235,9 +235,9 @@ void main() {
|
||||
const String profilePath = 'profile/executable';
|
||||
const String releasePath = 'release/executable';
|
||||
|
||||
expect(device.executablePathForDevice(package, BuildMode.debug), debugPath);
|
||||
expect(device.executablePathForDevice(package, BuildMode.profile), profilePath);
|
||||
expect(device.executablePathForDevice(package, BuildMode.release), releasePath);
|
||||
expect(device.executablePathForDevice(package, BuildInfo.debug), debugPath);
|
||||
expect(device.executablePathForDevice(package, BuildInfo.profile), profilePath);
|
||||
expect(device.executablePathForDevice(package, BuildInfo.release), releasePath);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -251,13 +251,13 @@ FlutterProject setUpFlutterProject(Directory directory) {
|
||||
|
||||
class FakeMacOSApp extends Fake implements MacOSApp {
|
||||
@override
|
||||
String executable(BuildMode buildMode) {
|
||||
switch (buildMode) {
|
||||
case BuildMode.debug:
|
||||
String executable(BuildInfo buildInfo) {
|
||||
switch (buildInfo) {
|
||||
case BuildInfo.debug:
|
||||
return 'debug/executable';
|
||||
case BuildMode.profile:
|
||||
case BuildInfo.profile:
|
||||
return 'profile/executable';
|
||||
case BuildMode.release:
|
||||
case BuildInfo.release:
|
||||
return 'release/executable';
|
||||
default:
|
||||
throw StateError('');
|
||||
|
||||
@@ -142,7 +142,7 @@ void main() {
|
||||
throwsA(isA<UnimplementedError>()),
|
||||
);
|
||||
await expectLater(() => device.buildForDevice(buildInfo: BuildInfo.debug), throwsA(isA<UnimplementedError>()));
|
||||
expect(device.executablePathForDevice(FakeIOSApp(), BuildMode.debug), null);
|
||||
expect(device.executablePathForDevice(FakeIOSApp(), BuildInfo.debug), null);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -101,9 +101,9 @@ void main() {
|
||||
final WindowsDevice windowsDevice = setUpWindowsDevice();
|
||||
final FakeWindowsApp fakeApp = FakeWindowsApp();
|
||||
|
||||
expect(windowsDevice.executablePathForDevice(fakeApp, BuildMode.debug), 'debug/executable');
|
||||
expect(windowsDevice.executablePathForDevice(fakeApp, BuildMode.profile), 'profile/executable');
|
||||
expect(windowsDevice.executablePathForDevice(fakeApp, BuildMode.release), 'release/executable');
|
||||
expect(windowsDevice.executablePathForDevice(fakeApp, BuildInfo.debug), 'debug/executable');
|
||||
expect(windowsDevice.executablePathForDevice(fakeApp, BuildInfo.profile), 'profile/executable');
|
||||
expect(windowsDevice.executablePathForDevice(fakeApp, BuildInfo.release), 'release/executable');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user