Reland: use flutter features for web and desktop (#36699)

This commit is contained in:
Jonah Williams
2019-07-22 15:34:03 -07:00
committed by GitHub
parent 295530dcaf
commit 3fedb8cb5a
38 changed files with 505 additions and 376 deletions

View File

@@ -5,8 +5,6 @@
import 'dart:async';
import 'package:args/command_runner.dart';
import 'package:flutter_tools/src/desktop.dart';
import 'package:flutter_tools/src/web/workflow.dart';
import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf;
import 'package:test_api/test_api.dart' as test_package show TypeMatcher;
@@ -20,19 +18,6 @@ import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
export 'package:test_core/test_core.dart' hide TypeMatcher, isInstanceOf; // Defines a 'package:test' shim.
/// Disable both web and desktop to make testing easier. For example, prevent
/// them from showing up in the devices list if the host happens to be setup
/// properly.
set debugDisableWebAndDesktop(bool value) {
if (value) {
debugDisableDesktop = true;
debugDisableWeb = true;
} else {
debugDisableDesktop = false;
debugDisableWeb = false;
}
}
/// A matcher that compares the type of the actual value to the type argument T.
// TODO(ianh): Remove this once https://github.com/dart-lang/matcher/issues/98 is fixed
Matcher isInstanceOf<T>() => test_package.TypeMatcher<T>();

View File

@@ -17,6 +17,7 @@ import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/context_runner.dart';
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/reporting/usage.dart';
import 'package:flutter_tools/src/version.dart';
@@ -687,3 +688,26 @@ class FakeFlutterVersion implements FlutterVersion {
return null;
}
}
// A test implementation of [FeatureFlags] that allows enabling without reading
// config. If not otherwise specified, all values default to false.
class TestFeatureFlags implements FeatureFlags {
TestFeatureFlags({
this.isLinuxEnabled = false,
this.isMacOSEnabled = false,
this.isWebEnabled = false,
this.isWindowsEnabled = false,
});
@override
final bool isLinuxEnabled;
@override
final bool isMacOSEnabled;
@override
final bool isWebEnabled;
@override
final bool isWindowsEnabled;
}