Migrate flutter_tools to use package:platform (#7642)
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_tools/src/base/context.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/commands/daemon.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
import 'package:flutter_tools/src/doctor.dart';
|
||||
@@ -32,9 +32,10 @@ void main() {
|
||||
setUp(() {
|
||||
appContext = new AppContext();
|
||||
notifyingLogger = new NotifyingLogger();
|
||||
appContext.setVariable(Platform, new LocalPlatform());
|
||||
appContext.setVariable(Logger, notifyingLogger);
|
||||
appContext.setVariable(Doctor, new Doctor());
|
||||
if (Platform.isMacOS)
|
||||
if (platform.isMacOS)
|
||||
appContext.setVariable(XCode, new XCode());
|
||||
appContext.setVariable(DeviceManager, new MockDeviceManager());
|
||||
});
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/dart/dependencies.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:test/test.dart';
|
||||
import 'src/context.dart';
|
||||
|
||||
void main() {
|
||||
group('DartDependencySetBuilder', () {
|
||||
final String basePath = path.dirname(Platform.script.path);
|
||||
final String basePath = path.dirname(platform.script.path);
|
||||
final String dataPath = path.join(basePath, 'data', 'dart_dependencies_test');
|
||||
testUsingContext('good', () {
|
||||
final String testPath = path.join(dataPath, 'good');
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/dart/dependencies.dart';
|
||||
import 'package:flutter_tools/src/dependency_checker.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
@@ -12,7 +12,7 @@ import 'src/context.dart';
|
||||
|
||||
void main() {
|
||||
group('DependencyChecker', () {
|
||||
final String basePath = path.dirname(Platform.script.path);
|
||||
final String basePath = path.dirname(platform.script.path);
|
||||
final String dataPath = path.join(basePath, 'data', 'dart_dependencies_test');
|
||||
testUsingContext('good', () {
|
||||
final String testPath = path.join(dataPath, 'good');
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
setUp(() {
|
||||
String flutterRoot = Platform.environment['FLUTTER_ROOT'];
|
||||
String flutterRoot = platform.environment['FLUTTER_ROOT'];
|
||||
assert(fs.currentDirectory.path == '$flutterRoot/packages/flutter_tools');
|
||||
});
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/os.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@@ -28,7 +28,7 @@ void main() {
|
||||
os.makeExecutable(file);
|
||||
|
||||
// Skip this test on windows.
|
||||
if (!Platform.isWindows) {
|
||||
if (!platform.isWindows) {
|
||||
String mode = file.statSync().modeString();
|
||||
// rwxr--r--
|
||||
expect(mode.substring(0, 3), endsWith('x'));
|
||||
|
||||
@@ -7,9 +7,9 @@ import 'dart:async';
|
||||
import 'package:flutter_tools/src/base/config.dart';
|
||||
import 'package:flutter_tools/src/base/context.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/os.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
import 'package:flutter_tools/src/devfs.dart';
|
||||
@@ -42,6 +42,7 @@ void testUsingContext(String description, dynamic testMethod(), {
|
||||
|
||||
// Initialize the test context with some default mocks.
|
||||
// Seed these context entries first since others depend on them
|
||||
testContext.putIfAbsent(Platform, () => new LocalPlatform());
|
||||
testContext.putIfAbsent(FileSystem, () => new LocalFileSystem());
|
||||
testContext.putIfAbsent(ProcessManager, () => new LocalProcessManager());
|
||||
testContext.putIfAbsent(Logger, () => new BufferLogger());
|
||||
@@ -68,7 +69,7 @@ void testUsingContext(String description, dynamic testMethod(), {
|
||||
testContext.putIfAbsent(SimControl, () => new MockSimControl());
|
||||
testContext.putIfAbsent(Usage, () => new MockUsage());
|
||||
|
||||
final String basePath = path.dirname(Platform.script.path);
|
||||
final String basePath = path.dirname(platform.script.path);
|
||||
final String flutterRoot =
|
||||
path.normalize(path.join(basePath, '..', '..', '..'));
|
||||
try {
|
||||
@@ -148,7 +149,7 @@ class MockOperatingSystemUtils extends Mock implements OperatingSystemUtils {
|
||||
// That way it wouldn't really matter what the mock returns here.
|
||||
@override
|
||||
String getExecutableName(String binaryName, { String winExtension }) {
|
||||
if (!Platform.isWindows)
|
||||
if (!platform.isWindows)
|
||||
return binaryName;
|
||||
winExtension ??= 'exe';
|
||||
if (path.extension(binaryName).isEmpty && winExtension.isNotEmpty)
|
||||
|
||||
Reference in New Issue
Block a user