Skip to content

Commit ad7e2f7

Browse files
authored
Disable Fuchsia SDK usage unless opted in (#123084)
Disable Fuchsia SDK usage unless opted in
1 parent 20de2a2 commit ad7e2f7

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

packages/flutter_tools/lib/src/fuchsia/fuchsia_sdk.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import '../base/file_system.dart';
88
import '../base/io.dart';
99
import '../base/platform.dart';
1010
import '../convert.dart';
11+
import '../features.dart' show featureFlags;
1112
import '../globals.dart' as globals;
1213

1314
import 'fuchsia_ffx.dart';
@@ -16,7 +17,7 @@ import 'fuchsia_pm.dart';
1617

1718
/// Returns [true] if the current platform supports Fuchsia targets.
1819
bool isFuchsiaSupportedPlatform(Platform platform) {
19-
return platform.isLinux || platform.isMacOS;
20+
return featureFlags.isFuchsiaEnabled && (platform.isLinux || platform.isMacOS);
2021
}
2122

2223
/// The Fuchsia SDK shell commands.

packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import 'package:flutter_tools/src/build_info.dart';
1717
import 'package:flutter_tools/src/cache.dart';
1818
import 'package:flutter_tools/src/device.dart';
1919
import 'package:flutter_tools/src/device_port_forwarder.dart';
20+
import 'package:flutter_tools/src/features.dart';
2021
import 'package:flutter_tools/src/fuchsia/fuchsia_device.dart';
2122
import 'package:flutter_tools/src/fuchsia/fuchsia_ffx.dart';
2223
import 'package:flutter_tools/src/fuchsia/fuchsia_kernel_compiler.dart';
@@ -32,6 +33,7 @@ import 'package:vm_service/vm_service.dart' as vm_service;
3233
import '../../src/common.dart';
3334
import '../../src/context.dart';
3435
import '../../src/fake_vm_services.dart';
36+
import '../../src/fakes.dart';
3537

3638
final vm_service.Isolate fakeIsolate = vm_service.Isolate(
3739
id: '1',
@@ -483,6 +485,7 @@ void main() {
483485
expect(device.supportsScreenshot, true);
484486
}, overrides: <Type, Generator>{
485487
Platform: () => FakePlatform(),
488+
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
486489
});
487490

488491
testUsingContext('is not supported on Windows', () {
@@ -493,6 +496,7 @@ void main() {
493496
Platform: () => FakePlatform(
494497
operatingSystem: 'windows',
495498
),
499+
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
496500
});
497501

498502
test("takeScreenshot throws if file isn't .ppm", () async {
@@ -532,6 +536,7 @@ void main() {
532536
'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh',
533537
},
534538
),
539+
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
535540
});
536541

537542
testUsingContext('takeScreenshot throws if scp failed', () async {
@@ -582,6 +587,7 @@ void main() {
582587
'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh',
583588
},
584589
),
590+
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
585591
});
586592

587593
testUsingContext(
@@ -632,6 +638,7 @@ void main() {
632638
'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh',
633639
},
634640
),
641+
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
635642
}, testOn: 'posix');
636643

637644
testUsingContext('takeScreenshot returns', () async {
@@ -674,6 +681,7 @@ void main() {
674681
'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh',
675682
},
676683
),
684+
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
677685
});
678686
});
679687

packages/flutter_tools/test/general.shard/fuchsia/fuchsia_ffx_test.dart

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ import 'package:file/file.dart';
66
import 'package:file/memory.dart';
77
import 'package:flutter_tools/src/base/file_system.dart';
88
import 'package:flutter_tools/src/base/logger.dart';
9+
import 'package:flutter_tools/src/base/platform.dart';
10+
import 'package:flutter_tools/src/features.dart';
911
import 'package:flutter_tools/src/fuchsia/fuchsia_ffx.dart';
1012
import 'package:flutter_tools/src/fuchsia/fuchsia_sdk.dart';
1113
import 'package:test/fake.dart';
1214

1315
import '../../src/common.dart';
14-
import '../../src/fake_process_manager.dart';
16+
import '../../src/context.dart';
17+
import '../../src/fakes.dart';
1518

1619
void main() {
1720
late FakeFuchsiaArtifacts fakeFuchsiaArtifacts;
@@ -27,6 +30,22 @@ void main() {
2730
fakeFuchsiaArtifacts.ffx = ffx;
2831
});
2932

33+
testUsingContext('isFuchsiaSupportedPlatform returns true when opted in on Linux and macOS', () {
34+
expect(isFuchsiaSupportedPlatform(FakePlatform(operatingSystem: 'macos')), true);
35+
expect(isFuchsiaSupportedPlatform(FakePlatform()), true);
36+
expect(isFuchsiaSupportedPlatform(FakePlatform(operatingSystem: 'windows')), false);
37+
}, overrides: <Type, Generator>{
38+
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
39+
});
40+
41+
testUsingContext('isFuchsiaSupportedPlatform returns false when opted out on Linux and macOS', () {
42+
expect(isFuchsiaSupportedPlatform(FakePlatform(operatingSystem: 'macos')), false);
43+
expect(isFuchsiaSupportedPlatform(FakePlatform()), false);
44+
expect(isFuchsiaSupportedPlatform(FakePlatform(operatingSystem: 'windows')), false);
45+
}, overrides: <Type, Generator>{
46+
FeatureFlags: () => TestFeatureFlags(),
47+
});
48+
3049
group('ffx list', () {
3150
testWithoutContext('ffx not found', () {
3251
final FuchsiaFfx fuchsiaFfx = FuchsiaFfx(

0 commit comments

Comments
 (0)