diff options
author | 2018-08-08 08:54:04 -0700 | |
---|---|---|
committer | 2018-08-08 08:55:32 -0700 | |
commit | c476baa337e94fa8109d3e6ee280a54d5a0cb847 (patch) | |
tree | ac1af1c3bc9d68666459842c0b5fa18e25d90f83 /src/test/java/com/google/devtools/build/lib/rules/android/ResourceTestBase.java | |
parent | f2732ebb78b0abc54402026efddd2b3ee6d20e82 (diff) |
Remove ResourceContainer
ValidatedAndroidResources is now the only implementation of
ValidatedAndroidData, so we can also clean up some code. (The actual interface
will be cleaned up in the next few changes.)
RELNOTES: none
PiperOrigin-RevId: 207891778
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/rules/android/ResourceTestBase.java')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/rules/android/ResourceTestBase.java | 58 |
1 files changed, 48 insertions, 10 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/ResourceTestBase.java b/src/test/java/com/google/devtools/build/lib/rules/android/ResourceTestBase.java index dad6ee04fe..073a2e4030 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/android/ResourceTestBase.java +++ b/src/test/java/com/google/devtools/build/lib/rules/android/ResourceTestBase.java @@ -34,6 +34,7 @@ import com.google.devtools.build.lib.cmdline.LabelSyntaxException; import com.google.devtools.build.lib.events.ExtendedEventHandler; import com.google.devtools.build.lib.events.StoredEventHandler; import com.google.devtools.build.lib.packages.AbstractRuleErrorConsumer; +import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException; import com.google.devtools.build.lib.packages.RuleErrorConsumer; import com.google.devtools.build.lib.skyframe.ConfiguredTargetKey; import com.google.devtools.build.lib.vfs.FileSystem; @@ -62,14 +63,15 @@ public abstract class ResourceTestBase extends AndroidBuildViewTestCase { "android.jar", "ResourceProcessorBusyBox_deploy.jar"); - private static final ArtifactOwner OWNER = () -> { - try { - return Label.create("java", "all"); - } catch (LabelSyntaxException e) { - assertWithMessage(e.getMessage()).fail(); - return null; - } - }; + private static final ArtifactOwner OWNER = + () -> { + try { + return Label.create("java", "all"); + } catch (LabelSyntaxException e) { + assertWithMessage(e.getMessage()).fail(); + return null; + } + }; /** A faked {@link RuleErrorConsumer} that validates that only expected errors were reported. */ public static final class FakeRuleErrorConsumer extends AbstractRuleErrorConsumer @@ -202,8 +204,16 @@ public abstract class ResourceTestBase extends AndroidBuildViewTestCase { return builder.build(); } - public Artifact getResource(String pathString) { - Path path = fileSystem.getPath("/" + RESOURCE_ROOT + "/" + pathString); + Artifact getResource(String pathString) { + return getArtifact(RESOURCE_ROOT, pathString); + } + + Artifact getOutput(String pathString) { + return getArtifact("outputs", pathString); + } + + private Artifact getArtifact(String subdir, String pathString) { + Path path = fileSystem.getPath("/" + subdir + "/" + pathString); return new Artifact( root, root.getExecPath().getRelative(root.getRoot().relativize(path)), OWNER); } @@ -236,6 +246,34 @@ public abstract class ResourceTestBase extends AndroidBuildViewTestCase { ImmutableList.of(dummy.getConfiguration()), dummy.getHostConfiguration())); } + public ValidatedAndroidResources makeValidatedResourcesFor( + ImmutableList<Artifact> resources, + boolean includeAapt2Outs, + ProcessedAndroidManifest manifest, + ResourceDependencies resourceDependencies) + throws RuleErrorException { + return ValidatedAndroidResources.of( + MergedAndroidResources.of( + ParsedAndroidResources.of( + AndroidResources.forResources(errorConsumer, resources, "resource_files"), + getOutput("symbols.bin"), + includeAapt2Outs ? getOutput("symbols.zip") : null, + manifest.getManifest().getOwnerLabel(), + manifest, + DataBinding.asDisabledDataBindingContext()), + getOutput("merged/resources.zip"), + getOutput("class.jar"), + /* dataBindingInfoZip = */ null, + resourceDependencies, + manifest), + getOutput("r.txt"), + getOutput("source.jar"), + getOutput("resources.apk"), + includeAapt2Outs ? getOutput("aapt2-r.txt") : null, + includeAapt2Outs ? getOutput("aapt2-source.jar") : null, + includeAapt2Outs ? getOutput("aapt2-static-lib") : null); + } + /** * Assets that the action used to generate the given outputs has the expected inputs and outputs. */ |