Loading services/tests/wmtests/src/com/android/server/wm/SurfaceControlTests.java +20 −6 Original line number Diff line number Diff line Loading @@ -39,6 +39,8 @@ import androidx.annotation.NonNull; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import com.android.server.wm.utils.CommonUtils; import org.junit.Test; import org.junit.runner.RunWith; Loading Loading @@ -131,18 +133,29 @@ public class SurfaceControlTests { final Activity activity = instrumentation.startActivitySync(intent); final SurfaceView sv = new SurfaceView(activity); final AtomicInteger surfaceChangedCount = new AtomicInteger(); final boolean[] unexpectedTransformHint = new boolean[1]; instrumentation.runOnMainSync(() -> activity.setContentView(sv)); sv.getHolder().addCallback(new SurfaceHolder.Callback() { int mInitialTransformHint = -1; @Override public void surfaceCreated(@NonNull SurfaceHolder holder) { } @Override public void surfaceChanged(@NonNull SurfaceHolder holder, int format, int width, int height) { final int transformHint = sv.getViewRootImpl().getSurfaceControl().getTransformHint(); if (mInitialTransformHint == -1) { mInitialTransformHint = transformHint; } else if (mInitialTransformHint == transformHint) { // For example, the initial hint is from portrait, so the later changes from // landscape should not receive the same hint. unexpectedTransformHint[0] = true; } surfaceChangedCount.getAndIncrement(); Log.i("surfaceChanged", "width=" + width + " height=" + height + " getTransformHint=" + sv.getViewRootImpl().getSurfaceControl().getTransformHint()); + " transformHint=" + transformHint); } @Override public void surfaceDestroyed(@NonNull SurfaceHolder holder) { Loading @@ -160,7 +173,7 @@ public class SurfaceControlTests { .windowConfiguration.getRotation(); if (rotation == newRotation) { // The device might not support requested orientation. activity.finishAndRemoveTask(); CommonUtils.waitUntilActivityRemoved(activity); return; } final int count = surfaceChangedCount.get(); Loading @@ -169,11 +182,12 @@ public class SurfaceControlTests { context.startActivity(intent); instrumentation.getUiAutomation().syncInputTransactions(); final int countAfterToFront = count - surfaceChangedCount.get(); activity.finishAndRemoveTask(); CommonUtils.waitUntilActivityRemoved(activity); // The first count is triggered from creation, so the target number is 2. if (count > 2) { fail("More than once surfaceChanged for rotation change: " + count); if (count > 2 && unexpectedTransformHint[0]) { fail("Received transform hint in previous orientation with more than once" + " surfaceChanged for rotation change: " + count); } if (countAfterToFront > 1) { fail("More than once surfaceChanged for app transition with rotation change: " Loading services/tests/wmtests/src/com/android/server/wm/TrustedPresentationCallbackTest.java +8 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,9 @@ import android.view.SurfaceControl.TrustedPresentationThresholds; import androidx.test.ext.junit.rules.ActivityScenarioRule; import com.android.server.wm.utils.CommonUtils; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; Loading Loading @@ -61,6 +64,11 @@ public class TrustedPresentationCallbackTest { mActivityRule.getScenario().onActivity(activity -> mActivity = activity); } @After public void tearDown() { CommonUtils.waitUntilActivityRemoved(mActivity); } @Test public void testAddTrustedPresentationListenerOnWindow() throws InterruptedException { boolean[] results = new boolean[1]; Loading Loading
services/tests/wmtests/src/com/android/server/wm/SurfaceControlTests.java +20 −6 Original line number Diff line number Diff line Loading @@ -39,6 +39,8 @@ import androidx.annotation.NonNull; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import com.android.server.wm.utils.CommonUtils; import org.junit.Test; import org.junit.runner.RunWith; Loading Loading @@ -131,18 +133,29 @@ public class SurfaceControlTests { final Activity activity = instrumentation.startActivitySync(intent); final SurfaceView sv = new SurfaceView(activity); final AtomicInteger surfaceChangedCount = new AtomicInteger(); final boolean[] unexpectedTransformHint = new boolean[1]; instrumentation.runOnMainSync(() -> activity.setContentView(sv)); sv.getHolder().addCallback(new SurfaceHolder.Callback() { int mInitialTransformHint = -1; @Override public void surfaceCreated(@NonNull SurfaceHolder holder) { } @Override public void surfaceChanged(@NonNull SurfaceHolder holder, int format, int width, int height) { final int transformHint = sv.getViewRootImpl().getSurfaceControl().getTransformHint(); if (mInitialTransformHint == -1) { mInitialTransformHint = transformHint; } else if (mInitialTransformHint == transformHint) { // For example, the initial hint is from portrait, so the later changes from // landscape should not receive the same hint. unexpectedTransformHint[0] = true; } surfaceChangedCount.getAndIncrement(); Log.i("surfaceChanged", "width=" + width + " height=" + height + " getTransformHint=" + sv.getViewRootImpl().getSurfaceControl().getTransformHint()); + " transformHint=" + transformHint); } @Override public void surfaceDestroyed(@NonNull SurfaceHolder holder) { Loading @@ -160,7 +173,7 @@ public class SurfaceControlTests { .windowConfiguration.getRotation(); if (rotation == newRotation) { // The device might not support requested orientation. activity.finishAndRemoveTask(); CommonUtils.waitUntilActivityRemoved(activity); return; } final int count = surfaceChangedCount.get(); Loading @@ -169,11 +182,12 @@ public class SurfaceControlTests { context.startActivity(intent); instrumentation.getUiAutomation().syncInputTransactions(); final int countAfterToFront = count - surfaceChangedCount.get(); activity.finishAndRemoveTask(); CommonUtils.waitUntilActivityRemoved(activity); // The first count is triggered from creation, so the target number is 2. if (count > 2) { fail("More than once surfaceChanged for rotation change: " + count); if (count > 2 && unexpectedTransformHint[0]) { fail("Received transform hint in previous orientation with more than once" + " surfaceChanged for rotation change: " + count); } if (countAfterToFront > 1) { fail("More than once surfaceChanged for app transition with rotation change: " Loading
services/tests/wmtests/src/com/android/server/wm/TrustedPresentationCallbackTest.java +8 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,9 @@ import android.view.SurfaceControl.TrustedPresentationThresholds; import androidx.test.ext.junit.rules.ActivityScenarioRule; import com.android.server.wm.utils.CommonUtils; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; Loading Loading @@ -61,6 +64,11 @@ public class TrustedPresentationCallbackTest { mActivityRule.getScenario().onActivity(activity -> mActivity = activity); } @After public void tearDown() { CommonUtils.waitUntilActivityRemoved(mActivity); } @Test public void testAddTrustedPresentationListenerOnWindow() throws InterruptedException { boolean[] results = new boolean[1]; Loading