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

Commit 8a9769d6 authored by Jason Monk's avatar Jason Monk Committed by android-build-merger
Browse files

Merge "Add system to avoid a crash stopping tests from running" into oc-dr1-dev

am: f10fcafc

Change-Id: Ib5a821f92aefb4200ab2aef958813d38820bea74
parents 700dfde8 f10fcafc
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -48,7 +48,7 @@
            android:process=":killable" />
            android:process=":killable" />
    </application>
    </application>


    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
    <instrumentation android:name="android.testing.TestableInstrumentation"
        android:targetPackage="com.android.systemui.tests"
        android:targetPackage="com.android.systemui.tests"
        android:label="Tests for SystemUI">
        android:label="Tests for SystemUI">
    </instrumentation>
    </instrumentation>
+5 −4
Original line number Original line Diff line number Diff line
@@ -21,7 +21,6 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.spy;
@@ -30,7 +29,6 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.when;


import android.app.Fragment;
import android.app.Fragment;
import android.support.test.filters.FlakyTest;
import android.support.test.filters.SmallTest;
import android.support.test.filters.SmallTest;
import android.testing.AndroidTestingRunner;
import android.testing.AndroidTestingRunner;
import android.view.Display;
import android.view.Display;
@@ -48,12 +46,10 @@ import com.android.systemui.tuner.TunablePadding.TunablePaddingService;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService;


import org.junit.Before;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runner.RunWith;


@RunWith(AndroidTestingRunner.class)
@RunWith(AndroidTestingRunner.class)
@FlakyTest
@SmallTest
@SmallTest
public class RoundedCornersTest extends SysuiTestCase {
public class RoundedCornersTest extends SysuiTestCase {


@@ -72,6 +68,7 @@ public class RoundedCornersTest extends SysuiTestCase {
        mWindowManager = mock(WindowManager.class);
        mWindowManager = mock(WindowManager.class);
        mView = spy(new StatusBarWindowView(mContext, null));
        mView = spy(new StatusBarWindowView(mContext, null));
        when(mStatusBar.getStatusBarWindow()).thenReturn(mView);
        when(mStatusBar.getStatusBarWindow()).thenReturn(mView);
        when(mStatusBar.getNavigationBarWindow()).thenReturn(mView);
        mContext.putComponent(StatusBar.class, mStatusBar);
        mContext.putComponent(StatusBar.class, mStatusBar);


        Display display = mContext.getSystemService(WindowManager.class).getDefaultDisplay();
        Display display = mContext.getSystemService(WindowManager.class).getDefaultDisplay();
@@ -94,6 +91,8 @@ public class RoundedCornersTest extends SysuiTestCase {
    @Test
    @Test
    public void testNoRounding() {
    public void testNoRounding() {
        mContext.getOrCreateTestableResources().addOverride(dimen.rounded_corner_radius, 0);
        mContext.getOrCreateTestableResources().addOverride(dimen.rounded_corner_radius, 0);
        mContext.getOrCreateTestableResources()
                .addOverride(dimen.rounded_corner_content_padding, 0);


        mRoundedCorners.start();
        mRoundedCorners.start();
        // No views added.
        // No views added.
@@ -107,6 +106,8 @@ public class RoundedCornersTest extends SysuiTestCase {
    @Test
    @Test
    public void testRounding() {
    public void testRounding() {
        mContext.getOrCreateTestableResources().addOverride(dimen.rounded_corner_radius, 20);
        mContext.getOrCreateTestableResources().addOverride(dimen.rounded_corner_radius, 20);
        mContext.getOrCreateTestableResources()
                .addOverride(dimen.rounded_corner_content_padding, 20);


        mRoundedCorners.start();
        mRoundedCorners.start();
        // Add 2 windows for rounded corners (top and bottom).
        // Add 2 windows for rounded corners (top and bottom).
+10 −4
Original line number Original line Diff line number Diff line
@@ -31,6 +31,8 @@ import android.util.Log;
import org.junit.After;
import org.junit.After;
import org.junit.Before;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Rule;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;


import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.Future;
@@ -56,10 +58,14 @@ public abstract class SysuiTestCase {


        mRealInstrumentation = InstrumentationRegistry.getInstrumentation();
        mRealInstrumentation = InstrumentationRegistry.getInstrumentation();
        Instrumentation inst = spy(mRealInstrumentation);
        Instrumentation inst = spy(mRealInstrumentation);
        when(inst.getContext()).thenThrow(new RuntimeException(
        when(inst.getContext()).thenAnswer(invocation -> {
                "SysUI Tests should use SysuiTestCase#getContext or SysuiTestCase#mContext"));
            throw new RuntimeException(
        when(inst.getTargetContext()).thenThrow(new RuntimeException(
                    "SysUI Tests should use SysuiTestCase#getContext or SysuiTestCase#mContext");
                "SysUI Tests should use SysuiTestCase#getContext or SysuiTestCase#mContext"));
        });
        when(inst.getTargetContext()).thenAnswer(invocation -> {
            throw new RuntimeException(
                    "SysUI Tests should use SysuiTestCase#getContext or SysuiTestCase#mContext");
        });
        InstrumentationRegistry.registerInstance(inst, InstrumentationRegistry.getArguments());
        InstrumentationRegistry.registerInstance(inst, InstrumentationRegistry.getArguments());
    }
    }


+0 −1
Original line number Original line Diff line number Diff line
@@ -27,7 +27,6 @@ import android.app.Instrumentation;
import android.os.Handler;
import android.os.Handler;
import android.os.Looper;
import android.os.Looper;
import android.support.test.InstrumentationRegistry;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.FlakyTest;
import android.support.test.filters.SmallTest;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
import android.support.test.runner.AndroidJUnit4;


+1 −3
Original line number Original line Diff line number Diff line
@@ -23,10 +23,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.when;


import org.junit.After;
import org.junit.Ignore;
import android.support.test.filters.SmallTest;
import android.support.test.filters.SmallTest;
import android.support.test.filters.FlakyTest;
import android.testing.AndroidTestingRunner;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
import android.testing.TestableLooper.RunWithLooper;
@@ -41,6 +38,7 @@ import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.qs.DetailAdapter;
import com.android.systemui.plugins.qs.DetailAdapter;


import org.junit.Before;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runner.RunWith;


Loading