mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

* Update project.pbxproj files to say Flutter rather than Chromium Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright. * Update the copyright notice checker to require a standard notice on all files * Update copyrights on Dart files. (This was a mechanical commit.) * Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine. Some were already marked "The Flutter Authors", not clear why. Their dates have been normalized. Some were missing the blank line after the license. Some were randomly different in trivial ways for no apparent reason (e.g. missing the trailing period). * Clean up the copyrights in non-Dart files. (Manual edits.) Also, make sure templates don't have copyrights. * Fix some more ORGANIZATIONNAMEs
197 lines
6.7 KiB
Dart
197 lines
6.7 KiB
Dart
// 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.
|
|
|
|
import 'package:flutter_tools/src/cache.dart';
|
|
import 'package:flutter_tools/src/commands/precache.dart';
|
|
import 'package:flutter_tools/src/features.dart';
|
|
import 'package:flutter_tools/src/runner/flutter_command.dart';
|
|
import 'package:flutter_tools/src/version.dart';
|
|
import 'package:mockito/mockito.dart';
|
|
|
|
import '../../src/common.dart';
|
|
import '../../src/context.dart';
|
|
import '../../src/mocks.dart';
|
|
import '../../src/testbed.dart';
|
|
|
|
void main() {
|
|
MockCache cache;
|
|
Set<DevelopmentArtifact> artifacts;
|
|
MockFlutterVersion flutterVersion;
|
|
MockFlutterVersion masterFlutterVersion;
|
|
|
|
setUp(() {
|
|
cache = MockCache();
|
|
// Release lock between test cases.
|
|
Cache.releaseLockEarly();
|
|
|
|
when(cache.isUpToDate()).thenReturn(false);
|
|
when(cache.updateAll(any)).thenAnswer((Invocation invocation) {
|
|
artifacts = invocation.positionalArguments.first as Set<DevelopmentArtifact>;
|
|
return Future<void>.value(null);
|
|
});
|
|
flutterVersion = MockFlutterVersion();
|
|
when(flutterVersion.isMaster).thenReturn(false);
|
|
masterFlutterVersion = MockFlutterVersion();
|
|
when(masterFlutterVersion.isMaster).thenReturn(true);
|
|
});
|
|
|
|
testUsingContext('precache downloads web artifacts on dev branch when feature is enabled.', () async {
|
|
final PrecacheCommand command = PrecacheCommand();
|
|
applyMocksToCommand(command);
|
|
await createTestCommandRunner(command).run(const <String>['precache', '--web', '--no-android', '--no-ios']);
|
|
|
|
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
|
|
DevelopmentArtifact.universal,
|
|
DevelopmentArtifact.web,
|
|
DevelopmentArtifact.androidGenSnapshot,
|
|
DevelopmentArtifact.androidMaven,
|
|
}));
|
|
}, overrides: <Type, Generator>{
|
|
Cache: () => cache,
|
|
FeatureFlags: () => TestFeatureFlags(isWebEnabled: true),
|
|
});
|
|
|
|
testUsingContext('precache does not download web artifacts on dev branch when feature is enabled.', () async {
|
|
final PrecacheCommand command = PrecacheCommand();
|
|
applyMocksToCommand(command);
|
|
await createTestCommandRunner(command).run(const <String>['precache', '--web', '--no-android', '--no-ios']);
|
|
|
|
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
|
|
DevelopmentArtifact.universal,
|
|
DevelopmentArtifact.androidGenSnapshot,
|
|
DevelopmentArtifact.androidMaven,
|
|
}));
|
|
}, overrides: <Type, Generator>{
|
|
Cache: () => cache,
|
|
FeatureFlags: () => TestFeatureFlags(isWebEnabled: false),
|
|
});
|
|
|
|
testUsingContext('precache adds artifact flags to requested artifacts', () async {
|
|
final PrecacheCommand command = PrecacheCommand();
|
|
applyMocksToCommand(command);
|
|
await createTestCommandRunner(command).run(
|
|
const <String>[
|
|
'precache',
|
|
'--ios',
|
|
'--android',
|
|
'--web',
|
|
'--macos',
|
|
'--linux',
|
|
'--windows',
|
|
'--fuchsia',
|
|
'--flutter_runner',
|
|
],
|
|
);
|
|
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
|
|
DevelopmentArtifact.universal,
|
|
DevelopmentArtifact.iOS,
|
|
DevelopmentArtifact.androidGenSnapshot,
|
|
DevelopmentArtifact.androidMaven,
|
|
DevelopmentArtifact.androidInternalBuild,
|
|
DevelopmentArtifact.web,
|
|
DevelopmentArtifact.macOS,
|
|
DevelopmentArtifact.linux,
|
|
DevelopmentArtifact.windows,
|
|
DevelopmentArtifact.fuchsia,
|
|
DevelopmentArtifact.flutterRunner,
|
|
}));
|
|
}, overrides: <Type, Generator>{
|
|
Cache: () => cache,
|
|
FeatureFlags: () => TestFeatureFlags(isWebEnabled: true),
|
|
FlutterVersion: () => masterFlutterVersion,
|
|
});
|
|
|
|
testUsingContext('precache expands android artifacts when the android flag is used', () async {
|
|
final PrecacheCommand command = PrecacheCommand();
|
|
applyMocksToCommand(command);
|
|
await createTestCommandRunner(command).run(
|
|
const <String>[
|
|
'precache',
|
|
'--no-ios',
|
|
'--android',
|
|
],
|
|
);
|
|
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
|
|
DevelopmentArtifact.universal,
|
|
DevelopmentArtifact.androidGenSnapshot,
|
|
DevelopmentArtifact.androidMaven,
|
|
DevelopmentArtifact.androidInternalBuild,
|
|
}));
|
|
}, overrides: <Type, Generator>{
|
|
Cache: () => cache,
|
|
});
|
|
|
|
testUsingContext('precache adds artifact flags to requested android artifacts', () async {
|
|
final PrecacheCommand command = PrecacheCommand();
|
|
applyMocksToCommand(command);
|
|
await createTestCommandRunner(command).run(
|
|
const <String>[
|
|
'precache',
|
|
'--no-ios',
|
|
'--android_gen_snapshot',
|
|
'--android_maven',
|
|
'--android_internal_build',
|
|
],
|
|
);
|
|
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
|
|
DevelopmentArtifact.universal,
|
|
DevelopmentArtifact.androidGenSnapshot,
|
|
DevelopmentArtifact.androidMaven,
|
|
DevelopmentArtifact.androidInternalBuild,
|
|
}));
|
|
}, overrides: <Type, Generator>{
|
|
Cache: () => cache,
|
|
});
|
|
|
|
testUsingContext('precache adds artifact flags to requested artifacts on stable', () async {
|
|
final PrecacheCommand command = PrecacheCommand();
|
|
applyMocksToCommand(command);
|
|
await createTestCommandRunner(command).run(
|
|
const <String>[
|
|
'precache',
|
|
'--ios',
|
|
'--android_gen_snapshot',
|
|
'--android_maven',
|
|
'--android_internal_build',
|
|
'--web',
|
|
'--macos',
|
|
'--linux',
|
|
'--windows',
|
|
'--fuchsia',
|
|
'--flutter_runner',
|
|
],
|
|
);
|
|
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
|
|
DevelopmentArtifact.universal,
|
|
DevelopmentArtifact.iOS,
|
|
DevelopmentArtifact.androidGenSnapshot,
|
|
DevelopmentArtifact.androidMaven,
|
|
DevelopmentArtifact.androidInternalBuild,
|
|
}));
|
|
}, overrides: <Type, Generator>{
|
|
Cache: () => cache,
|
|
FlutterVersion: () => flutterVersion,
|
|
FeatureFlags: () => TestFeatureFlags(isWebEnabled: false),
|
|
});
|
|
testUsingContext('precache downloads artifacts when --force is provided', () async {
|
|
when(cache.isUpToDate()).thenReturn(true);
|
|
final PrecacheCommand command = PrecacheCommand();
|
|
applyMocksToCommand(command);
|
|
await createTestCommandRunner(command).run(const <String>['precache', '--force']);
|
|
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
|
|
DevelopmentArtifact.universal,
|
|
DevelopmentArtifact.iOS,
|
|
DevelopmentArtifact.androidGenSnapshot,
|
|
DevelopmentArtifact.androidMaven,
|
|
DevelopmentArtifact.androidInternalBuild,
|
|
}));
|
|
}, overrides: <Type, Generator>{
|
|
Cache: () => cache,
|
|
FlutterVersion: () => flutterVersion,
|
|
});
|
|
}
|
|
|
|
class MockFlutterVersion extends Mock implements FlutterVersion {}
|
|
class MockCache extends Mock implements Cache {}
|