aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/rules/android/AndroidAssetsTest.java
diff options
context:
space:
mode:
authorGravatar asteinb <asteinb@google.com>2018-04-16 12:03:20 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-04-16 12:04:37 -0700
commitfd84a1333a9b2c17a8347ef0b21859624c9869f9 (patch)
treeb20991b30e34ef27a2a9abff81fc5719fd1f0995 /src/test/java/com/google/devtools/build/lib/rules/android/AndroidAssetsTest.java
parent835814895fffef00fe88658f91e4550dc61546cf (diff)
Independently parse assets
This is the first step in processing assets completely seperately from resources. RELNOTES: none PiperOrigin-RevId: 193076991
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/rules/android/AndroidAssetsTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/android/AndroidAssetsTest.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidAssetsTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidAssetsTest.java
new file mode 100644
index 0000000000..401443d3b5
--- /dev/null
+++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidAssetsTest.java
@@ -0,0 +1,56 @@
+// Copyright 2018 The Bazel Authors. All rights reserved.
+//
+// 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.google.devtools.build.lib.rules.android;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.google.common.collect.ImmutableList;
+import com.google.devtools.build.lib.analysis.RuleContext;
+import com.google.devtools.build.lib.vfs.PathFragment;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/** Tests {@link AndroidAssets} */
+@RunWith(JUnit4.class)
+public class AndroidAssetsTest extends ResourceTestBase {
+ @Test
+ public void testParse() throws Exception {
+ RuleContext ruleContext = getRuleContext();
+ AndroidAssets assets =
+ new AndroidAssets(
+ ImmutableList.of(getResource("asset_1"), getResource("asset_2")),
+ ImmutableList.of(PathFragment.create("asset_dir")));
+ ParsedAndroidAssets parsed = assets.parse(ruleContext);
+
+ // Assets should be unchanged
+ assertThat(parsed.getAssets()).isEqualTo(assets.getAssets());
+ assertThat(parsed.getAssetRoots()).isEqualTo(assets.getAssetRoots());
+
+ // Label should be correct
+ assertThat(parsed.getLabel()).isEqualTo(ruleContext.getLabel());
+
+ // Symbols file should be created from raw assets
+ assertActionArtifacts(
+ ruleContext,
+ /* inputs = */ assets.getAssets(),
+ /* outputs = */ ImmutableList.of(parsed.getSymbols()));
+ }
+
+ private RuleContext getRuleContext() throws Exception {
+ return getRuleContextForActionTesting(
+ scratchConfiguredTarget("pkg", "r", "android_library(name='r')"));
+ }
+}