diff options
author | Jerome Dochez <jedo@google.com> | 2024-04-23 21:42:56 -0700 |
---|---|---|
committer | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2024-04-29 23:05:45 +0000 |
commit | 078d6b8f9d7f9c9fc012430fe753fe17a939da3b (patch) | |
tree | 72dabf7d375c84c215c7e66b48ad5714a056ce48 | |
parent | 960fbf90d91241c0c97fc2df00864563a3bc5976 (diff) | |
download | base-mirror-goog-studio-main.tar.gz |
delete ScrenshotTesTImplmirror-goog-studio-main
and all references migraded to use `componentType` rather than
type casting.
Test: Existing
Bug: N/A
Change-Id: Ie77507f1b8a9bdcc2e35b3045f420a1eb51ac9f3
8 files changed, 49 insertions, 101 deletions
diff --git a/build-system/gradle-core/src/main/java/com/android/build/api/component/impl/HostTestImpl.kt b/build-system/gradle-core/src/main/java/com/android/build/api/component/impl/HostTestImpl.kt index 3a904c23e0..199421f3b6 100644 --- a/build-system/gradle-core/src/main/java/com/android/build/api/component/impl/HostTestImpl.kt +++ b/build-system/gradle-core/src/main/java/com/android/build/api/component/impl/HostTestImpl.kt @@ -20,6 +20,7 @@ import com.android.build.api.artifact.impl.ArtifactsImpl import com.android.build.api.variant.AndroidVersion import com.android.build.api.variant.ComponentIdentity import com.android.build.api.variant.HostTest +import com.android.build.api.variant.HostTestBuilder import com.android.build.api.variant.impl.HostTestBuilderImpl import com.android.build.gradle.internal.component.HostTestCreationConfig import com.android.build.gradle.internal.component.VariantCreationConfig diff --git a/build-system/gradle-core/src/main/java/com/android/build/api/component/impl/ScreenshotTestImpl.kt b/build-system/gradle-core/src/main/java/com/android/build/api/component/impl/ScreenshotTestImpl.kt deleted file mode 100644 index 20de4fb601..0000000000 --- a/build-system/gradle-core/src/main/java/com/android/build/api/component/impl/ScreenshotTestImpl.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.build.api.component.impl - -import com.android.build.api.artifact.impl.ArtifactsImpl -import com.android.build.api.variant.ComponentIdentity -import com.android.build.api.variant.HostTestBuilder -import com.android.build.api.variant.impl.HostTestBuilderImpl -import com.android.build.gradle.internal.component.HostTestCreationConfig -import com.android.build.gradle.internal.component.VariantCreationConfig -import com.android.build.gradle.internal.core.VariantSources -import com.android.build.gradle.internal.core.dsl.HostTestComponentDslInfo -import com.android.build.gradle.internal.dependency.VariantDependencies -import com.android.build.gradle.internal.scope.BuildFeatureValues -import com.android.build.gradle.internal.scope.MutableTaskContainer -import com.android.build.gradle.internal.services.TaskCreationServices -import com.android.build.gradle.internal.services.VariantServices -import com.android.build.gradle.internal.tasks.factory.GlobalTaskCreationConfig -import com.android.build.gradle.internal.variant.BaseVariantData -import com.android.build.gradle.internal.variant.VariantPathHelper -import com.android.builder.core.ComponentTypeImpl -import org.gradle.api.tasks.TaskProvider -import org.gradle.api.tasks.testing.Test -import javax.inject.Inject - -open class ScreenshotTestImpl @Inject constructor( - componentIdentity: ComponentIdentity, - buildFeatureValues: BuildFeatureValues, - dslInfo: HostTestComponentDslInfo, - variantDependencies: VariantDependencies, - variantSources: VariantSources, - paths: VariantPathHelper, - artifacts: ArtifactsImpl, - variantData: BaseVariantData, - taskContainer: MutableTaskContainer, - testedVariant: VariantCreationConfig, - internalServices: VariantServices, - taskCreationServices: TaskCreationServices, - global: GlobalTaskCreationConfig, - hostTestBuilder: HostTestBuilderImpl, -) : HostTestImpl( - componentIdentity, - buildFeatureValues, - dslInfo, - variantDependencies, - variantSources, - paths, - artifacts, - variantData, - taskContainer, - testedVariant, - internalServices, - taskCreationServices, - global, - hostTestBuilder, - HostTestBuilder.SCREENSHOT_TEST_TYPE, - useBuiltInKotlinSupport = true -), HostTestCreationConfig diff --git a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/VariantManager.kt b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/VariantManager.kt index 4d8401a06b..ba351f52f6 100644 --- a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/VariantManager.kt +++ b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/VariantManager.kt @@ -762,7 +762,7 @@ class VariantManager< ) } ?: throw IllegalArgumentException("Expected a HostTestBuilder instance for UNIT_TEST") ComponentTypeImpl.SCREENSHOT_TEST -> hostTestBuilder?.let { - variantFactory.createScreenshotTest( + variantFactory.createHostTest( testComponentDslInfo.componentIdentity, variantFactory.createHostTestBuildFeatureValues( dslExtension.buildFeatures, @@ -782,7 +782,9 @@ class VariantManager< variantPropertiesApiServices, taskCreationServices, globalTaskCreationConfig, - it + it, + HostTestBuilder.SCREENSHOT_TEST_TYPE, + true, ) } ?: throw IllegalArgumentException("Expected a HostTestBuilder instance for UNIT_TEST") else -> throw IllegalStateException("Expected a test component type, but ${componentIdentity.name} has type $componentType") diff --git a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/ide/v2/ModelBuilder.kt b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/ide/v2/ModelBuilder.kt index 1688c62ee1..36a4f89b16 100644 --- a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/ide/v2/ModelBuilder.kt +++ b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/ide/v2/ModelBuilder.kt @@ -20,8 +20,6 @@ import com.android.SdkConstants import com.android.Version import com.android.build.api.artifact.ScopedArtifact import com.android.build.api.component.impl.DeviceTestImpl -import com.android.build.api.component.impl.ScreenshotTestImpl -import com.android.build.api.component.impl.UnitTestImpl import com.android.build.api.dsl.AndroidResources import com.android.build.api.dsl.ApplicationExtension import com.android.build.api.dsl.BuildFeatures @@ -287,9 +285,13 @@ class ModelBuilder< // used by anything. val variantDimensionInfo = DimensionInformation.createFrom(variants) val androidTests = DimensionInformation.createFrom(variantModel.testComponents.filterIsInstance<DeviceTestCreationConfig>()) - val unitTests = DimensionInformation.createFrom(variantModel.testComponents.filterIsInstance<UnitTestImpl>()) + val unitTests = DimensionInformation.createFrom(variantModel.testComponents.filter { + it.componentType == ComponentTypeImpl.UNIT_TEST + }) val testFixtures = DimensionInformation.createFrom(variants.mapNotNull { (it as? HasTestFixtures)?.testFixtures }) - val screenshotTests = DimensionInformation.createFrom(variantModel.testComponents.filterIsInstance<ScreenshotTestImpl>()) + val screenshotTests = DimensionInformation.createFrom(variantModel.testComponents.filter { + it.componentType == ComponentTypeImpl.SCREENSHOT_TEST + }) // for now grab the first buildFeatureValues as they cannot be different. val buildFeatures = variantModel.buildFeatures diff --git a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/lint/LintTaskManager.kt b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/lint/LintTaskManager.kt index dd3a6827b6..f89542acc4 100644 --- a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/lint/LintTaskManager.kt +++ b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/lint/LintTaskManager.kt @@ -1,13 +1,13 @@ package com.android.build.gradle.internal.lint -import com.android.build.api.component.impl.ScreenshotTestImpl -import com.android.build.api.component.impl.UnitTestImpl import com.android.build.api.dsl.Lint +import com.android.build.api.variant.HostTest import com.android.build.api.variant.impl.HasTestFixtures import com.android.build.gradle.internal.TaskManager import com.android.build.gradle.internal.component.DeviceTestCreationConfig import com.android.build.gradle.internal.component.ApkCreationConfig import com.android.build.gradle.internal.component.ApplicationCreationConfig +import com.android.build.gradle.internal.component.HostTestCreationConfig import com.android.build.gradle.internal.component.TestComponentCreationConfig import com.android.build.gradle.internal.component.TestCreationConfig import com.android.build.gradle.internal.component.VariantCreationConfig @@ -17,6 +17,7 @@ import com.android.build.gradle.internal.tasks.factory.TaskFactory import com.android.build.gradle.internal.utils.createTargetSdkVersion import com.android.build.gradle.internal.variant.VariantModel import com.android.builder.core.ComponentType +import com.android.builder.core.ComponentTypeImpl import com.android.builder.errors.IssueReporter import com.android.utils.appendCapitalized import org.gradle.api.Project @@ -314,6 +315,7 @@ class LintTaskManager constructor( val current = variantsWithTests[key]!! when (testComponent) { is DeviceTestCreationConfig -> { + testComponent.componentType check(current.androidTest == null) { "Component ${current.main} appears to have two conflicting android test components ${current.androidTest} and $testComponent" } @@ -325,20 +327,25 @@ class LintTaskManager constructor( current.testFixtures ) } - is UnitTestImpl -> { - check(current.unitTest == null) { - "Component ${current.main} appears to have two conflicting unit test components ${current.unitTest} and $testComponent" + is HostTestCreationConfig -> { + when (testComponent.componentType) { + ComponentTypeImpl.UNIT_TEST -> { + check(current.unitTest == null) { + "Component ${current.main} appears to have two conflicting unit test components ${current.unitTest} and $testComponent" + } + variantsWithTests[key] = + VariantWithTests( + current.main, + current.androidTest, + testComponent, + current.testFixtures + ) + } + + ComponentTypeImpl.SCREENSHOT_TEST -> { + // TODO(karimai): b/337867828 add Screenshot Test support for Lint variant. + } } - variantsWithTests[key] = - VariantWithTests( - current.main, - current.androidTest, - testComponent, - current.testFixtures - ) - } - is ScreenshotTestImpl -> { - // TODO(karimai): add Screenshot Test support for Lint variant. } else -> throw IllegalStateException("Unexpected test component type") } diff --git a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/BaseVariantFactory.java b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/BaseVariantFactory.java index f91f4fd5b8..3bdf9d089a 100644 --- a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/BaseVariantFactory.java +++ b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/BaseVariantFactory.java @@ -21,7 +21,7 @@ import com.android.annotations.Nullable; import com.android.build.VariantOutput; import com.android.build.api.artifact.impl.ArtifactsImpl; import com.android.build.api.component.impl.DeviceTestImpl; -import com.android.build.api.component.impl.ScreenshotTestImpl; +import com.android.build.api.component.impl.HostTestImpl; import com.android.build.api.component.impl.TestFixturesImpl; import com.android.build.api.component.impl.UnitTestImpl; import com.android.build.api.dsl.CommonExtension; @@ -143,7 +143,7 @@ public abstract class BaseVariantFactory< @NonNull @Override - public HostTestCreationConfig createScreenshotTest( + public HostTestCreationConfig createHostTest( @NonNull ComponentIdentity componentIdentity, @NonNull BuildFeatureValues buildFeatures, @NonNull HostTestComponentDslInfo dslInfo, @@ -157,9 +157,11 @@ public abstract class BaseVariantFactory< @NonNull VariantServices variantServices, @NonNull TaskCreationServices taskCreationServices, @NonNull GlobalTaskCreationConfig globalConfig, - @NonNull HostTestBuilderImpl hostTestBuilder) { + @NonNull HostTestBuilderImpl hostTestBuilder, + @NonNull String hostTestName, + boolean useBuiltInKotlinSupport) { return dslServices.newInstance( - ScreenshotTestImpl.class, + HostTestImpl.class, componentIdentity, createUnitTestBuildFeatures(buildFeatures), // TODO dslInfo, @@ -173,7 +175,9 @@ public abstract class BaseVariantFactory< variantServices, taskCreationServices, globalConfig, - hostTestBuilder); + hostTestBuilder, + hostTestName, + useBuiltInKotlinSupport); } @NonNull diff --git a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/TestVariantFactory.java b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/TestVariantFactory.java index d2be9f5aa5..c0943bb782 100644 --- a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/TestVariantFactory.java +++ b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/TestVariantFactory.java @@ -219,7 +219,7 @@ public class TestVariantFactory @NonNull @Override - public HostTestCreationConfig createScreenshotTest( + public HostTestCreationConfig createHostTest( @NonNull ComponentIdentity componentIdentity, @NonNull BuildFeatureValues buildFeatures, @NonNull HostTestComponentDslInfo dslInfo, @@ -233,7 +233,9 @@ public class TestVariantFactory @NonNull VariantServices variantServices, @NonNull TaskCreationServices taskCreationServices, @NonNull GlobalTaskCreationConfig globalConfig, - @NonNull HostTestBuilderImpl hostTestBuilder) { + @NonNull HostTestBuilderImpl hostTestBuilder, + @NonNull String hostTestType, + boolean useBuiltInKotlinSupport) { throw new RuntimeException("cannot instantiate screenshot-test properties in test plugin"); } diff --git a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/VariantFactory.kt b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/VariantFactory.kt index 30c7286365..7204bcc95b 100644 --- a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/VariantFactory.kt +++ b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/variant/VariantFactory.kt @@ -117,7 +117,7 @@ interface VariantFactory<VariantBuilderT : VariantBuilder, VariantDslInfoT: Vari hostTestBuilder: HostTestBuilderImpl, ): HostTestCreationConfig - fun createScreenshotTest( + fun createHostTest( componentIdentity: ComponentIdentity, buildFeatures: BuildFeatureValues, dslInfo: HostTestComponentDslInfo, @@ -132,6 +132,8 @@ interface VariantFactory<VariantBuilderT : VariantBuilder, VariantDslInfoT: Vari taskCreationServices: TaskCreationServices, globalConfig: GlobalTaskCreationConfig, hostTestBuilder: HostTestBuilderImpl, + hostTestName: String, + useBuiltInKotlinSupport: Boolean, ): HostTestCreationConfig fun createAndroidTest( |