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

Commit 1fc931a3 authored by Jason Monk's avatar Jason Monk
Browse files

Switch to inline mockito for a bunch of tests

So we can mock final stuff

Test: The tests
Change-Id: Ia3a47c6655c4b0b9af0aea0ee6f8f6cb9ebaab09
parent 700448e4
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -35,12 +35,18 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src) \
LOCAL_STATIC_JAVA_LIBRARIES := \
    metrics-helper-lib \
    android-support-test \
    mockito-target-minus-junit4 \
    mockito-target-inline-minus-junit4 \
    SystemUI-proto \
    SystemUI-tags \
    testables \
    truth-prebuilt \

LOCAL_MULTILIB := both

LOCAL_JNI_SHARED_LIBRARIES := \
    libdexmakerjvmtiagent \
    libmultiplejvmtiagentsinterferenceagent

LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common

# sign this with platform cert, so this test is allowed to inject key events into
+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@

    <uses-permission android:name="android.permission.READ_FRAME_BUFFER" />

    <application>
    <application android:debuggable="true">
        <uses-library android:name="android.test.runner" />
    </application>

+8 −1
Original line number Diff line number Diff line
@@ -56,12 +56,19 @@ LOCAL_STATIC_ANDROID_LIBRARIES := \
LOCAL_STATIC_JAVA_LIBRARIES := \
    metrics-helper-lib \
    android-support-test \
    mockito-target-minus-junit4 \
    mockito-target-inline-minus-junit4 \
    SystemUI-proto \
    SystemUI-tags \
    testables \
    truth-prebuilt \

LOCAL_MULTILIB := both

LOCAL_JNI_SHARED_LIBRARIES := \
    libdexmakerjvmtiagent \
    libmultiplejvmtiagentsinterferenceagent


LOCAL_JAVA_LIBRARIES := \
    android.test.runner \
    telephony-common \
+2 −1
Original line number Diff line number Diff line
@@ -48,8 +48,9 @@
    <uses-permission android:name="android.permission.REAL_GET_TASKS" />
    <uses-permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW" />
    <uses-permission android:name="android.permission.NETWORK_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <application>
    <application android:debuggable="true">
        <uses-library android:name="android.test.runner" />
        <activity android:name="com.android.systemui.screenshot.ScreenshotStubActivity" />

+8 −3
Original line number Diff line number Diff line
@@ -27,8 +27,14 @@ import com.android.systemui.qs.tileimpl.SlashImageView;
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;


@SmallTest
@@ -80,13 +86,12 @@ public class SlashImageViewTest extends SysuiTestCase {
    public void testSetImageDrawableUsesDrawableLevel() {
        SlashImageView iv = new SlashImageView(mContext);
        Drawable mockDrawable = mock(Drawable.class);
        mockDrawable.setLevel(2);
        assertTrue(mockDrawable.getLevel() == 2);
        when(mockDrawable.getLevel()).thenReturn(2);

        iv.setImageDrawable(mockDrawable);

        // Make sure setting the drawable didn't reset its level to 0
        assertTrue(mockDrawable.getLevel() == 2);
        verify(mockDrawable).setLevel(eq(2));
    }

    // Expose getSlashDrawable
Loading