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

Commit ef8a1965 authored by Johannes Gallmann's avatar Johannes Gallmann
Browse files

Convert animation-lib tests to bivalent tests

Bug: 297950085
Test: atest animationlib_robo_tests, atest animationlib_tests
Change-Id: I3fcbca9f362eaaf6451d93f5013ed4a1f3ec66d9
parent 7ab80c62
Loading
Loading
Loading
Loading
+37 −8
Original line number Diff line number Diff line
@@ -40,23 +40,52 @@ android_library {
    platform_apis: false
}

android_test {
    name: "animationlib_tests",
    manifest: "tests/AndroidManifest.xml",

android_library {
    name: "animationlib-tests-base",
    libs: [
        "android.test.base",
        "androidx.test.core",
    ],
    static_libs: [
        "animationlib",
        "androidx.test.ext.junit",
        "androidx.test.rules",
        "testables",
    ]
}

android_app {
    name: "TestAnimationLibApp",
    platform_apis: true,
    static_libs: [
        "animationlib-tests-base",
    ]
}

android_robolectric_test {
    enabled: true,
    name: "animationlib_robo_tests",
    srcs: [
        "tests/src/**/*.kt",
        "tests/robolectric/src/**/*.kt"
    ],
    libs: [
        "android.test.base",
    java_resource_dirs: ["tests/robolectric/config"],
    instrumentation_for: "TestAnimationLibApp",
    upstream: true,
}

android_test {
    name: "animationlib_tests",
    manifest: "tests/AndroidManifest.xml",

    static_libs: [
        "animationlib-tests-base",
    ],
    srcs: [
        "**/*.java",
        "**/*.kt"
        "tests/src/**/*.java",
        "tests/src/**/*.kt"
    ],
    kotlincflags: ["-Xjvm-default=all"],
    test_suites: ["general-tests"],
}
+2 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ android {
            manifest.srcFile 'AndroidManifest.xml'
        }
        androidTest {
            java.srcDirs = ["tests/src"]
            java.srcDirs = ["tests/src", "tests/robolectric/src"]
            manifest.srcFile 'tests/AndroidManifest.xml'
        }
    }
@@ -37,6 +37,7 @@ dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0"
    implementation "androidx.core:core-animation:1.0.0-alpha02"
    implementation "androidx.core:core-ktx:1.9.0"
    androidTestImplementation libs.robolectric
    androidTestImplementation "androidx.test.ext:junit:1.1.3"
    androidTestImplementation "androidx.test:rules:1.4.0"
}
+2 −0
Original line number Diff line number Diff line
sdk=NEWEST_SDK
shadows=com.android.app.animation.robolectric.ShadowAnimationUtils2
+12 −0
Original line number Diff line number Diff line
package com.android.app.animation.robolectric

import android.view.animation.AnimationUtils
import org.robolectric.annotation.Implements
import org.robolectric.shadows.ShadowAnimationUtils

/**
 * This shadow overwrites [ShadowAnimationUtils] and ensures that the real implementation of
 * [AnimationUtils] is used in tests.
 */
@Implements(AnimationUtils::class)
class ShadowAnimationUtils2
+3 −3
Original line number Diff line number Diff line
@@ -3,23 +3,23 @@ package com.android.app.animation
import android.annotation.InterpolatorRes
import android.content.Context
import android.view.animation.AnimationUtils
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import androidx.test.platform.app.InstrumentationRegistry
import junit.framework.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

@SmallTest
@RunWith(JUnit4::class)
@RunWith(AndroidJUnit4::class)
class InterpolatorResourcesTest {

    private lateinit var context: Context

    @Before
    fun setup() {
        context = InstrumentationRegistry.getInstrumentation().context
        context = InstrumentationRegistry.getInstrumentation().targetContext
    }

    @Test
Loading