Unverified Commit ad7e2f7b authored by Dan Field's avatar Dan Field Committed by GitHub

Disable Fuchsia SDK usage unless opted in (#123084)

Disable Fuchsia SDK usage unless opted in
parent 20de2a28
......@@ -8,6 +8,7 @@ import '../base/file_system.dart';
import '../base/io.dart';
import '../base/platform.dart';
import '../convert.dart';
import '../features.dart' show featureFlags;
import '../globals.dart' as globals;
import 'fuchsia_ffx.dart';
......@@ -16,7 +17,7 @@ import 'fuchsia_pm.dart';
/// Returns [true] if the current platform supports Fuchsia targets.
bool isFuchsiaSupportedPlatform(Platform platform) {
return platform.isLinux || platform.isMacOS;
return featureFlags.isFuchsiaEnabled && (platform.isLinux || platform.isMacOS);
}
/// The Fuchsia SDK shell commands.
......
......@@ -17,6 +17,7 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/device_port_forwarder.dart';
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/fuchsia/fuchsia_device.dart';
import 'package:flutter_tools/src/fuchsia/fuchsia_ffx.dart';
import 'package:flutter_tools/src/fuchsia/fuchsia_kernel_compiler.dart';
......@@ -32,6 +33,7 @@ import 'package:vm_service/vm_service.dart' as vm_service;
import '../../src/common.dart';
import '../../src/context.dart';
import '../../src/fake_vm_services.dart';
import '../../src/fakes.dart';
final vm_service.Isolate fakeIsolate = vm_service.Isolate(
id: '1',
......@@ -483,6 +485,7 @@ void main() {
expect(device.supportsScreenshot, true);
}, overrides: <Type, Generator>{
Platform: () => FakePlatform(),
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
});
testUsingContext('is not supported on Windows', () {
......@@ -493,6 +496,7 @@ void main() {
Platform: () => FakePlatform(
operatingSystem: 'windows',
),
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
});
test("takeScreenshot throws if file isn't .ppm", () async {
......@@ -532,6 +536,7 @@ void main() {
'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh',
},
),
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
});
testUsingContext('takeScreenshot throws if scp failed', () async {
......@@ -582,6 +587,7 @@ void main() {
'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh',
},
),
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
});
testUsingContext(
......@@ -632,6 +638,7 @@ void main() {
'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh',
},
),
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
}, testOn: 'posix');
testUsingContext('takeScreenshot returns', () async {
......@@ -674,6 +681,7 @@ void main() {
'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh',
},
),
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
});
});
......
......@@ -6,12 +6,15 @@ import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/fuchsia/fuchsia_ffx.dart';
import 'package:flutter_tools/src/fuchsia/fuchsia_sdk.dart';
import 'package:test/fake.dart';
import '../../src/common.dart';
import '../../src/fake_process_manager.dart';
import '../../src/context.dart';
import '../../src/fakes.dart';
void main() {
late FakeFuchsiaArtifacts fakeFuchsiaArtifacts;
......@@ -27,6 +30,22 @@ void main() {
fakeFuchsiaArtifacts.ffx = ffx;
});
testUsingContext('isFuchsiaSupportedPlatform returns true when opted in on Linux and macOS', () {
expect(isFuchsiaSupportedPlatform(FakePlatform(operatingSystem: 'macos')), true);
expect(isFuchsiaSupportedPlatform(FakePlatform()), true);
expect(isFuchsiaSupportedPlatform(FakePlatform(operatingSystem: 'windows')), false);
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
});
testUsingContext('isFuchsiaSupportedPlatform returns false when opted out on Linux and macOS', () {
expect(isFuchsiaSupportedPlatform(FakePlatform(operatingSystem: 'macos')), false);
expect(isFuchsiaSupportedPlatform(FakePlatform()), false);
expect(isFuchsiaSupportedPlatform(FakePlatform(operatingSystem: 'windows')), false);
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(),
});
group('ffx list', () {
testWithoutContext('ffx not found', () {
final FuchsiaFfx fuchsiaFfx = FuchsiaFfx(
......
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