Unverified Commit 81525fa1 authored by Lau Ching Jun's avatar Lau Ching Jun Committed by GitHub

Support downloading font-subset for all platforms (#50240)

parent 247f6a18
...@@ -1229,11 +1229,15 @@ class FontSubsetArtifacts extends EngineCachedArtifact { ...@@ -1229,11 +1229,15 @@ class FontSubsetArtifacts extends EngineCachedArtifact {
'linux': <String>['linux-x64', 'linux-x64/$artifactName.zip'], 'linux': <String>['linux-x64', 'linux-x64/$artifactName.zip'],
'windows': <String>['windows-x64', 'windows-x64/$artifactName.zip'], 'windows': <String>['windows-x64', 'windows-x64/$artifactName.zip'],
}; };
final List<String> binaryDirs = artifacts[globals.platform.operatingSystem]; if (cache.includeAllPlatforms) {
if (binaryDirs == null) { return artifacts.values.toList();
throwToolExit('Unsupported operating system: ${globals.platform.operatingSystem}'); } 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 @override
......
...@@ -499,6 +499,7 @@ void main() { ...@@ -499,6 +499,7 @@ void main() {
testUsingContext('FontSubset artifacts on linux', () { testUsingContext('FontSubset artifacts on linux', () {
final MockCache mockCache = MockCache(); final MockCache mockCache = MockCache();
final FontSubsetArtifacts artifacts = FontSubsetArtifacts(mockCache); final FontSubsetArtifacts artifacts = FontSubsetArtifacts(mockCache);
when(mockCache.includeAllPlatforms).thenReturn(false);
expect(artifacts.getBinaryDirs(), <List<String>>[<String>['linux-x64', 'linux-x64/font-subset.zip']]); expect(artifacts.getBinaryDirs(), <List<String>>[<String>['linux-x64', 'linux-x64/font-subset.zip']]);
}, overrides: <Type, Generator> { }, overrides: <Type, Generator> {
Platform: () => FakePlatform()..operatingSystem = 'linux', Platform: () => FakePlatform()..operatingSystem = 'linux',
...@@ -507,6 +508,7 @@ void main() { ...@@ -507,6 +508,7 @@ void main() {
testUsingContext('FontSubset artifacts on windows', () { testUsingContext('FontSubset artifacts on windows', () {
final MockCache mockCache = MockCache(); final MockCache mockCache = MockCache();
final FontSubsetArtifacts artifacts = FontSubsetArtifacts(mockCache); final FontSubsetArtifacts artifacts = FontSubsetArtifacts(mockCache);
when(mockCache.includeAllPlatforms).thenReturn(false);
expect(artifacts.getBinaryDirs(), <List<String>>[<String>['windows-x64', 'windows-x64/font-subset.zip']]); expect(artifacts.getBinaryDirs(), <List<String>>[<String>['windows-x64', 'windows-x64/font-subset.zip']]);
}, overrides: <Type, Generator> { }, overrides: <Type, Generator> {
Platform: () => FakePlatform()..operatingSystem = 'windows', Platform: () => FakePlatform()..operatingSystem = 'windows',
...@@ -515,6 +517,7 @@ void main() { ...@@ -515,6 +517,7 @@ void main() {
testUsingContext('FontSubset artifacts on macos', () { testUsingContext('FontSubset artifacts on macos', () {
final MockCache mockCache = MockCache(); final MockCache mockCache = MockCache();
final FontSubsetArtifacts artifacts = FontSubsetArtifacts(mockCache); final FontSubsetArtifacts artifacts = FontSubsetArtifacts(mockCache);
when(mockCache.includeAllPlatforms).thenReturn(false);
expect(artifacts.getBinaryDirs(), <List<String>>[<String>['darwin-x64', 'darwin-x64/font-subset.zip']]); expect(artifacts.getBinaryDirs(), <List<String>>[<String>['darwin-x64', 'darwin-x64/font-subset.zip']]);
}, overrides: <Type, Generator> { }, overrides: <Type, Generator> {
Platform: () => FakePlatform()..operatingSystem = 'macos', Platform: () => FakePlatform()..operatingSystem = 'macos',
...@@ -523,10 +526,24 @@ void main() { ...@@ -523,10 +526,24 @@ void main() {
testUsingContext('FontSubset artifacts on fuchsia', () { testUsingContext('FontSubset artifacts on fuchsia', () {
final MockCache mockCache = MockCache(); final MockCache mockCache = MockCache();
final FontSubsetArtifacts artifacts = FontSubsetArtifacts(mockCache); final FontSubsetArtifacts artifacts = FontSubsetArtifacts(mockCache);
when(mockCache.includeAllPlatforms).thenReturn(false);
expect(() => artifacts.getBinaryDirs(), throwsToolExit(message: 'Unsupported operating system: ${globals.platform.operatingSystem}')); expect(() => artifacts.getBinaryDirs(), throwsToolExit(message: 'Unsupported operating system: ${globals.platform.operatingSystem}'));
}, overrides: <Type, Generator> { }, overrides: <Type, Generator> {
Platform: () => FakePlatform()..operatingSystem = 'fuchsia', 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 { class FakeCachedArtifact extends EngineCachedArtifact {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment