Skip to content

Commit

Permalink
Support downloading font-subset for all platforms (#50240)
Browse files Browse the repository at this point in the history
  • Loading branch information
chingjun committed Feb 6, 2020
1 parent 247f6a1 commit 81525fa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/flutter_tools/lib/src/cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1229,11 +1229,15 @@ class FontSubsetArtifacts extends EngineCachedArtifact {
'linux': <String>['linux-x64', 'linux-x64/$artifactName.zip'],
'windows': <String>['windows-x64', 'windows-x64/$artifactName.zip'],
};
final List<String> binaryDirs = artifacts[globals.platform.operatingSystem];
if (binaryDirs == null) {
throwToolExit('Unsupported operating system: ${globals.platform.operatingSystem}');
if (cache.includeAllPlatforms) {
return artifacts.values.toList();
} else {
final List<String> binaryDirs = artifacts[globals.platform.operatingSystem];
if (binaryDirs == null) {
throwToolExit('Unsupported operating system: ${globals.platform.operatingSystem}');
}
return <List<String>>[binaryDirs];
}
return <List<String>>[binaryDirs];
}

@override
Expand Down
17 changes: 17 additions & 0 deletions packages/flutter_tools/test/general.shard/cache_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ void main() {
testUsingContext('FontSubset artifacts on linux', () {
final MockCache mockCache = MockCache();
final FontSubsetArtifacts artifacts = FontSubsetArtifacts(mockCache);
when(mockCache.includeAllPlatforms).thenReturn(false);
expect(artifacts.getBinaryDirs(), <List<String>>[<String>['linux-x64', 'linux-x64/font-subset.zip']]);
}, overrides: <Type, Generator> {
Platform: () => FakePlatform()..operatingSystem = 'linux',
Expand All @@ -507,6 +508,7 @@ void main() {
testUsingContext('FontSubset artifacts on windows', () {
final MockCache mockCache = MockCache();
final FontSubsetArtifacts artifacts = FontSubsetArtifacts(mockCache);
when(mockCache.includeAllPlatforms).thenReturn(false);
expect(artifacts.getBinaryDirs(), <List<String>>[<String>['windows-x64', 'windows-x64/font-subset.zip']]);
}, overrides: <Type, Generator> {
Platform: () => FakePlatform()..operatingSystem = 'windows',
Expand All @@ -515,6 +517,7 @@ void main() {
testUsingContext('FontSubset artifacts on macos', () {
final MockCache mockCache = MockCache();
final FontSubsetArtifacts artifacts = FontSubsetArtifacts(mockCache);
when(mockCache.includeAllPlatforms).thenReturn(false);
expect(artifacts.getBinaryDirs(), <List<String>>[<String>['darwin-x64', 'darwin-x64/font-subset.zip']]);
}, overrides: <Type, Generator> {
Platform: () => FakePlatform()..operatingSystem = 'macos',
Expand All @@ -523,10 +526,24 @@ void main() {
testUsingContext('FontSubset artifacts on fuchsia', () {
final MockCache mockCache = MockCache();
final FontSubsetArtifacts artifacts = FontSubsetArtifacts(mockCache);
when(mockCache.includeAllPlatforms).thenReturn(false);
expect(() => artifacts.getBinaryDirs(), throwsToolExit(message: 'Unsupported operating system: ${globals.platform.operatingSystem}'));
}, overrides: <Type, Generator> {
Platform: () => FakePlatform()..operatingSystem = 'fuchsia',
});

testUsingContext('FontSubset artifacts for all platforms', () {
final MockCache mockCache = MockCache();
final FontSubsetArtifacts artifacts = FontSubsetArtifacts(mockCache);
when(mockCache.includeAllPlatforms).thenReturn(true);
expect(artifacts.getBinaryDirs(), <List<String>>[
<String>['darwin-x64', 'darwin-x64/font-subset.zip'],
<String>['linux-x64', 'linux-x64/font-subset.zip'],
<String>['windows-x64', 'windows-x64/font-subset.zip'],
]);
}, overrides: <Type, Generator> {
Platform: () => FakePlatform()..operatingSystem = 'fuchsia',
});
}

class FakeCachedArtifact extends EngineCachedArtifact {
Expand Down

0 comments on commit 81525fa

Please sign in to comment.