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

Commit feaa2f2b authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Only assert transform hint if the orientation of size is changed

The test may be failed by
1. surfaceChanged: width=720 height=1024 transformHint=0
2. surfaceChanged: width=720 height=1120 transformHint=0 <--
3. surfaceChanged: width=1184 height=560 transformHint=4

The height change could be from insets which should be fine.
The purpose of the test is to ensure the size and hint have
consistent orientation, so ignore the noise case.

Fix: 294582810
Test: SurfaceControlTests#testSurfaceChangedOnRotation
Change-Id: Iefab4381934e655a4fa4217cbb94495de5f3ddfb
parent 83a2357e
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -125,6 +125,7 @@ public class SurfaceControlTests {

    @Test
    public void testSurfaceChangedOnRotation() {
        CommonUtils.dismissKeyguard();
        final Instrumentation instrumentation = getInstrumentation();
        final Context context = instrumentation.getContext();
        final Intent intent = new Intent().setComponent(
@@ -137,6 +138,8 @@ public class SurfaceControlTests {
        instrumentation.runOnMainSync(() -> activity.setContentView(sv));
        sv.getHolder().addCallback(new SurfaceHolder.Callback() {
            int mInitialTransformHint = -1;
            int mInitialW;
            int mInitialH;

            @Override
            public void surfaceCreated(@NonNull SurfaceHolder holder) {
@@ -148,7 +151,10 @@ public class SurfaceControlTests {
                        sv.getViewRootImpl().getSurfaceControl().getTransformHint();
                if (mInitialTransformHint == -1) {
                    mInitialTransformHint = transformHint;
                } else if (mInitialTransformHint == transformHint) {
                    mInitialW = width;
                    mInitialH = height;
                } else if (mInitialTransformHint == transformHint
                        && (width > height) != (mInitialW > mInitialH)) {
                    // For example, the initial hint is from portrait, so the later changes from
                    // landscape should not receive the same hint.
                    unexpectedTransformHint[0] = true;