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

Commit 508dfdcd authored by Jason Monk's avatar Jason Monk Committed by android-build-merger
Browse files

Merge "Make NearestTouchFrameTest run on more device configurations" into oc-dr1-dev

am: a083c8f8

Change-Id: Ic17c6dd90a3ff3acd71885814d447a38b2c7b75d
parents 3a40330f a083c8f8
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -15,7 +15,9 @@
package com.android.systemui.statusbar.phone;

import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.support.annotation.VisibleForTesting;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Pair;
@@ -42,8 +44,13 @@ public class NearestTouchFrame extends FrameLayout {
    private View mTouchingChild;

    public NearestTouchFrame(Context context, AttributeSet attrs) {
        this(context, attrs, context.getResources().getConfiguration());
    }

    @VisibleForTesting
    NearestTouchFrame(Context context, AttributeSet attrs, Configuration c) {
        super(context, attrs);
        mIsActive = context.getResources().getConfiguration().smallestScreenWidthDp < 600;
        mIsActive = c.smallestScreenWidthDp < 600;
    }

    @Override
+25 −1
Original line number Diff line number Diff line
@@ -18,10 +18,12 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.content.res.Configuration;
import android.support.test.filters.SmallTest;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
@@ -43,7 +45,29 @@ public class NearestTouchFrameTest extends SysuiTestCase {

    @Before
    public void setup() {
        mNearestTouchFrame = new NearestTouchFrame(mContext, null);
        Configuration c = new Configuration(mContext.getResources().getConfiguration());
        c.smallestScreenWidthDp = 500;
        mNearestTouchFrame = new NearestTouchFrame(mContext, null, c);
    }

    @Test
    public void testNoActionOnLargeDevices() {
        Configuration c = new Configuration(mContext.getResources().getConfiguration());
        c.smallestScreenWidthDp = 700;
        mNearestTouchFrame = new NearestTouchFrame(mContext, null, c);

        View left = mockViewAt(0, 0, 10, 10);
        View right = mockViewAt(20, 0, 10, 10);

        mNearestTouchFrame.addView(left);
        mNearestTouchFrame.addView(right);
        mNearestTouchFrame.onMeasure(0, 0);

        MotionEvent ev = MotionEvent.obtain(0, 0, 0,
                12 /* x */, 5 /* y */, 0);
        mNearestTouchFrame.onTouchEvent(ev);
        verify(left, never()).onTouchEvent(eq(ev));
        ev.recycle();
    }

    @Test