Unverified Commit b3a6eda2 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Remove hacks that make macOs, Linux, and Windows not fail. (#19187)

They should fail, because we don't have real support yet.

Also, make the debug override work in release builds, so that people
on those platforms have a workaround.
parent 36437904
...@@ -23,29 +23,46 @@ enum TargetPlatform { ...@@ -23,29 +23,46 @@ enum TargetPlatform {
/// The [TargetPlatform] that matches the platform on which the framework is /// The [TargetPlatform] that matches the platform on which the framework is
/// currently executing. /// currently executing.
/// ///
/// This is the default value of [ThemeData.platform] (hence the name). Widgets
/// from the material library should use [Theme.of] to determine the current
/// platform, rather than using [defaultTargetPlatform]. However, if there is
/// widget behavior that depends on the actual underlying platform (e.g. because
/// it is controlling data being sent to the platform APIs, not just trying to
/// follow the platform's conventions) then depending on [defaultTargetPlatform]
/// makes sense.
///
/// In a test environment, the platform returned is [TargetPlatform.android] /// In a test environment, the platform returned is [TargetPlatform.android]
/// regardless of the host platform. (Android was chosen because the tests were /// regardless of the host platform. (Android was chosen because the tests were
/// originally written assuming Android-like behavior, and we added platform /// originally written assuming Android-like behavior, and we added platform
/// adaptations for iOS later). Tests can check iOS behavior by using the /// adaptations for iOS later). Tests can check iOS behavior by using the
/// platform override APIs (such as [ThemeData.platform] in the material /// platform override APIs (such as [ThemeData.platform] in the material
/// library) or by setting [debugDefaultTargetPlatformOverride]. The value /// library) or by setting [debugDefaultTargetPlatformOverride].
/// can only be explicitly set in debug mode. //
// When adding support for a new platform (e.g. Windows Phone, macOS), first
// create a new value on the [TargetPlatform] enum, then add a rule for
// selecting that platform here.
//
// It would be incorrect to make a platform that isn't supported by
// [TargetPlatform] default to the behavior of another platform, because doing
// that would mean we'd be stuck with that platform forever emulating the other,
// and we'd never be able to introduce dedicated behavior for that platform
// (since doing so would be a big breaking change).
TargetPlatform get defaultTargetPlatform { TargetPlatform get defaultTargetPlatform {
TargetPlatform result; TargetPlatform result;
if (Platform.isIOS || Platform.isMacOS) { if (Platform.isIOS) {
result = TargetPlatform.iOS; result = TargetPlatform.iOS;
} else if (Platform.isAndroid || Platform.isLinux || Platform.isWindows) { } else if (Platform.isAndroid) {
result = TargetPlatform.android; result = TargetPlatform.android;
} else if (Platform.operatingSystem == 'fuchsia') { } else if (Platform.isFuchsia) {
result = TargetPlatform.fuchsia; result = TargetPlatform.fuchsia;
} }
assert(() { assert(() {
if (Platform.environment.containsKey('FLUTTER_TEST')) if (Platform.environment.containsKey('FLUTTER_TEST'))
result = TargetPlatform.android; result = TargetPlatform.android;
if (debugDefaultTargetPlatformOverride != null)
result = debugDefaultTargetPlatformOverride;
return true; return true;
}()); }());
if (debugDefaultTargetPlatformOverride != null)
result = debugDefaultTargetPlatformOverride;
if (result == null) { if (result == null) {
throw new FlutterError( throw new FlutterError(
'Unknown platform.\n' 'Unknown platform.\n'
...@@ -55,12 +72,24 @@ TargetPlatform get defaultTargetPlatform { ...@@ -55,12 +72,24 @@ TargetPlatform get defaultTargetPlatform {
} }
return result; return result;
} }
/// Override the [defaultTargetPlatform]. /// Override the [defaultTargetPlatform].
/// ///
/// Setting this to null returns the [defaultTargetPlatform] to its original /// Setting this to null returns the [defaultTargetPlatform] to its original
/// value (based on the actual current platform). /// value (based on the actual current platform).
/// ///
/// This setter is only available intended for debugging purposes. To change the /// Generally speaking this override is only useful for tests. To change the
/// target platform in release builds, use the platform override APIs (such as /// platform that widgets resemble, consider using the platform override APIs
/// [ThemeData.platform] in the material library). /// (such as [ThemeData.platform] in the material library) instead.
///
/// Setting [debugDefaultTargetPlatformOverride] (as opposed to, say,
/// [ThemeData.platform]) will cause unexpected and undesireable effects. For
/// example, setting this to [TargetPlatform.iOS] when the application is
/// running on Android will cause the TalkBack accessibility tool on Android to
/// be confused because it would be receiving data intended for iOS VoiceOver.
/// Similarly, setting it to [TargetPlatform.android] while on iOS will cause
/// certainly widgets to work assuming the presence of a system-wide back
/// button, which will make those widgets unusable since iOS has no such button.
///
/// In general, therefore, this property should not be used in release builds.
TargetPlatform debugDefaultTargetPlatformOverride; TargetPlatform debugDefaultTargetPlatformOverride;
...@@ -102,14 +102,14 @@ class Drawer extends StatelessWidget { ...@@ -102,14 +102,14 @@ class Drawer extends StatelessWidget {
/// {@macro flutter.widgets.child} /// {@macro flutter.widgets.child}
final Widget child; final Widget child;
/// The semantic label of the dialog used by accessibility frameworks to /// The semantic label of the dialog used by accessibility frameworks to
/// announce screen transitions when the drawer is opened and closed. /// announce screen transitions when the drawer is opened and closed.
/// ///
/// If this label is not provided, it will default to /// If this label is not provided, it will default to
/// [MaterialLocalizations.drawerLabel]. /// [MaterialLocalizations.drawerLabel].
/// ///
/// See also: /// See also:
/// ///
/// * [SemanticsConfiguration.namesRoute], for a description of how this /// * [SemanticsConfiguration.namesRoute], for a description of how this
/// value is used. /// value is used.
final String semanticLabel; final String semanticLabel;
......
...@@ -432,28 +432,17 @@ class TextTheme extends Diagnosticable { ...@@ -432,28 +432,17 @@ class TextTheme extends Diagnosticable {
void debugFillProperties(DiagnosticPropertiesBuilder properties) { void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties); super.debugFillProperties(properties);
final TextTheme defaultTheme = new Typography(platform: defaultTargetPlatform).black; final TextTheme defaultTheme = new Typography(platform: defaultTargetPlatform).black;
properties.add(new DiagnosticsProperty<TextStyle>('display4', display4, properties.add(new DiagnosticsProperty<TextStyle>('display4', display4, defaultValue: defaultTheme.display4));
defaultValue: defaultTheme.display4)); properties.add(new DiagnosticsProperty<TextStyle>('display3', display3, defaultValue: defaultTheme.display3));
properties.add(new DiagnosticsProperty<TextStyle>('display3', display3, properties.add(new DiagnosticsProperty<TextStyle>('display2', display2, defaultValue: defaultTheme.display2));
defaultValue: defaultTheme.display3)); properties.add(new DiagnosticsProperty<TextStyle>('display1', display1, defaultValue: defaultTheme.display1));
properties.add(new DiagnosticsProperty<TextStyle>('display2', display2, properties.add(new DiagnosticsProperty<TextStyle>('headline', headline, defaultValue: defaultTheme.headline));
defaultValue: defaultTheme.display2)); properties.add(new DiagnosticsProperty<TextStyle>('title', title, defaultValue: defaultTheme.title));
properties.add(new DiagnosticsProperty<TextStyle>('display1', display1, properties.add(new DiagnosticsProperty<TextStyle>('subhead', subhead, defaultValue: defaultTheme.subhead));
defaultValue: defaultTheme.display1)); properties.add(new DiagnosticsProperty<TextStyle>('body2', body2, defaultValue: defaultTheme.body2));
properties.add(new DiagnosticsProperty<TextStyle>('headline', headline, properties.add(new DiagnosticsProperty<TextStyle>('body1', body1, defaultValue: defaultTheme.body1));
defaultValue: defaultTheme.headline)); properties.add(new DiagnosticsProperty<TextStyle>('caption', caption, defaultValue: defaultTheme.caption));
properties properties.add(new DiagnosticsProperty<TextStyle>('button', button, defaultValue: defaultTheme.button));
.add(new DiagnosticsProperty<TextStyle>('title', title, defaultValue: defaultTheme.title));
properties.add(
new DiagnosticsProperty<TextStyle>('subhead', subhead, defaultValue: defaultTheme.subhead));
properties
.add(new DiagnosticsProperty<TextStyle>('body2', body2, defaultValue: defaultTheme.body2));
properties
.add(new DiagnosticsProperty<TextStyle>('body1', body1, defaultValue: defaultTheme.body1));
properties.add(
new DiagnosticsProperty<TextStyle>('caption', caption, defaultValue: defaultTheme.caption));
properties.add(
new DiagnosticsProperty<TextStyle>('button', button, defaultValue: defaultTheme.button));
} }
} }
......
...@@ -83,7 +83,7 @@ class ModalBarrier extends StatelessWidget { ...@@ -83,7 +83,7 @@ class ModalBarrier extends StatelessWidget {
constraints: const BoxConstraints.expand(), constraints: const BoxConstraints.expand(),
child: color == null ? null : new DecoratedBox( child: color == null ? null : new DecoratedBox(
decoration: new BoxDecoration( decoration: new BoxDecoration(
color: color color: color,
) )
) )
) )
......
...@@ -151,9 +151,10 @@ class FlutterTesterDevice extends Device { ...@@ -151,9 +151,10 @@ class FlutterTesterDevice extends Device {
_isRunning = true; _isRunning = true;
_process = await processManager.start(command, _process = await processManager.start(command,
environment: <String, String>{ environment: <String, String>{
'FLUTTER_TEST': 'true', 'FLUTTER_TEST': 'true',
}); },
);
_process.exitCode.then((_) => _isRunning = false); _process.exitCode.then((_) => _isRunning = false);
_process.stdout _process.stdout
.transform(utf8.decoder) .transform(utf8.decoder)
......
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