mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Adopt Artifacts.test(localEngine:) in a few tests (#76354)
This commit is contained in:
parent
6fec8b3679
commit
62d8969203
@ -135,7 +135,6 @@ void main() {
|
||||
|
||||
testbed.test('flutter assemble does not inject engine revision with local-engine', () async {
|
||||
Environment environment;
|
||||
when(globals.artifacts.isLocalEngine).thenReturn(true);
|
||||
when(globals.buildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
|
||||
.thenAnswer((Invocation invocation) async {
|
||||
environment = invocation.positionalArguments[1] as Environment;
|
||||
@ -146,7 +145,7 @@ void main() {
|
||||
|
||||
expect(environment.engineVersion, isNull);
|
||||
}, overrides: <Type, Generator>{
|
||||
Artifacts: () => MockLocalEngineArtifacts()
|
||||
Artifacts: () => Artifacts.test(localEngine: 'out/host_release'),
|
||||
});
|
||||
|
||||
testbed.test('flutter assemble only writes input and output files when the values change', () async {
|
||||
@ -239,4 +238,3 @@ void main() {
|
||||
}
|
||||
|
||||
class MockBuildSystem extends Mock implements BuildSystem {}
|
||||
class MockLocalEngineArtifacts extends Mock implements LocalEngineArtifacts {}
|
||||
|
@ -315,24 +315,22 @@ include ':app'
|
||||
});
|
||||
|
||||
group('Gradle local.properties', () {
|
||||
MockLocalEngineArtifacts mockArtifacts;
|
||||
MockProcessManager mockProcessManager;
|
||||
Artifacts localEngineArtifacts;
|
||||
FakePlatform android;
|
||||
FileSystem fs;
|
||||
|
||||
setUp(() {
|
||||
fs = MemoryFileSystem.test();
|
||||
mockArtifacts = MockLocalEngineArtifacts();
|
||||
mockProcessManager = MockProcessManager();
|
||||
localEngineArtifacts = Artifacts.test(localEngine: 'out/android_arm');
|
||||
android = fakePlatform('android');
|
||||
});
|
||||
|
||||
void testUsingAndroidContext(String description, dynamic testMethod()) {
|
||||
testUsingContext(description, testMethod, overrides: <Type, Generator>{
|
||||
Artifacts: () => mockArtifacts,
|
||||
Artifacts: () => localEngineArtifacts,
|
||||
Platform: () => android,
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => mockProcessManager,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
}
|
||||
|
||||
@ -349,14 +347,6 @@ include ':app'
|
||||
String expectedBuildName,
|
||||
String expectedBuildNumber,
|
||||
}) async {
|
||||
when(mockArtifacts.getArtifactPath(
|
||||
Artifact.flutterFramework,
|
||||
platform: TargetPlatform.android_arm,
|
||||
mode: anyNamed('mode'),
|
||||
environmentType: anyNamed('environmentType'),
|
||||
)).thenReturn('engine');
|
||||
when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'android_arm'));
|
||||
|
||||
final File manifestFile = globals.fs.file('path/to/project/pubspec.yaml');
|
||||
manifestFile.createSync(recursive: true);
|
||||
manifestFile.writeAsStringSync(manifest);
|
||||
@ -1042,5 +1032,3 @@ class FakeGradleUtils extends GradleUtils {
|
||||
class MockAndroidSdk extends Mock implements AndroidSdk {}
|
||||
class MockAndroidProject extends Mock implements AndroidProject {}
|
||||
class MockFlutterProject extends Mock implements FlutterProject {}
|
||||
class MockLocalEngineArtifacts extends Mock implements LocalEngineArtifacts {}
|
||||
class MockProcessManager extends Mock implements ProcessManager {}
|
||||
|
@ -638,20 +638,20 @@ Information about project "Runner":
|
||||
});
|
||||
|
||||
group('updateGeneratedXcodeProperties', () {
|
||||
MockLocalEngineArtifacts mockArtifacts;
|
||||
Artifacts localArtifacts;
|
||||
FakePlatform macOS;
|
||||
FileSystem fs;
|
||||
|
||||
setUp(() {
|
||||
fs = MemoryFileSystem.test();
|
||||
mockArtifacts = MockLocalEngineArtifacts();
|
||||
localArtifacts = Artifacts.test(localEngine: 'out/ios_profile_arm');
|
||||
macOS = FakePlatform(operatingSystem: 'macos');
|
||||
fs.file(xcodebuild).createSync(recursive: true);
|
||||
});
|
||||
|
||||
void testUsingOsxContext(String description, dynamic testMethod()) {
|
||||
testUsingContext(description, testMethod, overrides: <Type, Generator>{
|
||||
Artifacts: () => mockArtifacts,
|
||||
Artifacts: () => localArtifacts,
|
||||
Platform: () => macOS,
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
@ -659,13 +659,6 @@ Information about project "Runner":
|
||||
}
|
||||
|
||||
testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async {
|
||||
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
|
||||
platform: TargetPlatform.ios,
|
||||
mode: anyNamed('mode'),
|
||||
environmentType: anyNamed('environmentType')))
|
||||
.thenReturn('engine');
|
||||
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
|
||||
|
||||
const BuildInfo buildInfo = BuildInfo.debug;
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.directory('path/to/project'));
|
||||
await updateGeneratedXcodeProperties(
|
||||
@ -686,41 +679,7 @@ Information about project "Runner":
|
||||
expect(buildPhaseScriptContents.contains('ARCHS=armv7'), isTrue);
|
||||
});
|
||||
|
||||
testUsingOsxContext('sets ARCHS=x86_64 when sim local engine is set', () async {
|
||||
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
|
||||
platform: TargetPlatform.ios,
|
||||
mode: anyNamed('mode'),
|
||||
environmentType: anyNamed('environmentType')))
|
||||
.thenReturn('engine');
|
||||
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_debug_sim_unopt'));
|
||||
|
||||
const BuildInfo buildInfo = BuildInfo.debug;
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.directory('path/to/project'));
|
||||
await updateGeneratedXcodeProperties(
|
||||
project: project,
|
||||
buildInfo: buildInfo,
|
||||
);
|
||||
|
||||
final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
|
||||
expect(config.existsSync(), isTrue);
|
||||
|
||||
final String contents = config.readAsStringSync();
|
||||
expect(contents.contains('ARCHS=x86_64'), isTrue);
|
||||
|
||||
final File buildPhaseScript = fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh');
|
||||
expect(buildPhaseScript.existsSync(), isTrue);
|
||||
|
||||
final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync();
|
||||
expect(buildPhaseScriptContents.contains('ARCHS=x86_64'), isTrue);
|
||||
});
|
||||
|
||||
testUsingOsxContext('sets TRACK_WIDGET_CREATION=true when trackWidgetCreation is true', () async {
|
||||
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
|
||||
platform: TargetPlatform.ios,
|
||||
mode: anyNamed('mode'),
|
||||
environmentType: anyNamed('environmentType')))
|
||||
.thenReturn('engine');
|
||||
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
|
||||
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, trackWidgetCreation: true, treeShakeIcons: false);
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.directory('path/to/project'));
|
||||
await updateGeneratedXcodeProperties(
|
||||
@ -742,12 +701,6 @@ Information about project "Runner":
|
||||
});
|
||||
|
||||
testUsingOsxContext('does not set TRACK_WIDGET_CREATION when trackWidgetCreation is false', () async {
|
||||
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
|
||||
platform: TargetPlatform.ios,
|
||||
mode: anyNamed('mode'),
|
||||
environmentType: anyNamed('environmentType')))
|
||||
.thenReturn('engine');
|
||||
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
|
||||
const BuildInfo buildInfo = BuildInfo.debug;
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.directory('path/to/project'));
|
||||
await updateGeneratedXcodeProperties(
|
||||
@ -768,26 +721,67 @@ Information about project "Runner":
|
||||
expect(buildPhaseScriptContents.contains('TRACK_WIDGET_CREATION=true'), isFalse);
|
||||
});
|
||||
|
||||
testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async {
|
||||
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
|
||||
platform: TargetPlatform.ios,
|
||||
mode: anyNamed('mode'),
|
||||
environmentType: anyNamed('environmentType')))
|
||||
.thenReturn('engine');
|
||||
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile'));
|
||||
const BuildInfo buildInfo = BuildInfo.debug;
|
||||
group('sim local engine', () {
|
||||
Artifacts localArtifacts;
|
||||
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.directory('path/to/project'));
|
||||
await updateGeneratedXcodeProperties(
|
||||
project: project,
|
||||
buildInfo: buildInfo,
|
||||
);
|
||||
setUp(() {
|
||||
localArtifacts = Artifacts.test(localEngine: 'out/ios_debug_sim_unopt');
|
||||
});
|
||||
|
||||
final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
|
||||
expect(config.existsSync(), isTrue);
|
||||
testUsingContext('sets ARCHS=x86_64 when sim local engine is set', () async {
|
||||
const BuildInfo buildInfo = BuildInfo.debug;
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.directory('path/to/project'));
|
||||
await updateGeneratedXcodeProperties(
|
||||
project: project,
|
||||
buildInfo: buildInfo,
|
||||
);
|
||||
|
||||
final String contents = config.readAsStringSync();
|
||||
expect(contents.contains('ARCHS=arm64'), isTrue);
|
||||
final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
|
||||
expect(config.existsSync(), isTrue);
|
||||
|
||||
final String contents = config.readAsStringSync();
|
||||
expect(contents.contains('ARCHS=x86_64'), isTrue);
|
||||
|
||||
final File buildPhaseScript = fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh');
|
||||
expect(buildPhaseScript.existsSync(), isTrue);
|
||||
|
||||
final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync();
|
||||
expect(buildPhaseScriptContents.contains('ARCHS=x86_64'), isTrue);
|
||||
}, overrides: <Type, Generator>{
|
||||
Artifacts: () => localArtifacts,
|
||||
Platform: () => macOS,
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
});
|
||||
|
||||
group('armv7 local engine', () {
|
||||
Artifacts localArtifacts;
|
||||
|
||||
setUp(() {
|
||||
localArtifacts = Artifacts.test(localEngine: 'out/ios_profile');
|
||||
});
|
||||
|
||||
testUsingContext('sets ARCHS=armv7 when armv7 local engine is set', () async {
|
||||
const BuildInfo buildInfo = BuildInfo.debug;
|
||||
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.directory('path/to/project'));
|
||||
await updateGeneratedXcodeProperties(
|
||||
project: project,
|
||||
buildInfo: buildInfo,
|
||||
);
|
||||
|
||||
final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
|
||||
expect(config.existsSync(), isTrue);
|
||||
|
||||
final String contents = config.readAsStringSync();
|
||||
expect(contents.contains('ARCHS=arm64'), isTrue);
|
||||
}, overrides: <Type, Generator>{
|
||||
Artifacts: () => localArtifacts,
|
||||
Platform: () => macOS,
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
});
|
||||
|
||||
String propertyFor(String key, File file) {
|
||||
@ -805,13 +799,6 @@ Information about project "Runner":
|
||||
String expectedBuildName,
|
||||
String expectedBuildNumber,
|
||||
}) async {
|
||||
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
|
||||
platform: TargetPlatform.ios,
|
||||
mode: anyNamed('mode'),
|
||||
environmentType: anyNamed('environmentType')))
|
||||
.thenReturn('engine');
|
||||
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios'));
|
||||
|
||||
final File manifestFile = fs.file('path/to/project/pubspec.yaml');
|
||||
manifestFile.createSync(recursive: true);
|
||||
manifestFile.writeAsStringSync(manifestString);
|
||||
@ -989,5 +976,3 @@ flutter:
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class MockLocalEngineArtifacts extends Mock implements LocalEngineArtifacts {}
|
||||
|
Loading…
Reference in New Issue
Block a user