2017-02-17 07:10:11 +00:00
|
|
|
// Copyright 2017 The Chromium Authors. All rights reserved.
|
|
|
|
// 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/file_system.dart';
|
|
|
|
import 'package:flutter_tools/src/base/platform.dart';
|
|
|
|
import 'package:flutter_tools/src/build_info.dart';
|
|
|
|
import 'package:flutter_tools/src/cache.dart';
|
|
|
|
import 'package:flutter_tools/src/artifacts.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() {
|
|
|
|
group('CachedArtifacts', () {
|
|
|
|
|
|
|
|
Directory tempDir;
|
|
|
|
CachedArtifacts artifacts;
|
|
|
|
|
|
|
|
setUp(() {
|
2018-08-17 20:17:23 +00:00
|
|
|
tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_artifacts_test_cached.');
|
2018-09-12 06:29:29 +00:00
|
|
|
artifacts = CachedArtifacts();
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
tearDown(() {
|
2018-08-17 20:17:23 +00:00
|
|
|
tryToDelete(tempDir);
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
testUsingContext('getArtifactPath', () {
|
|
|
|
expect(
|
2019-04-16 04:02:20 +00:00
|
|
|
artifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: BuildMode.release),
|
2019-03-01 07:17:55 +00:00
|
|
|
fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'ios-release', 'Flutter.framework'),
|
2017-02-17 07:10:11 +00:00
|
|
|
);
|
|
|
|
expect(
|
2017-03-29 23:30:41 +00:00
|
|
|
artifacts.getArtifactPath(Artifact.flutterTester),
|
2019-03-01 07:17:55 +00:00
|
|
|
fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'linux-x64', 'flutter_tester'),
|
2017-02-17 07:10:11 +00:00
|
|
|
);
|
2019-03-22 23:02:21 +00:00
|
|
|
}, overrides: <Type, Generator>{
|
2018-09-12 06:29:29 +00:00
|
|
|
Cache: () => Cache(rootOverride: tempDir),
|
2019-03-01 07:17:55 +00:00
|
|
|
Platform: () => FakePlatform(operatingSystem: 'linux'),
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
testUsingContext('getEngineType', () {
|
|
|
|
expect(
|
|
|
|
artifacts.getEngineType(TargetPlatform.android_arm, BuildMode.debug),
|
2019-03-01 07:17:55 +00:00
|
|
|
'android-arm',
|
2017-02-17 07:10:11 +00:00
|
|
|
);
|
|
|
|
expect(
|
|
|
|
artifacts.getEngineType(TargetPlatform.ios, BuildMode.release),
|
2019-03-01 07:17:55 +00:00
|
|
|
'ios-release',
|
2017-02-17 07:10:11 +00:00
|
|
|
);
|
|
|
|
expect(
|
|
|
|
artifacts.getEngineType(TargetPlatform.darwin_x64),
|
2019-03-01 07:17:55 +00:00
|
|
|
'darwin-x64',
|
2017-02-17 07:10:11 +00:00
|
|
|
);
|
2019-03-22 23:02:21 +00:00
|
|
|
}, overrides: <Type, Generator>{
|
2018-09-12 06:29:29 +00:00
|
|
|
Cache: () => Cache(rootOverride: tempDir),
|
2019-03-01 07:17:55 +00:00
|
|
|
Platform: () => FakePlatform(operatingSystem: 'linux'),
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
group('LocalEngineArtifacts', () {
|
|
|
|
|
|
|
|
Directory tempDir;
|
|
|
|
LocalEngineArtifacts artifacts;
|
|
|
|
|
|
|
|
setUp(() {
|
2018-08-17 20:17:23 +00:00
|
|
|
tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_artifacts_test_local.');
|
2018-09-12 06:29:29 +00:00
|
|
|
artifacts = LocalEngineArtifacts(tempDir.path,
|
2017-08-31 20:35:55 +00:00
|
|
|
fs.path.join(tempDir.path, 'out', 'android_debug_unopt'),
|
|
|
|
fs.path.join(tempDir.path, 'out', 'host_debug_unopt'),
|
|
|
|
);
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
tearDown(() {
|
2018-08-17 20:17:23 +00:00
|
|
|
tryToDelete(tempDir);
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
testUsingContext('getArtifactPath', () {
|
|
|
|
expect(
|
2019-04-16 04:02:20 +00:00
|
|
|
artifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: BuildMode.release),
|
2019-03-01 07:17:55 +00:00
|
|
|
fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'Flutter.framework'),
|
2017-02-17 07:10:11 +00:00
|
|
|
);
|
|
|
|
expect(
|
2017-03-29 23:30:41 +00:00
|
|
|
artifacts.getArtifactPath(Artifact.flutterTester),
|
2019-03-01 07:17:55 +00:00
|
|
|
fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'flutter_tester'),
|
2017-02-17 07:10:11 +00:00
|
|
|
);
|
2018-02-16 17:20:23 +00:00
|
|
|
expect(
|
|
|
|
artifacts.getArtifactPath(Artifact.engineDartSdkPath),
|
2019-03-01 07:17:55 +00:00
|
|
|
fs.path.join(tempDir.path, 'out', 'host_debug_unopt', 'dart-sdk'),
|
2018-02-16 17:20:23 +00:00
|
|
|
);
|
2019-03-22 23:02:21 +00:00
|
|
|
}, overrides: <Type, Generator>{
|
2019-03-01 07:17:55 +00:00
|
|
|
Platform: () => FakePlatform(operatingSystem: 'linux'),
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
testUsingContext('getEngineType', () {
|
|
|
|
expect(
|
|
|
|
artifacts.getEngineType(TargetPlatform.android_arm, BuildMode.debug),
|
2019-03-01 07:17:55 +00:00
|
|
|
'android_debug_unopt',
|
2017-02-17 07:10:11 +00:00
|
|
|
);
|
|
|
|
expect(
|
|
|
|
artifacts.getEngineType(TargetPlatform.ios, BuildMode.release),
|
2019-03-01 07:17:55 +00:00
|
|
|
'android_debug_unopt',
|
2017-02-17 07:10:11 +00:00
|
|
|
);
|
|
|
|
expect(
|
|
|
|
artifacts.getEngineType(TargetPlatform.darwin_x64),
|
2019-03-01 07:17:55 +00:00
|
|
|
'android_debug_unopt',
|
2017-02-17 07:10:11 +00:00
|
|
|
);
|
2019-03-22 23:02:21 +00:00
|
|
|
}, overrides: <Type, Generator>{
|
2019-03-01 07:17:55 +00:00
|
|
|
Platform: () => FakePlatform(operatingSystem: 'linux'),
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
});
|
2018-07-27 15:44:39 +00:00
|
|
|
}
|