Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a2a52be5 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "RRO: remove ability to overlay assets"

parents cc17afce dbf343be
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
com.android.overlaytest
+32 −0
Original line number Diff line number Diff line
@@ -17,9 +17,12 @@
package com.android.overlaytest;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import android.app.UiAutomation;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
@@ -30,6 +33,8 @@ import android.util.Xml;

import androidx.test.InstrumentationRegistry;

import com.android.internal.util.ArrayUtils;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -291,6 +296,33 @@ public abstract class OverlayBaseTest {
        assertEquals(getExpected(no, so, mo), actual);
    }

    @Test
    public void testAssetsNotPossibleToOverlay() throws Throwable {
        final AssetManager am = mResources.getAssets();

        // AssetManager#list will include assets from all loaded non-overlay
        // APKs, including the framework; framework-res.apk contains at least
        // assets/{images,webkit}. Rather than checking the list, verify that
        // assets only present in overlays are never part of the list.
        String[] files = am.list("");
        assertTrue(ArrayUtils.contains(files, "package-name.txt"));
        assertFalse(ArrayUtils.contains(files, "foo.txt"));
        assertFalse(ArrayUtils.contains(files, "bar.txt"));

        String contents = null;
        try (InputStream is = am.open("package-name.txt")) {
            final BufferedReader reader = new BufferedReader(
                    new InputStreamReader(is, StandardCharsets.UTF_8));
            StringBuilder str = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                str.append(line);
            }
            contents = str.toString();
        }
        assertEquals("com.android.overlaytest", contents);
    }

    /*
     * testMatrix* tests
     *
+1 −0
Original line number Diff line number Diff line
foo
+1 −0
Original line number Diff line number Diff line
com.android.overlaytest.app_overlay_one
+1 −0
Original line number Diff line number Diff line
bar
Loading