[flutter_tools] unify gradle/android sdk reinitialize checks in cache.dart (#76342)
This commit is contained in:
@@ -96,10 +96,6 @@ void main() {
|
||||
testUsingContext('Licenses available, build tools not, apk exists', () async {
|
||||
when(sdk.latestVersion).thenReturn(null);
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.currentDirectory);
|
||||
final File gradle = project.android.hostAppGradleRoot.childFile(
|
||||
globals.platform.isWindows ? 'gradlew.bat' : 'gradlew',
|
||||
)..createSync(recursive: true);
|
||||
|
||||
project.android.hostAppGradleRoot
|
||||
.childFile('gradle.properties')
|
||||
.writeAsStringSync('irrelevant');
|
||||
@@ -111,8 +107,6 @@ void main() {
|
||||
gradleWrapperDir.childFile('gradlew').writeAsStringSync('irrelevant');
|
||||
gradleWrapperDir.childFile('gradlew.bat').writeAsStringSync('irrelevant');
|
||||
|
||||
fakeProcessManager.addCommand(FakeCommand(command: <String>[gradle.path, 'dependencies']));
|
||||
|
||||
await ApplicationPackageFactory.instance.getPackageForPlatform(
|
||||
TargetPlatform.android_arm,
|
||||
buildInfo: null,
|
||||
|
||||
@@ -767,6 +767,7 @@ void main() {
|
||||
group('AndroidMavenArtifacts', () {
|
||||
MemoryFileSystem memoryFileSystem;
|
||||
Cache cache;
|
||||
FakeAndroidSdk fakeAndroidSdk;
|
||||
|
||||
setUp(() {
|
||||
memoryFileSystem = MemoryFileSystem.test();
|
||||
@@ -774,6 +775,7 @@ void main() {
|
||||
fileSystem: memoryFileSystem,
|
||||
processManager: FakeProcessManager.any(),
|
||||
);
|
||||
fakeAndroidSdk = FakeAndroidSdk();
|
||||
});
|
||||
|
||||
testWithoutContext('AndroidMavenArtifacts has a specified development artifact', () async {
|
||||
@@ -793,6 +795,7 @@ void main() {
|
||||
await mavenArtifacts.update(MockArtifactUpdater(), BufferLogger.test(), memoryFileSystem, MockOperatingSystemUtils());
|
||||
|
||||
expect(await mavenArtifacts.isUpToDate(memoryFileSystem), isFalse);
|
||||
expect(fakeAndroidSdk.reinitialized, true);
|
||||
}, overrides: <Type, Generator>{
|
||||
Cache: () => cache,
|
||||
FileSystem: () => memoryFileSystem,
|
||||
@@ -806,7 +809,7 @@ void main() {
|
||||
'resolveDependencies',
|
||||
])
|
||||
]),
|
||||
AndroidSdk: () => FakeAndroidSdk()
|
||||
AndroidSdk: () => fakeAndroidSdk
|
||||
});
|
||||
|
||||
testUsingContext('AndroidMavenArtifacts is a no-op if the Android SDK is absent', () async {
|
||||
@@ -903,4 +906,11 @@ class FakeCache extends Cache {
|
||||
return stampFile;
|
||||
}
|
||||
}
|
||||
class FakeAndroidSdk extends Fake implements AndroidSdk {}
|
||||
class FakeAndroidSdk extends Fake implements AndroidSdk {
|
||||
bool reinitialized = false;
|
||||
|
||||
@override
|
||||
void reinitialize() {
|
||||
reinitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user