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';
|
|
|
|
|
2018-08-15 03:33:58 +00:00
|
|
|
import 'src/common.dart';
|
2017-02-17 07:10:11 +00:00
|
|
|
import 'src/context.dart';
|
|
|
|
|
|
|
|
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(
|
|
|
|
artifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, BuildMode.release),
|
|
|
|
fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'ios-release', 'Flutter.framework')
|
|
|
|
);
|
|
|
|
expect(
|
2017-03-29 23:30:41 +00:00
|
|
|
artifacts.getArtifactPath(Artifact.flutterTester),
|
2017-03-29 22:31:36 +00:00
|
|
|
fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'linux-x64', 'flutter_tester')
|
2017-02-17 07:10:11 +00:00
|
|
|
);
|
|
|
|
}, overrides: <Type, Generator> {
|
2018-09-12 06:29:29 +00:00
|
|
|
Cache: () => Cache(rootOverride: tempDir),
|
|
|
|
Platform: () => FakePlatform(operatingSystem: 'linux')
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
testUsingContext('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'
|
|
|
|
);
|
|
|
|
}, overrides: <Type, Generator> {
|
2018-09-12 06:29:29 +00:00
|
|
|
Cache: () => Cache(rootOverride: tempDir),
|
|
|
|
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(
|
|
|
|
artifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, BuildMode.release),
|
|
|
|
fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'Flutter.framework')
|
|
|
|
);
|
|
|
|
expect(
|
2017-03-29 23:30:41 +00:00
|
|
|
artifacts.getArtifactPath(Artifact.flutterTester),
|
2017-03-29 22:31:36 +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),
|
|
|
|
fs.path.join(tempDir.path, 'out', 'host_debug_unopt', 'dart-sdk')
|
|
|
|
);
|
2017-02-17 07:10:11 +00:00
|
|
|
}, overrides: <Type, Generator> {
|
2018-09-12 06:29:29 +00:00
|
|
|
Platform: () => FakePlatform(operatingSystem: 'linux')
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
testUsingContext('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'
|
|
|
|
);
|
|
|
|
}, overrides: <Type, Generator> {
|
2018-09-12 06:29:29 +00:00
|
|
|
Platform: () => FakePlatform(operatingSystem: 'linux')
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
});
|
2018-07-27 15:44:39 +00:00
|
|
|
}
|