2019-11-27 23:04:02 +00:00
|
|
|
// Copyright 2014 The Flutter Authors. All rights reserved.
|
2017-02-17 07:10:11 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2019-07-18 22:29:06 +00:00
|
|
|
import 'package:file/memory.dart';
|
2020-01-15 00:47:34 +00:00
|
|
|
import 'package:flutter_tools/src/base/logger.dart';
|
|
|
|
import 'package:flutter_tools/src/base/os.dart';
|
|
|
|
import 'package:mockito/mockito.dart';
|
2020-01-06 19:04:20 +00:00
|
|
|
import 'package:platform/platform.dart';
|
|
|
|
|
2019-07-29 14:24:02 +00:00
|
|
|
import 'package:flutter_tools/src/artifacts.dart';
|
2017-02-17 07:10:11 +00:00
|
|
|
import 'package:flutter_tools/src/base/file_system.dart';
|
|
|
|
import 'package:flutter_tools/src/build_info.dart';
|
|
|
|
import 'package:flutter_tools/src/cache.dart';
|
|
|
|
|
2019-07-13 18:51:44 +00:00
|
|
|
import '../src/common.dart';
|
|
|
|
import '../src/context.dart';
|
2017-02-17 07:10:11 +00:00
|
|
|
|
|
|
|
void main() {
|
2020-01-15 00:47:34 +00:00
|
|
|
group('CachedArtifacts', () {
|
|
|
|
CachedArtifacts artifacts;
|
|
|
|
Cache cache;
|
|
|
|
FileSystem fileSystem;
|
|
|
|
Platform platform;
|
2017-02-17 07:10:11 +00:00
|
|
|
|
|
|
|
setUp(() {
|
2020-01-15 00:47:34 +00:00
|
|
|
fileSystem = MemoryFileSystem();
|
|
|
|
final Directory cacheRoot = fileSystem.directory('root')
|
|
|
|
..createSync();
|
|
|
|
platform = FakePlatform(operatingSystem: 'linux');
|
|
|
|
cache = Cache(
|
|
|
|
rootOverride: cacheRoot,
|
|
|
|
fileSystem: fileSystem,
|
|
|
|
platform: platform,
|
2020-03-03 00:23:56 +00:00
|
|
|
logger: BufferLogger.test(),
|
2020-01-15 00:47:34 +00:00
|
|
|
osUtils: MockOperatingSystemUtils(),
|
|
|
|
);
|
|
|
|
artifacts = CachedArtifacts(
|
|
|
|
fileSystem: fileSystem,
|
|
|
|
cache: cache,
|
|
|
|
platform: platform,
|
|
|
|
);
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
|
2020-01-15 00:47:34 +00:00
|
|
|
testWithoutContext('getArtifactPath', () {
|
|
|
|
expect(
|
|
|
|
artifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: BuildMode.release),
|
|
|
|
fileSystem.path.join('root', 'bin', 'cache', 'artifacts', 'engine', 'ios-release', 'Flutter.framework'),
|
|
|
|
);
|
|
|
|
expect(
|
|
|
|
artifacts.getArtifactPath(Artifact.flutterTester),
|
|
|
|
fileSystem.path.join('root', 'bin', 'cache', 'artifacts', 'engine', 'linux-x64', 'flutter_tester'),
|
|
|
|
);
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
|
2020-01-15 00:47:34 +00:00
|
|
|
testWithoutContext('getEngineType', () {
|
|
|
|
expect(
|
|
|
|
artifacts.getEngineType(TargetPlatform.android_arm, BuildMode.debug),
|
|
|
|
'android-arm',
|
|
|
|
);
|
|
|
|
expect(
|
|
|
|
artifacts.getEngineType(TargetPlatform.ios, BuildMode.release),
|
|
|
|
'ios-release',
|
|
|
|
);
|
|
|
|
expect(
|
|
|
|
artifacts.getEngineType(TargetPlatform.darwin_x64),
|
|
|
|
'darwin-x64',
|
|
|
|
);
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
2020-01-15 00:47:34 +00:00
|
|
|
});
|
2017-02-17 07:10:11 +00:00
|
|
|
|
2020-01-15 00:47:34 +00:00
|
|
|
group('LocalEngineArtifacts', () {
|
|
|
|
LocalEngineArtifacts artifacts;
|
|
|
|
Cache cache;
|
|
|
|
FileSystem fileSystem;
|
|
|
|
Platform platform;
|
2017-02-17 07:10:11 +00:00
|
|
|
|
2020-01-15 00:47:34 +00:00
|
|
|
setUp(() {
|
|
|
|
fileSystem = MemoryFileSystem();
|
|
|
|
final Directory cacheRoot = fileSystem.directory('root')
|
|
|
|
..createSync();
|
|
|
|
platform = FakePlatform(operatingSystem: 'linux');
|
|
|
|
cache = Cache(
|
|
|
|
rootOverride: cacheRoot,
|
|
|
|
fileSystem: fileSystem,
|
|
|
|
platform: platform,
|
2020-03-03 00:23:56 +00:00
|
|
|
logger: BufferLogger.test(),
|
2020-01-15 00:47:34 +00:00
|
|
|
osUtils: MockOperatingSystemUtils(),
|
|
|
|
);
|
|
|
|
artifacts = LocalEngineArtifacts(fileSystem.currentDirectory.path,
|
|
|
|
fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'android_debug_unopt'),
|
|
|
|
fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'host_debug_unopt'),
|
|
|
|
cache: cache,
|
|
|
|
fileSystem: fileSystem,
|
|
|
|
platform: platform,
|
|
|
|
processManager: FakeProcessManager.any(),
|
|
|
|
);
|
|
|
|
});
|
2017-02-17 07:10:11 +00:00
|
|
|
|
2020-01-15 00:47:34 +00:00
|
|
|
testWithoutContext('getArtifactPath', () {
|
|
|
|
expect(
|
|
|
|
artifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: BuildMode.release),
|
|
|
|
fileSystem.path.join('/out', 'android_debug_unopt', 'Flutter.framework'),
|
|
|
|
);
|
|
|
|
expect(
|
|
|
|
artifacts.getArtifactPath(Artifact.flutterTester),
|
|
|
|
fileSystem.path.join('/out', 'android_debug_unopt', 'flutter_tester'),
|
|
|
|
);
|
|
|
|
expect(
|
|
|
|
artifacts.getArtifactPath(Artifact.engineDartSdkPath),
|
|
|
|
fileSystem.path.join('/out', 'host_debug_unopt', 'dart-sdk'),
|
|
|
|
);
|
|
|
|
});
|
2017-02-17 07:10:11 +00:00
|
|
|
|
2020-01-15 00:47:34 +00:00
|
|
|
testWithoutContext('getEngineType', () {
|
|
|
|
expect(
|
|
|
|
artifacts.getEngineType(TargetPlatform.android_arm, BuildMode.debug),
|
|
|
|
'android_debug_unopt',
|
|
|
|
);
|
|
|
|
expect(
|
|
|
|
artifacts.getEngineType(TargetPlatform.ios, BuildMode.release),
|
|
|
|
'android_debug_unopt',
|
|
|
|
);
|
|
|
|
expect(
|
|
|
|
artifacts.getEngineType(TargetPlatform.darwin_x64),
|
|
|
|
'android_debug_unopt',
|
|
|
|
);
|
|
|
|
});
|
2019-09-28 01:54:24 +00:00
|
|
|
|
2020-01-15 00:47:34 +00:00
|
|
|
testWithoutContext('Looks up dart.exe on windows platforms', () async {
|
|
|
|
artifacts = LocalEngineArtifacts(fileSystem.currentDirectory.path,
|
|
|
|
fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'android_debug_unopt'),
|
|
|
|
fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'host_debug_unopt'),
|
|
|
|
cache: cache,
|
|
|
|
fileSystem: fileSystem,
|
|
|
|
platform: FakePlatform(operatingSystem: 'windows'),
|
|
|
|
processManager: FakeProcessManager.any(),
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(artifacts.getArtifactPath(Artifact.engineDartBinary), contains('.exe'));
|
|
|
|
});
|
2019-09-28 01:54:24 +00:00
|
|
|
|
2020-01-15 00:47:34 +00:00
|
|
|
testWithoutContext('Looks up dart on linux platforms', () async {
|
|
|
|
expect(artifacts.getArtifactPath(Artifact.engineDartBinary), isNot(contains('.exe')));
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
});
|
2018-07-27 15:44:39 +00:00
|
|
|
}
|
2020-01-15 00:47:34 +00:00
|
|
|
|
|
|
|
class MockOperatingSystemUtils extends Mock implements OperatingSystemUtils {}
|