Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions packages/flutter/lib/src/material/button_style_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,15 @@ class _ButtonStyleState extends State<ButtonStyleButton> with TickerProviderStat
}
}

final EdgeInsetsGeometry padding = resolvedPadding!.add(
EdgeInsets.only(
left: densityAdjustment.dx,
top: densityAdjustment.dy,
right: densityAdjustment.dx,
bottom: densityAdjustment.dy,
),
).clamp(EdgeInsets.zero, EdgeInsetsGeometry.infinity);
// Per the Material Design team: don't allow the VisualDensity
// adjustment to reduce the width of the left/right padding. If we
// did, VisualDensity.compact, the default for desktop/web, would
// reduce the horizontal padding to zero.
final double dy = densityAdjustment.dy;
final double dx = math.max(0, densityAdjustment.dx);
final EdgeInsetsGeometry padding = resolvedPadding!
.add(EdgeInsets.fromLTRB(dx, dy, dx, dy))
.clamp(EdgeInsets.zero, EdgeInsetsGeometry.infinity);

// If an opaque button's background is becoming translucent while its
// elevation is changing, change the elevation first. Material implicitly
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter/test/material/elevated_button_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ void main() {
await buildTest(const VisualDensity(horizontal: -3.0, vertical: -3.0));
await tester.pumpAndSettle();
childRect = tester.getRect(find.byKey(childKey));
expect(box.size, equals(const Size(108, 100)));
expect(box.size, equals(const Size(132, 100)));
expect(childRect, equals(const Rect.fromLTRB(350, 250, 450, 350)));

await buildTest(VisualDensity.standard, useText: true);
Expand All @@ -667,7 +667,7 @@ void main() {
await buildTest(const VisualDensity(horizontal: -3.0, vertical: -3.0), useText: true);
await tester.pumpAndSettle();
childRect = tester.getRect(find.byKey(childKey));
expect(box.size, equals(const Size(76, 36)));
expect(box.size, equals(const Size(88, 36)));
expect(childRect, equals(const Rect.fromLTRB(372.0, 293.0, 428.0, 307.0)));
});

Expand Down
4 changes: 2 additions & 2 deletions packages/flutter/test/material/outlined_button_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ void main() {
await buildTest(const VisualDensity(horizontal: -3.0, vertical: -3.0));
await tester.pumpAndSettle();
childRect = tester.getRect(find.byKey(childKey));
expect(box.size, equals(const Size(108, 100)));
expect(box.size, equals(const Size(132, 100)));
expect(childRect, equals(const Rect.fromLTRB(350, 250, 450, 350)));

await buildTest(VisualDensity.standard, useText: true);
Expand All @@ -974,7 +974,7 @@ void main() {
await buildTest(const VisualDensity(horizontal: -3.0, vertical: -3.0), useText: true);
await tester.pumpAndSettle();
childRect = tester.getRect(find.byKey(childKey));
expect(box.size, equals(const Size(64, 36)));
expect(box.size, equals(const Size(88, 36)));
expect(childRect, equals(const Rect.fromLTRB(372.0, 293.0, 428.0, 307.0)));
});

Expand Down
4 changes: 2 additions & 2 deletions packages/flutter/test/material/text_button_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ void main() {
await buildTest(const VisualDensity(horizontal: -3.0, vertical: -3.0));
await tester.pumpAndSettle();
childRect = tester.getRect(find.byKey(childKey));
expect(box.size, equals(const Size(100, 100)));
expect(box.size, equals(const Size(116, 100)));
expect(childRect, equals(const Rect.fromLTRB(350, 250, 450, 350)));

await buildTest(VisualDensity.standard, useText: true);
Expand All @@ -757,7 +757,7 @@ void main() {
await buildTest(const VisualDensity(horizontal: -3.0, vertical: -3.0), useText: true);
await tester.pumpAndSettle();
childRect = tester.getRect(find.byKey(childKey));
expect(box.size, equals(const Size(56, 36)));
expect(box.size, equals(const Size(72, 36)));
expect(childRect, equals(const Rect.fromLTRB(372.0, 293.0, 428.0, 307.0)));
});

