mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[flutter_tools] daemon does not report platforms that are not enabled (#73736)
This commit is contained in:
parent
737496e8db
commit
907bed6982
@ -19,6 +19,7 @@ import '../build_info.dart';
|
||||
import '../convert.dart';
|
||||
import '../device.dart';
|
||||
import '../emulator.dart';
|
||||
import '../features.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../project.dart';
|
||||
import '../resident_runner.dart';
|
||||
@ -365,28 +366,26 @@ class DaemonDomain extends Domain {
|
||||
final String projectRoot = _getStringArg(args, 'projectRoot', required: true);
|
||||
final List<String> result = <String>[];
|
||||
try {
|
||||
// TODO(jonahwilliams): replace this with a project metadata check once
|
||||
// that has been implemented.
|
||||
final FlutterProject flutterProject = FlutterProject.fromDirectory(globals.fs.directory(projectRoot));
|
||||
if (flutterProject.linux.existsSync()) {
|
||||
if (featureFlags.isLinuxEnabled && flutterProject.linux.existsSync()) {
|
||||
result.add('linux');
|
||||
}
|
||||
if (flutterProject.macos.existsSync()) {
|
||||
if (featureFlags.isMacOSEnabled && flutterProject.macos.existsSync()) {
|
||||
result.add('macos');
|
||||
}
|
||||
if (flutterProject.windows.existsSync()) {
|
||||
if (featureFlags.isWindowsEnabled && flutterProject.windows.existsSync()) {
|
||||
result.add('windows');
|
||||
}
|
||||
if (flutterProject.ios.existsSync()) {
|
||||
if (featureFlags.isIOSEnabled && flutterProject.ios.existsSync()) {
|
||||
result.add('ios');
|
||||
}
|
||||
if (flutterProject.android.existsSync()) {
|
||||
if (featureFlags.isAndroidEnabled && flutterProject.android.existsSync()) {
|
||||
result.add('android');
|
||||
}
|
||||
if (flutterProject.web.existsSync()) {
|
||||
if (featureFlags.isWebEnabled && flutterProject.web.existsSync()) {
|
||||
result.add('web');
|
||||
}
|
||||
if (flutterProject.fuchsia.existsSync()) {
|
||||
if (featureFlags.isFuchsiaEnabled && flutterProject.fuchsia.existsSync()) {
|
||||
result.add('fuchsia');
|
||||
}
|
||||
return <String, Object>{
|
||||
|
||||
@ -9,6 +9,7 @@ import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/utils.dart';
|
||||
import 'package:flutter_tools/src/commands/daemon.dart';
|
||||
import 'package:flutter_tools/src/features.dart';
|
||||
import 'package:flutter_tools/src/fuchsia/fuchsia_workflow.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/ios/ios_workflow.dart';
|
||||
@ -19,6 +20,7 @@ import 'package:fake_async/fake_async.dart';
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
import '../../src/mocks.dart';
|
||||
import '../../src/testbed.dart';
|
||||
|
||||
void main() {
|
||||
Daemon daemon;
|
||||
@ -57,6 +59,30 @@ void main() {
|
||||
await commands.close();
|
||||
});
|
||||
|
||||
testUsingContext('daemon.getSupportedPlatforms command should succeed', () async {
|
||||
final StreamController<Map<String, dynamic>> commands = StreamController<Map<String, dynamic>>();
|
||||
final StreamController<Map<String, dynamic>> responses = StreamController<Map<String, dynamic>>();
|
||||
daemon = Daemon(
|
||||
commands.stream,
|
||||
responses.add,
|
||||
notifyingLogger: notifyingLogger,
|
||||
);
|
||||
// Use the flutter_gallery project which has a known set of supported platforms.
|
||||
final String projectPath = globals.fs.path.join(getFlutterRoot(), 'dev', 'integration_tests', 'flutter_gallery');
|
||||
|
||||
commands.add(<String, dynamic>{'id': 0, 'method': 'daemon.getSupportedPlatforms', 'params': <String, Object>{'projectRoot': projectPath}});
|
||||
final Map<String, dynamic> response = await responses.stream.firstWhere(_notEvent);
|
||||
|
||||
expect(response['id'], 0);
|
||||
expect(response['result'], isNotEmpty);
|
||||
expect(response['result']['platforms'], <String>{'macos'});
|
||||
await responses.close();
|
||||
await commands.close();
|
||||
}, overrides: <Type, Generator>{
|
||||
// Disable Android/iOS and enable macOS to make sure result is consistent and defaults are tested off.
|
||||
FeatureFlags: () => TestFeatureFlags(isAndroidEnabled: false, isIOSEnabled: false, isMacOSEnabled: true),
|
||||
});
|
||||
|
||||
testUsingContext('printError should send daemon.logMessage event', () async {
|
||||
final StreamController<Map<String, dynamic>> commands = StreamController<Map<String, dynamic>>();
|
||||
final StreamController<Map<String, dynamic>> responses = StreamController<Map<String, dynamic>>();
|
||||
@ -443,7 +469,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWithoutContext('does not run any operations concurrently', () async {
|
||||
// Crete a function thats slow, but throws if another instance of the
|
||||
// Crete a function that's slow, but throws if another instance of the
|
||||
// function is running.
|
||||
bool isRunning = false;
|
||||
Future<int> f(int ret) async {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user