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

Commit c78131d5 authored by Pawan Wagh's avatar Pawan Wagh Committed by Android (Google) Code Review
Browse files

Merge "Add pagesizecompat testcases" into main

parents 622652f1 7490cf57
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -51,6 +51,36 @@ android_test_helper_app {
    use_embedded_native_libs: true,
}

android_test_helper_app {
    name: "app_with_4kb_compressed_elf",
    srcs: ["app_with_4kb_elf/src/**/*.java"],
    manifest: "app_with_4kb_elf/app_with_4kb_elf.xml",
    compile_multilib: "64",
    jni_libs: [
        "libpunchtest_4kb",
    ],
    static_libs: [
        "androidx.test.rules",
        "platform-test-annotations",
    ],
    use_embedded_native_libs: false,
}

android_test_helper_app {
    name: "page_size_compat_disabled_app",
    srcs: ["app_with_4kb_elf/src/**/*.java"],
    manifest: "app_with_4kb_elf/page_size_compat_disabled.xml",
    compile_multilib: "64",
    jni_libs: [
        "libpunchtest_4kb",
    ],
    static_libs: [
        "androidx.test.rules",
        "platform-test-annotations",
    ],
    use_embedded_native_libs: true,
}

android_test_helper_app {
    name: "embedded_native_libs_test_app",
    srcs: ["apk_embedded_native_libs/src/**/*.java"],
@@ -99,6 +129,8 @@ java_test_host {
        ":embedded_native_libs_test_app",
        ":extract_native_libs_test_app",
        ":app_with_4kb_elf",
        ":page_size_compat_disabled_app",
        ":app_with_4kb_compressed_elf",
    ],
    test_suites: ["general-tests"],
    test_config: "AndroidTest.xml",
+0 −1
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@
        <option name="cleanup-apks" value="true" />
        <option name="test-file-name" value="embedded_native_libs_test_app.apk" />
        <option name="test-file-name" value="extract_native_libs_test_app.apk" />
        <option name="test-file-name" value="app_with_4kb_elf.apk" />
    </target_preparer>

    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+0 −1
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="android.test.pagesizecompat">
    <application
        android:extractNativeLibs="false"
        android:pageSizeCompat="enabled">
        <uses-library android:name="android.test.runner"/>
        <activity android:name=".MainActivity"
+36 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2025 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.
  -->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="android.test.pagesizecompat">
    <application
        android:pageSizeCompat="disabled">
        <uses-library android:name="android.test.runner"/>
        <activity android:name=".MainActivity"
                  android:exported="true"
                  android:process=":NewProcess">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </activity>
    </application>
    <instrumentation
        android:name="androidx.test.runner.AndroidJUnitRunner"
        android:targetPackage="android.test.pagesizecompat"/>
</manifest>
 No newline at end of file
+12 −3
Original line number Diff line number Diff line
@@ -34,8 +34,7 @@ import java.util.concurrent.TimeUnit;
@RunWith(AndroidJUnit4.class)
public class PageSizeCompatTest {

    @Test
    public void testPageSizeCompat_embedded4KbLib() throws Exception {
    public void testPageSizeCompat_appLaunch(boolean shouldPass) throws Exception {
        Context context = InstrumentationRegistry.getContext();
        CountDownLatch receivedSignal = new CountDownLatch(1);

@@ -62,6 +61,16 @@ public class PageSizeCompatTest {
        launchIntent.putExtra(MainActivity.KEY_OPERAND_2, op2);
        context.startActivity(launchIntent);

        Assert.assertTrue("Failed to launch app", receivedSignal.await(10, TimeUnit.SECONDS));
        Assert.assertEquals(receivedSignal.await(10, TimeUnit.SECONDS), shouldPass);
    }

    @Test
    public void testPageSizeCompat_compatEnabled() throws Exception {
        testPageSizeCompat_appLaunch(true);
    }

    @Test
    public void testPageSizeCompat_compatDisabled() throws Exception {
        testPageSizeCompat_appLaunch(false);
    }
}
Loading