Expand Down
17 changes: 12 additions & 5 deletions packages/flutter/test/widgets/sliver_fill_remaining_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:math' as math;

import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';

Expand Down Expand Up @@ -322,10 +324,11 @@ void main() {
expect(tester.getCenter(logo), Offset(400.0, 351.0 - density.vertical * 2.0));

// Also check that the button alignment is true to expectations
// Buttons do not decrease their horizontal padding per the VisualDensity.
final Finder button = find.byType(ElevatedButton);
expect(
tester.renderObject<RenderBox>(button).size,
Size(116.0 + density.horizontal * 8.0, 48.0 + density.vertical * 4.0),
Size(116.0 + math.max(0, density.horizontal) * 8.0, 48.0 + density.vertical * 4.0),
);
expect(tester.getBottomLeft(button).dy, equals(600.0));
expect(tester.getCenter(button).dx, equals(400.0));
Expand All @@ -344,7 +347,8 @@ void main() {
expect(tester.getCenter(logo).dy, lessThan(351.0));
expect(
tester.renderObject<RenderBox>(button).size,
Size(116.0 + density.horizontal * 8.0, 48.0 + density.vertical * 4.0),
// Buttons do not decrease their horizontal padding per the VisualDensity.
Size(116.0 + math.max(0, density.horizontal) * 8.0, 48.0 + density.vertical * 4.0),
);
expect(tester.getBottomLeft(button).dy, lessThan(600.0));
expect(tester.getCenter(button).dx, equals(400.0));
Expand Down Expand Up @@ -592,10 +596,11 @@ void main() {
expect(tester.getCenter(logo), Offset(400.0, 351.0 - density.vertical * 2.0));

// Also check that the button alignment is true to expectations.
// Buttons do not decrease their horizontal padding per the VisualDensity.
final Finder button = find.byType(ElevatedButton);
expect(
tester.renderObject<RenderBox>(button).size,
Size(116.0 + density.horizontal * 8.0, 48.0 + density.vertical * 4.0),
Size(116.0 + math.max(0, density.horizontal) * 8.0, 48.0 + density.vertical * 4.0),
);
expect(tester.getBottomLeft(button).dy, equals(600.0));
expect(tester.getCenter(button).dx, equals(400.0));
Expand All @@ -616,7 +621,8 @@ void main() {
expect(tester.getCenter(logo).dy, lessThan(351.0));
expect(
tester.renderObject<RenderBox>(button).size,
Size(116.0 + density.horizontal * 8.0, 48.0 + density.vertical * 4.0),
// Buttons do not decrease their horizontal padding per the VisualDensity.
Size(116.0 + math.max(0, density.horizontal) * 8.0, 48.0 + density.vertical * 4.0),
);
expect(tester.getBottomLeft(button).dy, equals(600.0));
expect(tester.getCenter(button).dx, equals(400.0));
Expand All @@ -635,7 +641,8 @@ void main() {
expect(tester.getCenter(logo), Offset(400.0, 351.0 - density.vertical * 2.0));
expect(
tester.renderObject<RenderBox>(button).size,
Size(116.0 + density.horizontal * 8.0, 48.0 + density.vertical * 4.0),
// Buttons do not decrease their horizontal padding per the VisualDensity.
Size(116.0 + math.max(0, density.horizontal) * 8.0, 48.0 + density.vertical * 4.0),
);
expect(tester.getBottomLeft(button).dy, equals(600.0));
expect(tester.getCenter(button).dx, equals(400.0));
Expand Down
15 changes: 13 additions & 2 deletions packages/flutter_tools/lib/src/web/chrome.dart
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class ChromiumLauncher {
url,
];

final Process? process = await _spawnChromiumProcess(args);
final Process? process = await _spawnChromiumProcess(args, chromeExecutable);

// When the process exits, copy the user settings back to the provided data-dir.
if (process != null && cacheDir != null) {
Expand All @@ -235,7 +235,18 @@ class ChromiumLauncher {
), skipCheck);
}

Future<Process?> _spawnChromiumProcess(List<String> args) async {
Future<Process?> _spawnChromiumProcess(List<String> args, String chromeExecutable) async {
if (_operatingSystemUtils.hostPlatform == HostPlatform.darwin_arm) {
final ProcessResult result = _processManager.runSync(<String>['file', chromeExecutable]);
// Check if ARM Chrome is installed.
// Mach-O 64-bit executable arm64
if ((result.stdout as String).contains('arm64')) {
_logger.printTrace('Found ARM Chrome installation at $chromeExecutable, forcing native launch.');
// If so, force Chrome to launch natively.
args.insertAll(0, <String>['/usr/bin/arch', '-arm64']);
}
}

// Keep attempting to launch the browser until one of:
// - Chrome launched successfully, in which case we just return from the loop.
// - The tool detected an unretriable Chrome error, in which case we throw ToolExit.
Expand Down
11 changes: 10 additions & 1 deletion packages/flutter_tools/lib/src/windows/build_windows.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import '../flutter_plugins.dart';
import '../globals.dart' as globals;
import '../migrations/cmake_custom_command_migration.dart';
import '../project.dart';
import 'install_manifest.dart';
import 'visual_studio.dart';

// From https://cmake.org/cmake/help/v3.15/manual/cmake-generators.7.html#visual-studio-generators
Expand Down Expand Up @@ -120,6 +121,7 @@ Future<void> buildWindowsUwp(WindowsUwpProject windowsProject, BuildInfo buildIn
String target,
VisualStudio visualStudioOverride,
}) async {
final Directory buildDirectory = globals.fs.directory(getWindowsBuildUwpDirectory());
if (!windowsProject.existsSync()) {
throwToolExit(
'No Windows UWP desktop project configured. See '
Expand All @@ -136,6 +138,14 @@ Future<void> buildWindowsUwp(WindowsUwpProject windowsProject, BuildInfo buildIn
// Ensure that necessary ephemeral files are generated and up to date.
_writeGeneratedFlutterConfig(windowsProject, buildInfo, target);
createPluginSymlinks(windowsProject.parent);
await createManifest(
buildDirectory: buildDirectory,
logger: globals.logger,
platform: globals.platform,
project: windowsProject,
buildInfo: buildInfo,
fileSystem: globals.fs,
);

final VisualStudio visualStudio = visualStudioOverride ?? VisualStudio(
fileSystem: globals.fs,
Expand All @@ -149,7 +159,6 @@ Future<void> buildWindowsUwp(WindowsUwpProject windowsProject, BuildInfo buildIn
'Please run `flutter doctor` for more details.');
}

final Directory buildDirectory = globals.fs.directory(getWindowsBuildUwpDirectory());
final String buildModeName = getNameForBuildMode(buildInfo.mode ?? BuildMode.release);
final Status status = globals.logger.startProgress(
'Building Windows application...',
Expand Down
55 changes: 55 additions & 0 deletions packages/flutter_tools/lib/src/windows/install_manifest.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.8

import 'package:meta/meta.dart';

import '../asset.dart';
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/logger.dart';
import '../base/platform.dart';
import '../build_info.dart';
import '../project.dart';

/// Generate an install manifest that is required for CMAKE on UWP projects.
Future<void> createManifest({
@required Logger logger,
@required FileSystem fileSystem,
@required Platform platform,
@required WindowsUwpProject project,
@required BuildInfo buildInfo,
@required Directory buildDirectory,
}) async {
final List<File> outputs = <File>[];
final AssetBundle assetBundle = AssetBundleFactory.defaultInstance(
logger: logger,
fileSystem: fileSystem,
platform: platform,
splitDeferredAssets: false,
).createBundle();
final int resultCode = await assetBundle.build(
packagesPath: buildInfo.packagesPath,
assetDirPath: buildDirectory.childDirectory('flutter_assets').path,
);
if (resultCode != 0) {
throwToolExit('Failed to build assets.');
}

if (buildInfo.mode.isPrecompiled) {
outputs.add(buildDirectory.childFile('app.so'));
} else {
outputs.add(buildDirectory.childDirectory('flutter_assets').childFile('kernel_blob.bin'));
}
for (final String key in assetBundle.entries.keys) {
outputs.add(buildDirectory.childDirectory('flutter_assets').childFile(key));
}
outputs.add(project.ephemeralDirectory.childFile('flutter_windows_winuwp.dll'));
outputs.add(project.ephemeralDirectory.childFile('flutter_windows_winuwp.dll.pdb'));
outputs.add(project.ephemeralDirectory.childFile('icudtl.dat'));
project.ephemeralDirectory.childFile('install_manifest')
..createSync(recursive: true)
..writeAsStringSync(outputs.map((File file) => file.absolute.path).join('\n'));
}
115 changes: 115 additions & 0 deletions packages/flutter_tools/test/general.shard/web/chrome_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,121 @@ void main() {
expect(logger.errorText, contains('Failed to restore Chrome preferences'));
});

testWithoutContext('can launch Chrome on x86_64 macOS', () async {
final OperatingSystemUtils macOSUtils = FakeOperatingSystemUtils(hostPlatform: HostPlatform.darwin_x64);
final ChromiumLauncher chromiumLauncher = ChromiumLauncher(
fileSystem: fileSystem,
platform: platform,
processManager: processManager,
operatingSystemUtils: macOSUtils,
browserFinder: findChromeExecutable,
logger: BufferLogger.test(),
);

processManager.addCommands(<FakeCommand>[
const FakeCommand(
command: <String>[
'example_chrome',
'--user-data-dir=/.tmp_rand0/flutter_tools_chrome_device.rand0',
'--remote-debugging-port=12345',
...kChromeArgs,
'example_url',
],
stderr: kDevtoolsStderr,
)
]);

expect(
() async => chromiumLauncher.launch(
'example_url',
skipCheck: true,
),
returnsNormally,
);
});

testWithoutContext('can launch x86_64 Chrome on ARM macOS', () async {
final OperatingSystemUtils macOSUtils = FakeOperatingSystemUtils(hostPlatform: HostPlatform.darwin_arm);
final ChromiumLauncher chromiumLauncher = ChromiumLauncher(
fileSystem: fileSystem,
platform: platform,
processManager: processManager,
operatingSystemUtils: macOSUtils,
browserFinder: findChromeExecutable,
logger: BufferLogger.test(),
);

processManager.addCommands(<FakeCommand>[
const FakeCommand(
command: <String>[
'file',
'example_chrome',
],
stdout: 'Mach-O 64-bit executable x86_64',
),
const FakeCommand(
command: <String>[
'example_chrome',
'--user-data-dir=/.tmp_rand0/flutter_tools_chrome_device.rand0',
'--remote-debugging-port=12345',
...kChromeArgs,
'example_url',
],
stderr: kDevtoolsStderr,
)
]);

expect(
() async => chromiumLauncher.launch(
'example_url',
skipCheck: true,
),
returnsNormally,
);
});

testWithoutContext('can launch ARM Chrome natively on ARM macOS when installed', () async {
final OperatingSystemUtils macOSUtils = FakeOperatingSystemUtils(hostPlatform: HostPlatform.darwin_arm);
final ChromiumLauncher chromiumLauncher = ChromiumLauncher(
fileSystem: fileSystem,
platform: platform,
processManager: processManager,
operatingSystemUtils: macOSUtils,
browserFinder: findChromeExecutable,
logger: BufferLogger.test(),
);

processManager.addCommands(<FakeCommand>[
const FakeCommand(
command: <String>[
'file',
'example_chrome',
],
stdout: 'Mach-O 64-bit executable arm64',
),
const FakeCommand(
command: <String>[
'/usr/bin/arch',
'-arm64',
'example_chrome',
'--user-data-dir=/.tmp_rand0/flutter_tools_chrome_device.rand0',
'--remote-debugging-port=12345',
...kChromeArgs,
'example_url',
],
stderr: kDevtoolsStderr,
),
]);

expect(
() async => chromiumLauncher.launch(
'example_url',
skipCheck: true,
),
returnsNormally,
);
});

testWithoutContext('can launch chrome with a custom debug port', () async {
processManager.addCommand(const FakeCommand(
command: <String>[
Expand Down
Loading