summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/build/config/android/test/resource_overlay/java
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/libwebrtc/build/config/android/test/resource_overlay/java')
-rw-r--r--third_party/libwebrtc/build/config/android/test/resource_overlay/java/res_template/values/values.xml10
-rw-r--r--third_party/libwebrtc/build/config/android/test/resource_overlay/java/src/org/chromium/build/resource_overlay/ResourceOverlayTest.java49
2 files changed, 59 insertions, 0 deletions
diff --git a/third_party/libwebrtc/build/config/android/test/resource_overlay/java/res_template/values/values.xml b/third_party/libwebrtc/build/config/android/test/resource_overlay/java/res_template/values/values.xml
new file mode 100644
index 0000000000..973f855206
--- /dev/null
+++ b/third_party/libwebrtc/build/config/android/test/resource_overlay/java/res_template/values/values.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 2020 The Chromium Authors. All rights reserved.
+
+ Use of this source code is governed by a BSD-style license that can be
+ found in the LICENSE file.
+-->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+ <integer name="{{resource_name}}">{{resource_value}}</integer>
+</resources> \ No newline at end of file
diff --git a/third_party/libwebrtc/build/config/android/test/resource_overlay/java/src/org/chromium/build/resource_overlay/ResourceOverlayTest.java b/third_party/libwebrtc/build/config/android/test/resource_overlay/java/src/org/chromium/build/resource_overlay/ResourceOverlayTest.java
new file mode 100644
index 0000000000..794cafac53
--- /dev/null
+++ b/third_party/libwebrtc/build/config/android/test/resource_overlay/java/src/org/chromium/build/resource_overlay/ResourceOverlayTest.java
@@ -0,0 +1,49 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.build.resource_overlay;
+
+import static org.junit.Assert.assertEquals;
+
+import android.content.res.Resources;
+import android.support.test.InstrumentationRegistry;
+
+import androidx.test.filters.SmallTest;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.chromium.base.test.BaseJUnit4ClassRunner;
+import org.chromium.base.test.util.Batch;
+
+/**
+ * Test for resource_overlay parameter in android_resources() build rule.
+ */
+@RunWith(BaseJUnit4ClassRunner.class)
+@Batch(Batch.UNIT_TESTS)
+public class ResourceOverlayTest {
+ /**
+ * Test that when an android_resources() target with resource_overlay=false has a resource with
+ * the same name but a different value as a dependency with resource_overlay=true that the value
+ * of the resource in the dependency is used.
+ */
+ @Test
+ @SmallTest
+ public void testDependencyTagged() {
+ Resources resources = InstrumentationRegistry.getTargetContext().getResources();
+ assertEquals(41, resources.getInteger(R.integer.resource_overlay_dependency_tagged_secret));
+ }
+
+ /**
+ * Test that when an android_resources() target with resource_overlay=true has a resource with
+ * the same name but different value as one of its dependencies that the value of resource in
+ * the target with resource_overlay=true is used.
+ */
+ @Test
+ @SmallTest
+ public void testRootTagged() {
+ Resources resources = InstrumentationRegistry.getTargetContext().getResources();
+ assertEquals(42, resources.getInteger(R.integer.resource_overlay_root_tagged_secret));
+ }
+}